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__common::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__common::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
660pub mod device_control_ordinals {
661    pub const DEVICE_SET_GAIN_STATE: u64 = 0x7c5c028bb8c42d12;
662}
663
664pub mod player_ordinals {
665    pub const PLAY: u64 = 0x1e63779971512042;
666}
667
668pub mod record_canceler_ordinals {
669    pub const CANCEL: u64 = 0x5ea52b81e366daf6;
670}
671
672pub mod recorder_ordinals {
673    pub const RECORD: u64 = 0x47cabcb60b2c8ca7;
674}
675
676mod internal {
677    use super::*;
678    unsafe impl fidl::encoding::TypeMarker for DeviceType {
679        type Owned = Self;
680
681        #[inline(always)]
682        fn inline_align(_context: fidl::encoding::Context) -> usize {
683            std::mem::align_of::<u32>()
684        }
685
686        #[inline(always)]
687        fn inline_size(_context: fidl::encoding::Context) -> usize {
688            std::mem::size_of::<u32>()
689        }
690
691        #[inline(always)]
692        fn encode_is_copy() -> bool {
693            false
694        }
695
696        #[inline(always)]
697        fn decode_is_copy() -> bool {
698            false
699        }
700    }
701
702    impl fidl::encoding::ValueTypeMarker for DeviceType {
703        type Borrowed<'a> = Self;
704        #[inline(always)]
705        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
706            *value
707        }
708    }
709
710    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for DeviceType {
711        #[inline]
712        unsafe fn encode(
713            self,
714            encoder: &mut fidl::encoding::Encoder<'_, D>,
715            offset: usize,
716            _depth: fidl::encoding::Depth,
717        ) -> fidl::Result<()> {
718            encoder.debug_check_bounds::<Self>(offset);
719            encoder.write_num(self.into_primitive(), offset);
720            Ok(())
721        }
722    }
723
724    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceType {
725        #[inline(always)]
726        fn new_empty() -> Self {
727            Self::unknown()
728        }
729
730        #[inline]
731        unsafe fn decode(
732            &mut self,
733            decoder: &mut fidl::encoding::Decoder<'_, D>,
734            offset: usize,
735            _depth: fidl::encoding::Depth,
736        ) -> fidl::Result<()> {
737            decoder.debug_check_bounds::<Self>(offset);
738            let prim = decoder.read_num::<u32>(offset);
739
740            *self = Self::from_primitive_allow_unknown(prim);
741            Ok(())
742        }
743    }
744    unsafe impl fidl::encoding::TypeMarker for Error {
745        type Owned = Self;
746
747        #[inline(always)]
748        fn inline_align(_context: fidl::encoding::Context) -> usize {
749            std::mem::align_of::<u32>()
750        }
751
752        #[inline(always)]
753        fn inline_size(_context: fidl::encoding::Context) -> usize {
754            std::mem::size_of::<u32>()
755        }
756
757        #[inline(always)]
758        fn encode_is_copy() -> bool {
759            false
760        }
761
762        #[inline(always)]
763        fn decode_is_copy() -> bool {
764            false
765        }
766    }
767
768    impl fidl::encoding::ValueTypeMarker for Error {
769        type Borrowed<'a> = Self;
770        #[inline(always)]
771        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
772            *value
773        }
774    }
775
776    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
777        #[inline]
778        unsafe fn encode(
779            self,
780            encoder: &mut fidl::encoding::Encoder<'_, D>,
781            offset: usize,
782            _depth: fidl::encoding::Depth,
783        ) -> fidl::Result<()> {
784            encoder.debug_check_bounds::<Self>(offset);
785            encoder.write_num(self.into_primitive(), offset);
786            Ok(())
787        }
788    }
789
790    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
791        #[inline(always)]
792        fn new_empty() -> Self {
793            Self::unknown()
794        }
795
796        #[inline]
797        unsafe fn decode(
798            &mut self,
799            decoder: &mut fidl::encoding::Decoder<'_, D>,
800            offset: usize,
801            _depth: fidl::encoding::Depth,
802        ) -> fidl::Result<()> {
803            decoder.debug_check_bounds::<Self>(offset);
804            let prim = decoder.read_num::<u32>(offset);
805
806            *self = Self::from_primitive_allow_unknown(prim);
807            Ok(())
808        }
809    }
810
811    impl fidl::encoding::ValueTypeMarker for Devfs {
812        type Borrowed<'a> = &'a Self;
813        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
814            value
815        }
816    }
817
818    unsafe impl fidl::encoding::TypeMarker for Devfs {
819        type Owned = Self;
820
821        #[inline(always)]
822        fn inline_align(_context: fidl::encoding::Context) -> usize {
823            8
824        }
825
826        #[inline(always)]
827        fn inline_size(_context: fidl::encoding::Context) -> usize {
828            24
829        }
830    }
831
832    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Devfs, D> for &Devfs {
833        #[inline]
834        unsafe fn encode(
835            self,
836            encoder: &mut fidl::encoding::Encoder<'_, D>,
837            offset: usize,
838            _depth: fidl::encoding::Depth,
839        ) -> fidl::Result<()> {
840            encoder.debug_check_bounds::<Devfs>(offset);
841            // Delegate to tuple encoding.
842            fidl::encoding::Encode::<Devfs, D>::encode(
843                (
844                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
845                        &self.name,
846                    ),
847                    <DeviceType as fidl::encoding::ValueTypeMarker>::borrow(&self.device_type),
848                ),
849                encoder,
850                offset,
851                _depth,
852            )
853        }
854    }
855    unsafe impl<
856            D: fidl::encoding::ResourceDialect,
857            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<255>, D>,
858            T1: fidl::encoding::Encode<DeviceType, D>,
859        > fidl::encoding::Encode<Devfs, D> for (T0, T1)
860    {
861        #[inline]
862        unsafe fn encode(
863            self,
864            encoder: &mut fidl::encoding::Encoder<'_, D>,
865            offset: usize,
866            depth: fidl::encoding::Depth,
867        ) -> fidl::Result<()> {
868            encoder.debug_check_bounds::<Devfs>(offset);
869            // Zero out padding regions. There's no need to apply masks
870            // because the unmasked parts will be overwritten by fields.
871            unsafe {
872                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
873                (ptr as *mut u64).write_unaligned(0);
874            }
875            // Write the fields.
876            self.0.encode(encoder, offset + 0, depth)?;
877            self.1.encode(encoder, offset + 16, depth)?;
878            Ok(())
879        }
880    }
881
882    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Devfs {
883        #[inline(always)]
884        fn new_empty() -> Self {
885            Self {
886                name: fidl::new_empty!(fidl::encoding::BoundedString<255>, D),
887                device_type: fidl::new_empty!(DeviceType, D),
888            }
889        }
890
891        #[inline]
892        unsafe fn decode(
893            &mut self,
894            decoder: &mut fidl::encoding::Decoder<'_, D>,
895            offset: usize,
896            _depth: fidl::encoding::Depth,
897        ) -> fidl::Result<()> {
898            decoder.debug_check_bounds::<Self>(offset);
899            // Verify that padding bytes are zero.
900            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
901            let padval = unsafe { (ptr as *const u64).read_unaligned() };
902            let mask = 0xffffffff00000000u64;
903            let maskedval = padval & mask;
904            if maskedval != 0 {
905                return Err(fidl::Error::NonZeroPadding {
906                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
907                });
908            }
909            fidl::decode!(
910                fidl::encoding::BoundedString<255>,
911                D,
912                &mut self.name,
913                decoder,
914                offset + 0,
915                _depth
916            )?;
917            fidl::decode!(DeviceType, D, &mut self.device_type, decoder, offset + 16, _depth)?;
918            Ok(())
919        }
920    }
921
922    impl fidl::encoding::ValueTypeMarker for DeviceRingBuffer {
923        type Borrowed<'a> = &'a Self;
924        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
925            value
926        }
927    }
928
929    unsafe impl fidl::encoding::TypeMarker for DeviceRingBuffer {
930        type Owned = Self;
931
932        #[inline(always)]
933        fn inline_align(_context: fidl::encoding::Context) -> usize {
934            8
935        }
936
937        #[inline(always)]
938        fn inline_size(_context: fidl::encoding::Context) -> usize {
939            24
940        }
941    }
942
943    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceRingBuffer, D>
944        for &DeviceRingBuffer
945    {
946        #[inline]
947        unsafe fn encode(
948            self,
949            encoder: &mut fidl::encoding::Encoder<'_, D>,
950            offset: usize,
951            _depth: fidl::encoding::Depth,
952        ) -> fidl::Result<()> {
953            encoder.debug_check_bounds::<DeviceRingBuffer>(offset);
954            // Delegate to tuple encoding.
955            fidl::encoding::Encode::<DeviceRingBuffer, D>::encode(
956                (
957                    <DeviceSelector as fidl::encoding::ValueTypeMarker>::borrow(&self.selector),
958                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.ring_buffer_element_id),
959                ),
960                encoder,
961                offset,
962                _depth,
963            )
964        }
965    }
966    unsafe impl<
967            D: fidl::encoding::ResourceDialect,
968            T0: fidl::encoding::Encode<DeviceSelector, D>,
969            T1: fidl::encoding::Encode<u64, D>,
970        > fidl::encoding::Encode<DeviceRingBuffer, D> for (T0, T1)
971    {
972        #[inline]
973        unsafe fn encode(
974            self,
975            encoder: &mut fidl::encoding::Encoder<'_, D>,
976            offset: usize,
977            depth: fidl::encoding::Depth,
978        ) -> fidl::Result<()> {
979            encoder.debug_check_bounds::<DeviceRingBuffer>(offset);
980            // Zero out padding regions. There's no need to apply masks
981            // because the unmasked parts will be overwritten by fields.
982            // Write the fields.
983            self.0.encode(encoder, offset + 0, depth)?;
984            self.1.encode(encoder, offset + 16, depth)?;
985            Ok(())
986        }
987    }
988
989    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceRingBuffer {
990        #[inline(always)]
991        fn new_empty() -> Self {
992            Self {
993                selector: fidl::new_empty!(DeviceSelector, D),
994                ring_buffer_element_id: fidl::new_empty!(u64, D),
995            }
996        }
997
998        #[inline]
999        unsafe fn decode(
1000            &mut self,
1001            decoder: &mut fidl::encoding::Decoder<'_, D>,
1002            offset: usize,
1003            _depth: fidl::encoding::Depth,
1004        ) -> fidl::Result<()> {
1005            decoder.debug_check_bounds::<Self>(offset);
1006            // Verify that padding bytes are zero.
1007            fidl::decode!(DeviceSelector, D, &mut self.selector, decoder, offset + 0, _depth)?;
1008            fidl::decode!(u64, D, &mut self.ring_buffer_element_id, decoder, offset + 16, _depth)?;
1009            Ok(())
1010        }
1011    }
1012
1013    impl fidl::encoding::ValueTypeMarker for Flexible {
1014        type Borrowed<'a> = &'a Self;
1015        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1016            value
1017        }
1018    }
1019
1020    unsafe impl fidl::encoding::TypeMarker for Flexible {
1021        type Owned = Self;
1022
1023        #[inline(always)]
1024        fn inline_align(_context: fidl::encoding::Context) -> usize {
1025            1
1026        }
1027
1028        #[inline(always)]
1029        fn inline_size(_context: fidl::encoding::Context) -> usize {
1030            1
1031        }
1032    }
1033
1034    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Flexible, D> for &Flexible {
1035        #[inline]
1036        unsafe fn encode(
1037            self,
1038            encoder: &mut fidl::encoding::Encoder<'_, D>,
1039            offset: usize,
1040            _depth: fidl::encoding::Depth,
1041        ) -> fidl::Result<()> {
1042            encoder.debug_check_bounds::<Flexible>(offset);
1043            encoder.write_num(0u8, offset);
1044            Ok(())
1045        }
1046    }
1047
1048    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Flexible {
1049        #[inline(always)]
1050        fn new_empty() -> Self {
1051            Self
1052        }
1053
1054        #[inline]
1055        unsafe fn decode(
1056            &mut self,
1057            decoder: &mut fidl::encoding::Decoder<'_, D>,
1058            offset: usize,
1059            _depth: fidl::encoding::Depth,
1060        ) -> fidl::Result<()> {
1061            decoder.debug_check_bounds::<Self>(offset);
1062            match decoder.read_num::<u8>(offset) {
1063                0 => Ok(()),
1064                _ => Err(fidl::Error::Invalid),
1065            }
1066        }
1067    }
1068
1069    impl fidl::encoding::ValueTypeMarker for Loopback {
1070        type Borrowed<'a> = &'a Self;
1071        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1072            value
1073        }
1074    }
1075
1076    unsafe impl fidl::encoding::TypeMarker for Loopback {
1077        type Owned = Self;
1078
1079        #[inline(always)]
1080        fn inline_align(_context: fidl::encoding::Context) -> usize {
1081            1
1082        }
1083
1084        #[inline(always)]
1085        fn inline_size(_context: fidl::encoding::Context) -> usize {
1086            1
1087        }
1088    }
1089
1090    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Loopback, D> for &Loopback {
1091        #[inline]
1092        unsafe fn encode(
1093            self,
1094            encoder: &mut fidl::encoding::Encoder<'_, D>,
1095            offset: usize,
1096            _depth: fidl::encoding::Depth,
1097        ) -> fidl::Result<()> {
1098            encoder.debug_check_bounds::<Loopback>(offset);
1099            encoder.write_num(0u8, offset);
1100            Ok(())
1101        }
1102    }
1103
1104    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Loopback {
1105        #[inline(always)]
1106        fn new_empty() -> Self {
1107            Self
1108        }
1109
1110        #[inline]
1111        unsafe fn decode(
1112            &mut self,
1113            decoder: &mut fidl::encoding::Decoder<'_, D>,
1114            offset: usize,
1115            _depth: fidl::encoding::Depth,
1116        ) -> fidl::Result<()> {
1117            decoder.debug_check_bounds::<Self>(offset);
1118            match decoder.read_num::<u8>(offset) {
1119                0 => Ok(()),
1120                _ => Err(fidl::Error::Invalid),
1121            }
1122        }
1123    }
1124
1125    impl fidl::encoding::ValueTypeMarker for SystemMonotonic {
1126        type Borrowed<'a> = &'a Self;
1127        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1128            value
1129        }
1130    }
1131
1132    unsafe impl fidl::encoding::TypeMarker for SystemMonotonic {
1133        type Owned = Self;
1134
1135        #[inline(always)]
1136        fn inline_align(_context: fidl::encoding::Context) -> usize {
1137            1
1138        }
1139
1140        #[inline(always)]
1141        fn inline_size(_context: fidl::encoding::Context) -> usize {
1142            1
1143        }
1144    }
1145
1146    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SystemMonotonic, D>
1147        for &SystemMonotonic
1148    {
1149        #[inline]
1150        unsafe fn encode(
1151            self,
1152            encoder: &mut fidl::encoding::Encoder<'_, D>,
1153            offset: usize,
1154            _depth: fidl::encoding::Depth,
1155        ) -> fidl::Result<()> {
1156            encoder.debug_check_bounds::<SystemMonotonic>(offset);
1157            encoder.write_num(0u8, offset);
1158            Ok(())
1159        }
1160    }
1161
1162    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SystemMonotonic {
1163        #[inline(always)]
1164        fn new_empty() -> Self {
1165            Self
1166        }
1167
1168        #[inline]
1169        unsafe fn decode(
1170            &mut self,
1171            decoder: &mut fidl::encoding::Decoder<'_, D>,
1172            offset: usize,
1173            _depth: fidl::encoding::Depth,
1174        ) -> fidl::Result<()> {
1175            decoder.debug_check_bounds::<Self>(offset);
1176            match decoder.read_num::<u8>(offset) {
1177                0 => Ok(()),
1178                _ => Err(fidl::Error::Invalid),
1179            }
1180        }
1181    }
1182
1183    impl fidl::encoding::ValueTypeMarker for UltrasoundCapturer {
1184        type Borrowed<'a> = &'a Self;
1185        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1186            value
1187        }
1188    }
1189
1190    unsafe impl fidl::encoding::TypeMarker for UltrasoundCapturer {
1191        type Owned = Self;
1192
1193        #[inline(always)]
1194        fn inline_align(_context: fidl::encoding::Context) -> usize {
1195            1
1196        }
1197
1198        #[inline(always)]
1199        fn inline_size(_context: fidl::encoding::Context) -> usize {
1200            1
1201        }
1202    }
1203
1204    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<UltrasoundCapturer, D>
1205        for &UltrasoundCapturer
1206    {
1207        #[inline]
1208        unsafe fn encode(
1209            self,
1210            encoder: &mut fidl::encoding::Encoder<'_, D>,
1211            offset: usize,
1212            _depth: fidl::encoding::Depth,
1213        ) -> fidl::Result<()> {
1214            encoder.debug_check_bounds::<UltrasoundCapturer>(offset);
1215            encoder.write_num(0u8, offset);
1216            Ok(())
1217        }
1218    }
1219
1220    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for UltrasoundCapturer {
1221        #[inline(always)]
1222        fn new_empty() -> Self {
1223            Self
1224        }
1225
1226        #[inline]
1227        unsafe fn decode(
1228            &mut self,
1229            decoder: &mut fidl::encoding::Decoder<'_, D>,
1230            offset: usize,
1231            _depth: fidl::encoding::Depth,
1232        ) -> fidl::Result<()> {
1233            decoder.debug_check_bounds::<Self>(offset);
1234            match decoder.read_num::<u8>(offset) {
1235                0 => Ok(()),
1236                _ => Err(fidl::Error::Invalid),
1237            }
1238        }
1239    }
1240
1241    impl CustomClockConfig {
1242        #[inline(always)]
1243        fn max_ordinal_present(&self) -> u64 {
1244            if let Some(_) = self.offset {
1245                return 2;
1246            }
1247            if let Some(_) = self.rate_adjust {
1248                return 1;
1249            }
1250            0
1251        }
1252    }
1253
1254    impl fidl::encoding::ValueTypeMarker for CustomClockConfig {
1255        type Borrowed<'a> = &'a Self;
1256        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1257            value
1258        }
1259    }
1260
1261    unsafe impl fidl::encoding::TypeMarker for CustomClockConfig {
1262        type Owned = Self;
1263
1264        #[inline(always)]
1265        fn inline_align(_context: fidl::encoding::Context) -> usize {
1266            8
1267        }
1268
1269        #[inline(always)]
1270        fn inline_size(_context: fidl::encoding::Context) -> usize {
1271            16
1272        }
1273    }
1274
1275    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CustomClockConfig, D>
1276        for &CustomClockConfig
1277    {
1278        unsafe fn encode(
1279            self,
1280            encoder: &mut fidl::encoding::Encoder<'_, D>,
1281            offset: usize,
1282            mut depth: fidl::encoding::Depth,
1283        ) -> fidl::Result<()> {
1284            encoder.debug_check_bounds::<CustomClockConfig>(offset);
1285            // Vector header
1286            let max_ordinal: u64 = self.max_ordinal_present();
1287            encoder.write_num(max_ordinal, offset);
1288            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1289            // Calling encoder.out_of_line_offset(0) is not allowed.
1290            if max_ordinal == 0 {
1291                return Ok(());
1292            }
1293            depth.increment()?;
1294            let envelope_size = 8;
1295            let bytes_len = max_ordinal as usize * envelope_size;
1296            #[allow(unused_variables)]
1297            let offset = encoder.out_of_line_offset(bytes_len);
1298            let mut _prev_end_offset: usize = 0;
1299            if 1 > max_ordinal {
1300                return Ok(());
1301            }
1302
1303            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1304            // are envelope_size bytes.
1305            let cur_offset: usize = (1 - 1) * envelope_size;
1306
1307            // Zero reserved fields.
1308            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1309
1310            // Safety:
1311            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1312            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1313            //   envelope_size bytes, there is always sufficient room.
1314            fidl::encoding::encode_in_envelope_optional::<i32, D>(
1315                self.rate_adjust.as_ref().map(<i32 as fidl::encoding::ValueTypeMarker>::borrow),
1316                encoder,
1317                offset + cur_offset,
1318                depth,
1319            )?;
1320
1321            _prev_end_offset = cur_offset + envelope_size;
1322            if 2 > max_ordinal {
1323                return Ok(());
1324            }
1325
1326            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1327            // are envelope_size bytes.
1328            let cur_offset: usize = (2 - 1) * envelope_size;
1329
1330            // Zero reserved fields.
1331            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1332
1333            // Safety:
1334            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1335            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1336            //   envelope_size bytes, there is always sufficient room.
1337            fidl::encoding::encode_in_envelope_optional::<i32, D>(
1338                self.offset.as_ref().map(<i32 as fidl::encoding::ValueTypeMarker>::borrow),
1339                encoder,
1340                offset + cur_offset,
1341                depth,
1342            )?;
1343
1344            _prev_end_offset = cur_offset + envelope_size;
1345
1346            Ok(())
1347        }
1348    }
1349
1350    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CustomClockConfig {
1351        #[inline(always)]
1352        fn new_empty() -> Self {
1353            Self::default()
1354        }
1355
1356        unsafe fn decode(
1357            &mut self,
1358            decoder: &mut fidl::encoding::Decoder<'_, D>,
1359            offset: usize,
1360            mut depth: fidl::encoding::Depth,
1361        ) -> fidl::Result<()> {
1362            decoder.debug_check_bounds::<Self>(offset);
1363            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1364                None => return Err(fidl::Error::NotNullable),
1365                Some(len) => len,
1366            };
1367            // Calling decoder.out_of_line_offset(0) is not allowed.
1368            if len == 0 {
1369                return Ok(());
1370            };
1371            depth.increment()?;
1372            let envelope_size = 8;
1373            let bytes_len = len * envelope_size;
1374            let offset = decoder.out_of_line_offset(bytes_len)?;
1375            // Decode the envelope for each type.
1376            let mut _next_ordinal_to_read = 0;
1377            let mut next_offset = offset;
1378            let end_offset = offset + bytes_len;
1379            _next_ordinal_to_read += 1;
1380            if next_offset >= end_offset {
1381                return Ok(());
1382            }
1383
1384            // Decode unknown envelopes for gaps in ordinals.
1385            while _next_ordinal_to_read < 1 {
1386                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1387                _next_ordinal_to_read += 1;
1388                next_offset += envelope_size;
1389            }
1390
1391            let next_out_of_line = decoder.next_out_of_line();
1392            let handles_before = decoder.remaining_handles();
1393            if let Some((inlined, num_bytes, num_handles)) =
1394                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1395            {
1396                let member_inline_size =
1397                    <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1398                if inlined != (member_inline_size <= 4) {
1399                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1400                }
1401                let inner_offset;
1402                let mut inner_depth = depth.clone();
1403                if inlined {
1404                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1405                    inner_offset = next_offset;
1406                } else {
1407                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1408                    inner_depth.increment()?;
1409                }
1410                let val_ref = self.rate_adjust.get_or_insert_with(|| fidl::new_empty!(i32, D));
1411                fidl::decode!(i32, D, val_ref, decoder, inner_offset, inner_depth)?;
1412                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1413                {
1414                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1415                }
1416                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1417                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1418                }
1419            }
1420
1421            next_offset += envelope_size;
1422            _next_ordinal_to_read += 1;
1423            if next_offset >= end_offset {
1424                return Ok(());
1425            }
1426
1427            // Decode unknown envelopes for gaps in ordinals.
1428            while _next_ordinal_to_read < 2 {
1429                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1430                _next_ordinal_to_read += 1;
1431                next_offset += envelope_size;
1432            }
1433
1434            let next_out_of_line = decoder.next_out_of_line();
1435            let handles_before = decoder.remaining_handles();
1436            if let Some((inlined, num_bytes, num_handles)) =
1437                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1438            {
1439                let member_inline_size =
1440                    <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1441                if inlined != (member_inline_size <= 4) {
1442                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1443                }
1444                let inner_offset;
1445                let mut inner_depth = depth.clone();
1446                if inlined {
1447                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1448                    inner_offset = next_offset;
1449                } else {
1450                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1451                    inner_depth.increment()?;
1452                }
1453                let val_ref = self.offset.get_or_insert_with(|| fidl::new_empty!(i32, D));
1454                fidl::decode!(i32, D, val_ref, decoder, inner_offset, inner_depth)?;
1455                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1456                {
1457                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1458                }
1459                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1460                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1461                }
1462            }
1463
1464            next_offset += envelope_size;
1465
1466            // Decode the remaining unknown envelopes.
1467            while next_offset < end_offset {
1468                _next_ordinal_to_read += 1;
1469                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1470                next_offset += envelope_size;
1471            }
1472
1473            Ok(())
1474        }
1475    }
1476
1477    impl GainSettings {
1478        #[inline(always)]
1479        fn max_ordinal_present(&self) -> u64 {
1480            if let Some(_) = self.gain {
1481                return 2;
1482            }
1483            if let Some(_) = self.mute {
1484                return 1;
1485            }
1486            0
1487        }
1488    }
1489
1490    impl fidl::encoding::ValueTypeMarker for GainSettings {
1491        type Borrowed<'a> = &'a Self;
1492        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1493            value
1494        }
1495    }
1496
1497    unsafe impl fidl::encoding::TypeMarker for GainSettings {
1498        type Owned = Self;
1499
1500        #[inline(always)]
1501        fn inline_align(_context: fidl::encoding::Context) -> usize {
1502            8
1503        }
1504
1505        #[inline(always)]
1506        fn inline_size(_context: fidl::encoding::Context) -> usize {
1507            16
1508        }
1509    }
1510
1511    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<GainSettings, D>
1512        for &GainSettings
1513    {
1514        unsafe fn encode(
1515            self,
1516            encoder: &mut fidl::encoding::Encoder<'_, D>,
1517            offset: usize,
1518            mut depth: fidl::encoding::Depth,
1519        ) -> fidl::Result<()> {
1520            encoder.debug_check_bounds::<GainSettings>(offset);
1521            // Vector header
1522            let max_ordinal: u64 = self.max_ordinal_present();
1523            encoder.write_num(max_ordinal, offset);
1524            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1525            // Calling encoder.out_of_line_offset(0) is not allowed.
1526            if max_ordinal == 0 {
1527                return Ok(());
1528            }
1529            depth.increment()?;
1530            let envelope_size = 8;
1531            let bytes_len = max_ordinal as usize * envelope_size;
1532            #[allow(unused_variables)]
1533            let offset = encoder.out_of_line_offset(bytes_len);
1534            let mut _prev_end_offset: usize = 0;
1535            if 1 > max_ordinal {
1536                return Ok(());
1537            }
1538
1539            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1540            // are envelope_size bytes.
1541            let cur_offset: usize = (1 - 1) * envelope_size;
1542
1543            // Zero reserved fields.
1544            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1545
1546            // Safety:
1547            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1548            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1549            //   envelope_size bytes, there is always sufficient room.
1550            fidl::encoding::encode_in_envelope_optional::<bool, D>(
1551                self.mute.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1552                encoder,
1553                offset + cur_offset,
1554                depth,
1555            )?;
1556
1557            _prev_end_offset = cur_offset + envelope_size;
1558            if 2 > max_ordinal {
1559                return Ok(());
1560            }
1561
1562            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1563            // are envelope_size bytes.
1564            let cur_offset: usize = (2 - 1) * envelope_size;
1565
1566            // Zero reserved fields.
1567            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1568
1569            // Safety:
1570            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1571            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1572            //   envelope_size bytes, there is always sufficient room.
1573            fidl::encoding::encode_in_envelope_optional::<f32, D>(
1574                self.gain.as_ref().map(<f32 as fidl::encoding::ValueTypeMarker>::borrow),
1575                encoder,
1576                offset + cur_offset,
1577                depth,
1578            )?;
1579
1580            _prev_end_offset = cur_offset + envelope_size;
1581
1582            Ok(())
1583        }
1584    }
1585
1586    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for GainSettings {
1587        #[inline(always)]
1588        fn new_empty() -> Self {
1589            Self::default()
1590        }
1591
1592        unsafe fn decode(
1593            &mut self,
1594            decoder: &mut fidl::encoding::Decoder<'_, D>,
1595            offset: usize,
1596            mut depth: fidl::encoding::Depth,
1597        ) -> fidl::Result<()> {
1598            decoder.debug_check_bounds::<Self>(offset);
1599            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1600                None => return Err(fidl::Error::NotNullable),
1601                Some(len) => len,
1602            };
1603            // Calling decoder.out_of_line_offset(0) is not allowed.
1604            if len == 0 {
1605                return Ok(());
1606            };
1607            depth.increment()?;
1608            let envelope_size = 8;
1609            let bytes_len = len * envelope_size;
1610            let offset = decoder.out_of_line_offset(bytes_len)?;
1611            // Decode the envelope for each type.
1612            let mut _next_ordinal_to_read = 0;
1613            let mut next_offset = offset;
1614            let end_offset = offset + bytes_len;
1615            _next_ordinal_to_read += 1;
1616            if next_offset >= end_offset {
1617                return Ok(());
1618            }
1619
1620            // Decode unknown envelopes for gaps in ordinals.
1621            while _next_ordinal_to_read < 1 {
1622                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1623                _next_ordinal_to_read += 1;
1624                next_offset += envelope_size;
1625            }
1626
1627            let next_out_of_line = decoder.next_out_of_line();
1628            let handles_before = decoder.remaining_handles();
1629            if let Some((inlined, num_bytes, num_handles)) =
1630                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1631            {
1632                let member_inline_size =
1633                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1634                if inlined != (member_inline_size <= 4) {
1635                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1636                }
1637                let inner_offset;
1638                let mut inner_depth = depth.clone();
1639                if inlined {
1640                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1641                    inner_offset = next_offset;
1642                } else {
1643                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1644                    inner_depth.increment()?;
1645                }
1646                let val_ref = self.mute.get_or_insert_with(|| fidl::new_empty!(bool, D));
1647                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1648                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1649                {
1650                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1651                }
1652                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1653                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1654                }
1655            }
1656
1657            next_offset += envelope_size;
1658            _next_ordinal_to_read += 1;
1659            if next_offset >= end_offset {
1660                return Ok(());
1661            }
1662
1663            // Decode unknown envelopes for gaps in ordinals.
1664            while _next_ordinal_to_read < 2 {
1665                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1666                _next_ordinal_to_read += 1;
1667                next_offset += envelope_size;
1668            }
1669
1670            let next_out_of_line = decoder.next_out_of_line();
1671            let handles_before = decoder.remaining_handles();
1672            if let Some((inlined, num_bytes, num_handles)) =
1673                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1674            {
1675                let member_inline_size =
1676                    <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1677                if inlined != (member_inline_size <= 4) {
1678                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1679                }
1680                let inner_offset;
1681                let mut inner_depth = depth.clone();
1682                if inlined {
1683                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1684                    inner_offset = next_offset;
1685                } else {
1686                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1687                    inner_depth.increment()?;
1688                }
1689                let val_ref = self.gain.get_or_insert_with(|| fidl::new_empty!(f32, D));
1690                fidl::decode!(f32, D, val_ref, decoder, inner_offset, inner_depth)?;
1691                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1692                {
1693                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1694                }
1695                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1696                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1697                }
1698            }
1699
1700            next_offset += envelope_size;
1701
1702            // Decode the remaining unknown envelopes.
1703            while next_offset < end_offset {
1704                _next_ordinal_to_read += 1;
1705                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1706                next_offset += envelope_size;
1707            }
1708
1709            Ok(())
1710        }
1711    }
1712
1713    impl StandardCapturerConfig {
1714        #[inline(always)]
1715        fn max_ordinal_present(&self) -> u64 {
1716            if let Some(_) = self.clock {
1717                return 2;
1718            }
1719            if let Some(_) = self.usage {
1720                return 1;
1721            }
1722            0
1723        }
1724    }
1725
1726    impl fidl::encoding::ValueTypeMarker for StandardCapturerConfig {
1727        type Borrowed<'a> = &'a Self;
1728        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1729            value
1730        }
1731    }
1732
1733    unsafe impl fidl::encoding::TypeMarker for StandardCapturerConfig {
1734        type Owned = Self;
1735
1736        #[inline(always)]
1737        fn inline_align(_context: fidl::encoding::Context) -> usize {
1738            8
1739        }
1740
1741        #[inline(always)]
1742        fn inline_size(_context: fidl::encoding::Context) -> usize {
1743            16
1744        }
1745    }
1746
1747    unsafe impl<D: fidl::encoding::ResourceDialect>
1748        fidl::encoding::Encode<StandardCapturerConfig, D> for &StandardCapturerConfig
1749    {
1750        unsafe fn encode(
1751            self,
1752            encoder: &mut fidl::encoding::Encoder<'_, D>,
1753            offset: usize,
1754            mut depth: fidl::encoding::Depth,
1755        ) -> fidl::Result<()> {
1756            encoder.debug_check_bounds::<StandardCapturerConfig>(offset);
1757            // Vector header
1758            let max_ordinal: u64 = self.max_ordinal_present();
1759            encoder.write_num(max_ordinal, offset);
1760            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1761            // Calling encoder.out_of_line_offset(0) is not allowed.
1762            if max_ordinal == 0 {
1763                return Ok(());
1764            }
1765            depth.increment()?;
1766            let envelope_size = 8;
1767            let bytes_len = max_ordinal as usize * envelope_size;
1768            #[allow(unused_variables)]
1769            let offset = encoder.out_of_line_offset(bytes_len);
1770            let mut _prev_end_offset: usize = 0;
1771            if 1 > max_ordinal {
1772                return Ok(());
1773            }
1774
1775            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1776            // are envelope_size bytes.
1777            let cur_offset: usize = (1 - 1) * envelope_size;
1778
1779            // Zero reserved fields.
1780            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1781
1782            // Safety:
1783            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1784            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1785            //   envelope_size bytes, there is always sufficient room.
1786            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media__common::AudioCaptureUsage2, D>(
1787            self.usage.as_ref().map(<fidl_fuchsia_media__common::AudioCaptureUsage2 as fidl::encoding::ValueTypeMarker>::borrow),
1788            encoder, offset + cur_offset, depth
1789        )?;
1790
1791            _prev_end_offset = cur_offset + envelope_size;
1792            if 2 > max_ordinal {
1793                return Ok(());
1794            }
1795
1796            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1797            // are envelope_size bytes.
1798            let cur_offset: usize = (2 - 1) * envelope_size;
1799
1800            // Zero reserved fields.
1801            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1802
1803            // Safety:
1804            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1805            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1806            //   envelope_size bytes, there is always sufficient room.
1807            fidl::encoding::encode_in_envelope_optional::<ClockType, D>(
1808                self.clock.as_ref().map(<ClockType as fidl::encoding::ValueTypeMarker>::borrow),
1809                encoder,
1810                offset + cur_offset,
1811                depth,
1812            )?;
1813
1814            _prev_end_offset = cur_offset + envelope_size;
1815
1816            Ok(())
1817        }
1818    }
1819
1820    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1821        for StandardCapturerConfig
1822    {
1823        #[inline(always)]
1824        fn new_empty() -> Self {
1825            Self::default()
1826        }
1827
1828        unsafe fn decode(
1829            &mut self,
1830            decoder: &mut fidl::encoding::Decoder<'_, D>,
1831            offset: usize,
1832            mut depth: fidl::encoding::Depth,
1833        ) -> fidl::Result<()> {
1834            decoder.debug_check_bounds::<Self>(offset);
1835            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1836                None => return Err(fidl::Error::NotNullable),
1837                Some(len) => len,
1838            };
1839            // Calling decoder.out_of_line_offset(0) is not allowed.
1840            if len == 0 {
1841                return Ok(());
1842            };
1843            depth.increment()?;
1844            let envelope_size = 8;
1845            let bytes_len = len * envelope_size;
1846            let offset = decoder.out_of_line_offset(bytes_len)?;
1847            // Decode the envelope for each type.
1848            let mut _next_ordinal_to_read = 0;
1849            let mut next_offset = offset;
1850            let end_offset = offset + bytes_len;
1851            _next_ordinal_to_read += 1;
1852            if next_offset >= end_offset {
1853                return Ok(());
1854            }
1855
1856            // Decode unknown envelopes for gaps in ordinals.
1857            while _next_ordinal_to_read < 1 {
1858                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1859                _next_ordinal_to_read += 1;
1860                next_offset += envelope_size;
1861            }
1862
1863            let next_out_of_line = decoder.next_out_of_line();
1864            let handles_before = decoder.remaining_handles();
1865            if let Some((inlined, num_bytes, num_handles)) =
1866                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1867            {
1868                let member_inline_size = <fidl_fuchsia_media__common::AudioCaptureUsage2 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1869                if inlined != (member_inline_size <= 4) {
1870                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1871                }
1872                let inner_offset;
1873                let mut inner_depth = depth.clone();
1874                if inlined {
1875                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1876                    inner_offset = next_offset;
1877                } else {
1878                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1879                    inner_depth.increment()?;
1880                }
1881                let val_ref = self.usage.get_or_insert_with(|| {
1882                    fidl::new_empty!(fidl_fuchsia_media__common::AudioCaptureUsage2, D)
1883                });
1884                fidl::decode!(
1885                    fidl_fuchsia_media__common::AudioCaptureUsage2,
1886                    D,
1887                    val_ref,
1888                    decoder,
1889                    inner_offset,
1890                    inner_depth
1891                )?;
1892                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1893                {
1894                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1895                }
1896                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1897                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1898                }
1899            }
1900
1901            next_offset += envelope_size;
1902            _next_ordinal_to_read += 1;
1903            if next_offset >= end_offset {
1904                return Ok(());
1905            }
1906
1907            // Decode unknown envelopes for gaps in ordinals.
1908            while _next_ordinal_to_read < 2 {
1909                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1910                _next_ordinal_to_read += 1;
1911                next_offset += envelope_size;
1912            }
1913
1914            let next_out_of_line = decoder.next_out_of_line();
1915            let handles_before = decoder.remaining_handles();
1916            if let Some((inlined, num_bytes, num_handles)) =
1917                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1918            {
1919                let member_inline_size =
1920                    <ClockType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1921                if inlined != (member_inline_size <= 4) {
1922                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1923                }
1924                let inner_offset;
1925                let mut inner_depth = depth.clone();
1926                if inlined {
1927                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1928                    inner_offset = next_offset;
1929                } else {
1930                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1931                    inner_depth.increment()?;
1932                }
1933                let val_ref = self.clock.get_or_insert_with(|| fidl::new_empty!(ClockType, D));
1934                fidl::decode!(ClockType, D, val_ref, decoder, inner_offset, inner_depth)?;
1935                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1936                {
1937                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1938                }
1939                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1940                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1941                }
1942            }
1943
1944            next_offset += envelope_size;
1945
1946            // Decode the remaining unknown envelopes.
1947            while next_offset < end_offset {
1948                _next_ordinal_to_read += 1;
1949                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1950                next_offset += envelope_size;
1951            }
1952
1953            Ok(())
1954        }
1955    }
1956
1957    impl StandardRendererConfig {
1958        #[inline(always)]
1959        fn max_ordinal_present(&self) -> u64 {
1960            if let Some(_) = self.packet_count {
1961                return 3;
1962            }
1963            if let Some(_) = self.clock {
1964                return 2;
1965            }
1966            if let Some(_) = self.usage {
1967                return 1;
1968            }
1969            0
1970        }
1971    }
1972
1973    impl fidl::encoding::ValueTypeMarker for StandardRendererConfig {
1974        type Borrowed<'a> = &'a Self;
1975        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1976            value
1977        }
1978    }
1979
1980    unsafe impl fidl::encoding::TypeMarker for StandardRendererConfig {
1981        type Owned = Self;
1982
1983        #[inline(always)]
1984        fn inline_align(_context: fidl::encoding::Context) -> usize {
1985            8
1986        }
1987
1988        #[inline(always)]
1989        fn inline_size(_context: fidl::encoding::Context) -> usize {
1990            16
1991        }
1992    }
1993
1994    unsafe impl<D: fidl::encoding::ResourceDialect>
1995        fidl::encoding::Encode<StandardRendererConfig, D> for &StandardRendererConfig
1996    {
1997        unsafe fn encode(
1998            self,
1999            encoder: &mut fidl::encoding::Encoder<'_, D>,
2000            offset: usize,
2001            mut depth: fidl::encoding::Depth,
2002        ) -> fidl::Result<()> {
2003            encoder.debug_check_bounds::<StandardRendererConfig>(offset);
2004            // Vector header
2005            let max_ordinal: u64 = self.max_ordinal_present();
2006            encoder.write_num(max_ordinal, offset);
2007            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2008            // Calling encoder.out_of_line_offset(0) is not allowed.
2009            if max_ordinal == 0 {
2010                return Ok(());
2011            }
2012            depth.increment()?;
2013            let envelope_size = 8;
2014            let bytes_len = max_ordinal as usize * envelope_size;
2015            #[allow(unused_variables)]
2016            let offset = encoder.out_of_line_offset(bytes_len);
2017            let mut _prev_end_offset: usize = 0;
2018            if 1 > max_ordinal {
2019                return Ok(());
2020            }
2021
2022            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2023            // are envelope_size bytes.
2024            let cur_offset: usize = (1 - 1) * envelope_size;
2025
2026            // Zero reserved fields.
2027            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2028
2029            // Safety:
2030            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2031            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2032            //   envelope_size bytes, there is always sufficient room.
2033            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media__common::AudioRenderUsage2, D>(
2034            self.usage.as_ref().map(<fidl_fuchsia_media__common::AudioRenderUsage2 as fidl::encoding::ValueTypeMarker>::borrow),
2035            encoder, offset + cur_offset, depth
2036        )?;
2037
2038            _prev_end_offset = cur_offset + envelope_size;
2039            if 2 > max_ordinal {
2040                return Ok(());
2041            }
2042
2043            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2044            // are envelope_size bytes.
2045            let cur_offset: usize = (2 - 1) * envelope_size;
2046
2047            // Zero reserved fields.
2048            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2049
2050            // Safety:
2051            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2052            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2053            //   envelope_size bytes, there is always sufficient room.
2054            fidl::encoding::encode_in_envelope_optional::<ClockType, D>(
2055                self.clock.as_ref().map(<ClockType as fidl::encoding::ValueTypeMarker>::borrow),
2056                encoder,
2057                offset + cur_offset,
2058                depth,
2059            )?;
2060
2061            _prev_end_offset = cur_offset + envelope_size;
2062            if 3 > max_ordinal {
2063                return Ok(());
2064            }
2065
2066            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2067            // are envelope_size bytes.
2068            let cur_offset: usize = (3 - 1) * envelope_size;
2069
2070            // Zero reserved fields.
2071            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2072
2073            // Safety:
2074            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2075            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2076            //   envelope_size bytes, there is always sufficient room.
2077            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2078                self.packet_count.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2079                encoder,
2080                offset + cur_offset,
2081                depth,
2082            )?;
2083
2084            _prev_end_offset = cur_offset + envelope_size;
2085
2086            Ok(())
2087        }
2088    }
2089
2090    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2091        for StandardRendererConfig
2092    {
2093        #[inline(always)]
2094        fn new_empty() -> Self {
2095            Self::default()
2096        }
2097
2098        unsafe fn decode(
2099            &mut self,
2100            decoder: &mut fidl::encoding::Decoder<'_, D>,
2101            offset: usize,
2102            mut depth: fidl::encoding::Depth,
2103        ) -> fidl::Result<()> {
2104            decoder.debug_check_bounds::<Self>(offset);
2105            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2106                None => return Err(fidl::Error::NotNullable),
2107                Some(len) => len,
2108            };
2109            // Calling decoder.out_of_line_offset(0) is not allowed.
2110            if len == 0 {
2111                return Ok(());
2112            };
2113            depth.increment()?;
2114            let envelope_size = 8;
2115            let bytes_len = len * envelope_size;
2116            let offset = decoder.out_of_line_offset(bytes_len)?;
2117            // Decode the envelope for each type.
2118            let mut _next_ordinal_to_read = 0;
2119            let mut next_offset = offset;
2120            let end_offset = offset + bytes_len;
2121            _next_ordinal_to_read += 1;
2122            if next_offset >= end_offset {
2123                return Ok(());
2124            }
2125
2126            // Decode unknown envelopes for gaps in ordinals.
2127            while _next_ordinal_to_read < 1 {
2128                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2129                _next_ordinal_to_read += 1;
2130                next_offset += envelope_size;
2131            }
2132
2133            let next_out_of_line = decoder.next_out_of_line();
2134            let handles_before = decoder.remaining_handles();
2135            if let Some((inlined, num_bytes, num_handles)) =
2136                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2137            {
2138                let member_inline_size = <fidl_fuchsia_media__common::AudioRenderUsage2 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2139                if inlined != (member_inline_size <= 4) {
2140                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2141                }
2142                let inner_offset;
2143                let mut inner_depth = depth.clone();
2144                if inlined {
2145                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2146                    inner_offset = next_offset;
2147                } else {
2148                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2149                    inner_depth.increment()?;
2150                }
2151                let val_ref = self.usage.get_or_insert_with(|| {
2152                    fidl::new_empty!(fidl_fuchsia_media__common::AudioRenderUsage2, D)
2153                });
2154                fidl::decode!(
2155                    fidl_fuchsia_media__common::AudioRenderUsage2,
2156                    D,
2157                    val_ref,
2158                    decoder,
2159                    inner_offset,
2160                    inner_depth
2161                )?;
2162                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2163                {
2164                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2165                }
2166                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2167                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2168                }
2169            }
2170
2171            next_offset += envelope_size;
2172            _next_ordinal_to_read += 1;
2173            if next_offset >= end_offset {
2174                return Ok(());
2175            }
2176
2177            // Decode unknown envelopes for gaps in ordinals.
2178            while _next_ordinal_to_read < 2 {
2179                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2180                _next_ordinal_to_read += 1;
2181                next_offset += envelope_size;
2182            }
2183
2184            let next_out_of_line = decoder.next_out_of_line();
2185            let handles_before = decoder.remaining_handles();
2186            if let Some((inlined, num_bytes, num_handles)) =
2187                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2188            {
2189                let member_inline_size =
2190                    <ClockType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2191                if inlined != (member_inline_size <= 4) {
2192                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2193                }
2194                let inner_offset;
2195                let mut inner_depth = depth.clone();
2196                if inlined {
2197                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2198                    inner_offset = next_offset;
2199                } else {
2200                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2201                    inner_depth.increment()?;
2202                }
2203                let val_ref = self.clock.get_or_insert_with(|| fidl::new_empty!(ClockType, D));
2204                fidl::decode!(ClockType, D, val_ref, decoder, inner_offset, inner_depth)?;
2205                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2206                {
2207                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2208                }
2209                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2210                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2211                }
2212            }
2213
2214            next_offset += envelope_size;
2215            _next_ordinal_to_read += 1;
2216            if next_offset >= end_offset {
2217                return Ok(());
2218            }
2219
2220            // Decode unknown envelopes for gaps in ordinals.
2221            while _next_ordinal_to_read < 3 {
2222                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2223                _next_ordinal_to_read += 1;
2224                next_offset += envelope_size;
2225            }
2226
2227            let next_out_of_line = decoder.next_out_of_line();
2228            let handles_before = decoder.remaining_handles();
2229            if let Some((inlined, num_bytes, num_handles)) =
2230                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2231            {
2232                let member_inline_size =
2233                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2234                if inlined != (member_inline_size <= 4) {
2235                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2236                }
2237                let inner_offset;
2238                let mut inner_depth = depth.clone();
2239                if inlined {
2240                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2241                    inner_offset = next_offset;
2242                } else {
2243                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2244                    inner_depth.increment()?;
2245                }
2246                let val_ref = self.packet_count.get_or_insert_with(|| fidl::new_empty!(u32, D));
2247                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2248                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2249                {
2250                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2251                }
2252                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2253                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2254                }
2255            }
2256
2257            next_offset += envelope_size;
2258
2259            // Decode the remaining unknown envelopes.
2260            while next_offset < end_offset {
2261                _next_ordinal_to_read += 1;
2262                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2263                next_offset += envelope_size;
2264            }
2265
2266            Ok(())
2267        }
2268    }
2269
2270    impl UltrasoundRendererConfig {
2271        #[inline(always)]
2272        fn max_ordinal_present(&self) -> u64 {
2273            if let Some(_) = self.packet_count {
2274                return 1;
2275            }
2276            0
2277        }
2278    }
2279
2280    impl fidl::encoding::ValueTypeMarker for UltrasoundRendererConfig {
2281        type Borrowed<'a> = &'a Self;
2282        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2283            value
2284        }
2285    }
2286
2287    unsafe impl fidl::encoding::TypeMarker for UltrasoundRendererConfig {
2288        type Owned = Self;
2289
2290        #[inline(always)]
2291        fn inline_align(_context: fidl::encoding::Context) -> usize {
2292            8
2293        }
2294
2295        #[inline(always)]
2296        fn inline_size(_context: fidl::encoding::Context) -> usize {
2297            16
2298        }
2299    }
2300
2301    unsafe impl<D: fidl::encoding::ResourceDialect>
2302        fidl::encoding::Encode<UltrasoundRendererConfig, D> for &UltrasoundRendererConfig
2303    {
2304        unsafe fn encode(
2305            self,
2306            encoder: &mut fidl::encoding::Encoder<'_, D>,
2307            offset: usize,
2308            mut depth: fidl::encoding::Depth,
2309        ) -> fidl::Result<()> {
2310            encoder.debug_check_bounds::<UltrasoundRendererConfig>(offset);
2311            // Vector header
2312            let max_ordinal: u64 = self.max_ordinal_present();
2313            encoder.write_num(max_ordinal, offset);
2314            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2315            // Calling encoder.out_of_line_offset(0) is not allowed.
2316            if max_ordinal == 0 {
2317                return Ok(());
2318            }
2319            depth.increment()?;
2320            let envelope_size = 8;
2321            let bytes_len = max_ordinal as usize * envelope_size;
2322            #[allow(unused_variables)]
2323            let offset = encoder.out_of_line_offset(bytes_len);
2324            let mut _prev_end_offset: usize = 0;
2325            if 1 > max_ordinal {
2326                return Ok(());
2327            }
2328
2329            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2330            // are envelope_size bytes.
2331            let cur_offset: usize = (1 - 1) * envelope_size;
2332
2333            // Zero reserved fields.
2334            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2335
2336            // Safety:
2337            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2338            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2339            //   envelope_size bytes, there is always sufficient room.
2340            fidl::encoding::encode_in_envelope_optional::<u32, D>(
2341                self.packet_count.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2342                encoder,
2343                offset + cur_offset,
2344                depth,
2345            )?;
2346
2347            _prev_end_offset = cur_offset + envelope_size;
2348
2349            Ok(())
2350        }
2351    }
2352
2353    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2354        for UltrasoundRendererConfig
2355    {
2356        #[inline(always)]
2357        fn new_empty() -> Self {
2358            Self::default()
2359        }
2360
2361        unsafe fn decode(
2362            &mut self,
2363            decoder: &mut fidl::encoding::Decoder<'_, D>,
2364            offset: usize,
2365            mut depth: fidl::encoding::Depth,
2366        ) -> fidl::Result<()> {
2367            decoder.debug_check_bounds::<Self>(offset);
2368            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2369                None => return Err(fidl::Error::NotNullable),
2370                Some(len) => len,
2371            };
2372            // Calling decoder.out_of_line_offset(0) is not allowed.
2373            if len == 0 {
2374                return Ok(());
2375            };
2376            depth.increment()?;
2377            let envelope_size = 8;
2378            let bytes_len = len * envelope_size;
2379            let offset = decoder.out_of_line_offset(bytes_len)?;
2380            // Decode the envelope for each type.
2381            let mut _next_ordinal_to_read = 0;
2382            let mut next_offset = offset;
2383            let end_offset = offset + bytes_len;
2384            _next_ordinal_to_read += 1;
2385            if next_offset >= end_offset {
2386                return Ok(());
2387            }
2388
2389            // Decode unknown envelopes for gaps in ordinals.
2390            while _next_ordinal_to_read < 1 {
2391                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2392                _next_ordinal_to_read += 1;
2393                next_offset += envelope_size;
2394            }
2395
2396            let next_out_of_line = decoder.next_out_of_line();
2397            let handles_before = decoder.remaining_handles();
2398            if let Some((inlined, num_bytes, num_handles)) =
2399                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2400            {
2401                let member_inline_size =
2402                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2403                if inlined != (member_inline_size <= 4) {
2404                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2405                }
2406                let inner_offset;
2407                let mut inner_depth = depth.clone();
2408                if inlined {
2409                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2410                    inner_offset = next_offset;
2411                } else {
2412                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2413                    inner_depth.increment()?;
2414                }
2415                let val_ref = self.packet_count.get_or_insert_with(|| fidl::new_empty!(u32, D));
2416                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2417                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2418                {
2419                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2420                }
2421                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2422                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2423                }
2424            }
2425
2426            next_offset += envelope_size;
2427
2428            // Decode the remaining unknown envelopes.
2429            while next_offset < end_offset {
2430                _next_ordinal_to_read += 1;
2431                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2432                next_offset += envelope_size;
2433            }
2434
2435            Ok(())
2436        }
2437    }
2438
2439    impl fidl::encoding::ValueTypeMarker for CapturerConfig {
2440        type Borrowed<'a> = &'a Self;
2441        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2442            value
2443        }
2444    }
2445
2446    unsafe impl fidl::encoding::TypeMarker for CapturerConfig {
2447        type Owned = Self;
2448
2449        #[inline(always)]
2450        fn inline_align(_context: fidl::encoding::Context) -> usize {
2451            8
2452        }
2453
2454        #[inline(always)]
2455        fn inline_size(_context: fidl::encoding::Context) -> usize {
2456            16
2457        }
2458    }
2459
2460    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CapturerConfig, D>
2461        for &CapturerConfig
2462    {
2463        #[inline]
2464        unsafe fn encode(
2465            self,
2466            encoder: &mut fidl::encoding::Encoder<'_, D>,
2467            offset: usize,
2468            _depth: fidl::encoding::Depth,
2469        ) -> fidl::Result<()> {
2470            encoder.debug_check_bounds::<CapturerConfig>(offset);
2471            encoder.write_num::<u64>(self.ordinal(), offset);
2472            match self {
2473                CapturerConfig::StandardCapturer(ref val) => {
2474                    fidl::encoding::encode_in_envelope::<StandardCapturerConfig, D>(
2475                        <StandardCapturerConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
2476                        encoder,
2477                        offset + 8,
2478                        _depth,
2479                    )
2480                }
2481                CapturerConfig::UltrasoundCapturer(ref val) => {
2482                    fidl::encoding::encode_in_envelope::<UltrasoundCapturer, D>(
2483                        <UltrasoundCapturer as fidl::encoding::ValueTypeMarker>::borrow(val),
2484                        encoder,
2485                        offset + 8,
2486                        _depth,
2487                    )
2488                }
2489                CapturerConfig::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2490            }
2491        }
2492    }
2493
2494    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CapturerConfig {
2495        #[inline(always)]
2496        fn new_empty() -> Self {
2497            Self::__SourceBreaking { unknown_ordinal: 0 }
2498        }
2499
2500        #[inline]
2501        unsafe fn decode(
2502            &mut self,
2503            decoder: &mut fidl::encoding::Decoder<'_, D>,
2504            offset: usize,
2505            mut depth: fidl::encoding::Depth,
2506        ) -> fidl::Result<()> {
2507            decoder.debug_check_bounds::<Self>(offset);
2508            #[allow(unused_variables)]
2509            let next_out_of_line = decoder.next_out_of_line();
2510            let handles_before = decoder.remaining_handles();
2511            let (ordinal, inlined, num_bytes, num_handles) =
2512                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2513
2514            let member_inline_size = match ordinal {
2515                1 => <StandardCapturerConfig as fidl::encoding::TypeMarker>::inline_size(
2516                    decoder.context,
2517                ),
2518                2 => {
2519                    <UltrasoundCapturer as fidl::encoding::TypeMarker>::inline_size(decoder.context)
2520                }
2521                0 => return Err(fidl::Error::UnknownUnionTag),
2522                _ => num_bytes as usize,
2523            };
2524
2525            if inlined != (member_inline_size <= 4) {
2526                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2527            }
2528            let _inner_offset;
2529            if inlined {
2530                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2531                _inner_offset = offset + 8;
2532            } else {
2533                depth.increment()?;
2534                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2535            }
2536            match ordinal {
2537                1 => {
2538                    #[allow(irrefutable_let_patterns)]
2539                    if let CapturerConfig::StandardCapturer(_) = self {
2540                        // Do nothing, read the value into the object
2541                    } else {
2542                        // Initialize `self` to the right variant
2543                        *self = CapturerConfig::StandardCapturer(fidl::new_empty!(
2544                            StandardCapturerConfig,
2545                            D
2546                        ));
2547                    }
2548                    #[allow(irrefutable_let_patterns)]
2549                    if let CapturerConfig::StandardCapturer(ref mut val) = self {
2550                        fidl::decode!(
2551                            StandardCapturerConfig,
2552                            D,
2553                            val,
2554                            decoder,
2555                            _inner_offset,
2556                            depth
2557                        )?;
2558                    } else {
2559                        unreachable!()
2560                    }
2561                }
2562                2 => {
2563                    #[allow(irrefutable_let_patterns)]
2564                    if let CapturerConfig::UltrasoundCapturer(_) = self {
2565                        // Do nothing, read the value into the object
2566                    } else {
2567                        // Initialize `self` to the right variant
2568                        *self = CapturerConfig::UltrasoundCapturer(fidl::new_empty!(
2569                            UltrasoundCapturer,
2570                            D
2571                        ));
2572                    }
2573                    #[allow(irrefutable_let_patterns)]
2574                    if let CapturerConfig::UltrasoundCapturer(ref mut val) = self {
2575                        fidl::decode!(UltrasoundCapturer, D, val, decoder, _inner_offset, depth)?;
2576                    } else {
2577                        unreachable!()
2578                    }
2579                }
2580                #[allow(deprecated)]
2581                ordinal => {
2582                    for _ in 0..num_handles {
2583                        decoder.drop_next_handle()?;
2584                    }
2585                    *self = CapturerConfig::__SourceBreaking { unknown_ordinal: ordinal };
2586                }
2587            }
2588            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2589                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2590            }
2591            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2592                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2593            }
2594            Ok(())
2595        }
2596    }
2597
2598    impl fidl::encoding::ValueTypeMarker for ClockType {
2599        type Borrowed<'a> = &'a Self;
2600        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2601            value
2602        }
2603    }
2604
2605    unsafe impl fidl::encoding::TypeMarker for ClockType {
2606        type Owned = Self;
2607
2608        #[inline(always)]
2609        fn inline_align(_context: fidl::encoding::Context) -> usize {
2610            8
2611        }
2612
2613        #[inline(always)]
2614        fn inline_size(_context: fidl::encoding::Context) -> usize {
2615            16
2616        }
2617    }
2618
2619    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ClockType, D>
2620        for &ClockType
2621    {
2622        #[inline]
2623        unsafe fn encode(
2624            self,
2625            encoder: &mut fidl::encoding::Encoder<'_, D>,
2626            offset: usize,
2627            _depth: fidl::encoding::Depth,
2628        ) -> fidl::Result<()> {
2629            encoder.debug_check_bounds::<ClockType>(offset);
2630            encoder.write_num::<u64>(self.ordinal(), offset);
2631            match self {
2632                ClockType::Flexible(ref val) => fidl::encoding::encode_in_envelope::<Flexible, D>(
2633                    <Flexible as fidl::encoding::ValueTypeMarker>::borrow(val),
2634                    encoder,
2635                    offset + 8,
2636                    _depth,
2637                ),
2638                ClockType::SystemMonotonic(ref val) => {
2639                    fidl::encoding::encode_in_envelope::<SystemMonotonic, D>(
2640                        <SystemMonotonic as fidl::encoding::ValueTypeMarker>::borrow(val),
2641                        encoder,
2642                        offset + 8,
2643                        _depth,
2644                    )
2645                }
2646                ClockType::Custom(ref val) => {
2647                    fidl::encoding::encode_in_envelope::<CustomClockConfig, D>(
2648                        <CustomClockConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
2649                        encoder,
2650                        offset + 8,
2651                        _depth,
2652                    )
2653                }
2654                ClockType::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2655            }
2656        }
2657    }
2658
2659    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ClockType {
2660        #[inline(always)]
2661        fn new_empty() -> Self {
2662            Self::__SourceBreaking { unknown_ordinal: 0 }
2663        }
2664
2665        #[inline]
2666        unsafe fn decode(
2667            &mut self,
2668            decoder: &mut fidl::encoding::Decoder<'_, D>,
2669            offset: usize,
2670            mut depth: fidl::encoding::Depth,
2671        ) -> fidl::Result<()> {
2672            decoder.debug_check_bounds::<Self>(offset);
2673            #[allow(unused_variables)]
2674            let next_out_of_line = decoder.next_out_of_line();
2675            let handles_before = decoder.remaining_handles();
2676            let (ordinal, inlined, num_bytes, num_handles) =
2677                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2678
2679            let member_inline_size = match ordinal {
2680                1 => <Flexible as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2681                2 => <SystemMonotonic as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2682                3 => {
2683                    <CustomClockConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context)
2684                }
2685                0 => return Err(fidl::Error::UnknownUnionTag),
2686                _ => num_bytes as usize,
2687            };
2688
2689            if inlined != (member_inline_size <= 4) {
2690                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2691            }
2692            let _inner_offset;
2693            if inlined {
2694                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2695                _inner_offset = offset + 8;
2696            } else {
2697                depth.increment()?;
2698                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2699            }
2700            match ordinal {
2701                1 => {
2702                    #[allow(irrefutable_let_patterns)]
2703                    if let ClockType::Flexible(_) = self {
2704                        // Do nothing, read the value into the object
2705                    } else {
2706                        // Initialize `self` to the right variant
2707                        *self = ClockType::Flexible(fidl::new_empty!(Flexible, D));
2708                    }
2709                    #[allow(irrefutable_let_patterns)]
2710                    if let ClockType::Flexible(ref mut val) = self {
2711                        fidl::decode!(Flexible, D, val, decoder, _inner_offset, depth)?;
2712                    } else {
2713                        unreachable!()
2714                    }
2715                }
2716                2 => {
2717                    #[allow(irrefutable_let_patterns)]
2718                    if let ClockType::SystemMonotonic(_) = self {
2719                        // Do nothing, read the value into the object
2720                    } else {
2721                        // Initialize `self` to the right variant
2722                        *self = ClockType::SystemMonotonic(fidl::new_empty!(SystemMonotonic, D));
2723                    }
2724                    #[allow(irrefutable_let_patterns)]
2725                    if let ClockType::SystemMonotonic(ref mut val) = self {
2726                        fidl::decode!(SystemMonotonic, D, val, decoder, _inner_offset, depth)?;
2727                    } else {
2728                        unreachable!()
2729                    }
2730                }
2731                3 => {
2732                    #[allow(irrefutable_let_patterns)]
2733                    if let ClockType::Custom(_) = self {
2734                        // Do nothing, read the value into the object
2735                    } else {
2736                        // Initialize `self` to the right variant
2737                        *self = ClockType::Custom(fidl::new_empty!(CustomClockConfig, D));
2738                    }
2739                    #[allow(irrefutable_let_patterns)]
2740                    if let ClockType::Custom(ref mut val) = self {
2741                        fidl::decode!(CustomClockConfig, D, val, decoder, _inner_offset, depth)?;
2742                    } else {
2743                        unreachable!()
2744                    }
2745                }
2746                #[allow(deprecated)]
2747                ordinal => {
2748                    for _ in 0..num_handles {
2749                        decoder.drop_next_handle()?;
2750                    }
2751                    *self = ClockType::__SourceBreaking { unknown_ordinal: ordinal };
2752                }
2753            }
2754            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2755                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2756            }
2757            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2758                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2759            }
2760            Ok(())
2761        }
2762    }
2763
2764    impl fidl::encoding::ValueTypeMarker for DeviceSelector {
2765        type Borrowed<'a> = &'a Self;
2766        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2767            value
2768        }
2769    }
2770
2771    unsafe impl fidl::encoding::TypeMarker for DeviceSelector {
2772        type Owned = Self;
2773
2774        #[inline(always)]
2775        fn inline_align(_context: fidl::encoding::Context) -> usize {
2776            8
2777        }
2778
2779        #[inline(always)]
2780        fn inline_size(_context: fidl::encoding::Context) -> usize {
2781            16
2782        }
2783    }
2784
2785    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceSelector, D>
2786        for &DeviceSelector
2787    {
2788        #[inline]
2789        unsafe fn encode(
2790            self,
2791            encoder: &mut fidl::encoding::Encoder<'_, D>,
2792            offset: usize,
2793            _depth: fidl::encoding::Depth,
2794        ) -> fidl::Result<()> {
2795            encoder.debug_check_bounds::<DeviceSelector>(offset);
2796            encoder.write_num::<u64>(self.ordinal(), offset);
2797            match self {
2798                DeviceSelector::Devfs(ref val) => fidl::encoding::encode_in_envelope::<Devfs, D>(
2799                    <Devfs as fidl::encoding::ValueTypeMarker>::borrow(val),
2800                    encoder,
2801                    offset + 8,
2802                    _depth,
2803                ),
2804                DeviceSelector::Registry(ref val) => fidl::encoding::encode_in_envelope::<u64, D>(
2805                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(val),
2806                    encoder,
2807                    offset + 8,
2808                    _depth,
2809                ),
2810                DeviceSelector::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2811            }
2812        }
2813    }
2814
2815    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceSelector {
2816        #[inline(always)]
2817        fn new_empty() -> Self {
2818            Self::__SourceBreaking { unknown_ordinal: 0 }
2819        }
2820
2821        #[inline]
2822        unsafe fn decode(
2823            &mut self,
2824            decoder: &mut fidl::encoding::Decoder<'_, D>,
2825            offset: usize,
2826            mut depth: fidl::encoding::Depth,
2827        ) -> fidl::Result<()> {
2828            decoder.debug_check_bounds::<Self>(offset);
2829            #[allow(unused_variables)]
2830            let next_out_of_line = decoder.next_out_of_line();
2831            let handles_before = decoder.remaining_handles();
2832            let (ordinal, inlined, num_bytes, num_handles) =
2833                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2834
2835            let member_inline_size = match ordinal {
2836                1 => <Devfs as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2837                2 => <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2838                0 => return Err(fidl::Error::UnknownUnionTag),
2839                _ => num_bytes as usize,
2840            };
2841
2842            if inlined != (member_inline_size <= 4) {
2843                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2844            }
2845            let _inner_offset;
2846            if inlined {
2847                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2848                _inner_offset = offset + 8;
2849            } else {
2850                depth.increment()?;
2851                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2852            }
2853            match ordinal {
2854                1 => {
2855                    #[allow(irrefutable_let_patterns)]
2856                    if let DeviceSelector::Devfs(_) = self {
2857                        // Do nothing, read the value into the object
2858                    } else {
2859                        // Initialize `self` to the right variant
2860                        *self = DeviceSelector::Devfs(fidl::new_empty!(Devfs, D));
2861                    }
2862                    #[allow(irrefutable_let_patterns)]
2863                    if let DeviceSelector::Devfs(ref mut val) = self {
2864                        fidl::decode!(Devfs, D, val, decoder, _inner_offset, depth)?;
2865                    } else {
2866                        unreachable!()
2867                    }
2868                }
2869                2 => {
2870                    #[allow(irrefutable_let_patterns)]
2871                    if let DeviceSelector::Registry(_) = self {
2872                        // Do nothing, read the value into the object
2873                    } else {
2874                        // Initialize `self` to the right variant
2875                        *self = DeviceSelector::Registry(fidl::new_empty!(u64, D));
2876                    }
2877                    #[allow(irrefutable_let_patterns)]
2878                    if let DeviceSelector::Registry(ref mut val) = self {
2879                        fidl::decode!(u64, D, val, decoder, _inner_offset, depth)?;
2880                    } else {
2881                        unreachable!()
2882                    }
2883                }
2884                #[allow(deprecated)]
2885                ordinal => {
2886                    for _ in 0..num_handles {
2887                        decoder.drop_next_handle()?;
2888                    }
2889                    *self = DeviceSelector::__SourceBreaking { unknown_ordinal: ordinal };
2890                }
2891            }
2892            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2893                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2894            }
2895            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2896                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2897            }
2898            Ok(())
2899        }
2900    }
2901
2902    impl fidl::encoding::ValueTypeMarker for PlayDestination {
2903        type Borrowed<'a> = &'a Self;
2904        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2905            value
2906        }
2907    }
2908
2909    unsafe impl fidl::encoding::TypeMarker for PlayDestination {
2910        type Owned = Self;
2911
2912        #[inline(always)]
2913        fn inline_align(_context: fidl::encoding::Context) -> usize {
2914            8
2915        }
2916
2917        #[inline(always)]
2918        fn inline_size(_context: fidl::encoding::Context) -> usize {
2919            16
2920        }
2921    }
2922
2923    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PlayDestination, D>
2924        for &PlayDestination
2925    {
2926        #[inline]
2927        unsafe fn encode(
2928            self,
2929            encoder: &mut fidl::encoding::Encoder<'_, D>,
2930            offset: usize,
2931            _depth: fidl::encoding::Depth,
2932        ) -> fidl::Result<()> {
2933            encoder.debug_check_bounds::<PlayDestination>(offset);
2934            encoder.write_num::<u64>(self.ordinal(), offset);
2935            match self {
2936                PlayDestination::Renderer(ref val) => {
2937                    fidl::encoding::encode_in_envelope::<RendererConfig, D>(
2938                        <RendererConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
2939                        encoder,
2940                        offset + 8,
2941                        _depth,
2942                    )
2943                }
2944                PlayDestination::DeviceRingBuffer(ref val) => {
2945                    fidl::encoding::encode_in_envelope::<DeviceRingBuffer, D>(
2946                        <DeviceRingBuffer as fidl::encoding::ValueTypeMarker>::borrow(val),
2947                        encoder,
2948                        offset + 8,
2949                        _depth,
2950                    )
2951                }
2952                PlayDestination::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2953            }
2954        }
2955    }
2956
2957    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PlayDestination {
2958        #[inline(always)]
2959        fn new_empty() -> Self {
2960            Self::__SourceBreaking { unknown_ordinal: 0 }
2961        }
2962
2963        #[inline]
2964        unsafe fn decode(
2965            &mut self,
2966            decoder: &mut fidl::encoding::Decoder<'_, D>,
2967            offset: usize,
2968            mut depth: fidl::encoding::Depth,
2969        ) -> fidl::Result<()> {
2970            decoder.debug_check_bounds::<Self>(offset);
2971            #[allow(unused_variables)]
2972            let next_out_of_line = decoder.next_out_of_line();
2973            let handles_before = decoder.remaining_handles();
2974            let (ordinal, inlined, num_bytes, num_handles) =
2975                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2976
2977            let member_inline_size = match ordinal {
2978                1 => <RendererConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2979                2 => <DeviceRingBuffer as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2980                0 => return Err(fidl::Error::UnknownUnionTag),
2981                _ => num_bytes as usize,
2982            };
2983
2984            if inlined != (member_inline_size <= 4) {
2985                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2986            }
2987            let _inner_offset;
2988            if inlined {
2989                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2990                _inner_offset = offset + 8;
2991            } else {
2992                depth.increment()?;
2993                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2994            }
2995            match ordinal {
2996                1 => {
2997                    #[allow(irrefutable_let_patterns)]
2998                    if let PlayDestination::Renderer(_) = self {
2999                        // Do nothing, read the value into the object
3000                    } else {
3001                        // Initialize `self` to the right variant
3002                        *self = PlayDestination::Renderer(fidl::new_empty!(RendererConfig, D));
3003                    }
3004                    #[allow(irrefutable_let_patterns)]
3005                    if let PlayDestination::Renderer(ref mut val) = self {
3006                        fidl::decode!(RendererConfig, D, val, decoder, _inner_offset, depth)?;
3007                    } else {
3008                        unreachable!()
3009                    }
3010                }
3011                2 => {
3012                    #[allow(irrefutable_let_patterns)]
3013                    if let PlayDestination::DeviceRingBuffer(_) = self {
3014                        // Do nothing, read the value into the object
3015                    } else {
3016                        // Initialize `self` to the right variant
3017                        *self = PlayDestination::DeviceRingBuffer(fidl::new_empty!(
3018                            DeviceRingBuffer,
3019                            D
3020                        ));
3021                    }
3022                    #[allow(irrefutable_let_patterns)]
3023                    if let PlayDestination::DeviceRingBuffer(ref mut val) = self {
3024                        fidl::decode!(DeviceRingBuffer, D, val, decoder, _inner_offset, depth)?;
3025                    } else {
3026                        unreachable!()
3027                    }
3028                }
3029                #[allow(deprecated)]
3030                ordinal => {
3031                    for _ in 0..num_handles {
3032                        decoder.drop_next_handle()?;
3033                    }
3034                    *self = PlayDestination::__SourceBreaking { unknown_ordinal: ordinal };
3035                }
3036            }
3037            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
3038                return Err(fidl::Error::InvalidNumBytesInEnvelope);
3039            }
3040            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3041                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3042            }
3043            Ok(())
3044        }
3045    }
3046
3047    impl fidl::encoding::ValueTypeMarker for RecordSource {
3048        type Borrowed<'a> = &'a Self;
3049        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3050            value
3051        }
3052    }
3053
3054    unsafe impl fidl::encoding::TypeMarker for RecordSource {
3055        type Owned = Self;
3056
3057        #[inline(always)]
3058        fn inline_align(_context: fidl::encoding::Context) -> usize {
3059            8
3060        }
3061
3062        #[inline(always)]
3063        fn inline_size(_context: fidl::encoding::Context) -> usize {
3064            16
3065        }
3066    }
3067
3068    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RecordSource, D>
3069        for &RecordSource
3070    {
3071        #[inline]
3072        unsafe fn encode(
3073            self,
3074            encoder: &mut fidl::encoding::Encoder<'_, D>,
3075            offset: usize,
3076            _depth: fidl::encoding::Depth,
3077        ) -> fidl::Result<()> {
3078            encoder.debug_check_bounds::<RecordSource>(offset);
3079            encoder.write_num::<u64>(self.ordinal(), offset);
3080            match self {
3081                RecordSource::Capturer(ref val) => {
3082                    fidl::encoding::encode_in_envelope::<CapturerConfig, D>(
3083                        <CapturerConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
3084                        encoder,
3085                        offset + 8,
3086                        _depth,
3087                    )
3088                }
3089                RecordSource::Loopback(ref val) => {
3090                    fidl::encoding::encode_in_envelope::<Loopback, D>(
3091                        <Loopback as fidl::encoding::ValueTypeMarker>::borrow(val),
3092                        encoder,
3093                        offset + 8,
3094                        _depth,
3095                    )
3096                }
3097                RecordSource::DeviceRingBuffer(ref val) => {
3098                    fidl::encoding::encode_in_envelope::<DeviceRingBuffer, D>(
3099                        <DeviceRingBuffer as fidl::encoding::ValueTypeMarker>::borrow(val),
3100                        encoder,
3101                        offset + 8,
3102                        _depth,
3103                    )
3104                }
3105                RecordSource::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
3106            }
3107        }
3108    }
3109
3110    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RecordSource {
3111        #[inline(always)]
3112        fn new_empty() -> Self {
3113            Self::__SourceBreaking { unknown_ordinal: 0 }
3114        }
3115
3116        #[inline]
3117        unsafe fn decode(
3118            &mut self,
3119            decoder: &mut fidl::encoding::Decoder<'_, D>,
3120            offset: usize,
3121            mut depth: fidl::encoding::Depth,
3122        ) -> fidl::Result<()> {
3123            decoder.debug_check_bounds::<Self>(offset);
3124            #[allow(unused_variables)]
3125            let next_out_of_line = decoder.next_out_of_line();
3126            let handles_before = decoder.remaining_handles();
3127            let (ordinal, inlined, num_bytes, num_handles) =
3128                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
3129
3130            let member_inline_size = match ordinal {
3131                1 => <CapturerConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3132                2 => <Loopback as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3133                3 => <DeviceRingBuffer as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3134                0 => return Err(fidl::Error::UnknownUnionTag),
3135                _ => num_bytes as usize,
3136            };
3137
3138            if inlined != (member_inline_size <= 4) {
3139                return Err(fidl::Error::InvalidInlineBitInEnvelope);
3140            }
3141            let _inner_offset;
3142            if inlined {
3143                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
3144                _inner_offset = offset + 8;
3145            } else {
3146                depth.increment()?;
3147                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3148            }
3149            match ordinal {
3150                1 => {
3151                    #[allow(irrefutable_let_patterns)]
3152                    if let RecordSource::Capturer(_) = self {
3153                        // Do nothing, read the value into the object
3154                    } else {
3155                        // Initialize `self` to the right variant
3156                        *self = RecordSource::Capturer(fidl::new_empty!(CapturerConfig, D));
3157                    }
3158                    #[allow(irrefutable_let_patterns)]
3159                    if let RecordSource::Capturer(ref mut val) = self {
3160                        fidl::decode!(CapturerConfig, D, val, decoder, _inner_offset, depth)?;
3161                    } else {
3162                        unreachable!()
3163                    }
3164                }
3165                2 => {
3166                    #[allow(irrefutable_let_patterns)]
3167                    if let RecordSource::Loopback(_) = self {
3168                        // Do nothing, read the value into the object
3169                    } else {
3170                        // Initialize `self` to the right variant
3171                        *self = RecordSource::Loopback(fidl::new_empty!(Loopback, D));
3172                    }
3173                    #[allow(irrefutable_let_patterns)]
3174                    if let RecordSource::Loopback(ref mut val) = self {
3175                        fidl::decode!(Loopback, D, val, decoder, _inner_offset, depth)?;
3176                    } else {
3177                        unreachable!()
3178                    }
3179                }
3180                3 => {
3181                    #[allow(irrefutable_let_patterns)]
3182                    if let RecordSource::DeviceRingBuffer(_) = self {
3183                        // Do nothing, read the value into the object
3184                    } else {
3185                        // Initialize `self` to the right variant
3186                        *self =
3187                            RecordSource::DeviceRingBuffer(fidl::new_empty!(DeviceRingBuffer, D));
3188                    }
3189                    #[allow(irrefutable_let_patterns)]
3190                    if let RecordSource::DeviceRingBuffer(ref mut val) = self {
3191                        fidl::decode!(DeviceRingBuffer, D, val, decoder, _inner_offset, depth)?;
3192                    } else {
3193                        unreachable!()
3194                    }
3195                }
3196                #[allow(deprecated)]
3197                ordinal => {
3198                    for _ in 0..num_handles {
3199                        decoder.drop_next_handle()?;
3200                    }
3201                    *self = RecordSource::__SourceBreaking { unknown_ordinal: ordinal };
3202                }
3203            }
3204            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
3205                return Err(fidl::Error::InvalidNumBytesInEnvelope);
3206            }
3207            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3208                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3209            }
3210            Ok(())
3211        }
3212    }
3213
3214    impl fidl::encoding::ValueTypeMarker for RendererConfig {
3215        type Borrowed<'a> = &'a Self;
3216        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3217            value
3218        }
3219    }
3220
3221    unsafe impl fidl::encoding::TypeMarker for RendererConfig {
3222        type Owned = Self;
3223
3224        #[inline(always)]
3225        fn inline_align(_context: fidl::encoding::Context) -> usize {
3226            8
3227        }
3228
3229        #[inline(always)]
3230        fn inline_size(_context: fidl::encoding::Context) -> usize {
3231            16
3232        }
3233    }
3234
3235    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RendererConfig, D>
3236        for &RendererConfig
3237    {
3238        #[inline]
3239        unsafe fn encode(
3240            self,
3241            encoder: &mut fidl::encoding::Encoder<'_, D>,
3242            offset: usize,
3243            _depth: fidl::encoding::Depth,
3244        ) -> fidl::Result<()> {
3245            encoder.debug_check_bounds::<RendererConfig>(offset);
3246            encoder.write_num::<u64>(self.ordinal(), offset);
3247            match self {
3248                RendererConfig::StandardRenderer(ref val) => {
3249                    fidl::encoding::encode_in_envelope::<StandardRendererConfig, D>(
3250                        <StandardRendererConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
3251                        encoder,
3252                        offset + 8,
3253                        _depth,
3254                    )
3255                }
3256                RendererConfig::UltrasoundRenderer(ref val) => {
3257                    fidl::encoding::encode_in_envelope::<UltrasoundRendererConfig, D>(
3258                        <UltrasoundRendererConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
3259                        encoder,
3260                        offset + 8,
3261                        _depth,
3262                    )
3263                }
3264                RendererConfig::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
3265            }
3266        }
3267    }
3268
3269    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RendererConfig {
3270        #[inline(always)]
3271        fn new_empty() -> Self {
3272            Self::__SourceBreaking { unknown_ordinal: 0 }
3273        }
3274
3275        #[inline]
3276        unsafe fn decode(
3277            &mut self,
3278            decoder: &mut fidl::encoding::Decoder<'_, D>,
3279            offset: usize,
3280            mut depth: fidl::encoding::Depth,
3281        ) -> fidl::Result<()> {
3282            decoder.debug_check_bounds::<Self>(offset);
3283            #[allow(unused_variables)]
3284            let next_out_of_line = decoder.next_out_of_line();
3285            let handles_before = decoder.remaining_handles();
3286            let (ordinal, inlined, num_bytes, num_handles) =
3287                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
3288
3289            let member_inline_size = match ordinal {
3290                1 => <StandardRendererConfig as fidl::encoding::TypeMarker>::inline_size(
3291                    decoder.context,
3292                ),
3293                2 => <UltrasoundRendererConfig as fidl::encoding::TypeMarker>::inline_size(
3294                    decoder.context,
3295                ),
3296                0 => return Err(fidl::Error::UnknownUnionTag),
3297                _ => num_bytes as usize,
3298            };
3299
3300            if inlined != (member_inline_size <= 4) {
3301                return Err(fidl::Error::InvalidInlineBitInEnvelope);
3302            }
3303            let _inner_offset;
3304            if inlined {
3305                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
3306                _inner_offset = offset + 8;
3307            } else {
3308                depth.increment()?;
3309                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3310            }
3311            match ordinal {
3312                1 => {
3313                    #[allow(irrefutable_let_patterns)]
3314                    if let RendererConfig::StandardRenderer(_) = self {
3315                        // Do nothing, read the value into the object
3316                    } else {
3317                        // Initialize `self` to the right variant
3318                        *self = RendererConfig::StandardRenderer(fidl::new_empty!(
3319                            StandardRendererConfig,
3320                            D
3321                        ));
3322                    }
3323                    #[allow(irrefutable_let_patterns)]
3324                    if let RendererConfig::StandardRenderer(ref mut val) = self {
3325                        fidl::decode!(
3326                            StandardRendererConfig,
3327                            D,
3328                            val,
3329                            decoder,
3330                            _inner_offset,
3331                            depth
3332                        )?;
3333                    } else {
3334                        unreachable!()
3335                    }
3336                }
3337                2 => {
3338                    #[allow(irrefutable_let_patterns)]
3339                    if let RendererConfig::UltrasoundRenderer(_) = self {
3340                        // Do nothing, read the value into the object
3341                    } else {
3342                        // Initialize `self` to the right variant
3343                        *self = RendererConfig::UltrasoundRenderer(fidl::new_empty!(
3344                            UltrasoundRendererConfig,
3345                            D
3346                        ));
3347                    }
3348                    #[allow(irrefutable_let_patterns)]
3349                    if let RendererConfig::UltrasoundRenderer(ref mut val) = self {
3350                        fidl::decode!(
3351                            UltrasoundRendererConfig,
3352                            D,
3353                            val,
3354                            decoder,
3355                            _inner_offset,
3356                            depth
3357                        )?;
3358                    } else {
3359                        unreachable!()
3360                    }
3361                }
3362                #[allow(deprecated)]
3363                ordinal => {
3364                    for _ in 0..num_handles {
3365                        decoder.drop_next_handle()?;
3366                    }
3367                    *self = RendererConfig::__SourceBreaking { unknown_ordinal: ordinal };
3368                }
3369            }
3370            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
3371                return Err(fidl::Error::InvalidNumBytesInEnvelope);
3372            }
3373            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3374                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3375            }
3376            Ok(())
3377        }
3378    }
3379}