fidl_fuchsia_audio__common/
fidl_fuchsia_audio__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/// The maximum size of `Compression.parameters`.
12pub const MAX_COMPRESSION_PARAMETERS_SIZE: u64 = 32768;
13
14bitflags! {
15    /// Flags describing a packet.
16    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
17    pub struct PacketFlags: u32 {
18        /// Indicates that this packet is provided only so that later packets can be interpreted. A
19        /// decoder should drop the decompressed packets generated from this packet.
20        const DROP_AFTER_DECODE = 1;
21    }
22}
23
24impl PacketFlags {
25    #[inline(always)]
26    pub fn from_bits_allow_unknown(bits: u32) -> Self {
27        Self::from_bits_retain(bits)
28    }
29
30    #[inline(always)]
31    pub fn has_unknown_bits(&self) -> bool {
32        self.get_unknown_bits() != 0
33    }
34
35    #[inline(always)]
36    pub fn get_unknown_bits(&self) -> u32 {
37        self.bits() & !Self::all().bits()
38    }
39}
40
41/// Spatial assignment of channels.
42#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
43pub enum ChannelConfig {
44    /// Front.C (CENTER)
45    Mono,
46    /// Front.L (LEFT) | Front.R (RIGHT)
47    Stereo,
48    /// Front.L | Front.R | Back.L | Back.R, aka “Four corners”
49    Quad,
50    /// Front.L | Front.R | Back.C, aka “LRS”
51    Surround3,
52    /// Front.L | Front.R | Front.C | Back.C, aka “LRCS”
53    Surround4,
54    /// Front.L | Front.R | Front.C | LFE | Side.L | Side.R
55    Surround51,
56    #[doc(hidden)]
57    __SourceBreaking { unknown_ordinal: u32 },
58}
59
60/// Pattern that matches an unknown `ChannelConfig` member.
61#[macro_export]
62macro_rules! ChannelConfigUnknown {
63    () => {
64        _
65    };
66}
67
68impl ChannelConfig {
69    #[inline]
70    pub fn from_primitive(prim: u32) -> Option<Self> {
71        match prim {
72            1 => Some(Self::Mono),
73            2 => Some(Self::Stereo),
74            3 => Some(Self::Quad),
75            4 => Some(Self::Surround3),
76            5 => Some(Self::Surround4),
77            6 => Some(Self::Surround51),
78            _ => None,
79        }
80    }
81
82    #[inline]
83    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
84        match prim {
85            1 => Self::Mono,
86            2 => Self::Stereo,
87            3 => Self::Quad,
88            4 => Self::Surround3,
89            5 => Self::Surround4,
90            6 => Self::Surround51,
91            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
92        }
93    }
94
95    #[inline]
96    pub fn unknown() -> Self {
97        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
98    }
99
100    #[inline]
101    pub const fn into_primitive(self) -> u32 {
102        match self {
103            Self::Mono => 1,
104            Self::Stereo => 2,
105            Self::Quad => 3,
106            Self::Surround3 => 4,
107            Self::Surround4 => 5,
108            Self::Surround51 => 6,
109            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
110        }
111    }
112
113    #[inline]
114    pub fn is_unknown(&self) -> bool {
115        match self {
116            Self::__SourceBreaking { unknown_ordinal: _ } => true,
117            _ => false,
118        }
119    }
120}
121
122#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
123pub enum CompressionType {
124    None,
125    Aac,
126    Aaclatm,
127    Amrnb,
128    Amrwb,
129    Aptx,
130    Flac,
131    Gsmms,
132    Mp3,
133    Pcmalaw,
134    Pcmmulaw,
135    Sbc,
136    Vorbis,
137    Opus,
138    #[doc(hidden)]
139    __SourceBreaking {
140        unknown_ordinal: u32,
141    },
142}
143
144/// Pattern that matches an unknown `CompressionType` member.
145#[macro_export]
146macro_rules! CompressionTypeUnknown {
147    () => {
148        _
149    };
150}
151
152impl CompressionType {
153    #[inline]
154    pub fn from_primitive(prim: u32) -> Option<Self> {
155        match prim {
156            0 => Some(Self::None),
157            1 => Some(Self::Aac),
158            2 => Some(Self::Aaclatm),
159            3 => Some(Self::Amrnb),
160            4 => Some(Self::Amrwb),
161            5 => Some(Self::Aptx),
162            6 => Some(Self::Flac),
163            7 => Some(Self::Gsmms),
164            8 => Some(Self::Mp3),
165            9 => Some(Self::Pcmalaw),
166            10 => Some(Self::Pcmmulaw),
167            11 => Some(Self::Sbc),
168            12 => Some(Self::Vorbis),
169            13 => Some(Self::Opus),
170            _ => None,
171        }
172    }
173
174    #[inline]
175    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
176        match prim {
177            0 => Self::None,
178            1 => Self::Aac,
179            2 => Self::Aaclatm,
180            3 => Self::Amrnb,
181            4 => Self::Amrwb,
182            5 => Self::Aptx,
183            6 => Self::Flac,
184            7 => Self::Gsmms,
185            8 => Self::Mp3,
186            9 => Self::Pcmalaw,
187            10 => Self::Pcmmulaw,
188            11 => Self::Sbc,
189            12 => Self::Vorbis,
190            13 => Self::Opus,
191            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
192        }
193    }
194
195    #[inline]
196    pub fn unknown() -> Self {
197        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
198    }
199
200    #[inline]
201    pub const fn into_primitive(self) -> u32 {
202        match self {
203            Self::None => 0,
204            Self::Aac => 1,
205            Self::Aaclatm => 2,
206            Self::Amrnb => 3,
207            Self::Amrwb => 4,
208            Self::Aptx => 5,
209            Self::Flac => 6,
210            Self::Gsmms => 7,
211            Self::Mp3 => 8,
212            Self::Pcmalaw => 9,
213            Self::Pcmmulaw => 10,
214            Self::Sbc => 11,
215            Self::Vorbis => 12,
216            Self::Opus => 13,
217            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
218        }
219    }
220
221    #[inline]
222    pub fn is_unknown(&self) -> bool {
223        match self {
224            Self::__SourceBreaking { unknown_ordinal: _ } => true,
225            _ => false,
226        }
227    }
228}
229
230/// Type of errors returned by `GainControl`.
231#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
232pub enum GainError {
233    /// A required field was not provided.
234    MissingRequiredField,
235    /// A flexible field had an unsupported option. This can happen when a
236    /// client built with API version X+1 talks to a server built with API
237    /// version X.
238    UnsupportedOption,
239    #[doc(hidden)]
240    __SourceBreaking { unknown_ordinal: u32 },
241}
242
243/// Pattern that matches an unknown `GainError` member.
244#[macro_export]
245macro_rules! GainErrorUnknown {
246    () => {
247        _
248    };
249}
250
251impl GainError {
252    #[inline]
253    pub fn from_primitive(prim: u32) -> Option<Self> {
254        match prim {
255            1 => Some(Self::MissingRequiredField),
256            2 => Some(Self::UnsupportedOption),
257            _ => None,
258        }
259    }
260
261    #[inline]
262    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
263        match prim {
264            1 => Self::MissingRequiredField,
265            2 => Self::UnsupportedOption,
266            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
267        }
268    }
269
270    #[inline]
271    pub fn unknown() -> Self {
272        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
273    }
274
275    #[inline]
276    pub const fn into_primitive(self) -> u32 {
277        match self {
278            Self::MissingRequiredField => 1,
279            Self::UnsupportedOption => 2,
280            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
281        }
282    }
283
284    #[inline]
285    pub fn is_unknown(&self) -> bool {
286        match self {
287            Self::__SourceBreaking { unknown_ordinal: _ } => true,
288            _ => false,
289        }
290    }
291}
292
293/// Expresses the type of individual audio samples.
294#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
295pub enum SampleType {
296    Uint8,
297    Int16,
298    Int32,
299    Float32,
300    Float64,
301    #[doc(hidden)]
302    __SourceBreaking {
303        unknown_ordinal: u32,
304    },
305}
306
307/// Pattern that matches an unknown `SampleType` member.
308#[macro_export]
309macro_rules! SampleTypeUnknown {
310    () => {
311        _
312    };
313}
314
315impl SampleType {
316    #[inline]
317    pub fn from_primitive(prim: u32) -> Option<Self> {
318        match prim {
319            1 => Some(Self::Uint8),
320            2 => Some(Self::Int16),
321            3 => Some(Self::Int32),
322            4 => Some(Self::Float32),
323            5 => Some(Self::Float64),
324            _ => None,
325        }
326    }
327
328    #[inline]
329    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
330        match prim {
331            1 => Self::Uint8,
332            2 => Self::Int16,
333            3 => Self::Int32,
334            4 => Self::Float32,
335            5 => Self::Float64,
336            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
337        }
338    }
339
340    #[inline]
341    pub fn unknown() -> Self {
342        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
343    }
344
345    #[inline]
346    pub const fn into_primitive(self) -> u32 {
347        match self {
348            Self::Uint8 => 1,
349            Self::Int16 => 2,
350            Self::Int32 => 3,
351            Self::Float32 => 4,
352            Self::Float64 => 5,
353            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
354        }
355    }
356
357    #[inline]
358    pub fn is_unknown(&self) -> bool {
359        match self {
360            Self::__SourceBreaking { unknown_ordinal: _ } => true,
361            _ => false,
362        }
363    }
364}
365
366#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
367pub struct UnspecifiedBestEffort;
368
369impl fidl::Persistable for UnspecifiedBestEffort {}
370
371#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
372pub struct UnspecifiedContinuous;
373
374impl fidl::Persistable for UnspecifiedContinuous {}
375
376/// Describes the compression applied to a stream.
377#[derive(Clone, Debug, Default, PartialEq)]
378pub struct Compression {
379    /// The type of compression applied to the stream.
380    pub type_: Option<CompressionType>,
381    /// Opaque ‘out-of-band’ parameters describing the compression of the stream. The format of
382    /// this field is a function of the `CompressionType`. It communicates to decoders parameters
383    /// that are required to decompress the described stream. Many compression types do not require
384    /// this field.
385    pub oob_parameters: Option<Vec<u8>>,
386    #[doc(hidden)]
387    pub __source_breaking: fidl::marker::SourceBreaking,
388}
389
390impl fidl::Persistable for Compression {}
391
392#[derive(Clone, Debug, Default, PartialEq)]
393pub struct DelayWatcherWatchDelayRequest {
394    #[doc(hidden)]
395    pub __source_breaking: fidl::marker::SourceBreaking,
396}
397
398impl fidl::Persistable for DelayWatcherWatchDelayRequest {}
399
400#[derive(Clone, Debug, Default, PartialEq)]
401pub struct DelayWatcherWatchDelayResponse {
402    /// Optional. If not specified, the delay is unknown.
403    pub delay: Option<i64>,
404    #[doc(hidden)]
405    pub __source_breaking: fidl::marker::SourceBreaking,
406}
407
408impl fidl::Persistable for DelayWatcherWatchDelayResponse {}
409
410/// Describes a format used for audio streams without reference to compression. Where
411/// compression is supported, this type should be combined with `fuchsia.media2.Compression`.
412/// An uncompressed audio stream uses LPCM encoding.
413#[derive(Clone, Debug, Default, PartialEq)]
414pub struct Format {
415    /// The type of individual samples.
416    pub sample_type: Option<SampleType>,
417    /// The number of samples per frame.
418    pub channel_count: Option<u32>,
419    /// The number of frames per second.
420    pub frames_per_second: Option<u32>,
421    /// The spatial assignment of each channel.
422    pub channel_layout: Option<ChannelLayout>,
423    #[doc(hidden)]
424    pub __source_breaking: fidl::marker::SourceBreaking,
425}
426
427impl fidl::Persistable for Format {}
428
429#[derive(Clone, Debug, Default, PartialEq)]
430pub struct GainControlSetGainRequest {
431    /// How to update the gain knob.
432    ///
433    /// Required.
434    pub how: Option<GainUpdateMethod>,
435    /// When to apply this update.
436    ///
437    /// Required.
438    pub when: Option<fidl_fuchsia_media2__common::RealTime>,
439    #[doc(hidden)]
440    pub __source_breaking: fidl::marker::SourceBreaking,
441}
442
443impl fidl::Persistable for GainControlSetGainRequest {}
444
445#[derive(Clone, Debug, Default, PartialEq)]
446pub struct GainControlSetMuteRequest {
447    /// New value of the mute knob.
448    ///
449    /// Required.
450    pub muted: Option<bool>,
451    /// When to apply this update.
452    ///
453    /// Required.
454    pub when: Option<fidl_fuchsia_media2__common::RealTime>,
455    #[doc(hidden)]
456    pub __source_breaking: fidl::marker::SourceBreaking,
457}
458
459impl fidl::Persistable for GainControlSetMuteRequest {}
460
461#[derive(Clone, Debug, Default, PartialEq)]
462pub struct GainControlSetGainResponse {
463    #[doc(hidden)]
464    pub __source_breaking: fidl::marker::SourceBreaking,
465}
466
467impl fidl::Persistable for GainControlSetGainResponse {}
468
469#[derive(Clone, Debug, Default, PartialEq)]
470pub struct GainControlSetMuteResponse {
471    #[doc(hidden)]
472    pub __source_breaking: fidl::marker::SourceBreaking,
473}
474
475impl fidl::Persistable for GainControlSetMuteResponse {}
476
477/// Describes a packet delivered via `StreamSink`.
478#[derive(Clone, Debug, Default, PartialEq)]
479pub struct Packet {
480    /// Location of the payload for this packet. This field is required.
481    pub payload: Option<fidl_fuchsia_media2__common::PayloadRange>,
482    /// Timestamp indicating when this packet should be presented. Omitting this field implies an
483    /// `unspecified_best_effort` timestamp.
484    pub timestamp: Option<Timestamp>,
485    /// Capture time for this packet as a system monotonic time value. This field is optional and
486    /// may be set by capturers to indicate when this packet was captured.
487    pub capture_timestamp: Option<i64>,
488    /// Flags describing the packet. Omitting this field implies all flags are clear.
489    pub flags: Option<PacketFlags>,
490    /// Indicates how many frames should be dropped from the front of the output packet produced by
491    /// a decoder from this input packet. This value should only be provided for compressed streams.
492    /// If this field is omitted, no front frames should be dropped.
493    pub front_frames_to_drop: Option<u32>,
494    /// Indicates how many frames should be dropped from the back of the output packet produced by
495    /// a decoder from this input packet. This value should only be provided for compressed streams.
496    /// If this field is omitted, no back frames should be dropped.
497    pub back_frames_to_drop: Option<u32>,
498    /// Describes the encryption applied to this packet. Omitting this field implies the packet is
499    /// not encrypted.
500    pub encryption_properties: Option<fidl_fuchsia_drm__common::PacketEncryptionProperties>,
501    #[doc(hidden)]
502    pub __source_breaking: fidl::marker::SourceBreaking,
503}
504
505impl fidl::Persistable for Packet {}
506
507/// Gain follows a linear slope over a linear domain.
508///
509/// For example, a ramp from gain -2.3dB to -1.6dB is a ramp in the linear
510/// domain from 0.1 to 0.5. If this is applied over 4ms, then the sequence of
511/// gain updates is:
512///
513/// * At 0ms, gain = 0.1 = -2.3dB
514/// * At 1ms, gain = 0.2 = -2.0dB
515/// * At 2ms, gain = 0.3 = -1.8dB
516/// * At 3ms, gain = 0.4 = -1.7dB
517/// * At 4ms, gain = 0.5 = -1.6dB
518///
519/// Note that the changes in dB follow a logarithmic (not linear) curve.
520#[derive(Clone, Debug, Default, PartialEq)]
521pub struct RampFunctionLinearSlope {
522    #[doc(hidden)]
523    pub __source_breaking: fidl::marker::SourceBreaking,
524}
525
526impl fidl::Persistable for RampFunctionLinearSlope {}
527
528/// Describes a ramped gain command. When this command is applied, gain is
529/// ramped from its current value to the target value, over the specified
530/// duration, using the specified function.
531#[derive(Clone, Debug, Default, PartialEq)]
532pub struct RampedGain {
533    pub target_gain_db: Option<f32>,
534    pub duration: Option<i64>,
535    pub function: Option<RampFunction>,
536    #[doc(hidden)]
537    pub __source_breaking: fidl::marker::SourceBreaking,
538}
539
540impl fidl::Persistable for RampedGain {}
541
542#[derive(Clone, Debug, Default, PartialEq)]
543pub struct StreamSinkOnWillCloseRequest {
544    /// Reason the connection will close.
545    pub reason: Option<fidl_fuchsia_media2__common::ConsumerClosedReason>,
546    #[doc(hidden)]
547    pub __source_breaking: fidl::marker::SourceBreaking,
548}
549
550impl fidl::Persistable for StreamSinkOnWillCloseRequest {}
551
552#[derive(Clone, Debug, Default, PartialEq)]
553pub struct StreamSinkStartSegmentRequest {
554    /// Identifies the segment. New segment IDs for a given connection must always be strictly
555    /// increasing. This field is required.
556    pub segment_id: Option<i64>,
557    #[doc(hidden)]
558    pub __source_breaking: fidl::marker::SourceBreaking,
559}
560
561impl fidl::Persistable for StreamSinkStartSegmentRequest {}
562
563#[derive(Clone, Debug, Default, PartialEq)]
564pub struct StreamSinkWillCloseRequest {
565    /// Reason the connection will close.
566    pub reason: Option<fidl_fuchsia_media2__common::ProducerClosedReason>,
567    #[doc(hidden)]
568    pub __source_breaking: fidl::marker::SourceBreaking,
569}
570
571impl fidl::Persistable for StreamSinkWillCloseRequest {}
572
573/// Expresses the intended assignment of channels in an audio elementary stream.
574#[derive(Clone, Debug)]
575pub enum ChannelLayout {
576    /// This value describes the assignment of every channel. Channel
577    /// configuration must agree with `channel_count`.
578    Config(ChannelConfig),
579    #[doc(hidden)]
580    __SourceBreaking { unknown_ordinal: u64 },
581}
582
583/// Pattern that matches an unknown `ChannelLayout` member.
584#[macro_export]
585macro_rules! ChannelLayoutUnknown {
586    () => {
587        _
588    };
589}
590
591// Custom PartialEq so that unknown variants are not equal to themselves.
592impl PartialEq for ChannelLayout {
593    fn eq(&self, other: &Self) -> bool {
594        match (self, other) {
595            (Self::Config(x), Self::Config(y)) => *x == *y,
596            _ => false,
597        }
598    }
599}
600
601impl ChannelLayout {
602    #[inline]
603    pub fn ordinal(&self) -> u64 {
604        match *self {
605            Self::Config(_) => 1,
606            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
607        }
608    }
609
610    #[inline]
611    pub fn unknown_variant_for_testing() -> Self {
612        Self::__SourceBreaking { unknown_ordinal: 0 }
613    }
614
615    #[inline]
616    pub fn is_unknown(&self) -> bool {
617        match self {
618            Self::__SourceBreaking { .. } => true,
619            _ => false,
620        }
621    }
622}
623
624impl fidl::Persistable for ChannelLayout {}
625
626/// Supported types of gain updates.
627#[derive(Clone, Debug)]
628pub enum GainUpdateMethod {
629    /// Immediately set the gain to this value.
630    GainDb(f32),
631    /// Change the gain gradually using a ramp.
632    Ramped(RampedGain),
633    #[doc(hidden)]
634    __SourceBreaking { unknown_ordinal: u64 },
635}
636
637/// Pattern that matches an unknown `GainUpdateMethod` member.
638#[macro_export]
639macro_rules! GainUpdateMethodUnknown {
640    () => {
641        _
642    };
643}
644
645// Custom PartialEq so that unknown variants are not equal to themselves.
646impl PartialEq for GainUpdateMethod {
647    fn eq(&self, other: &Self) -> bool {
648        match (self, other) {
649            (Self::GainDb(x), Self::GainDb(y)) => *x == *y,
650            (Self::Ramped(x), Self::Ramped(y)) => *x == *y,
651            _ => false,
652        }
653    }
654}
655
656impl GainUpdateMethod {
657    #[inline]
658    pub fn ordinal(&self) -> u64 {
659        match *self {
660            Self::GainDb(_) => 1,
661            Self::Ramped(_) => 2,
662            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
663        }
664    }
665
666    #[inline]
667    pub fn unknown_variant_for_testing() -> Self {
668        Self::__SourceBreaking { unknown_ordinal: 0 }
669    }
670
671    #[inline]
672    pub fn is_unknown(&self) -> bool {
673        match self {
674            Self::__SourceBreaking { .. } => true,
675            _ => false,
676        }
677    }
678}
679
680impl fidl::Persistable for GainUpdateMethod {}
681
682/// Supported types of ramping functions.
683#[derive(Clone, Debug)]
684pub enum RampFunction {
685    LinearSlope(RampFunctionLinearSlope),
686    #[doc(hidden)]
687    __SourceBreaking {
688        unknown_ordinal: u64,
689    },
690}
691
692/// Pattern that matches an unknown `RampFunction` member.
693#[macro_export]
694macro_rules! RampFunctionUnknown {
695    () => {
696        _
697    };
698}
699
700// Custom PartialEq so that unknown variants are not equal to themselves.
701impl PartialEq for RampFunction {
702    fn eq(&self, other: &Self) -> bool {
703        match (self, other) {
704            (Self::LinearSlope(x), Self::LinearSlope(y)) => *x == *y,
705            _ => false,
706        }
707    }
708}
709
710impl RampFunction {
711    #[inline]
712    pub fn ordinal(&self) -> u64 {
713        match *self {
714            Self::LinearSlope(_) => 1,
715            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
716        }
717    }
718
719    #[inline]
720    pub fn unknown_variant_for_testing() -> Self {
721        Self::__SourceBreaking { unknown_ordinal: 0 }
722    }
723
724    #[inline]
725    pub fn is_unknown(&self) -> bool {
726        match self {
727            Self::__SourceBreaking { .. } => true,
728            _ => false,
729        }
730    }
731}
732
733impl fidl::Persistable for RampFunction {}
734
735/// Indicates the position of an audio packet in the stream timeline.
736#[derive(Clone, Debug)]
737pub enum Timestamp {
738    /// Specific time in the stream timeline. Units vary and are provided when the connection
739    /// is established.
740    Specified(i64),
741    /// Indicates the packet should be presented immediately after the previous packet, if there is
742    /// a previous packet. If there is no previous packet, this option is equivalent to a
743    /// `specified` value of 0.
744    ///
745    /// This option implies that the stream timeline should not ‘slip’ even if the packet
746    /// arrives late. The packet is intended to be presented immediately after the previous packet,
747    /// and the resulting timing is to be maintained regardless of the arrival time of the packet.
748    UnspecifiedContinuous(UnspecifiedContinuous),
749    /// Indicates the packet should be presented as soon as possible after the previous packet, if
750    /// there is one, as soon as possible if not.
751    ///
752    /// This option implies that the stream time should ‘slip’ if the packet arrives too late
753    /// to be rendered immediately after the previous packet. This option is often used when a gap
754    /// occurs in an un-timestamped stream, perhaps due to a lossy upstream source.
755    UnspecifiedBestEffort(UnspecifiedBestEffort),
756    #[doc(hidden)]
757    __SourceBreaking { unknown_ordinal: u64 },
758}
759
760/// Pattern that matches an unknown `Timestamp` member.
761#[macro_export]
762macro_rules! TimestampUnknown {
763    () => {
764        _
765    };
766}
767
768// Custom PartialEq so that unknown variants are not equal to themselves.
769impl PartialEq for Timestamp {
770    fn eq(&self, other: &Self) -> bool {
771        match (self, other) {
772            (Self::Specified(x), Self::Specified(y)) => *x == *y,
773            (Self::UnspecifiedContinuous(x), Self::UnspecifiedContinuous(y)) => *x == *y,
774            (Self::UnspecifiedBestEffort(x), Self::UnspecifiedBestEffort(y)) => *x == *y,
775            _ => false,
776        }
777    }
778}
779
780impl Timestamp {
781    #[inline]
782    pub fn ordinal(&self) -> u64 {
783        match *self {
784            Self::Specified(_) => 1,
785            Self::UnspecifiedContinuous(_) => 2,
786            Self::UnspecifiedBestEffort(_) => 3,
787            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
788        }
789    }
790
791    #[inline]
792    pub fn unknown_variant_for_testing() -> Self {
793        Self::__SourceBreaking { unknown_ordinal: 0 }
794    }
795
796    #[inline]
797    pub fn is_unknown(&self) -> bool {
798        match self {
799            Self::__SourceBreaking { .. } => true,
800            _ => false,
801        }
802    }
803}
804
805impl fidl::Persistable for Timestamp {}
806
807pub mod delay_watcher_ordinals {
808    pub const WATCH_DELAY: u64 = 0x3a90c91ee2f1644c;
809}
810
811pub mod gain_control_ordinals {
812    pub const SET_GAIN: u64 = 0x6ece305e4a5823dc;
813    pub const SET_MUTE: u64 = 0xed03d88ce4f8965;
814}
815
816pub mod stream_sink_ordinals {
817    pub const PUT_PACKET: u64 = 0x558d757afd726899;
818    pub const START_SEGMENT: u64 = 0x6dd9bc66aa9f715f;
819    pub const END: u64 = 0x1a3a528e83b32f6e;
820    pub const WILL_CLOSE: u64 = 0x6303ee33dbb0fd11;
821    pub const ON_WILL_CLOSE: u64 = 0x77093453926bce5b;
822}
823
824mod internal {
825    use super::*;
826    unsafe impl fidl::encoding::TypeMarker for PacketFlags {
827        type Owned = Self;
828
829        #[inline(always)]
830        fn inline_align(_context: fidl::encoding::Context) -> usize {
831            4
832        }
833
834        #[inline(always)]
835        fn inline_size(_context: fidl::encoding::Context) -> usize {
836            4
837        }
838    }
839
840    impl fidl::encoding::ValueTypeMarker for PacketFlags {
841        type Borrowed<'a> = Self;
842        #[inline(always)]
843        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
844            *value
845        }
846    }
847
848    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for PacketFlags {
849        #[inline]
850        unsafe fn encode(
851            self,
852            encoder: &mut fidl::encoding::Encoder<'_, D>,
853            offset: usize,
854            _depth: fidl::encoding::Depth,
855        ) -> fidl::Result<()> {
856            encoder.debug_check_bounds::<Self>(offset);
857            encoder.write_num(self.bits(), offset);
858            Ok(())
859        }
860    }
861
862    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PacketFlags {
863        #[inline(always)]
864        fn new_empty() -> Self {
865            Self::empty()
866        }
867
868        #[inline]
869        unsafe fn decode(
870            &mut self,
871            decoder: &mut fidl::encoding::Decoder<'_, D>,
872            offset: usize,
873            _depth: fidl::encoding::Depth,
874        ) -> fidl::Result<()> {
875            decoder.debug_check_bounds::<Self>(offset);
876            let prim = decoder.read_num::<u32>(offset);
877            *self = Self::from_bits_allow_unknown(prim);
878            Ok(())
879        }
880    }
881    unsafe impl fidl::encoding::TypeMarker for ChannelConfig {
882        type Owned = Self;
883
884        #[inline(always)]
885        fn inline_align(_context: fidl::encoding::Context) -> usize {
886            std::mem::align_of::<u32>()
887        }
888
889        #[inline(always)]
890        fn inline_size(_context: fidl::encoding::Context) -> usize {
891            std::mem::size_of::<u32>()
892        }
893
894        #[inline(always)]
895        fn encode_is_copy() -> bool {
896            false
897        }
898
899        #[inline(always)]
900        fn decode_is_copy() -> bool {
901            false
902        }
903    }
904
905    impl fidl::encoding::ValueTypeMarker for ChannelConfig {
906        type Borrowed<'a> = Self;
907        #[inline(always)]
908        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
909            *value
910        }
911    }
912
913    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ChannelConfig {
914        #[inline]
915        unsafe fn encode(
916            self,
917            encoder: &mut fidl::encoding::Encoder<'_, D>,
918            offset: usize,
919            _depth: fidl::encoding::Depth,
920        ) -> fidl::Result<()> {
921            encoder.debug_check_bounds::<Self>(offset);
922            encoder.write_num(self.into_primitive(), offset);
923            Ok(())
924        }
925    }
926
927    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ChannelConfig {
928        #[inline(always)]
929        fn new_empty() -> Self {
930            Self::unknown()
931        }
932
933        #[inline]
934        unsafe fn decode(
935            &mut self,
936            decoder: &mut fidl::encoding::Decoder<'_, D>,
937            offset: usize,
938            _depth: fidl::encoding::Depth,
939        ) -> fidl::Result<()> {
940            decoder.debug_check_bounds::<Self>(offset);
941            let prim = decoder.read_num::<u32>(offset);
942
943            *self = Self::from_primitive_allow_unknown(prim);
944            Ok(())
945        }
946    }
947    unsafe impl fidl::encoding::TypeMarker for CompressionType {
948        type Owned = Self;
949
950        #[inline(always)]
951        fn inline_align(_context: fidl::encoding::Context) -> usize {
952            std::mem::align_of::<u32>()
953        }
954
955        #[inline(always)]
956        fn inline_size(_context: fidl::encoding::Context) -> usize {
957            std::mem::size_of::<u32>()
958        }
959
960        #[inline(always)]
961        fn encode_is_copy() -> bool {
962            false
963        }
964
965        #[inline(always)]
966        fn decode_is_copy() -> bool {
967            false
968        }
969    }
970
971    impl fidl::encoding::ValueTypeMarker for CompressionType {
972        type Borrowed<'a> = Self;
973        #[inline(always)]
974        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
975            *value
976        }
977    }
978
979    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
980        for CompressionType
981    {
982        #[inline]
983        unsafe fn encode(
984            self,
985            encoder: &mut fidl::encoding::Encoder<'_, D>,
986            offset: usize,
987            _depth: fidl::encoding::Depth,
988        ) -> fidl::Result<()> {
989            encoder.debug_check_bounds::<Self>(offset);
990            encoder.write_num(self.into_primitive(), offset);
991            Ok(())
992        }
993    }
994
995    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CompressionType {
996        #[inline(always)]
997        fn new_empty() -> Self {
998            Self::unknown()
999        }
1000
1001        #[inline]
1002        unsafe fn decode(
1003            &mut self,
1004            decoder: &mut fidl::encoding::Decoder<'_, D>,
1005            offset: usize,
1006            _depth: fidl::encoding::Depth,
1007        ) -> fidl::Result<()> {
1008            decoder.debug_check_bounds::<Self>(offset);
1009            let prim = decoder.read_num::<u32>(offset);
1010
1011            *self = Self::from_primitive_allow_unknown(prim);
1012            Ok(())
1013        }
1014    }
1015    unsafe impl fidl::encoding::TypeMarker for GainError {
1016        type Owned = Self;
1017
1018        #[inline(always)]
1019        fn inline_align(_context: fidl::encoding::Context) -> usize {
1020            std::mem::align_of::<u32>()
1021        }
1022
1023        #[inline(always)]
1024        fn inline_size(_context: fidl::encoding::Context) -> usize {
1025            std::mem::size_of::<u32>()
1026        }
1027
1028        #[inline(always)]
1029        fn encode_is_copy() -> bool {
1030            false
1031        }
1032
1033        #[inline(always)]
1034        fn decode_is_copy() -> bool {
1035            false
1036        }
1037    }
1038
1039    impl fidl::encoding::ValueTypeMarker for GainError {
1040        type Borrowed<'a> = Self;
1041        #[inline(always)]
1042        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1043            *value
1044        }
1045    }
1046
1047    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for GainError {
1048        #[inline]
1049        unsafe fn encode(
1050            self,
1051            encoder: &mut fidl::encoding::Encoder<'_, D>,
1052            offset: usize,
1053            _depth: fidl::encoding::Depth,
1054        ) -> fidl::Result<()> {
1055            encoder.debug_check_bounds::<Self>(offset);
1056            encoder.write_num(self.into_primitive(), offset);
1057            Ok(())
1058        }
1059    }
1060
1061    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for GainError {
1062        #[inline(always)]
1063        fn new_empty() -> Self {
1064            Self::unknown()
1065        }
1066
1067        #[inline]
1068        unsafe fn decode(
1069            &mut self,
1070            decoder: &mut fidl::encoding::Decoder<'_, D>,
1071            offset: usize,
1072            _depth: fidl::encoding::Depth,
1073        ) -> fidl::Result<()> {
1074            decoder.debug_check_bounds::<Self>(offset);
1075            let prim = decoder.read_num::<u32>(offset);
1076
1077            *self = Self::from_primitive_allow_unknown(prim);
1078            Ok(())
1079        }
1080    }
1081    unsafe impl fidl::encoding::TypeMarker for SampleType {
1082        type Owned = Self;
1083
1084        #[inline(always)]
1085        fn inline_align(_context: fidl::encoding::Context) -> usize {
1086            std::mem::align_of::<u32>()
1087        }
1088
1089        #[inline(always)]
1090        fn inline_size(_context: fidl::encoding::Context) -> usize {
1091            std::mem::size_of::<u32>()
1092        }
1093
1094        #[inline(always)]
1095        fn encode_is_copy() -> bool {
1096            false
1097        }
1098
1099        #[inline(always)]
1100        fn decode_is_copy() -> bool {
1101            false
1102        }
1103    }
1104
1105    impl fidl::encoding::ValueTypeMarker for SampleType {
1106        type Borrowed<'a> = Self;
1107        #[inline(always)]
1108        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1109            *value
1110        }
1111    }
1112
1113    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for SampleType {
1114        #[inline]
1115        unsafe fn encode(
1116            self,
1117            encoder: &mut fidl::encoding::Encoder<'_, D>,
1118            offset: usize,
1119            _depth: fidl::encoding::Depth,
1120        ) -> fidl::Result<()> {
1121            encoder.debug_check_bounds::<Self>(offset);
1122            encoder.write_num(self.into_primitive(), offset);
1123            Ok(())
1124        }
1125    }
1126
1127    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SampleType {
1128        #[inline(always)]
1129        fn new_empty() -> Self {
1130            Self::unknown()
1131        }
1132
1133        #[inline]
1134        unsafe fn decode(
1135            &mut self,
1136            decoder: &mut fidl::encoding::Decoder<'_, D>,
1137            offset: usize,
1138            _depth: fidl::encoding::Depth,
1139        ) -> fidl::Result<()> {
1140            decoder.debug_check_bounds::<Self>(offset);
1141            let prim = decoder.read_num::<u32>(offset);
1142
1143            *self = Self::from_primitive_allow_unknown(prim);
1144            Ok(())
1145        }
1146    }
1147
1148    impl fidl::encoding::ValueTypeMarker for UnspecifiedBestEffort {
1149        type Borrowed<'a> = &'a Self;
1150        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1151            value
1152        }
1153    }
1154
1155    unsafe impl fidl::encoding::TypeMarker for UnspecifiedBestEffort {
1156        type Owned = Self;
1157
1158        #[inline(always)]
1159        fn inline_align(_context: fidl::encoding::Context) -> usize {
1160            1
1161        }
1162
1163        #[inline(always)]
1164        fn inline_size(_context: fidl::encoding::Context) -> usize {
1165            1
1166        }
1167    }
1168
1169    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<UnspecifiedBestEffort, D>
1170        for &UnspecifiedBestEffort
1171    {
1172        #[inline]
1173        unsafe fn encode(
1174            self,
1175            encoder: &mut fidl::encoding::Encoder<'_, D>,
1176            offset: usize,
1177            _depth: fidl::encoding::Depth,
1178        ) -> fidl::Result<()> {
1179            encoder.debug_check_bounds::<UnspecifiedBestEffort>(offset);
1180            encoder.write_num(0u8, offset);
1181            Ok(())
1182        }
1183    }
1184
1185    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for UnspecifiedBestEffort {
1186        #[inline(always)]
1187        fn new_empty() -> Self {
1188            Self
1189        }
1190
1191        #[inline]
1192        unsafe fn decode(
1193            &mut self,
1194            decoder: &mut fidl::encoding::Decoder<'_, D>,
1195            offset: usize,
1196            _depth: fidl::encoding::Depth,
1197        ) -> fidl::Result<()> {
1198            decoder.debug_check_bounds::<Self>(offset);
1199            match decoder.read_num::<u8>(offset) {
1200                0 => Ok(()),
1201                _ => Err(fidl::Error::Invalid),
1202            }
1203        }
1204    }
1205
1206    impl fidl::encoding::ValueTypeMarker for UnspecifiedContinuous {
1207        type Borrowed<'a> = &'a Self;
1208        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1209            value
1210        }
1211    }
1212
1213    unsafe impl fidl::encoding::TypeMarker for UnspecifiedContinuous {
1214        type Owned = Self;
1215
1216        #[inline(always)]
1217        fn inline_align(_context: fidl::encoding::Context) -> usize {
1218            1
1219        }
1220
1221        #[inline(always)]
1222        fn inline_size(_context: fidl::encoding::Context) -> usize {
1223            1
1224        }
1225    }
1226
1227    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<UnspecifiedContinuous, D>
1228        for &UnspecifiedContinuous
1229    {
1230        #[inline]
1231        unsafe fn encode(
1232            self,
1233            encoder: &mut fidl::encoding::Encoder<'_, D>,
1234            offset: usize,
1235            _depth: fidl::encoding::Depth,
1236        ) -> fidl::Result<()> {
1237            encoder.debug_check_bounds::<UnspecifiedContinuous>(offset);
1238            encoder.write_num(0u8, offset);
1239            Ok(())
1240        }
1241    }
1242
1243    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for UnspecifiedContinuous {
1244        #[inline(always)]
1245        fn new_empty() -> Self {
1246            Self
1247        }
1248
1249        #[inline]
1250        unsafe fn decode(
1251            &mut self,
1252            decoder: &mut fidl::encoding::Decoder<'_, D>,
1253            offset: usize,
1254            _depth: fidl::encoding::Depth,
1255        ) -> fidl::Result<()> {
1256            decoder.debug_check_bounds::<Self>(offset);
1257            match decoder.read_num::<u8>(offset) {
1258                0 => Ok(()),
1259                _ => Err(fidl::Error::Invalid),
1260            }
1261        }
1262    }
1263
1264    impl Compression {
1265        #[inline(always)]
1266        fn max_ordinal_present(&self) -> u64 {
1267            if let Some(_) = self.oob_parameters {
1268                return 2;
1269            }
1270            if let Some(_) = self.type_ {
1271                return 1;
1272            }
1273            0
1274        }
1275    }
1276
1277    impl fidl::encoding::ValueTypeMarker for Compression {
1278        type Borrowed<'a> = &'a Self;
1279        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1280            value
1281        }
1282    }
1283
1284    unsafe impl fidl::encoding::TypeMarker for Compression {
1285        type Owned = Self;
1286
1287        #[inline(always)]
1288        fn inline_align(_context: fidl::encoding::Context) -> usize {
1289            8
1290        }
1291
1292        #[inline(always)]
1293        fn inline_size(_context: fidl::encoding::Context) -> usize {
1294            16
1295        }
1296    }
1297
1298    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Compression, D>
1299        for &Compression
1300    {
1301        unsafe fn encode(
1302            self,
1303            encoder: &mut fidl::encoding::Encoder<'_, D>,
1304            offset: usize,
1305            mut depth: fidl::encoding::Depth,
1306        ) -> fidl::Result<()> {
1307            encoder.debug_check_bounds::<Compression>(offset);
1308            // Vector header
1309            let max_ordinal: u64 = self.max_ordinal_present();
1310            encoder.write_num(max_ordinal, offset);
1311            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1312            // Calling encoder.out_of_line_offset(0) is not allowed.
1313            if max_ordinal == 0 {
1314                return Ok(());
1315            }
1316            depth.increment()?;
1317            let envelope_size = 8;
1318            let bytes_len = max_ordinal as usize * envelope_size;
1319            #[allow(unused_variables)]
1320            let offset = encoder.out_of_line_offset(bytes_len);
1321            let mut _prev_end_offset: usize = 0;
1322            if 1 > max_ordinal {
1323                return Ok(());
1324            }
1325
1326            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1327            // are envelope_size bytes.
1328            let cur_offset: usize = (1 - 1) * envelope_size;
1329
1330            // Zero reserved fields.
1331            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1332
1333            // Safety:
1334            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1335            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1336            //   envelope_size bytes, there is always sufficient room.
1337            fidl::encoding::encode_in_envelope_optional::<CompressionType, D>(
1338                self.type_
1339                    .as_ref()
1340                    .map(<CompressionType as fidl::encoding::ValueTypeMarker>::borrow),
1341                encoder,
1342                offset + cur_offset,
1343                depth,
1344            )?;
1345
1346            _prev_end_offset = cur_offset + envelope_size;
1347            if 2 > max_ordinal {
1348                return Ok(());
1349            }
1350
1351            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1352            // are envelope_size bytes.
1353            let cur_offset: usize = (2 - 1) * envelope_size;
1354
1355            // Zero reserved fields.
1356            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1357
1358            // Safety:
1359            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1360            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1361            //   envelope_size bytes, there is always sufficient room.
1362            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<u8, 32768>, D>(
1363                self.oob_parameters.as_ref().map(
1364                    <fidl::encoding::Vector<u8, 32768> as fidl::encoding::ValueTypeMarker>::borrow,
1365                ),
1366                encoder,
1367                offset + cur_offset,
1368                depth,
1369            )?;
1370
1371            _prev_end_offset = cur_offset + envelope_size;
1372
1373            Ok(())
1374        }
1375    }
1376
1377    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Compression {
1378        #[inline(always)]
1379        fn new_empty() -> Self {
1380            Self::default()
1381        }
1382
1383        unsafe fn decode(
1384            &mut self,
1385            decoder: &mut fidl::encoding::Decoder<'_, D>,
1386            offset: usize,
1387            mut depth: fidl::encoding::Depth,
1388        ) -> fidl::Result<()> {
1389            decoder.debug_check_bounds::<Self>(offset);
1390            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1391                None => return Err(fidl::Error::NotNullable),
1392                Some(len) => len,
1393            };
1394            // Calling decoder.out_of_line_offset(0) is not allowed.
1395            if len == 0 {
1396                return Ok(());
1397            };
1398            depth.increment()?;
1399            let envelope_size = 8;
1400            let bytes_len = len * envelope_size;
1401            let offset = decoder.out_of_line_offset(bytes_len)?;
1402            // Decode the envelope for each type.
1403            let mut _next_ordinal_to_read = 0;
1404            let mut next_offset = offset;
1405            let end_offset = offset + bytes_len;
1406            _next_ordinal_to_read += 1;
1407            if next_offset >= end_offset {
1408                return Ok(());
1409            }
1410
1411            // Decode unknown envelopes for gaps in ordinals.
1412            while _next_ordinal_to_read < 1 {
1413                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1414                _next_ordinal_to_read += 1;
1415                next_offset += envelope_size;
1416            }
1417
1418            let next_out_of_line = decoder.next_out_of_line();
1419            let handles_before = decoder.remaining_handles();
1420            if let Some((inlined, num_bytes, num_handles)) =
1421                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1422            {
1423                let member_inline_size =
1424                    <CompressionType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1425                if inlined != (member_inline_size <= 4) {
1426                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1427                }
1428                let inner_offset;
1429                let mut inner_depth = depth.clone();
1430                if inlined {
1431                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1432                    inner_offset = next_offset;
1433                } else {
1434                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1435                    inner_depth.increment()?;
1436                }
1437                let val_ref =
1438                    self.type_.get_or_insert_with(|| fidl::new_empty!(CompressionType, D));
1439                fidl::decode!(CompressionType, D, val_ref, decoder, inner_offset, inner_depth)?;
1440                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1441                {
1442                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1443                }
1444                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1445                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1446                }
1447            }
1448
1449            next_offset += envelope_size;
1450            _next_ordinal_to_read += 1;
1451            if next_offset >= end_offset {
1452                return Ok(());
1453            }
1454
1455            // Decode unknown envelopes for gaps in ordinals.
1456            while _next_ordinal_to_read < 2 {
1457                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1458                _next_ordinal_to_read += 1;
1459                next_offset += envelope_size;
1460            }
1461
1462            let next_out_of_line = decoder.next_out_of_line();
1463            let handles_before = decoder.remaining_handles();
1464            if let Some((inlined, num_bytes, num_handles)) =
1465                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1466            {
1467                let member_inline_size =
1468                    <fidl::encoding::Vector<u8, 32768> as fidl::encoding::TypeMarker>::inline_size(
1469                        decoder.context,
1470                    );
1471                if inlined != (member_inline_size <= 4) {
1472                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1473                }
1474                let inner_offset;
1475                let mut inner_depth = depth.clone();
1476                if inlined {
1477                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1478                    inner_offset = next_offset;
1479                } else {
1480                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1481                    inner_depth.increment()?;
1482                }
1483                let val_ref = self
1484                    .oob_parameters
1485                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 32768>, D));
1486                fidl::decode!(fidl::encoding::Vector<u8, 32768>, D, val_ref, decoder, inner_offset, inner_depth)?;
1487                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1488                {
1489                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1490                }
1491                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1492                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1493                }
1494            }
1495
1496            next_offset += envelope_size;
1497
1498            // Decode the remaining unknown envelopes.
1499            while next_offset < end_offset {
1500                _next_ordinal_to_read += 1;
1501                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1502                next_offset += envelope_size;
1503            }
1504
1505            Ok(())
1506        }
1507    }
1508
1509    impl DelayWatcherWatchDelayRequest {
1510        #[inline(always)]
1511        fn max_ordinal_present(&self) -> u64 {
1512            0
1513        }
1514    }
1515
1516    impl fidl::encoding::ValueTypeMarker for DelayWatcherWatchDelayRequest {
1517        type Borrowed<'a> = &'a Self;
1518        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1519            value
1520        }
1521    }
1522
1523    unsafe impl fidl::encoding::TypeMarker for DelayWatcherWatchDelayRequest {
1524        type Owned = Self;
1525
1526        #[inline(always)]
1527        fn inline_align(_context: fidl::encoding::Context) -> usize {
1528            8
1529        }
1530
1531        #[inline(always)]
1532        fn inline_size(_context: fidl::encoding::Context) -> usize {
1533            16
1534        }
1535    }
1536
1537    unsafe impl<D: fidl::encoding::ResourceDialect>
1538        fidl::encoding::Encode<DelayWatcherWatchDelayRequest, D>
1539        for &DelayWatcherWatchDelayRequest
1540    {
1541        unsafe fn encode(
1542            self,
1543            encoder: &mut fidl::encoding::Encoder<'_, D>,
1544            offset: usize,
1545            mut depth: fidl::encoding::Depth,
1546        ) -> fidl::Result<()> {
1547            encoder.debug_check_bounds::<DelayWatcherWatchDelayRequest>(offset);
1548            // Vector header
1549            let max_ordinal: u64 = self.max_ordinal_present();
1550            encoder.write_num(max_ordinal, offset);
1551            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1552            // Calling encoder.out_of_line_offset(0) is not allowed.
1553            if max_ordinal == 0 {
1554                return Ok(());
1555            }
1556            depth.increment()?;
1557            let envelope_size = 8;
1558            let bytes_len = max_ordinal as usize * envelope_size;
1559            #[allow(unused_variables)]
1560            let offset = encoder.out_of_line_offset(bytes_len);
1561            let mut _prev_end_offset: usize = 0;
1562
1563            Ok(())
1564        }
1565    }
1566
1567    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1568        for DelayWatcherWatchDelayRequest
1569    {
1570        #[inline(always)]
1571        fn new_empty() -> Self {
1572            Self::default()
1573        }
1574
1575        unsafe fn decode(
1576            &mut self,
1577            decoder: &mut fidl::encoding::Decoder<'_, D>,
1578            offset: usize,
1579            mut depth: fidl::encoding::Depth,
1580        ) -> fidl::Result<()> {
1581            decoder.debug_check_bounds::<Self>(offset);
1582            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1583                None => return Err(fidl::Error::NotNullable),
1584                Some(len) => len,
1585            };
1586            // Calling decoder.out_of_line_offset(0) is not allowed.
1587            if len == 0 {
1588                return Ok(());
1589            };
1590            depth.increment()?;
1591            let envelope_size = 8;
1592            let bytes_len = len * envelope_size;
1593            let offset = decoder.out_of_line_offset(bytes_len)?;
1594            // Decode the envelope for each type.
1595            let mut _next_ordinal_to_read = 0;
1596            let mut next_offset = offset;
1597            let end_offset = offset + bytes_len;
1598
1599            // Decode the remaining unknown envelopes.
1600            while next_offset < end_offset {
1601                _next_ordinal_to_read += 1;
1602                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1603                next_offset += envelope_size;
1604            }
1605
1606            Ok(())
1607        }
1608    }
1609
1610    impl DelayWatcherWatchDelayResponse {
1611        #[inline(always)]
1612        fn max_ordinal_present(&self) -> u64 {
1613            if let Some(_) = self.delay {
1614                return 1;
1615            }
1616            0
1617        }
1618    }
1619
1620    impl fidl::encoding::ValueTypeMarker for DelayWatcherWatchDelayResponse {
1621        type Borrowed<'a> = &'a Self;
1622        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1623            value
1624        }
1625    }
1626
1627    unsafe impl fidl::encoding::TypeMarker for DelayWatcherWatchDelayResponse {
1628        type Owned = Self;
1629
1630        #[inline(always)]
1631        fn inline_align(_context: fidl::encoding::Context) -> usize {
1632            8
1633        }
1634
1635        #[inline(always)]
1636        fn inline_size(_context: fidl::encoding::Context) -> usize {
1637            16
1638        }
1639    }
1640
1641    unsafe impl<D: fidl::encoding::ResourceDialect>
1642        fidl::encoding::Encode<DelayWatcherWatchDelayResponse, D>
1643        for &DelayWatcherWatchDelayResponse
1644    {
1645        unsafe fn encode(
1646            self,
1647            encoder: &mut fidl::encoding::Encoder<'_, D>,
1648            offset: usize,
1649            mut depth: fidl::encoding::Depth,
1650        ) -> fidl::Result<()> {
1651            encoder.debug_check_bounds::<DelayWatcherWatchDelayResponse>(offset);
1652            // Vector header
1653            let max_ordinal: u64 = self.max_ordinal_present();
1654            encoder.write_num(max_ordinal, offset);
1655            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1656            // Calling encoder.out_of_line_offset(0) is not allowed.
1657            if max_ordinal == 0 {
1658                return Ok(());
1659            }
1660            depth.increment()?;
1661            let envelope_size = 8;
1662            let bytes_len = max_ordinal as usize * envelope_size;
1663            #[allow(unused_variables)]
1664            let offset = encoder.out_of_line_offset(bytes_len);
1665            let mut _prev_end_offset: usize = 0;
1666            if 1 > max_ordinal {
1667                return Ok(());
1668            }
1669
1670            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1671            // are envelope_size bytes.
1672            let cur_offset: usize = (1 - 1) * envelope_size;
1673
1674            // Zero reserved fields.
1675            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1676
1677            // Safety:
1678            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1679            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1680            //   envelope_size bytes, there is always sufficient room.
1681            fidl::encoding::encode_in_envelope_optional::<i64, D>(
1682                self.delay.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
1683                encoder,
1684                offset + cur_offset,
1685                depth,
1686            )?;
1687
1688            _prev_end_offset = cur_offset + envelope_size;
1689
1690            Ok(())
1691        }
1692    }
1693
1694    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1695        for DelayWatcherWatchDelayResponse
1696    {
1697        #[inline(always)]
1698        fn new_empty() -> Self {
1699            Self::default()
1700        }
1701
1702        unsafe fn decode(
1703            &mut self,
1704            decoder: &mut fidl::encoding::Decoder<'_, D>,
1705            offset: usize,
1706            mut depth: fidl::encoding::Depth,
1707        ) -> fidl::Result<()> {
1708            decoder.debug_check_bounds::<Self>(offset);
1709            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1710                None => return Err(fidl::Error::NotNullable),
1711                Some(len) => len,
1712            };
1713            // Calling decoder.out_of_line_offset(0) is not allowed.
1714            if len == 0 {
1715                return Ok(());
1716            };
1717            depth.increment()?;
1718            let envelope_size = 8;
1719            let bytes_len = len * envelope_size;
1720            let offset = decoder.out_of_line_offset(bytes_len)?;
1721            // Decode the envelope for each type.
1722            let mut _next_ordinal_to_read = 0;
1723            let mut next_offset = offset;
1724            let end_offset = offset + bytes_len;
1725            _next_ordinal_to_read += 1;
1726            if next_offset >= end_offset {
1727                return Ok(());
1728            }
1729
1730            // Decode unknown envelopes for gaps in ordinals.
1731            while _next_ordinal_to_read < 1 {
1732                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1733                _next_ordinal_to_read += 1;
1734                next_offset += envelope_size;
1735            }
1736
1737            let next_out_of_line = decoder.next_out_of_line();
1738            let handles_before = decoder.remaining_handles();
1739            if let Some((inlined, num_bytes, num_handles)) =
1740                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1741            {
1742                let member_inline_size =
1743                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1744                if inlined != (member_inline_size <= 4) {
1745                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1746                }
1747                let inner_offset;
1748                let mut inner_depth = depth.clone();
1749                if inlined {
1750                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1751                    inner_offset = next_offset;
1752                } else {
1753                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1754                    inner_depth.increment()?;
1755                }
1756                let val_ref = self.delay.get_or_insert_with(|| fidl::new_empty!(i64, D));
1757                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
1758                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1759                {
1760                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1761                }
1762                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1763                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1764                }
1765            }
1766
1767            next_offset += envelope_size;
1768
1769            // Decode the remaining unknown envelopes.
1770            while next_offset < end_offset {
1771                _next_ordinal_to_read += 1;
1772                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1773                next_offset += envelope_size;
1774            }
1775
1776            Ok(())
1777        }
1778    }
1779
1780    impl Format {
1781        #[inline(always)]
1782        fn max_ordinal_present(&self) -> u64 {
1783            if let Some(_) = self.channel_layout {
1784                return 4;
1785            }
1786            if let Some(_) = self.frames_per_second {
1787                return 3;
1788            }
1789            if let Some(_) = self.channel_count {
1790                return 2;
1791            }
1792            if let Some(_) = self.sample_type {
1793                return 1;
1794            }
1795            0
1796        }
1797    }
1798
1799    impl fidl::encoding::ValueTypeMarker for Format {
1800        type Borrowed<'a> = &'a Self;
1801        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1802            value
1803        }
1804    }
1805
1806    unsafe impl fidl::encoding::TypeMarker for Format {
1807        type Owned = Self;
1808
1809        #[inline(always)]
1810        fn inline_align(_context: fidl::encoding::Context) -> usize {
1811            8
1812        }
1813
1814        #[inline(always)]
1815        fn inline_size(_context: fidl::encoding::Context) -> usize {
1816            16
1817        }
1818    }
1819
1820    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Format, D> for &Format {
1821        unsafe fn encode(
1822            self,
1823            encoder: &mut fidl::encoding::Encoder<'_, D>,
1824            offset: usize,
1825            mut depth: fidl::encoding::Depth,
1826        ) -> fidl::Result<()> {
1827            encoder.debug_check_bounds::<Format>(offset);
1828            // Vector header
1829            let max_ordinal: u64 = self.max_ordinal_present();
1830            encoder.write_num(max_ordinal, offset);
1831            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1832            // Calling encoder.out_of_line_offset(0) is not allowed.
1833            if max_ordinal == 0 {
1834                return Ok(());
1835            }
1836            depth.increment()?;
1837            let envelope_size = 8;
1838            let bytes_len = max_ordinal as usize * envelope_size;
1839            #[allow(unused_variables)]
1840            let offset = encoder.out_of_line_offset(bytes_len);
1841            let mut _prev_end_offset: usize = 0;
1842            if 1 > max_ordinal {
1843                return Ok(());
1844            }
1845
1846            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1847            // are envelope_size bytes.
1848            let cur_offset: usize = (1 - 1) * envelope_size;
1849
1850            // Zero reserved fields.
1851            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1852
1853            // Safety:
1854            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1855            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1856            //   envelope_size bytes, there is always sufficient room.
1857            fidl::encoding::encode_in_envelope_optional::<SampleType, D>(
1858                self.sample_type
1859                    .as_ref()
1860                    .map(<SampleType as fidl::encoding::ValueTypeMarker>::borrow),
1861                encoder,
1862                offset + cur_offset,
1863                depth,
1864            )?;
1865
1866            _prev_end_offset = cur_offset + envelope_size;
1867            if 2 > max_ordinal {
1868                return Ok(());
1869            }
1870
1871            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1872            // are envelope_size bytes.
1873            let cur_offset: usize = (2 - 1) * envelope_size;
1874
1875            // Zero reserved fields.
1876            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1877
1878            // Safety:
1879            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1880            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1881            //   envelope_size bytes, there is always sufficient room.
1882            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1883                self.channel_count.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1884                encoder,
1885                offset + cur_offset,
1886                depth,
1887            )?;
1888
1889            _prev_end_offset = cur_offset + envelope_size;
1890            if 3 > max_ordinal {
1891                return Ok(());
1892            }
1893
1894            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1895            // are envelope_size bytes.
1896            let cur_offset: usize = (3 - 1) * envelope_size;
1897
1898            // Zero reserved fields.
1899            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1900
1901            // Safety:
1902            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1903            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1904            //   envelope_size bytes, there is always sufficient room.
1905            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1906                self.frames_per_second
1907                    .as_ref()
1908                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1909                encoder,
1910                offset + cur_offset,
1911                depth,
1912            )?;
1913
1914            _prev_end_offset = cur_offset + envelope_size;
1915            if 4 > max_ordinal {
1916                return Ok(());
1917            }
1918
1919            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1920            // are envelope_size bytes.
1921            let cur_offset: usize = (4 - 1) * envelope_size;
1922
1923            // Zero reserved fields.
1924            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1925
1926            // Safety:
1927            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1928            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1929            //   envelope_size bytes, there is always sufficient room.
1930            fidl::encoding::encode_in_envelope_optional::<ChannelLayout, D>(
1931                self.channel_layout
1932                    .as_ref()
1933                    .map(<ChannelLayout as fidl::encoding::ValueTypeMarker>::borrow),
1934                encoder,
1935                offset + cur_offset,
1936                depth,
1937            )?;
1938
1939            _prev_end_offset = cur_offset + envelope_size;
1940
1941            Ok(())
1942        }
1943    }
1944
1945    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Format {
1946        #[inline(always)]
1947        fn new_empty() -> Self {
1948            Self::default()
1949        }
1950
1951        unsafe fn decode(
1952            &mut self,
1953            decoder: &mut fidl::encoding::Decoder<'_, D>,
1954            offset: usize,
1955            mut depth: fidl::encoding::Depth,
1956        ) -> fidl::Result<()> {
1957            decoder.debug_check_bounds::<Self>(offset);
1958            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1959                None => return Err(fidl::Error::NotNullable),
1960                Some(len) => len,
1961            };
1962            // Calling decoder.out_of_line_offset(0) is not allowed.
1963            if len == 0 {
1964                return Ok(());
1965            };
1966            depth.increment()?;
1967            let envelope_size = 8;
1968            let bytes_len = len * envelope_size;
1969            let offset = decoder.out_of_line_offset(bytes_len)?;
1970            // Decode the envelope for each type.
1971            let mut _next_ordinal_to_read = 0;
1972            let mut next_offset = offset;
1973            let end_offset = offset + bytes_len;
1974            _next_ordinal_to_read += 1;
1975            if next_offset >= end_offset {
1976                return Ok(());
1977            }
1978
1979            // Decode unknown envelopes for gaps in ordinals.
1980            while _next_ordinal_to_read < 1 {
1981                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1982                _next_ordinal_to_read += 1;
1983                next_offset += envelope_size;
1984            }
1985
1986            let next_out_of_line = decoder.next_out_of_line();
1987            let handles_before = decoder.remaining_handles();
1988            if let Some((inlined, num_bytes, num_handles)) =
1989                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1990            {
1991                let member_inline_size =
1992                    <SampleType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1993                if inlined != (member_inline_size <= 4) {
1994                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1995                }
1996                let inner_offset;
1997                let mut inner_depth = depth.clone();
1998                if inlined {
1999                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2000                    inner_offset = next_offset;
2001                } else {
2002                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2003                    inner_depth.increment()?;
2004                }
2005                let val_ref =
2006                    self.sample_type.get_or_insert_with(|| fidl::new_empty!(SampleType, D));
2007                fidl::decode!(SampleType, D, val_ref, decoder, inner_offset, inner_depth)?;
2008                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2009                {
2010                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2011                }
2012                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2013                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2014                }
2015            }
2016
2017            next_offset += envelope_size;
2018            _next_ordinal_to_read += 1;
2019            if next_offset >= end_offset {
2020                return Ok(());
2021            }
2022
2023            // Decode unknown envelopes for gaps in ordinals.
2024            while _next_ordinal_to_read < 2 {
2025                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2026                _next_ordinal_to_read += 1;
2027                next_offset += envelope_size;
2028            }
2029
2030            let next_out_of_line = decoder.next_out_of_line();
2031            let handles_before = decoder.remaining_handles();
2032            if let Some((inlined, num_bytes, num_handles)) =
2033                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2034            {
2035                let member_inline_size =
2036                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2037                if inlined != (member_inline_size <= 4) {
2038                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2039                }
2040                let inner_offset;
2041                let mut inner_depth = depth.clone();
2042                if inlined {
2043                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2044                    inner_offset = next_offset;
2045                } else {
2046                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2047                    inner_depth.increment()?;
2048                }
2049                let val_ref = self.channel_count.get_or_insert_with(|| fidl::new_empty!(u32, D));
2050                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2051                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2052                {
2053                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2054                }
2055                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2056                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2057                }
2058            }
2059
2060            next_offset += envelope_size;
2061            _next_ordinal_to_read += 1;
2062            if next_offset >= end_offset {
2063                return Ok(());
2064            }
2065
2066            // Decode unknown envelopes for gaps in ordinals.
2067            while _next_ordinal_to_read < 3 {
2068                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2069                _next_ordinal_to_read += 1;
2070                next_offset += envelope_size;
2071            }
2072
2073            let next_out_of_line = decoder.next_out_of_line();
2074            let handles_before = decoder.remaining_handles();
2075            if let Some((inlined, num_bytes, num_handles)) =
2076                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2077            {
2078                let member_inline_size =
2079                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2080                if inlined != (member_inline_size <= 4) {
2081                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2082                }
2083                let inner_offset;
2084                let mut inner_depth = depth.clone();
2085                if inlined {
2086                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2087                    inner_offset = next_offset;
2088                } else {
2089                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2090                    inner_depth.increment()?;
2091                }
2092                let val_ref =
2093                    self.frames_per_second.get_or_insert_with(|| fidl::new_empty!(u32, D));
2094                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2095                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2096                {
2097                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2098                }
2099                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2100                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2101                }
2102            }
2103
2104            next_offset += envelope_size;
2105            _next_ordinal_to_read += 1;
2106            if next_offset >= end_offset {
2107                return Ok(());
2108            }
2109
2110            // Decode unknown envelopes for gaps in ordinals.
2111            while _next_ordinal_to_read < 4 {
2112                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2113                _next_ordinal_to_read += 1;
2114                next_offset += envelope_size;
2115            }
2116
2117            let next_out_of_line = decoder.next_out_of_line();
2118            let handles_before = decoder.remaining_handles();
2119            if let Some((inlined, num_bytes, num_handles)) =
2120                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2121            {
2122                let member_inline_size =
2123                    <ChannelLayout as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2124                if inlined != (member_inline_size <= 4) {
2125                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2126                }
2127                let inner_offset;
2128                let mut inner_depth = depth.clone();
2129                if inlined {
2130                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2131                    inner_offset = next_offset;
2132                } else {
2133                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2134                    inner_depth.increment()?;
2135                }
2136                let val_ref =
2137                    self.channel_layout.get_or_insert_with(|| fidl::new_empty!(ChannelLayout, D));
2138                fidl::decode!(ChannelLayout, D, val_ref, decoder, inner_offset, inner_depth)?;
2139                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2140                {
2141                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2142                }
2143                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2144                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2145                }
2146            }
2147
2148            next_offset += envelope_size;
2149
2150            // Decode the remaining unknown envelopes.
2151            while next_offset < end_offset {
2152                _next_ordinal_to_read += 1;
2153                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2154                next_offset += envelope_size;
2155            }
2156
2157            Ok(())
2158        }
2159    }
2160
2161    impl GainControlSetGainRequest {
2162        #[inline(always)]
2163        fn max_ordinal_present(&self) -> u64 {
2164            if let Some(_) = self.when {
2165                return 2;
2166            }
2167            if let Some(_) = self.how {
2168                return 1;
2169            }
2170            0
2171        }
2172    }
2173
2174    impl fidl::encoding::ValueTypeMarker for GainControlSetGainRequest {
2175        type Borrowed<'a> = &'a Self;
2176        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2177            value
2178        }
2179    }
2180
2181    unsafe impl fidl::encoding::TypeMarker for GainControlSetGainRequest {
2182        type Owned = Self;
2183
2184        #[inline(always)]
2185        fn inline_align(_context: fidl::encoding::Context) -> usize {
2186            8
2187        }
2188
2189        #[inline(always)]
2190        fn inline_size(_context: fidl::encoding::Context) -> usize {
2191            16
2192        }
2193    }
2194
2195    unsafe impl<D: fidl::encoding::ResourceDialect>
2196        fidl::encoding::Encode<GainControlSetGainRequest, D> for &GainControlSetGainRequest
2197    {
2198        unsafe fn encode(
2199            self,
2200            encoder: &mut fidl::encoding::Encoder<'_, D>,
2201            offset: usize,
2202            mut depth: fidl::encoding::Depth,
2203        ) -> fidl::Result<()> {
2204            encoder.debug_check_bounds::<GainControlSetGainRequest>(offset);
2205            // Vector header
2206            let max_ordinal: u64 = self.max_ordinal_present();
2207            encoder.write_num(max_ordinal, offset);
2208            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2209            // Calling encoder.out_of_line_offset(0) is not allowed.
2210            if max_ordinal == 0 {
2211                return Ok(());
2212            }
2213            depth.increment()?;
2214            let envelope_size = 8;
2215            let bytes_len = max_ordinal as usize * envelope_size;
2216            #[allow(unused_variables)]
2217            let offset = encoder.out_of_line_offset(bytes_len);
2218            let mut _prev_end_offset: usize = 0;
2219            if 1 > max_ordinal {
2220                return Ok(());
2221            }
2222
2223            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2224            // are envelope_size bytes.
2225            let cur_offset: usize = (1 - 1) * envelope_size;
2226
2227            // Zero reserved fields.
2228            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2229
2230            // Safety:
2231            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2232            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2233            //   envelope_size bytes, there is always sufficient room.
2234            fidl::encoding::encode_in_envelope_optional::<GainUpdateMethod, D>(
2235                self.how
2236                    .as_ref()
2237                    .map(<GainUpdateMethod as fidl::encoding::ValueTypeMarker>::borrow),
2238                encoder,
2239                offset + cur_offset,
2240                depth,
2241            )?;
2242
2243            _prev_end_offset = cur_offset + envelope_size;
2244            if 2 > max_ordinal {
2245                return Ok(());
2246            }
2247
2248            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2249            // are envelope_size bytes.
2250            let cur_offset: usize = (2 - 1) * envelope_size;
2251
2252            // Zero reserved fields.
2253            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2254
2255            // Safety:
2256            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2257            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2258            //   envelope_size bytes, there is always sufficient room.
2259            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media2__common::RealTime, D>(
2260            self.when.as_ref().map(<fidl_fuchsia_media2__common::RealTime as fidl::encoding::ValueTypeMarker>::borrow),
2261            encoder, offset + cur_offset, depth
2262        )?;
2263
2264            _prev_end_offset = cur_offset + envelope_size;
2265
2266            Ok(())
2267        }
2268    }
2269
2270    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2271        for GainControlSetGainRequest
2272    {
2273        #[inline(always)]
2274        fn new_empty() -> Self {
2275            Self::default()
2276        }
2277
2278        unsafe fn decode(
2279            &mut self,
2280            decoder: &mut fidl::encoding::Decoder<'_, D>,
2281            offset: usize,
2282            mut depth: fidl::encoding::Depth,
2283        ) -> fidl::Result<()> {
2284            decoder.debug_check_bounds::<Self>(offset);
2285            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2286                None => return Err(fidl::Error::NotNullable),
2287                Some(len) => len,
2288            };
2289            // Calling decoder.out_of_line_offset(0) is not allowed.
2290            if len == 0 {
2291                return Ok(());
2292            };
2293            depth.increment()?;
2294            let envelope_size = 8;
2295            let bytes_len = len * envelope_size;
2296            let offset = decoder.out_of_line_offset(bytes_len)?;
2297            // Decode the envelope for each type.
2298            let mut _next_ordinal_to_read = 0;
2299            let mut next_offset = offset;
2300            let end_offset = offset + bytes_len;
2301            _next_ordinal_to_read += 1;
2302            if next_offset >= end_offset {
2303                return Ok(());
2304            }
2305
2306            // Decode unknown envelopes for gaps in ordinals.
2307            while _next_ordinal_to_read < 1 {
2308                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2309                _next_ordinal_to_read += 1;
2310                next_offset += envelope_size;
2311            }
2312
2313            let next_out_of_line = decoder.next_out_of_line();
2314            let handles_before = decoder.remaining_handles();
2315            if let Some((inlined, num_bytes, num_handles)) =
2316                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2317            {
2318                let member_inline_size =
2319                    <GainUpdateMethod as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2320                if inlined != (member_inline_size <= 4) {
2321                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2322                }
2323                let inner_offset;
2324                let mut inner_depth = depth.clone();
2325                if inlined {
2326                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2327                    inner_offset = next_offset;
2328                } else {
2329                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2330                    inner_depth.increment()?;
2331                }
2332                let val_ref = self.how.get_or_insert_with(|| fidl::new_empty!(GainUpdateMethod, D));
2333                fidl::decode!(GainUpdateMethod, D, val_ref, decoder, inner_offset, inner_depth)?;
2334                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2335                {
2336                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2337                }
2338                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2339                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2340                }
2341            }
2342
2343            next_offset += envelope_size;
2344            _next_ordinal_to_read += 1;
2345            if next_offset >= end_offset {
2346                return Ok(());
2347            }
2348
2349            // Decode unknown envelopes for gaps in ordinals.
2350            while _next_ordinal_to_read < 2 {
2351                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2352                _next_ordinal_to_read += 1;
2353                next_offset += envelope_size;
2354            }
2355
2356            let next_out_of_line = decoder.next_out_of_line();
2357            let handles_before = decoder.remaining_handles();
2358            if let Some((inlined, num_bytes, num_handles)) =
2359                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2360            {
2361                let member_inline_size = <fidl_fuchsia_media2__common::RealTime as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2362                if inlined != (member_inline_size <= 4) {
2363                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2364                }
2365                let inner_offset;
2366                let mut inner_depth = depth.clone();
2367                if inlined {
2368                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2369                    inner_offset = next_offset;
2370                } else {
2371                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2372                    inner_depth.increment()?;
2373                }
2374                let val_ref = self.when.get_or_insert_with(|| {
2375                    fidl::new_empty!(fidl_fuchsia_media2__common::RealTime, D)
2376                });
2377                fidl::decode!(
2378                    fidl_fuchsia_media2__common::RealTime,
2379                    D,
2380                    val_ref,
2381                    decoder,
2382                    inner_offset,
2383                    inner_depth
2384                )?;
2385                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2386                {
2387                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2388                }
2389                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2390                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2391                }
2392            }
2393
2394            next_offset += envelope_size;
2395
2396            // Decode the remaining unknown envelopes.
2397            while next_offset < end_offset {
2398                _next_ordinal_to_read += 1;
2399                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2400                next_offset += envelope_size;
2401            }
2402
2403            Ok(())
2404        }
2405    }
2406
2407    impl GainControlSetMuteRequest {
2408        #[inline(always)]
2409        fn max_ordinal_present(&self) -> u64 {
2410            if let Some(_) = self.when {
2411                return 2;
2412            }
2413            if let Some(_) = self.muted {
2414                return 1;
2415            }
2416            0
2417        }
2418    }
2419
2420    impl fidl::encoding::ValueTypeMarker for GainControlSetMuteRequest {
2421        type Borrowed<'a> = &'a Self;
2422        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2423            value
2424        }
2425    }
2426
2427    unsafe impl fidl::encoding::TypeMarker for GainControlSetMuteRequest {
2428        type Owned = Self;
2429
2430        #[inline(always)]
2431        fn inline_align(_context: fidl::encoding::Context) -> usize {
2432            8
2433        }
2434
2435        #[inline(always)]
2436        fn inline_size(_context: fidl::encoding::Context) -> usize {
2437            16
2438        }
2439    }
2440
2441    unsafe impl<D: fidl::encoding::ResourceDialect>
2442        fidl::encoding::Encode<GainControlSetMuteRequest, D> for &GainControlSetMuteRequest
2443    {
2444        unsafe fn encode(
2445            self,
2446            encoder: &mut fidl::encoding::Encoder<'_, D>,
2447            offset: usize,
2448            mut depth: fidl::encoding::Depth,
2449        ) -> fidl::Result<()> {
2450            encoder.debug_check_bounds::<GainControlSetMuteRequest>(offset);
2451            // Vector header
2452            let max_ordinal: u64 = self.max_ordinal_present();
2453            encoder.write_num(max_ordinal, offset);
2454            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2455            // Calling encoder.out_of_line_offset(0) is not allowed.
2456            if max_ordinal == 0 {
2457                return Ok(());
2458            }
2459            depth.increment()?;
2460            let envelope_size = 8;
2461            let bytes_len = max_ordinal as usize * envelope_size;
2462            #[allow(unused_variables)]
2463            let offset = encoder.out_of_line_offset(bytes_len);
2464            let mut _prev_end_offset: usize = 0;
2465            if 1 > max_ordinal {
2466                return Ok(());
2467            }
2468
2469            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2470            // are envelope_size bytes.
2471            let cur_offset: usize = (1 - 1) * envelope_size;
2472
2473            // Zero reserved fields.
2474            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2475
2476            // Safety:
2477            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2478            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2479            //   envelope_size bytes, there is always sufficient room.
2480            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2481                self.muted.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2482                encoder,
2483                offset + cur_offset,
2484                depth,
2485            )?;
2486
2487            _prev_end_offset = cur_offset + envelope_size;
2488            if 2 > max_ordinal {
2489                return Ok(());
2490            }
2491
2492            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2493            // are envelope_size bytes.
2494            let cur_offset: usize = (2 - 1) * envelope_size;
2495
2496            // Zero reserved fields.
2497            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2498
2499            // Safety:
2500            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2501            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2502            //   envelope_size bytes, there is always sufficient room.
2503            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media2__common::RealTime, D>(
2504            self.when.as_ref().map(<fidl_fuchsia_media2__common::RealTime as fidl::encoding::ValueTypeMarker>::borrow),
2505            encoder, offset + cur_offset, depth
2506        )?;
2507
2508            _prev_end_offset = cur_offset + envelope_size;
2509
2510            Ok(())
2511        }
2512    }
2513
2514    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2515        for GainControlSetMuteRequest
2516    {
2517        #[inline(always)]
2518        fn new_empty() -> Self {
2519            Self::default()
2520        }
2521
2522        unsafe fn decode(
2523            &mut self,
2524            decoder: &mut fidl::encoding::Decoder<'_, D>,
2525            offset: usize,
2526            mut depth: fidl::encoding::Depth,
2527        ) -> fidl::Result<()> {
2528            decoder.debug_check_bounds::<Self>(offset);
2529            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2530                None => return Err(fidl::Error::NotNullable),
2531                Some(len) => len,
2532            };
2533            // Calling decoder.out_of_line_offset(0) is not allowed.
2534            if len == 0 {
2535                return Ok(());
2536            };
2537            depth.increment()?;
2538            let envelope_size = 8;
2539            let bytes_len = len * envelope_size;
2540            let offset = decoder.out_of_line_offset(bytes_len)?;
2541            // Decode the envelope for each type.
2542            let mut _next_ordinal_to_read = 0;
2543            let mut next_offset = offset;
2544            let end_offset = offset + bytes_len;
2545            _next_ordinal_to_read += 1;
2546            if next_offset >= end_offset {
2547                return Ok(());
2548            }
2549
2550            // Decode unknown envelopes for gaps in ordinals.
2551            while _next_ordinal_to_read < 1 {
2552                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2553                _next_ordinal_to_read += 1;
2554                next_offset += envelope_size;
2555            }
2556
2557            let next_out_of_line = decoder.next_out_of_line();
2558            let handles_before = decoder.remaining_handles();
2559            if let Some((inlined, num_bytes, num_handles)) =
2560                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2561            {
2562                let member_inline_size =
2563                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2564                if inlined != (member_inline_size <= 4) {
2565                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2566                }
2567                let inner_offset;
2568                let mut inner_depth = depth.clone();
2569                if inlined {
2570                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2571                    inner_offset = next_offset;
2572                } else {
2573                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2574                    inner_depth.increment()?;
2575                }
2576                let val_ref = self.muted.get_or_insert_with(|| fidl::new_empty!(bool, D));
2577                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2578                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2579                {
2580                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2581                }
2582                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2583                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2584                }
2585            }
2586
2587            next_offset += envelope_size;
2588            _next_ordinal_to_read += 1;
2589            if next_offset >= end_offset {
2590                return Ok(());
2591            }
2592
2593            // Decode unknown envelopes for gaps in ordinals.
2594            while _next_ordinal_to_read < 2 {
2595                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2596                _next_ordinal_to_read += 1;
2597                next_offset += envelope_size;
2598            }
2599
2600            let next_out_of_line = decoder.next_out_of_line();
2601            let handles_before = decoder.remaining_handles();
2602            if let Some((inlined, num_bytes, num_handles)) =
2603                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2604            {
2605                let member_inline_size = <fidl_fuchsia_media2__common::RealTime as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2606                if inlined != (member_inline_size <= 4) {
2607                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2608                }
2609                let inner_offset;
2610                let mut inner_depth = depth.clone();
2611                if inlined {
2612                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2613                    inner_offset = next_offset;
2614                } else {
2615                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2616                    inner_depth.increment()?;
2617                }
2618                let val_ref = self.when.get_or_insert_with(|| {
2619                    fidl::new_empty!(fidl_fuchsia_media2__common::RealTime, D)
2620                });
2621                fidl::decode!(
2622                    fidl_fuchsia_media2__common::RealTime,
2623                    D,
2624                    val_ref,
2625                    decoder,
2626                    inner_offset,
2627                    inner_depth
2628                )?;
2629                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2630                {
2631                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2632                }
2633                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2634                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2635                }
2636            }
2637
2638            next_offset += envelope_size;
2639
2640            // Decode the remaining unknown envelopes.
2641            while next_offset < end_offset {
2642                _next_ordinal_to_read += 1;
2643                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2644                next_offset += envelope_size;
2645            }
2646
2647            Ok(())
2648        }
2649    }
2650
2651    impl GainControlSetGainResponse {
2652        #[inline(always)]
2653        fn max_ordinal_present(&self) -> u64 {
2654            0
2655        }
2656    }
2657
2658    impl fidl::encoding::ValueTypeMarker for GainControlSetGainResponse {
2659        type Borrowed<'a> = &'a Self;
2660        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2661            value
2662        }
2663    }
2664
2665    unsafe impl fidl::encoding::TypeMarker for GainControlSetGainResponse {
2666        type Owned = Self;
2667
2668        #[inline(always)]
2669        fn inline_align(_context: fidl::encoding::Context) -> usize {
2670            8
2671        }
2672
2673        #[inline(always)]
2674        fn inline_size(_context: fidl::encoding::Context) -> usize {
2675            16
2676        }
2677    }
2678
2679    unsafe impl<D: fidl::encoding::ResourceDialect>
2680        fidl::encoding::Encode<GainControlSetGainResponse, D> for &GainControlSetGainResponse
2681    {
2682        unsafe fn encode(
2683            self,
2684            encoder: &mut fidl::encoding::Encoder<'_, D>,
2685            offset: usize,
2686            mut depth: fidl::encoding::Depth,
2687        ) -> fidl::Result<()> {
2688            encoder.debug_check_bounds::<GainControlSetGainResponse>(offset);
2689            // Vector header
2690            let max_ordinal: u64 = self.max_ordinal_present();
2691            encoder.write_num(max_ordinal, offset);
2692            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2693            // Calling encoder.out_of_line_offset(0) is not allowed.
2694            if max_ordinal == 0 {
2695                return Ok(());
2696            }
2697            depth.increment()?;
2698            let envelope_size = 8;
2699            let bytes_len = max_ordinal as usize * envelope_size;
2700            #[allow(unused_variables)]
2701            let offset = encoder.out_of_line_offset(bytes_len);
2702            let mut _prev_end_offset: usize = 0;
2703
2704            Ok(())
2705        }
2706    }
2707
2708    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2709        for GainControlSetGainResponse
2710    {
2711        #[inline(always)]
2712        fn new_empty() -> Self {
2713            Self::default()
2714        }
2715
2716        unsafe fn decode(
2717            &mut self,
2718            decoder: &mut fidl::encoding::Decoder<'_, D>,
2719            offset: usize,
2720            mut depth: fidl::encoding::Depth,
2721        ) -> fidl::Result<()> {
2722            decoder.debug_check_bounds::<Self>(offset);
2723            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2724                None => return Err(fidl::Error::NotNullable),
2725                Some(len) => len,
2726            };
2727            // Calling decoder.out_of_line_offset(0) is not allowed.
2728            if len == 0 {
2729                return Ok(());
2730            };
2731            depth.increment()?;
2732            let envelope_size = 8;
2733            let bytes_len = len * envelope_size;
2734            let offset = decoder.out_of_line_offset(bytes_len)?;
2735            // Decode the envelope for each type.
2736            let mut _next_ordinal_to_read = 0;
2737            let mut next_offset = offset;
2738            let end_offset = offset + bytes_len;
2739
2740            // Decode the remaining unknown envelopes.
2741            while next_offset < end_offset {
2742                _next_ordinal_to_read += 1;
2743                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2744                next_offset += envelope_size;
2745            }
2746
2747            Ok(())
2748        }
2749    }
2750
2751    impl GainControlSetMuteResponse {
2752        #[inline(always)]
2753        fn max_ordinal_present(&self) -> u64 {
2754            0
2755        }
2756    }
2757
2758    impl fidl::encoding::ValueTypeMarker for GainControlSetMuteResponse {
2759        type Borrowed<'a> = &'a Self;
2760        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2761            value
2762        }
2763    }
2764
2765    unsafe impl fidl::encoding::TypeMarker for GainControlSetMuteResponse {
2766        type Owned = Self;
2767
2768        #[inline(always)]
2769        fn inline_align(_context: fidl::encoding::Context) -> usize {
2770            8
2771        }
2772
2773        #[inline(always)]
2774        fn inline_size(_context: fidl::encoding::Context) -> usize {
2775            16
2776        }
2777    }
2778
2779    unsafe impl<D: fidl::encoding::ResourceDialect>
2780        fidl::encoding::Encode<GainControlSetMuteResponse, D> for &GainControlSetMuteResponse
2781    {
2782        unsafe fn encode(
2783            self,
2784            encoder: &mut fidl::encoding::Encoder<'_, D>,
2785            offset: usize,
2786            mut depth: fidl::encoding::Depth,
2787        ) -> fidl::Result<()> {
2788            encoder.debug_check_bounds::<GainControlSetMuteResponse>(offset);
2789            // Vector header
2790            let max_ordinal: u64 = self.max_ordinal_present();
2791            encoder.write_num(max_ordinal, offset);
2792            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2793            // Calling encoder.out_of_line_offset(0) is not allowed.
2794            if max_ordinal == 0 {
2795                return Ok(());
2796            }
2797            depth.increment()?;
2798            let envelope_size = 8;
2799            let bytes_len = max_ordinal as usize * envelope_size;
2800            #[allow(unused_variables)]
2801            let offset = encoder.out_of_line_offset(bytes_len);
2802            let mut _prev_end_offset: usize = 0;
2803
2804            Ok(())
2805        }
2806    }
2807
2808    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2809        for GainControlSetMuteResponse
2810    {
2811        #[inline(always)]
2812        fn new_empty() -> Self {
2813            Self::default()
2814        }
2815
2816        unsafe fn decode(
2817            &mut self,
2818            decoder: &mut fidl::encoding::Decoder<'_, D>,
2819            offset: usize,
2820            mut depth: fidl::encoding::Depth,
2821        ) -> fidl::Result<()> {
2822            decoder.debug_check_bounds::<Self>(offset);
2823            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2824                None => return Err(fidl::Error::NotNullable),
2825                Some(len) => len,
2826            };
2827            // Calling decoder.out_of_line_offset(0) is not allowed.
2828            if len == 0 {
2829                return Ok(());
2830            };
2831            depth.increment()?;
2832            let envelope_size = 8;
2833            let bytes_len = len * envelope_size;
2834            let offset = decoder.out_of_line_offset(bytes_len)?;
2835            // Decode the envelope for each type.
2836            let mut _next_ordinal_to_read = 0;
2837            let mut next_offset = offset;
2838            let end_offset = offset + bytes_len;
2839
2840            // Decode the remaining unknown envelopes.
2841            while next_offset < end_offset {
2842                _next_ordinal_to_read += 1;
2843                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2844                next_offset += envelope_size;
2845            }
2846
2847            Ok(())
2848        }
2849    }
2850
2851    impl Packet {
2852        #[inline(always)]
2853        fn max_ordinal_present(&self) -> u64 {
2854            if let Some(_) = self.encryption_properties {
2855                return 7;
2856            }
2857            if let Some(_) = self.back_frames_to_drop {
2858                return 6;
2859            }
2860            if let Some(_) = self.front_frames_to_drop {
2861                return 5;
2862            }
2863            if let Some(_) = self.flags {
2864                return 4;
2865            }
2866            if let Some(_) = self.capture_timestamp {
2867                return 3;
2868            }
2869            if let Some(_) = self.timestamp {
2870                return 2;
2871            }
2872            if let Some(_) = self.payload {
2873                return 1;
2874            }
2875            0
2876        }
2877    }
2878
2879    impl fidl::encoding::ValueTypeMarker for Packet {
2880        type Borrowed<'a> = &'a Self;
2881        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2882            value
2883        }
2884    }
2885
2886    unsafe impl fidl::encoding::TypeMarker for Packet {
2887        type Owned = Self;
2888
2889        #[inline(always)]
2890        fn inline_align(_context: fidl::encoding::Context) -> usize {
2891            8
2892        }
2893
2894        #[inline(always)]
2895        fn inline_size(_context: fidl::encoding::Context) -> usize {
2896            16
2897        }
2898    }
2899
2900    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Packet, D> for &Packet {
2901        unsafe fn encode(
2902            self,
2903            encoder: &mut fidl::encoding::Encoder<'_, D>,
2904            offset: usize,
2905            mut depth: fidl::encoding::Depth,
2906        ) -> fidl::Result<()> {
2907            encoder.debug_check_bounds::<Packet>(offset);
2908            // Vector header
2909            let max_ordinal: u64 = self.max_ordinal_present();
2910            encoder.write_num(max_ordinal, offset);
2911            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2912            // Calling encoder.out_of_line_offset(0) is not allowed.
2913            if max_ordinal == 0 {
2914                return Ok(());
2915            }
2916            depth.increment()?;
2917            let envelope_size = 8;
2918            let bytes_len = max_ordinal as usize * envelope_size;
2919            #[allow(unused_variables)]
2920            let offset = encoder.out_of_line_offset(bytes_len);
2921            let mut _prev_end_offset: usize = 0;
2922            if 1 > max_ordinal {
2923                return Ok(());
2924            }
2925
2926            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2927            // are envelope_size bytes.
2928            let cur_offset: usize = (1 - 1) * envelope_size;
2929
2930            // Zero reserved fields.
2931            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2932
2933            // Safety:
2934            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2935            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2936            //   envelope_size bytes, there is always sufficient room.
2937            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media2__common::PayloadRange, D>(
2938            self.payload.as_ref().map(<fidl_fuchsia_media2__common::PayloadRange as fidl::encoding::ValueTypeMarker>::borrow),
2939            encoder, offset + cur_offset, depth
2940        )?;
2941
2942            _prev_end_offset = cur_offset + envelope_size;
2943            if 2 > max_ordinal {
2944                return Ok(());
2945            }
2946
2947            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2948            // are envelope_size bytes.
2949            let cur_offset: usize = (2 - 1) * envelope_size;
2950
2951            // Zero reserved fields.
2952            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2953
2954            // Safety:
2955            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2956            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2957            //   envelope_size bytes, there is always sufficient room.
2958            fidl::encoding::encode_in_envelope_optional::<Timestamp, D>(
2959                self.timestamp.as_ref().map(<Timestamp as fidl::encoding::ValueTypeMarker>::borrow),
2960                encoder,
2961                offset + cur_offset,
2962                depth,
2963            )?;
2964
2965            _prev_end_offset = cur_offset + envelope_size;
2966            if 3 > max_ordinal {
2967                return Ok(());
2968            }
2969
2970            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2971            // are envelope_size bytes.
2972            let cur_offset: usize = (3 - 1) * envelope_size;
2973
2974            // Zero reserved fields.
2975            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2976
2977            // Safety:
2978            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2979            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2980            //   envelope_size bytes, there is always sufficient room.
2981            fidl::encoding::encode_in_envelope_optional::<i64, D>(
2982                self.capture_timestamp
2983                    .as_ref()
2984                    .map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
2985                encoder,
2986                offset + cur_offset,
2987                depth,
2988            )?;
2989
2990            _prev_end_offset = cur_offset + envelope_size;
2991            if 4 > max_ordinal {
2992                return Ok(());
2993            }
2994
2995            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2996            // are envelope_size bytes.
2997            let cur_offset: usize = (4 - 1) * envelope_size;
2998
2999            // Zero reserved fields.
3000            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3001
3002            // Safety:
3003            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3004            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3005            //   envelope_size bytes, there is always sufficient room.
3006            fidl::encoding::encode_in_envelope_optional::<PacketFlags, D>(
3007                self.flags.as_ref().map(<PacketFlags as fidl::encoding::ValueTypeMarker>::borrow),
3008                encoder,
3009                offset + cur_offset,
3010                depth,
3011            )?;
3012
3013            _prev_end_offset = cur_offset + envelope_size;
3014            if 5 > max_ordinal {
3015                return Ok(());
3016            }
3017
3018            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3019            // are envelope_size bytes.
3020            let cur_offset: usize = (5 - 1) * envelope_size;
3021
3022            // Zero reserved fields.
3023            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3024
3025            // Safety:
3026            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3027            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3028            //   envelope_size bytes, there is always sufficient room.
3029            fidl::encoding::encode_in_envelope_optional::<u32, D>(
3030                self.front_frames_to_drop
3031                    .as_ref()
3032                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
3033                encoder,
3034                offset + cur_offset,
3035                depth,
3036            )?;
3037
3038            _prev_end_offset = cur_offset + envelope_size;
3039            if 6 > max_ordinal {
3040                return Ok(());
3041            }
3042
3043            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3044            // are envelope_size bytes.
3045            let cur_offset: usize = (6 - 1) * envelope_size;
3046
3047            // Zero reserved fields.
3048            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3049
3050            // Safety:
3051            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3052            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3053            //   envelope_size bytes, there is always sufficient room.
3054            fidl::encoding::encode_in_envelope_optional::<u32, D>(
3055                self.back_frames_to_drop
3056                    .as_ref()
3057                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
3058                encoder,
3059                offset + cur_offset,
3060                depth,
3061            )?;
3062
3063            _prev_end_offset = cur_offset + envelope_size;
3064            if 7 > max_ordinal {
3065                return Ok(());
3066            }
3067
3068            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3069            // are envelope_size bytes.
3070            let cur_offset: usize = (7 - 1) * envelope_size;
3071
3072            // Zero reserved fields.
3073            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3074
3075            // Safety:
3076            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3077            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3078            //   envelope_size bytes, there is always sufficient room.
3079            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_drm__common::PacketEncryptionProperties, D>(
3080            self.encryption_properties.as_ref().map(<fidl_fuchsia_drm__common::PacketEncryptionProperties as fidl::encoding::ValueTypeMarker>::borrow),
3081            encoder, offset + cur_offset, depth
3082        )?;
3083
3084            _prev_end_offset = cur_offset + envelope_size;
3085
3086            Ok(())
3087        }
3088    }
3089
3090    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Packet {
3091        #[inline(always)]
3092        fn new_empty() -> Self {
3093            Self::default()
3094        }
3095
3096        unsafe fn decode(
3097            &mut self,
3098            decoder: &mut fidl::encoding::Decoder<'_, D>,
3099            offset: usize,
3100            mut depth: fidl::encoding::Depth,
3101        ) -> fidl::Result<()> {
3102            decoder.debug_check_bounds::<Self>(offset);
3103            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3104                None => return Err(fidl::Error::NotNullable),
3105                Some(len) => len,
3106            };
3107            // Calling decoder.out_of_line_offset(0) is not allowed.
3108            if len == 0 {
3109                return Ok(());
3110            };
3111            depth.increment()?;
3112            let envelope_size = 8;
3113            let bytes_len = len * envelope_size;
3114            let offset = decoder.out_of_line_offset(bytes_len)?;
3115            // Decode the envelope for each type.
3116            let mut _next_ordinal_to_read = 0;
3117            let mut next_offset = offset;
3118            let end_offset = offset + bytes_len;
3119            _next_ordinal_to_read += 1;
3120            if next_offset >= end_offset {
3121                return Ok(());
3122            }
3123
3124            // Decode unknown envelopes for gaps in ordinals.
3125            while _next_ordinal_to_read < 1 {
3126                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3127                _next_ordinal_to_read += 1;
3128                next_offset += envelope_size;
3129            }
3130
3131            let next_out_of_line = decoder.next_out_of_line();
3132            let handles_before = decoder.remaining_handles();
3133            if let Some((inlined, num_bytes, num_handles)) =
3134                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3135            {
3136                let member_inline_size = <fidl_fuchsia_media2__common::PayloadRange as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3137                if inlined != (member_inline_size <= 4) {
3138                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3139                }
3140                let inner_offset;
3141                let mut inner_depth = depth.clone();
3142                if inlined {
3143                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3144                    inner_offset = next_offset;
3145                } else {
3146                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3147                    inner_depth.increment()?;
3148                }
3149                let val_ref = self.payload.get_or_insert_with(|| {
3150                    fidl::new_empty!(fidl_fuchsia_media2__common::PayloadRange, D)
3151                });
3152                fidl::decode!(
3153                    fidl_fuchsia_media2__common::PayloadRange,
3154                    D,
3155                    val_ref,
3156                    decoder,
3157                    inner_offset,
3158                    inner_depth
3159                )?;
3160                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3161                {
3162                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3163                }
3164                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3165                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3166                }
3167            }
3168
3169            next_offset += envelope_size;
3170            _next_ordinal_to_read += 1;
3171            if next_offset >= end_offset {
3172                return Ok(());
3173            }
3174
3175            // Decode unknown envelopes for gaps in ordinals.
3176            while _next_ordinal_to_read < 2 {
3177                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3178                _next_ordinal_to_read += 1;
3179                next_offset += envelope_size;
3180            }
3181
3182            let next_out_of_line = decoder.next_out_of_line();
3183            let handles_before = decoder.remaining_handles();
3184            if let Some((inlined, num_bytes, num_handles)) =
3185                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3186            {
3187                let member_inline_size =
3188                    <Timestamp as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3189                if inlined != (member_inline_size <= 4) {
3190                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3191                }
3192                let inner_offset;
3193                let mut inner_depth = depth.clone();
3194                if inlined {
3195                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3196                    inner_offset = next_offset;
3197                } else {
3198                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3199                    inner_depth.increment()?;
3200                }
3201                let val_ref = self.timestamp.get_or_insert_with(|| fidl::new_empty!(Timestamp, D));
3202                fidl::decode!(Timestamp, D, val_ref, decoder, inner_offset, inner_depth)?;
3203                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3204                {
3205                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3206                }
3207                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3208                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3209                }
3210            }
3211
3212            next_offset += envelope_size;
3213            _next_ordinal_to_read += 1;
3214            if next_offset >= end_offset {
3215                return Ok(());
3216            }
3217
3218            // Decode unknown envelopes for gaps in ordinals.
3219            while _next_ordinal_to_read < 3 {
3220                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3221                _next_ordinal_to_read += 1;
3222                next_offset += envelope_size;
3223            }
3224
3225            let next_out_of_line = decoder.next_out_of_line();
3226            let handles_before = decoder.remaining_handles();
3227            if let Some((inlined, num_bytes, num_handles)) =
3228                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3229            {
3230                let member_inline_size =
3231                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3232                if inlined != (member_inline_size <= 4) {
3233                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3234                }
3235                let inner_offset;
3236                let mut inner_depth = depth.clone();
3237                if inlined {
3238                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3239                    inner_offset = next_offset;
3240                } else {
3241                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3242                    inner_depth.increment()?;
3243                }
3244                let val_ref =
3245                    self.capture_timestamp.get_or_insert_with(|| fidl::new_empty!(i64, D));
3246                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
3247                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3248                {
3249                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3250                }
3251                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3252                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3253                }
3254            }
3255
3256            next_offset += envelope_size;
3257            _next_ordinal_to_read += 1;
3258            if next_offset >= end_offset {
3259                return Ok(());
3260            }
3261
3262            // Decode unknown envelopes for gaps in ordinals.
3263            while _next_ordinal_to_read < 4 {
3264                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3265                _next_ordinal_to_read += 1;
3266                next_offset += envelope_size;
3267            }
3268
3269            let next_out_of_line = decoder.next_out_of_line();
3270            let handles_before = decoder.remaining_handles();
3271            if let Some((inlined, num_bytes, num_handles)) =
3272                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3273            {
3274                let member_inline_size =
3275                    <PacketFlags as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3276                if inlined != (member_inline_size <= 4) {
3277                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3278                }
3279                let inner_offset;
3280                let mut inner_depth = depth.clone();
3281                if inlined {
3282                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3283                    inner_offset = next_offset;
3284                } else {
3285                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3286                    inner_depth.increment()?;
3287                }
3288                let val_ref = self.flags.get_or_insert_with(|| fidl::new_empty!(PacketFlags, D));
3289                fidl::decode!(PacketFlags, D, val_ref, decoder, inner_offset, inner_depth)?;
3290                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3291                {
3292                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3293                }
3294                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3295                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3296                }
3297            }
3298
3299            next_offset += envelope_size;
3300            _next_ordinal_to_read += 1;
3301            if next_offset >= end_offset {
3302                return Ok(());
3303            }
3304
3305            // Decode unknown envelopes for gaps in ordinals.
3306            while _next_ordinal_to_read < 5 {
3307                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3308                _next_ordinal_to_read += 1;
3309                next_offset += envelope_size;
3310            }
3311
3312            let next_out_of_line = decoder.next_out_of_line();
3313            let handles_before = decoder.remaining_handles();
3314            if let Some((inlined, num_bytes, num_handles)) =
3315                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3316            {
3317                let member_inline_size =
3318                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3319                if inlined != (member_inline_size <= 4) {
3320                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3321                }
3322                let inner_offset;
3323                let mut inner_depth = depth.clone();
3324                if inlined {
3325                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3326                    inner_offset = next_offset;
3327                } else {
3328                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3329                    inner_depth.increment()?;
3330                }
3331                let val_ref =
3332                    self.front_frames_to_drop.get_or_insert_with(|| fidl::new_empty!(u32, D));
3333                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3334                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3335                {
3336                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3337                }
3338                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3339                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3340                }
3341            }
3342
3343            next_offset += envelope_size;
3344            _next_ordinal_to_read += 1;
3345            if next_offset >= end_offset {
3346                return Ok(());
3347            }
3348
3349            // Decode unknown envelopes for gaps in ordinals.
3350            while _next_ordinal_to_read < 6 {
3351                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3352                _next_ordinal_to_read += 1;
3353                next_offset += envelope_size;
3354            }
3355
3356            let next_out_of_line = decoder.next_out_of_line();
3357            let handles_before = decoder.remaining_handles();
3358            if let Some((inlined, num_bytes, num_handles)) =
3359                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3360            {
3361                let member_inline_size =
3362                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3363                if inlined != (member_inline_size <= 4) {
3364                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3365                }
3366                let inner_offset;
3367                let mut inner_depth = depth.clone();
3368                if inlined {
3369                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3370                    inner_offset = next_offset;
3371                } else {
3372                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3373                    inner_depth.increment()?;
3374                }
3375                let val_ref =
3376                    self.back_frames_to_drop.get_or_insert_with(|| fidl::new_empty!(u32, D));
3377                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3378                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3379                {
3380                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3381                }
3382                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3383                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3384                }
3385            }
3386
3387            next_offset += envelope_size;
3388            _next_ordinal_to_read += 1;
3389            if next_offset >= end_offset {
3390                return Ok(());
3391            }
3392
3393            // Decode unknown envelopes for gaps in ordinals.
3394            while _next_ordinal_to_read < 7 {
3395                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3396                _next_ordinal_to_read += 1;
3397                next_offset += envelope_size;
3398            }
3399
3400            let next_out_of_line = decoder.next_out_of_line();
3401            let handles_before = decoder.remaining_handles();
3402            if let Some((inlined, num_bytes, num_handles)) =
3403                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3404            {
3405                let member_inline_size = <fidl_fuchsia_drm__common::PacketEncryptionProperties as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3406                if inlined != (member_inline_size <= 4) {
3407                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3408                }
3409                let inner_offset;
3410                let mut inner_depth = depth.clone();
3411                if inlined {
3412                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3413                    inner_offset = next_offset;
3414                } else {
3415                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3416                    inner_depth.increment()?;
3417                }
3418                let val_ref = self.encryption_properties.get_or_insert_with(|| {
3419                    fidl::new_empty!(fidl_fuchsia_drm__common::PacketEncryptionProperties, D)
3420                });
3421                fidl::decode!(
3422                    fidl_fuchsia_drm__common::PacketEncryptionProperties,
3423                    D,
3424                    val_ref,
3425                    decoder,
3426                    inner_offset,
3427                    inner_depth
3428                )?;
3429                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3430                {
3431                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3432                }
3433                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3434                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3435                }
3436            }
3437
3438            next_offset += envelope_size;
3439
3440            // Decode the remaining unknown envelopes.
3441            while next_offset < end_offset {
3442                _next_ordinal_to_read += 1;
3443                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3444                next_offset += envelope_size;
3445            }
3446
3447            Ok(())
3448        }
3449    }
3450
3451    impl RampFunctionLinearSlope {
3452        #[inline(always)]
3453        fn max_ordinal_present(&self) -> u64 {
3454            0
3455        }
3456    }
3457
3458    impl fidl::encoding::ValueTypeMarker for RampFunctionLinearSlope {
3459        type Borrowed<'a> = &'a Self;
3460        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3461            value
3462        }
3463    }
3464
3465    unsafe impl fidl::encoding::TypeMarker for RampFunctionLinearSlope {
3466        type Owned = Self;
3467
3468        #[inline(always)]
3469        fn inline_align(_context: fidl::encoding::Context) -> usize {
3470            8
3471        }
3472
3473        #[inline(always)]
3474        fn inline_size(_context: fidl::encoding::Context) -> usize {
3475            16
3476        }
3477    }
3478
3479    unsafe impl<D: fidl::encoding::ResourceDialect>
3480        fidl::encoding::Encode<RampFunctionLinearSlope, D> for &RampFunctionLinearSlope
3481    {
3482        unsafe fn encode(
3483            self,
3484            encoder: &mut fidl::encoding::Encoder<'_, D>,
3485            offset: usize,
3486            mut depth: fidl::encoding::Depth,
3487        ) -> fidl::Result<()> {
3488            encoder.debug_check_bounds::<RampFunctionLinearSlope>(offset);
3489            // Vector header
3490            let max_ordinal: u64 = self.max_ordinal_present();
3491            encoder.write_num(max_ordinal, offset);
3492            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3493            // Calling encoder.out_of_line_offset(0) is not allowed.
3494            if max_ordinal == 0 {
3495                return Ok(());
3496            }
3497            depth.increment()?;
3498            let envelope_size = 8;
3499            let bytes_len = max_ordinal as usize * envelope_size;
3500            #[allow(unused_variables)]
3501            let offset = encoder.out_of_line_offset(bytes_len);
3502            let mut _prev_end_offset: usize = 0;
3503
3504            Ok(())
3505        }
3506    }
3507
3508    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3509        for RampFunctionLinearSlope
3510    {
3511        #[inline(always)]
3512        fn new_empty() -> Self {
3513            Self::default()
3514        }
3515
3516        unsafe fn decode(
3517            &mut self,
3518            decoder: &mut fidl::encoding::Decoder<'_, D>,
3519            offset: usize,
3520            mut depth: fidl::encoding::Depth,
3521        ) -> fidl::Result<()> {
3522            decoder.debug_check_bounds::<Self>(offset);
3523            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3524                None => return Err(fidl::Error::NotNullable),
3525                Some(len) => len,
3526            };
3527            // Calling decoder.out_of_line_offset(0) is not allowed.
3528            if len == 0 {
3529                return Ok(());
3530            };
3531            depth.increment()?;
3532            let envelope_size = 8;
3533            let bytes_len = len * envelope_size;
3534            let offset = decoder.out_of_line_offset(bytes_len)?;
3535            // Decode the envelope for each type.
3536            let mut _next_ordinal_to_read = 0;
3537            let mut next_offset = offset;
3538            let end_offset = offset + bytes_len;
3539
3540            // Decode the remaining unknown envelopes.
3541            while next_offset < end_offset {
3542                _next_ordinal_to_read += 1;
3543                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3544                next_offset += envelope_size;
3545            }
3546
3547            Ok(())
3548        }
3549    }
3550
3551    impl RampedGain {
3552        #[inline(always)]
3553        fn max_ordinal_present(&self) -> u64 {
3554            if let Some(_) = self.function {
3555                return 3;
3556            }
3557            if let Some(_) = self.duration {
3558                return 2;
3559            }
3560            if let Some(_) = self.target_gain_db {
3561                return 1;
3562            }
3563            0
3564        }
3565    }
3566
3567    impl fidl::encoding::ValueTypeMarker for RampedGain {
3568        type Borrowed<'a> = &'a Self;
3569        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3570            value
3571        }
3572    }
3573
3574    unsafe impl fidl::encoding::TypeMarker for RampedGain {
3575        type Owned = Self;
3576
3577        #[inline(always)]
3578        fn inline_align(_context: fidl::encoding::Context) -> usize {
3579            8
3580        }
3581
3582        #[inline(always)]
3583        fn inline_size(_context: fidl::encoding::Context) -> usize {
3584            16
3585        }
3586    }
3587
3588    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RampedGain, D>
3589        for &RampedGain
3590    {
3591        unsafe fn encode(
3592            self,
3593            encoder: &mut fidl::encoding::Encoder<'_, D>,
3594            offset: usize,
3595            mut depth: fidl::encoding::Depth,
3596        ) -> fidl::Result<()> {
3597            encoder.debug_check_bounds::<RampedGain>(offset);
3598            // Vector header
3599            let max_ordinal: u64 = self.max_ordinal_present();
3600            encoder.write_num(max_ordinal, offset);
3601            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3602            // Calling encoder.out_of_line_offset(0) is not allowed.
3603            if max_ordinal == 0 {
3604                return Ok(());
3605            }
3606            depth.increment()?;
3607            let envelope_size = 8;
3608            let bytes_len = max_ordinal as usize * envelope_size;
3609            #[allow(unused_variables)]
3610            let offset = encoder.out_of_line_offset(bytes_len);
3611            let mut _prev_end_offset: usize = 0;
3612            if 1 > max_ordinal {
3613                return Ok(());
3614            }
3615
3616            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3617            // are envelope_size bytes.
3618            let cur_offset: usize = (1 - 1) * envelope_size;
3619
3620            // Zero reserved fields.
3621            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3622
3623            // Safety:
3624            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3625            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3626            //   envelope_size bytes, there is always sufficient room.
3627            fidl::encoding::encode_in_envelope_optional::<f32, D>(
3628                self.target_gain_db.as_ref().map(<f32 as fidl::encoding::ValueTypeMarker>::borrow),
3629                encoder,
3630                offset + cur_offset,
3631                depth,
3632            )?;
3633
3634            _prev_end_offset = cur_offset + envelope_size;
3635            if 2 > max_ordinal {
3636                return Ok(());
3637            }
3638
3639            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3640            // are envelope_size bytes.
3641            let cur_offset: usize = (2 - 1) * envelope_size;
3642
3643            // Zero reserved fields.
3644            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3645
3646            // Safety:
3647            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3648            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3649            //   envelope_size bytes, there is always sufficient room.
3650            fidl::encoding::encode_in_envelope_optional::<i64, D>(
3651                self.duration.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
3652                encoder,
3653                offset + cur_offset,
3654                depth,
3655            )?;
3656
3657            _prev_end_offset = cur_offset + envelope_size;
3658            if 3 > max_ordinal {
3659                return Ok(());
3660            }
3661
3662            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3663            // are envelope_size bytes.
3664            let cur_offset: usize = (3 - 1) * envelope_size;
3665
3666            // Zero reserved fields.
3667            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3668
3669            // Safety:
3670            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3671            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3672            //   envelope_size bytes, there is always sufficient room.
3673            fidl::encoding::encode_in_envelope_optional::<RampFunction, D>(
3674                self.function
3675                    .as_ref()
3676                    .map(<RampFunction as fidl::encoding::ValueTypeMarker>::borrow),
3677                encoder,
3678                offset + cur_offset,
3679                depth,
3680            )?;
3681
3682            _prev_end_offset = cur_offset + envelope_size;
3683
3684            Ok(())
3685        }
3686    }
3687
3688    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RampedGain {
3689        #[inline(always)]
3690        fn new_empty() -> Self {
3691            Self::default()
3692        }
3693
3694        unsafe fn decode(
3695            &mut self,
3696            decoder: &mut fidl::encoding::Decoder<'_, D>,
3697            offset: usize,
3698            mut depth: fidl::encoding::Depth,
3699        ) -> fidl::Result<()> {
3700            decoder.debug_check_bounds::<Self>(offset);
3701            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3702                None => return Err(fidl::Error::NotNullable),
3703                Some(len) => len,
3704            };
3705            // Calling decoder.out_of_line_offset(0) is not allowed.
3706            if len == 0 {
3707                return Ok(());
3708            };
3709            depth.increment()?;
3710            let envelope_size = 8;
3711            let bytes_len = len * envelope_size;
3712            let offset = decoder.out_of_line_offset(bytes_len)?;
3713            // Decode the envelope for each type.
3714            let mut _next_ordinal_to_read = 0;
3715            let mut next_offset = offset;
3716            let end_offset = offset + bytes_len;
3717            _next_ordinal_to_read += 1;
3718            if next_offset >= end_offset {
3719                return Ok(());
3720            }
3721
3722            // Decode unknown envelopes for gaps in ordinals.
3723            while _next_ordinal_to_read < 1 {
3724                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3725                _next_ordinal_to_read += 1;
3726                next_offset += envelope_size;
3727            }
3728
3729            let next_out_of_line = decoder.next_out_of_line();
3730            let handles_before = decoder.remaining_handles();
3731            if let Some((inlined, num_bytes, num_handles)) =
3732                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3733            {
3734                let member_inline_size =
3735                    <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3736                if inlined != (member_inline_size <= 4) {
3737                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3738                }
3739                let inner_offset;
3740                let mut inner_depth = depth.clone();
3741                if inlined {
3742                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3743                    inner_offset = next_offset;
3744                } else {
3745                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3746                    inner_depth.increment()?;
3747                }
3748                let val_ref = self.target_gain_db.get_or_insert_with(|| fidl::new_empty!(f32, D));
3749                fidl::decode!(f32, D, val_ref, decoder, inner_offset, inner_depth)?;
3750                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3751                {
3752                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3753                }
3754                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3755                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3756                }
3757            }
3758
3759            next_offset += envelope_size;
3760            _next_ordinal_to_read += 1;
3761            if next_offset >= end_offset {
3762                return Ok(());
3763            }
3764
3765            // Decode unknown envelopes for gaps in ordinals.
3766            while _next_ordinal_to_read < 2 {
3767                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3768                _next_ordinal_to_read += 1;
3769                next_offset += envelope_size;
3770            }
3771
3772            let next_out_of_line = decoder.next_out_of_line();
3773            let handles_before = decoder.remaining_handles();
3774            if let Some((inlined, num_bytes, num_handles)) =
3775                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3776            {
3777                let member_inline_size =
3778                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3779                if inlined != (member_inline_size <= 4) {
3780                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3781                }
3782                let inner_offset;
3783                let mut inner_depth = depth.clone();
3784                if inlined {
3785                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3786                    inner_offset = next_offset;
3787                } else {
3788                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3789                    inner_depth.increment()?;
3790                }
3791                let val_ref = self.duration.get_or_insert_with(|| fidl::new_empty!(i64, D));
3792                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
3793                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3794                {
3795                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3796                }
3797                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3798                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3799                }
3800            }
3801
3802            next_offset += envelope_size;
3803            _next_ordinal_to_read += 1;
3804            if next_offset >= end_offset {
3805                return Ok(());
3806            }
3807
3808            // Decode unknown envelopes for gaps in ordinals.
3809            while _next_ordinal_to_read < 3 {
3810                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3811                _next_ordinal_to_read += 1;
3812                next_offset += envelope_size;
3813            }
3814
3815            let next_out_of_line = decoder.next_out_of_line();
3816            let handles_before = decoder.remaining_handles();
3817            if let Some((inlined, num_bytes, num_handles)) =
3818                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3819            {
3820                let member_inline_size =
3821                    <RampFunction as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3822                if inlined != (member_inline_size <= 4) {
3823                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3824                }
3825                let inner_offset;
3826                let mut inner_depth = depth.clone();
3827                if inlined {
3828                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3829                    inner_offset = next_offset;
3830                } else {
3831                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3832                    inner_depth.increment()?;
3833                }
3834                let val_ref =
3835                    self.function.get_or_insert_with(|| fidl::new_empty!(RampFunction, D));
3836                fidl::decode!(RampFunction, D, val_ref, decoder, inner_offset, inner_depth)?;
3837                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3838                {
3839                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3840                }
3841                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3842                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3843                }
3844            }
3845
3846            next_offset += envelope_size;
3847
3848            // Decode the remaining unknown envelopes.
3849            while next_offset < end_offset {
3850                _next_ordinal_to_read += 1;
3851                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3852                next_offset += envelope_size;
3853            }
3854
3855            Ok(())
3856        }
3857    }
3858
3859    impl StreamSinkOnWillCloseRequest {
3860        #[inline(always)]
3861        fn max_ordinal_present(&self) -> u64 {
3862            if let Some(_) = self.reason {
3863                return 1;
3864            }
3865            0
3866        }
3867    }
3868
3869    impl fidl::encoding::ValueTypeMarker for StreamSinkOnWillCloseRequest {
3870        type Borrowed<'a> = &'a Self;
3871        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3872            value
3873        }
3874    }
3875
3876    unsafe impl fidl::encoding::TypeMarker for StreamSinkOnWillCloseRequest {
3877        type Owned = Self;
3878
3879        #[inline(always)]
3880        fn inline_align(_context: fidl::encoding::Context) -> usize {
3881            8
3882        }
3883
3884        #[inline(always)]
3885        fn inline_size(_context: fidl::encoding::Context) -> usize {
3886            16
3887        }
3888    }
3889
3890    unsafe impl<D: fidl::encoding::ResourceDialect>
3891        fidl::encoding::Encode<StreamSinkOnWillCloseRequest, D> for &StreamSinkOnWillCloseRequest
3892    {
3893        unsafe fn encode(
3894            self,
3895            encoder: &mut fidl::encoding::Encoder<'_, D>,
3896            offset: usize,
3897            mut depth: fidl::encoding::Depth,
3898        ) -> fidl::Result<()> {
3899            encoder.debug_check_bounds::<StreamSinkOnWillCloseRequest>(offset);
3900            // Vector header
3901            let max_ordinal: u64 = self.max_ordinal_present();
3902            encoder.write_num(max_ordinal, offset);
3903            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3904            // Calling encoder.out_of_line_offset(0) is not allowed.
3905            if max_ordinal == 0 {
3906                return Ok(());
3907            }
3908            depth.increment()?;
3909            let envelope_size = 8;
3910            let bytes_len = max_ordinal as usize * envelope_size;
3911            #[allow(unused_variables)]
3912            let offset = encoder.out_of_line_offset(bytes_len);
3913            let mut _prev_end_offset: usize = 0;
3914            if 1 > max_ordinal {
3915                return Ok(());
3916            }
3917
3918            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3919            // are envelope_size bytes.
3920            let cur_offset: usize = (1 - 1) * envelope_size;
3921
3922            // Zero reserved fields.
3923            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3924
3925            // Safety:
3926            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3927            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3928            //   envelope_size bytes, there is always sufficient room.
3929            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media2__common::ConsumerClosedReason, D>(
3930            self.reason.as_ref().map(<fidl_fuchsia_media2__common::ConsumerClosedReason as fidl::encoding::ValueTypeMarker>::borrow),
3931            encoder, offset + cur_offset, depth
3932        )?;
3933
3934            _prev_end_offset = cur_offset + envelope_size;
3935
3936            Ok(())
3937        }
3938    }
3939
3940    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3941        for StreamSinkOnWillCloseRequest
3942    {
3943        #[inline(always)]
3944        fn new_empty() -> Self {
3945            Self::default()
3946        }
3947
3948        unsafe fn decode(
3949            &mut self,
3950            decoder: &mut fidl::encoding::Decoder<'_, D>,
3951            offset: usize,
3952            mut depth: fidl::encoding::Depth,
3953        ) -> fidl::Result<()> {
3954            decoder.debug_check_bounds::<Self>(offset);
3955            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3956                None => return Err(fidl::Error::NotNullable),
3957                Some(len) => len,
3958            };
3959            // Calling decoder.out_of_line_offset(0) is not allowed.
3960            if len == 0 {
3961                return Ok(());
3962            };
3963            depth.increment()?;
3964            let envelope_size = 8;
3965            let bytes_len = len * envelope_size;
3966            let offset = decoder.out_of_line_offset(bytes_len)?;
3967            // Decode the envelope for each type.
3968            let mut _next_ordinal_to_read = 0;
3969            let mut next_offset = offset;
3970            let end_offset = offset + bytes_len;
3971            _next_ordinal_to_read += 1;
3972            if next_offset >= end_offset {
3973                return Ok(());
3974            }
3975
3976            // Decode unknown envelopes for gaps in ordinals.
3977            while _next_ordinal_to_read < 1 {
3978                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3979                _next_ordinal_to_read += 1;
3980                next_offset += envelope_size;
3981            }
3982
3983            let next_out_of_line = decoder.next_out_of_line();
3984            let handles_before = decoder.remaining_handles();
3985            if let Some((inlined, num_bytes, num_handles)) =
3986                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3987            {
3988                let member_inline_size = <fidl_fuchsia_media2__common::ConsumerClosedReason as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3989                if inlined != (member_inline_size <= 4) {
3990                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3991                }
3992                let inner_offset;
3993                let mut inner_depth = depth.clone();
3994                if inlined {
3995                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3996                    inner_offset = next_offset;
3997                } else {
3998                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3999                    inner_depth.increment()?;
4000                }
4001                let val_ref = self.reason.get_or_insert_with(|| {
4002                    fidl::new_empty!(fidl_fuchsia_media2__common::ConsumerClosedReason, D)
4003                });
4004                fidl::decode!(
4005                    fidl_fuchsia_media2__common::ConsumerClosedReason,
4006                    D,
4007                    val_ref,
4008                    decoder,
4009                    inner_offset,
4010                    inner_depth
4011                )?;
4012                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4013                {
4014                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4015                }
4016                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4017                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4018                }
4019            }
4020
4021            next_offset += envelope_size;
4022
4023            // Decode the remaining unknown envelopes.
4024            while next_offset < end_offset {
4025                _next_ordinal_to_read += 1;
4026                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4027                next_offset += envelope_size;
4028            }
4029
4030            Ok(())
4031        }
4032    }
4033
4034    impl StreamSinkStartSegmentRequest {
4035        #[inline(always)]
4036        fn max_ordinal_present(&self) -> u64 {
4037            if let Some(_) = self.segment_id {
4038                return 1;
4039            }
4040            0
4041        }
4042    }
4043
4044    impl fidl::encoding::ValueTypeMarker for StreamSinkStartSegmentRequest {
4045        type Borrowed<'a> = &'a Self;
4046        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4047            value
4048        }
4049    }
4050
4051    unsafe impl fidl::encoding::TypeMarker for StreamSinkStartSegmentRequest {
4052        type Owned = Self;
4053
4054        #[inline(always)]
4055        fn inline_align(_context: fidl::encoding::Context) -> usize {
4056            8
4057        }
4058
4059        #[inline(always)]
4060        fn inline_size(_context: fidl::encoding::Context) -> usize {
4061            16
4062        }
4063    }
4064
4065    unsafe impl<D: fidl::encoding::ResourceDialect>
4066        fidl::encoding::Encode<StreamSinkStartSegmentRequest, D>
4067        for &StreamSinkStartSegmentRequest
4068    {
4069        unsafe fn encode(
4070            self,
4071            encoder: &mut fidl::encoding::Encoder<'_, D>,
4072            offset: usize,
4073            mut depth: fidl::encoding::Depth,
4074        ) -> fidl::Result<()> {
4075            encoder.debug_check_bounds::<StreamSinkStartSegmentRequest>(offset);
4076            // Vector header
4077            let max_ordinal: u64 = self.max_ordinal_present();
4078            encoder.write_num(max_ordinal, offset);
4079            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4080            // Calling encoder.out_of_line_offset(0) is not allowed.
4081            if max_ordinal == 0 {
4082                return Ok(());
4083            }
4084            depth.increment()?;
4085            let envelope_size = 8;
4086            let bytes_len = max_ordinal as usize * envelope_size;
4087            #[allow(unused_variables)]
4088            let offset = encoder.out_of_line_offset(bytes_len);
4089            let mut _prev_end_offset: usize = 0;
4090            if 1 > max_ordinal {
4091                return Ok(());
4092            }
4093
4094            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4095            // are envelope_size bytes.
4096            let cur_offset: usize = (1 - 1) * envelope_size;
4097
4098            // Zero reserved fields.
4099            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4100
4101            // Safety:
4102            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4103            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4104            //   envelope_size bytes, there is always sufficient room.
4105            fidl::encoding::encode_in_envelope_optional::<i64, D>(
4106                self.segment_id.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
4107                encoder,
4108                offset + cur_offset,
4109                depth,
4110            )?;
4111
4112            _prev_end_offset = cur_offset + envelope_size;
4113
4114            Ok(())
4115        }
4116    }
4117
4118    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
4119        for StreamSinkStartSegmentRequest
4120    {
4121        #[inline(always)]
4122        fn new_empty() -> Self {
4123            Self::default()
4124        }
4125
4126        unsafe fn decode(
4127            &mut self,
4128            decoder: &mut fidl::encoding::Decoder<'_, D>,
4129            offset: usize,
4130            mut depth: fidl::encoding::Depth,
4131        ) -> fidl::Result<()> {
4132            decoder.debug_check_bounds::<Self>(offset);
4133            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4134                None => return Err(fidl::Error::NotNullable),
4135                Some(len) => len,
4136            };
4137            // Calling decoder.out_of_line_offset(0) is not allowed.
4138            if len == 0 {
4139                return Ok(());
4140            };
4141            depth.increment()?;
4142            let envelope_size = 8;
4143            let bytes_len = len * envelope_size;
4144            let offset = decoder.out_of_line_offset(bytes_len)?;
4145            // Decode the envelope for each type.
4146            let mut _next_ordinal_to_read = 0;
4147            let mut next_offset = offset;
4148            let end_offset = offset + bytes_len;
4149            _next_ordinal_to_read += 1;
4150            if next_offset >= end_offset {
4151                return Ok(());
4152            }
4153
4154            // Decode unknown envelopes for gaps in ordinals.
4155            while _next_ordinal_to_read < 1 {
4156                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4157                _next_ordinal_to_read += 1;
4158                next_offset += envelope_size;
4159            }
4160
4161            let next_out_of_line = decoder.next_out_of_line();
4162            let handles_before = decoder.remaining_handles();
4163            if let Some((inlined, num_bytes, num_handles)) =
4164                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4165            {
4166                let member_inline_size =
4167                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4168                if inlined != (member_inline_size <= 4) {
4169                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4170                }
4171                let inner_offset;
4172                let mut inner_depth = depth.clone();
4173                if inlined {
4174                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4175                    inner_offset = next_offset;
4176                } else {
4177                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4178                    inner_depth.increment()?;
4179                }
4180                let val_ref = self.segment_id.get_or_insert_with(|| fidl::new_empty!(i64, D));
4181                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
4182                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4183                {
4184                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4185                }
4186                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4187                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4188                }
4189            }
4190
4191            next_offset += envelope_size;
4192
4193            // Decode the remaining unknown envelopes.
4194            while next_offset < end_offset {
4195                _next_ordinal_to_read += 1;
4196                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4197                next_offset += envelope_size;
4198            }
4199
4200            Ok(())
4201        }
4202    }
4203
4204    impl StreamSinkWillCloseRequest {
4205        #[inline(always)]
4206        fn max_ordinal_present(&self) -> u64 {
4207            if let Some(_) = self.reason {
4208                return 1;
4209            }
4210            0
4211        }
4212    }
4213
4214    impl fidl::encoding::ValueTypeMarker for StreamSinkWillCloseRequest {
4215        type Borrowed<'a> = &'a Self;
4216        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4217            value
4218        }
4219    }
4220
4221    unsafe impl fidl::encoding::TypeMarker for StreamSinkWillCloseRequest {
4222        type Owned = Self;
4223
4224        #[inline(always)]
4225        fn inline_align(_context: fidl::encoding::Context) -> usize {
4226            8
4227        }
4228
4229        #[inline(always)]
4230        fn inline_size(_context: fidl::encoding::Context) -> usize {
4231            16
4232        }
4233    }
4234
4235    unsafe impl<D: fidl::encoding::ResourceDialect>
4236        fidl::encoding::Encode<StreamSinkWillCloseRequest, D> for &StreamSinkWillCloseRequest
4237    {
4238        unsafe fn encode(
4239            self,
4240            encoder: &mut fidl::encoding::Encoder<'_, D>,
4241            offset: usize,
4242            mut depth: fidl::encoding::Depth,
4243        ) -> fidl::Result<()> {
4244            encoder.debug_check_bounds::<StreamSinkWillCloseRequest>(offset);
4245            // Vector header
4246            let max_ordinal: u64 = self.max_ordinal_present();
4247            encoder.write_num(max_ordinal, offset);
4248            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4249            // Calling encoder.out_of_line_offset(0) is not allowed.
4250            if max_ordinal == 0 {
4251                return Ok(());
4252            }
4253            depth.increment()?;
4254            let envelope_size = 8;
4255            let bytes_len = max_ordinal as usize * envelope_size;
4256            #[allow(unused_variables)]
4257            let offset = encoder.out_of_line_offset(bytes_len);
4258            let mut _prev_end_offset: usize = 0;
4259            if 1 > max_ordinal {
4260                return Ok(());
4261            }
4262
4263            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4264            // are envelope_size bytes.
4265            let cur_offset: usize = (1 - 1) * envelope_size;
4266
4267            // Zero reserved fields.
4268            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4269
4270            // Safety:
4271            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4272            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4273            //   envelope_size bytes, there is always sufficient room.
4274            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media2__common::ProducerClosedReason, D>(
4275            self.reason.as_ref().map(<fidl_fuchsia_media2__common::ProducerClosedReason as fidl::encoding::ValueTypeMarker>::borrow),
4276            encoder, offset + cur_offset, depth
4277        )?;
4278
4279            _prev_end_offset = cur_offset + envelope_size;
4280
4281            Ok(())
4282        }
4283    }
4284
4285    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
4286        for StreamSinkWillCloseRequest
4287    {
4288        #[inline(always)]
4289        fn new_empty() -> Self {
4290            Self::default()
4291        }
4292
4293        unsafe fn decode(
4294            &mut self,
4295            decoder: &mut fidl::encoding::Decoder<'_, D>,
4296            offset: usize,
4297            mut depth: fidl::encoding::Depth,
4298        ) -> fidl::Result<()> {
4299            decoder.debug_check_bounds::<Self>(offset);
4300            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4301                None => return Err(fidl::Error::NotNullable),
4302                Some(len) => len,
4303            };
4304            // Calling decoder.out_of_line_offset(0) is not allowed.
4305            if len == 0 {
4306                return Ok(());
4307            };
4308            depth.increment()?;
4309            let envelope_size = 8;
4310            let bytes_len = len * envelope_size;
4311            let offset = decoder.out_of_line_offset(bytes_len)?;
4312            // Decode the envelope for each type.
4313            let mut _next_ordinal_to_read = 0;
4314            let mut next_offset = offset;
4315            let end_offset = offset + bytes_len;
4316            _next_ordinal_to_read += 1;
4317            if next_offset >= end_offset {
4318                return Ok(());
4319            }
4320
4321            // Decode unknown envelopes for gaps in ordinals.
4322            while _next_ordinal_to_read < 1 {
4323                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4324                _next_ordinal_to_read += 1;
4325                next_offset += envelope_size;
4326            }
4327
4328            let next_out_of_line = decoder.next_out_of_line();
4329            let handles_before = decoder.remaining_handles();
4330            if let Some((inlined, num_bytes, num_handles)) =
4331                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4332            {
4333                let member_inline_size = <fidl_fuchsia_media2__common::ProducerClosedReason as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4334                if inlined != (member_inline_size <= 4) {
4335                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4336                }
4337                let inner_offset;
4338                let mut inner_depth = depth.clone();
4339                if inlined {
4340                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4341                    inner_offset = next_offset;
4342                } else {
4343                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4344                    inner_depth.increment()?;
4345                }
4346                let val_ref = self.reason.get_or_insert_with(|| {
4347                    fidl::new_empty!(fidl_fuchsia_media2__common::ProducerClosedReason, D)
4348                });
4349                fidl::decode!(
4350                    fidl_fuchsia_media2__common::ProducerClosedReason,
4351                    D,
4352                    val_ref,
4353                    decoder,
4354                    inner_offset,
4355                    inner_depth
4356                )?;
4357                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4358                {
4359                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4360                }
4361                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4362                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4363                }
4364            }
4365
4366            next_offset += envelope_size;
4367
4368            // Decode the remaining unknown envelopes.
4369            while next_offset < end_offset {
4370                _next_ordinal_to_read += 1;
4371                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4372                next_offset += envelope_size;
4373            }
4374
4375            Ok(())
4376        }
4377    }
4378
4379    impl fidl::encoding::ValueTypeMarker for ChannelLayout {
4380        type Borrowed<'a> = &'a Self;
4381        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4382            value
4383        }
4384    }
4385
4386    unsafe impl fidl::encoding::TypeMarker for ChannelLayout {
4387        type Owned = Self;
4388
4389        #[inline(always)]
4390        fn inline_align(_context: fidl::encoding::Context) -> usize {
4391            8
4392        }
4393
4394        #[inline(always)]
4395        fn inline_size(_context: fidl::encoding::Context) -> usize {
4396            16
4397        }
4398    }
4399
4400    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ChannelLayout, D>
4401        for &ChannelLayout
4402    {
4403        #[inline]
4404        unsafe fn encode(
4405            self,
4406            encoder: &mut fidl::encoding::Encoder<'_, D>,
4407            offset: usize,
4408            _depth: fidl::encoding::Depth,
4409        ) -> fidl::Result<()> {
4410            encoder.debug_check_bounds::<ChannelLayout>(offset);
4411            encoder.write_num::<u64>(self.ordinal(), offset);
4412            match self {
4413                ChannelLayout::Config(ref val) => {
4414                    fidl::encoding::encode_in_envelope::<ChannelConfig, D>(
4415                        <ChannelConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
4416                        encoder,
4417                        offset + 8,
4418                        _depth,
4419                    )
4420                }
4421                ChannelLayout::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
4422            }
4423        }
4424    }
4425
4426    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ChannelLayout {
4427        #[inline(always)]
4428        fn new_empty() -> Self {
4429            Self::__SourceBreaking { unknown_ordinal: 0 }
4430        }
4431
4432        #[inline]
4433        unsafe fn decode(
4434            &mut self,
4435            decoder: &mut fidl::encoding::Decoder<'_, D>,
4436            offset: usize,
4437            mut depth: fidl::encoding::Depth,
4438        ) -> fidl::Result<()> {
4439            decoder.debug_check_bounds::<Self>(offset);
4440            #[allow(unused_variables)]
4441            let next_out_of_line = decoder.next_out_of_line();
4442            let handles_before = decoder.remaining_handles();
4443            let (ordinal, inlined, num_bytes, num_handles) =
4444                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
4445
4446            let member_inline_size = match ordinal {
4447                1 => <ChannelConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4448                0 => return Err(fidl::Error::UnknownUnionTag),
4449                _ => num_bytes as usize,
4450            };
4451
4452            if inlined != (member_inline_size <= 4) {
4453                return Err(fidl::Error::InvalidInlineBitInEnvelope);
4454            }
4455            let _inner_offset;
4456            if inlined {
4457                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
4458                _inner_offset = offset + 8;
4459            } else {
4460                depth.increment()?;
4461                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4462            }
4463            match ordinal {
4464                1 => {
4465                    #[allow(irrefutable_let_patterns)]
4466                    if let ChannelLayout::Config(_) = self {
4467                        // Do nothing, read the value into the object
4468                    } else {
4469                        // Initialize `self` to the right variant
4470                        *self = ChannelLayout::Config(fidl::new_empty!(ChannelConfig, D));
4471                    }
4472                    #[allow(irrefutable_let_patterns)]
4473                    if let ChannelLayout::Config(ref mut val) = self {
4474                        fidl::decode!(ChannelConfig, D, val, decoder, _inner_offset, depth)?;
4475                    } else {
4476                        unreachable!()
4477                    }
4478                }
4479                #[allow(deprecated)]
4480                ordinal => {
4481                    for _ in 0..num_handles {
4482                        decoder.drop_next_handle()?;
4483                    }
4484                    *self = ChannelLayout::__SourceBreaking { unknown_ordinal: ordinal };
4485                }
4486            }
4487            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
4488                return Err(fidl::Error::InvalidNumBytesInEnvelope);
4489            }
4490            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4491                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4492            }
4493            Ok(())
4494        }
4495    }
4496
4497    impl fidl::encoding::ValueTypeMarker for GainUpdateMethod {
4498        type Borrowed<'a> = &'a Self;
4499        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4500            value
4501        }
4502    }
4503
4504    unsafe impl fidl::encoding::TypeMarker for GainUpdateMethod {
4505        type Owned = Self;
4506
4507        #[inline(always)]
4508        fn inline_align(_context: fidl::encoding::Context) -> usize {
4509            8
4510        }
4511
4512        #[inline(always)]
4513        fn inline_size(_context: fidl::encoding::Context) -> usize {
4514            16
4515        }
4516    }
4517
4518    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<GainUpdateMethod, D>
4519        for &GainUpdateMethod
4520    {
4521        #[inline]
4522        unsafe fn encode(
4523            self,
4524            encoder: &mut fidl::encoding::Encoder<'_, D>,
4525            offset: usize,
4526            _depth: fidl::encoding::Depth,
4527        ) -> fidl::Result<()> {
4528            encoder.debug_check_bounds::<GainUpdateMethod>(offset);
4529            encoder.write_num::<u64>(self.ordinal(), offset);
4530            match self {
4531                GainUpdateMethod::GainDb(ref val) => fidl::encoding::encode_in_envelope::<f32, D>(
4532                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(val),
4533                    encoder,
4534                    offset + 8,
4535                    _depth,
4536                ),
4537                GainUpdateMethod::Ramped(ref val) => {
4538                    fidl::encoding::encode_in_envelope::<RampedGain, D>(
4539                        <RampedGain as fidl::encoding::ValueTypeMarker>::borrow(val),
4540                        encoder,
4541                        offset + 8,
4542                        _depth,
4543                    )
4544                }
4545                GainUpdateMethod::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
4546            }
4547        }
4548    }
4549
4550    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for GainUpdateMethod {
4551        #[inline(always)]
4552        fn new_empty() -> Self {
4553            Self::__SourceBreaking { unknown_ordinal: 0 }
4554        }
4555
4556        #[inline]
4557        unsafe fn decode(
4558            &mut self,
4559            decoder: &mut fidl::encoding::Decoder<'_, D>,
4560            offset: usize,
4561            mut depth: fidl::encoding::Depth,
4562        ) -> fidl::Result<()> {
4563            decoder.debug_check_bounds::<Self>(offset);
4564            #[allow(unused_variables)]
4565            let next_out_of_line = decoder.next_out_of_line();
4566            let handles_before = decoder.remaining_handles();
4567            let (ordinal, inlined, num_bytes, num_handles) =
4568                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
4569
4570            let member_inline_size = match ordinal {
4571                1 => <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4572                2 => <RampedGain as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4573                0 => return Err(fidl::Error::UnknownUnionTag),
4574                _ => num_bytes as usize,
4575            };
4576
4577            if inlined != (member_inline_size <= 4) {
4578                return Err(fidl::Error::InvalidInlineBitInEnvelope);
4579            }
4580            let _inner_offset;
4581            if inlined {
4582                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
4583                _inner_offset = offset + 8;
4584            } else {
4585                depth.increment()?;
4586                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4587            }
4588            match ordinal {
4589                1 => {
4590                    #[allow(irrefutable_let_patterns)]
4591                    if let GainUpdateMethod::GainDb(_) = self {
4592                        // Do nothing, read the value into the object
4593                    } else {
4594                        // Initialize `self` to the right variant
4595                        *self = GainUpdateMethod::GainDb(fidl::new_empty!(f32, D));
4596                    }
4597                    #[allow(irrefutable_let_patterns)]
4598                    if let GainUpdateMethod::GainDb(ref mut val) = self {
4599                        fidl::decode!(f32, D, val, decoder, _inner_offset, depth)?;
4600                    } else {
4601                        unreachable!()
4602                    }
4603                }
4604                2 => {
4605                    #[allow(irrefutable_let_patterns)]
4606                    if let GainUpdateMethod::Ramped(_) = self {
4607                        // Do nothing, read the value into the object
4608                    } else {
4609                        // Initialize `self` to the right variant
4610                        *self = GainUpdateMethod::Ramped(fidl::new_empty!(RampedGain, D));
4611                    }
4612                    #[allow(irrefutable_let_patterns)]
4613                    if let GainUpdateMethod::Ramped(ref mut val) = self {
4614                        fidl::decode!(RampedGain, D, val, decoder, _inner_offset, depth)?;
4615                    } else {
4616                        unreachable!()
4617                    }
4618                }
4619                #[allow(deprecated)]
4620                ordinal => {
4621                    for _ in 0..num_handles {
4622                        decoder.drop_next_handle()?;
4623                    }
4624                    *self = GainUpdateMethod::__SourceBreaking { unknown_ordinal: ordinal };
4625                }
4626            }
4627            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
4628                return Err(fidl::Error::InvalidNumBytesInEnvelope);
4629            }
4630            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4631                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4632            }
4633            Ok(())
4634        }
4635    }
4636
4637    impl fidl::encoding::ValueTypeMarker for RampFunction {
4638        type Borrowed<'a> = &'a Self;
4639        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4640            value
4641        }
4642    }
4643
4644    unsafe impl fidl::encoding::TypeMarker for RampFunction {
4645        type Owned = Self;
4646
4647        #[inline(always)]
4648        fn inline_align(_context: fidl::encoding::Context) -> usize {
4649            8
4650        }
4651
4652        #[inline(always)]
4653        fn inline_size(_context: fidl::encoding::Context) -> usize {
4654            16
4655        }
4656    }
4657
4658    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RampFunction, D>
4659        for &RampFunction
4660    {
4661        #[inline]
4662        unsafe fn encode(
4663            self,
4664            encoder: &mut fidl::encoding::Encoder<'_, D>,
4665            offset: usize,
4666            _depth: fidl::encoding::Depth,
4667        ) -> fidl::Result<()> {
4668            encoder.debug_check_bounds::<RampFunction>(offset);
4669            encoder.write_num::<u64>(self.ordinal(), offset);
4670            match self {
4671                RampFunction::LinearSlope(ref val) => {
4672                    fidl::encoding::encode_in_envelope::<RampFunctionLinearSlope, D>(
4673                        <RampFunctionLinearSlope as fidl::encoding::ValueTypeMarker>::borrow(val),
4674                        encoder,
4675                        offset + 8,
4676                        _depth,
4677                    )
4678                }
4679                RampFunction::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
4680            }
4681        }
4682    }
4683
4684    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RampFunction {
4685        #[inline(always)]
4686        fn new_empty() -> Self {
4687            Self::__SourceBreaking { unknown_ordinal: 0 }
4688        }
4689
4690        #[inline]
4691        unsafe fn decode(
4692            &mut self,
4693            decoder: &mut fidl::encoding::Decoder<'_, D>,
4694            offset: usize,
4695            mut depth: fidl::encoding::Depth,
4696        ) -> fidl::Result<()> {
4697            decoder.debug_check_bounds::<Self>(offset);
4698            #[allow(unused_variables)]
4699            let next_out_of_line = decoder.next_out_of_line();
4700            let handles_before = decoder.remaining_handles();
4701            let (ordinal, inlined, num_bytes, num_handles) =
4702                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
4703
4704            let member_inline_size = match ordinal {
4705                1 => <RampFunctionLinearSlope as fidl::encoding::TypeMarker>::inline_size(
4706                    decoder.context,
4707                ),
4708                0 => return Err(fidl::Error::UnknownUnionTag),
4709                _ => num_bytes as usize,
4710            };
4711
4712            if inlined != (member_inline_size <= 4) {
4713                return Err(fidl::Error::InvalidInlineBitInEnvelope);
4714            }
4715            let _inner_offset;
4716            if inlined {
4717                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
4718                _inner_offset = offset + 8;
4719            } else {
4720                depth.increment()?;
4721                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4722            }
4723            match ordinal {
4724                1 => {
4725                    #[allow(irrefutable_let_patterns)]
4726                    if let RampFunction::LinearSlope(_) = self {
4727                        // Do nothing, read the value into the object
4728                    } else {
4729                        // Initialize `self` to the right variant
4730                        *self =
4731                            RampFunction::LinearSlope(fidl::new_empty!(RampFunctionLinearSlope, D));
4732                    }
4733                    #[allow(irrefutable_let_patterns)]
4734                    if let RampFunction::LinearSlope(ref mut val) = self {
4735                        fidl::decode!(
4736                            RampFunctionLinearSlope,
4737                            D,
4738                            val,
4739                            decoder,
4740                            _inner_offset,
4741                            depth
4742                        )?;
4743                    } else {
4744                        unreachable!()
4745                    }
4746                }
4747                #[allow(deprecated)]
4748                ordinal => {
4749                    for _ in 0..num_handles {
4750                        decoder.drop_next_handle()?;
4751                    }
4752                    *self = RampFunction::__SourceBreaking { unknown_ordinal: ordinal };
4753                }
4754            }
4755            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
4756                return Err(fidl::Error::InvalidNumBytesInEnvelope);
4757            }
4758            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4759                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4760            }
4761            Ok(())
4762        }
4763    }
4764
4765    impl fidl::encoding::ValueTypeMarker for Timestamp {
4766        type Borrowed<'a> = &'a Self;
4767        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4768            value
4769        }
4770    }
4771
4772    unsafe impl fidl::encoding::TypeMarker for Timestamp {
4773        type Owned = Self;
4774
4775        #[inline(always)]
4776        fn inline_align(_context: fidl::encoding::Context) -> usize {
4777            8
4778        }
4779
4780        #[inline(always)]
4781        fn inline_size(_context: fidl::encoding::Context) -> usize {
4782            16
4783        }
4784    }
4785
4786    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Timestamp, D>
4787        for &Timestamp
4788    {
4789        #[inline]
4790        unsafe fn encode(
4791            self,
4792            encoder: &mut fidl::encoding::Encoder<'_, D>,
4793            offset: usize,
4794            _depth: fidl::encoding::Depth,
4795        ) -> fidl::Result<()> {
4796            encoder.debug_check_bounds::<Timestamp>(offset);
4797            encoder.write_num::<u64>(self.ordinal(), offset);
4798            match self {
4799                Timestamp::Specified(ref val) => fidl::encoding::encode_in_envelope::<i64, D>(
4800                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
4801                    encoder,
4802                    offset + 8,
4803                    _depth,
4804                ),
4805                Timestamp::UnspecifiedContinuous(ref val) => {
4806                    fidl::encoding::encode_in_envelope::<UnspecifiedContinuous, D>(
4807                        <UnspecifiedContinuous as fidl::encoding::ValueTypeMarker>::borrow(val),
4808                        encoder,
4809                        offset + 8,
4810                        _depth,
4811                    )
4812                }
4813                Timestamp::UnspecifiedBestEffort(ref val) => {
4814                    fidl::encoding::encode_in_envelope::<UnspecifiedBestEffort, D>(
4815                        <UnspecifiedBestEffort as fidl::encoding::ValueTypeMarker>::borrow(val),
4816                        encoder,
4817                        offset + 8,
4818                        _depth,
4819                    )
4820                }
4821                Timestamp::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
4822            }
4823        }
4824    }
4825
4826    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Timestamp {
4827        #[inline(always)]
4828        fn new_empty() -> Self {
4829            Self::__SourceBreaking { unknown_ordinal: 0 }
4830        }
4831
4832        #[inline]
4833        unsafe fn decode(
4834            &mut self,
4835            decoder: &mut fidl::encoding::Decoder<'_, D>,
4836            offset: usize,
4837            mut depth: fidl::encoding::Depth,
4838        ) -> fidl::Result<()> {
4839            decoder.debug_check_bounds::<Self>(offset);
4840            #[allow(unused_variables)]
4841            let next_out_of_line = decoder.next_out_of_line();
4842            let handles_before = decoder.remaining_handles();
4843            let (ordinal, inlined, num_bytes, num_handles) =
4844                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
4845
4846            let member_inline_size = match ordinal {
4847                1 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4848                2 => <UnspecifiedContinuous as fidl::encoding::TypeMarker>::inline_size(
4849                    decoder.context,
4850                ),
4851                3 => <UnspecifiedBestEffort as fidl::encoding::TypeMarker>::inline_size(
4852                    decoder.context,
4853                ),
4854                0 => return Err(fidl::Error::UnknownUnionTag),
4855                _ => num_bytes as usize,
4856            };
4857
4858            if inlined != (member_inline_size <= 4) {
4859                return Err(fidl::Error::InvalidInlineBitInEnvelope);
4860            }
4861            let _inner_offset;
4862            if inlined {
4863                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
4864                _inner_offset = offset + 8;
4865            } else {
4866                depth.increment()?;
4867                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4868            }
4869            match ordinal {
4870                1 => {
4871                    #[allow(irrefutable_let_patterns)]
4872                    if let Timestamp::Specified(_) = self {
4873                        // Do nothing, read the value into the object
4874                    } else {
4875                        // Initialize `self` to the right variant
4876                        *self = Timestamp::Specified(fidl::new_empty!(i64, D));
4877                    }
4878                    #[allow(irrefutable_let_patterns)]
4879                    if let Timestamp::Specified(ref mut val) = self {
4880                        fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
4881                    } else {
4882                        unreachable!()
4883                    }
4884                }
4885                2 => {
4886                    #[allow(irrefutable_let_patterns)]
4887                    if let Timestamp::UnspecifiedContinuous(_) = self {
4888                        // Do nothing, read the value into the object
4889                    } else {
4890                        // Initialize `self` to the right variant
4891                        *self = Timestamp::UnspecifiedContinuous(fidl::new_empty!(
4892                            UnspecifiedContinuous,
4893                            D
4894                        ));
4895                    }
4896                    #[allow(irrefutable_let_patterns)]
4897                    if let Timestamp::UnspecifiedContinuous(ref mut val) = self {
4898                        fidl::decode!(
4899                            UnspecifiedContinuous,
4900                            D,
4901                            val,
4902                            decoder,
4903                            _inner_offset,
4904                            depth
4905                        )?;
4906                    } else {
4907                        unreachable!()
4908                    }
4909                }
4910                3 => {
4911                    #[allow(irrefutable_let_patterns)]
4912                    if let Timestamp::UnspecifiedBestEffort(_) = self {
4913                        // Do nothing, read the value into the object
4914                    } else {
4915                        // Initialize `self` to the right variant
4916                        *self = Timestamp::UnspecifiedBestEffort(fidl::new_empty!(
4917                            UnspecifiedBestEffort,
4918                            D
4919                        ));
4920                    }
4921                    #[allow(irrefutable_let_patterns)]
4922                    if let Timestamp::UnspecifiedBestEffort(ref mut val) = self {
4923                        fidl::decode!(
4924                            UnspecifiedBestEffort,
4925                            D,
4926                            val,
4927                            decoder,
4928                            _inner_offset,
4929                            depth
4930                        )?;
4931                    } else {
4932                        unreachable!()
4933                    }
4934                }
4935                #[allow(deprecated)]
4936                ordinal => {
4937                    for _ in 0..num_handles {
4938                        decoder.drop_next_handle()?;
4939                    }
4940                    *self = Timestamp::__SourceBreaking { unknown_ordinal: ordinal };
4941                }
4942            }
4943            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
4944                return Err(fidl::Error::InvalidNumBytesInEnvelope);
4945            }
4946            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4947                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4948            }
4949            Ok(())
4950        }
4951    }
4952}