Skip to main content

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