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
807mod internal {
808    use super::*;
809    unsafe impl fidl::encoding::TypeMarker for PacketFlags {
810        type Owned = Self;
811
812        #[inline(always)]
813        fn inline_align(_context: fidl::encoding::Context) -> usize {
814            4
815        }
816
817        #[inline(always)]
818        fn inline_size(_context: fidl::encoding::Context) -> usize {
819            4
820        }
821    }
822
823    impl fidl::encoding::ValueTypeMarker for PacketFlags {
824        type Borrowed<'a> = Self;
825        #[inline(always)]
826        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
827            *value
828        }
829    }
830
831    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for PacketFlags {
832        #[inline]
833        unsafe fn encode(
834            self,
835            encoder: &mut fidl::encoding::Encoder<'_, D>,
836            offset: usize,
837            _depth: fidl::encoding::Depth,
838        ) -> fidl::Result<()> {
839            encoder.debug_check_bounds::<Self>(offset);
840            encoder.write_num(self.bits(), offset);
841            Ok(())
842        }
843    }
844
845    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PacketFlags {
846        #[inline(always)]
847        fn new_empty() -> Self {
848            Self::empty()
849        }
850
851        #[inline]
852        unsafe fn decode(
853            &mut self,
854            decoder: &mut fidl::encoding::Decoder<'_, D>,
855            offset: usize,
856            _depth: fidl::encoding::Depth,
857        ) -> fidl::Result<()> {
858            decoder.debug_check_bounds::<Self>(offset);
859            let prim = decoder.read_num::<u32>(offset);
860            *self = Self::from_bits_allow_unknown(prim);
861            Ok(())
862        }
863    }
864    unsafe impl fidl::encoding::TypeMarker for ChannelConfig {
865        type Owned = Self;
866
867        #[inline(always)]
868        fn inline_align(_context: fidl::encoding::Context) -> usize {
869            std::mem::align_of::<u32>()
870        }
871
872        #[inline(always)]
873        fn inline_size(_context: fidl::encoding::Context) -> usize {
874            std::mem::size_of::<u32>()
875        }
876
877        #[inline(always)]
878        fn encode_is_copy() -> bool {
879            false
880        }
881
882        #[inline(always)]
883        fn decode_is_copy() -> bool {
884            false
885        }
886    }
887
888    impl fidl::encoding::ValueTypeMarker for ChannelConfig {
889        type Borrowed<'a> = Self;
890        #[inline(always)]
891        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
892            *value
893        }
894    }
895
896    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ChannelConfig {
897        #[inline]
898        unsafe fn encode(
899            self,
900            encoder: &mut fidl::encoding::Encoder<'_, D>,
901            offset: usize,
902            _depth: fidl::encoding::Depth,
903        ) -> fidl::Result<()> {
904            encoder.debug_check_bounds::<Self>(offset);
905            encoder.write_num(self.into_primitive(), offset);
906            Ok(())
907        }
908    }
909
910    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ChannelConfig {
911        #[inline(always)]
912        fn new_empty() -> Self {
913            Self::unknown()
914        }
915
916        #[inline]
917        unsafe fn decode(
918            &mut self,
919            decoder: &mut fidl::encoding::Decoder<'_, D>,
920            offset: usize,
921            _depth: fidl::encoding::Depth,
922        ) -> fidl::Result<()> {
923            decoder.debug_check_bounds::<Self>(offset);
924            let prim = decoder.read_num::<u32>(offset);
925
926            *self = Self::from_primitive_allow_unknown(prim);
927            Ok(())
928        }
929    }
930    unsafe impl fidl::encoding::TypeMarker for CompressionType {
931        type Owned = Self;
932
933        #[inline(always)]
934        fn inline_align(_context: fidl::encoding::Context) -> usize {
935            std::mem::align_of::<u32>()
936        }
937
938        #[inline(always)]
939        fn inline_size(_context: fidl::encoding::Context) -> usize {
940            std::mem::size_of::<u32>()
941        }
942
943        #[inline(always)]
944        fn encode_is_copy() -> bool {
945            false
946        }
947
948        #[inline(always)]
949        fn decode_is_copy() -> bool {
950            false
951        }
952    }
953
954    impl fidl::encoding::ValueTypeMarker for CompressionType {
955        type Borrowed<'a> = Self;
956        #[inline(always)]
957        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
958            *value
959        }
960    }
961
962    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
963        for CompressionType
964    {
965        #[inline]
966        unsafe fn encode(
967            self,
968            encoder: &mut fidl::encoding::Encoder<'_, D>,
969            offset: usize,
970            _depth: fidl::encoding::Depth,
971        ) -> fidl::Result<()> {
972            encoder.debug_check_bounds::<Self>(offset);
973            encoder.write_num(self.into_primitive(), offset);
974            Ok(())
975        }
976    }
977
978    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CompressionType {
979        #[inline(always)]
980        fn new_empty() -> Self {
981            Self::unknown()
982        }
983
984        #[inline]
985        unsafe fn decode(
986            &mut self,
987            decoder: &mut fidl::encoding::Decoder<'_, D>,
988            offset: usize,
989            _depth: fidl::encoding::Depth,
990        ) -> fidl::Result<()> {
991            decoder.debug_check_bounds::<Self>(offset);
992            let prim = decoder.read_num::<u32>(offset);
993
994            *self = Self::from_primitive_allow_unknown(prim);
995            Ok(())
996        }
997    }
998    unsafe impl fidl::encoding::TypeMarker for GainError {
999        type Owned = Self;
1000
1001        #[inline(always)]
1002        fn inline_align(_context: fidl::encoding::Context) -> usize {
1003            std::mem::align_of::<u32>()
1004        }
1005
1006        #[inline(always)]
1007        fn inline_size(_context: fidl::encoding::Context) -> usize {
1008            std::mem::size_of::<u32>()
1009        }
1010
1011        #[inline(always)]
1012        fn encode_is_copy() -> bool {
1013            false
1014        }
1015
1016        #[inline(always)]
1017        fn decode_is_copy() -> bool {
1018            false
1019        }
1020    }
1021
1022    impl fidl::encoding::ValueTypeMarker for GainError {
1023        type Borrowed<'a> = Self;
1024        #[inline(always)]
1025        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1026            *value
1027        }
1028    }
1029
1030    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for GainError {
1031        #[inline]
1032        unsafe fn encode(
1033            self,
1034            encoder: &mut fidl::encoding::Encoder<'_, D>,
1035            offset: usize,
1036            _depth: fidl::encoding::Depth,
1037        ) -> fidl::Result<()> {
1038            encoder.debug_check_bounds::<Self>(offset);
1039            encoder.write_num(self.into_primitive(), offset);
1040            Ok(())
1041        }
1042    }
1043
1044    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for GainError {
1045        #[inline(always)]
1046        fn new_empty() -> Self {
1047            Self::unknown()
1048        }
1049
1050        #[inline]
1051        unsafe fn decode(
1052            &mut self,
1053            decoder: &mut fidl::encoding::Decoder<'_, D>,
1054            offset: usize,
1055            _depth: fidl::encoding::Depth,
1056        ) -> fidl::Result<()> {
1057            decoder.debug_check_bounds::<Self>(offset);
1058            let prim = decoder.read_num::<u32>(offset);
1059
1060            *self = Self::from_primitive_allow_unknown(prim);
1061            Ok(())
1062        }
1063    }
1064    unsafe impl fidl::encoding::TypeMarker for SampleType {
1065        type Owned = Self;
1066
1067        #[inline(always)]
1068        fn inline_align(_context: fidl::encoding::Context) -> usize {
1069            std::mem::align_of::<u32>()
1070        }
1071
1072        #[inline(always)]
1073        fn inline_size(_context: fidl::encoding::Context) -> usize {
1074            std::mem::size_of::<u32>()
1075        }
1076
1077        #[inline(always)]
1078        fn encode_is_copy() -> bool {
1079            false
1080        }
1081
1082        #[inline(always)]
1083        fn decode_is_copy() -> bool {
1084            false
1085        }
1086    }
1087
1088    impl fidl::encoding::ValueTypeMarker for SampleType {
1089        type Borrowed<'a> = Self;
1090        #[inline(always)]
1091        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1092            *value
1093        }
1094    }
1095
1096    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for SampleType {
1097        #[inline]
1098        unsafe fn encode(
1099            self,
1100            encoder: &mut fidl::encoding::Encoder<'_, D>,
1101            offset: usize,
1102            _depth: fidl::encoding::Depth,
1103        ) -> fidl::Result<()> {
1104            encoder.debug_check_bounds::<Self>(offset);
1105            encoder.write_num(self.into_primitive(), offset);
1106            Ok(())
1107        }
1108    }
1109
1110    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SampleType {
1111        #[inline(always)]
1112        fn new_empty() -> Self {
1113            Self::unknown()
1114        }
1115
1116        #[inline]
1117        unsafe fn decode(
1118            &mut self,
1119            decoder: &mut fidl::encoding::Decoder<'_, D>,
1120            offset: usize,
1121            _depth: fidl::encoding::Depth,
1122        ) -> fidl::Result<()> {
1123            decoder.debug_check_bounds::<Self>(offset);
1124            let prim = decoder.read_num::<u32>(offset);
1125
1126            *self = Self::from_primitive_allow_unknown(prim);
1127            Ok(())
1128        }
1129    }
1130
1131    impl fidl::encoding::ValueTypeMarker for UnspecifiedBestEffort {
1132        type Borrowed<'a> = &'a Self;
1133        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1134            value
1135        }
1136    }
1137
1138    unsafe impl fidl::encoding::TypeMarker for UnspecifiedBestEffort {
1139        type Owned = Self;
1140
1141        #[inline(always)]
1142        fn inline_align(_context: fidl::encoding::Context) -> usize {
1143            1
1144        }
1145
1146        #[inline(always)]
1147        fn inline_size(_context: fidl::encoding::Context) -> usize {
1148            1
1149        }
1150    }
1151
1152    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<UnspecifiedBestEffort, D>
1153        for &UnspecifiedBestEffort
1154    {
1155        #[inline]
1156        unsafe fn encode(
1157            self,
1158            encoder: &mut fidl::encoding::Encoder<'_, D>,
1159            offset: usize,
1160            _depth: fidl::encoding::Depth,
1161        ) -> fidl::Result<()> {
1162            encoder.debug_check_bounds::<UnspecifiedBestEffort>(offset);
1163            encoder.write_num(0u8, offset);
1164            Ok(())
1165        }
1166    }
1167
1168    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for UnspecifiedBestEffort {
1169        #[inline(always)]
1170        fn new_empty() -> Self {
1171            Self
1172        }
1173
1174        #[inline]
1175        unsafe fn decode(
1176            &mut self,
1177            decoder: &mut fidl::encoding::Decoder<'_, D>,
1178            offset: usize,
1179            _depth: fidl::encoding::Depth,
1180        ) -> fidl::Result<()> {
1181            decoder.debug_check_bounds::<Self>(offset);
1182            match decoder.read_num::<u8>(offset) {
1183                0 => Ok(()),
1184                _ => Err(fidl::Error::Invalid),
1185            }
1186        }
1187    }
1188
1189    impl fidl::encoding::ValueTypeMarker for UnspecifiedContinuous {
1190        type Borrowed<'a> = &'a Self;
1191        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1192            value
1193        }
1194    }
1195
1196    unsafe impl fidl::encoding::TypeMarker for UnspecifiedContinuous {
1197        type Owned = Self;
1198
1199        #[inline(always)]
1200        fn inline_align(_context: fidl::encoding::Context) -> usize {
1201            1
1202        }
1203
1204        #[inline(always)]
1205        fn inline_size(_context: fidl::encoding::Context) -> usize {
1206            1
1207        }
1208    }
1209
1210    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<UnspecifiedContinuous, D>
1211        for &UnspecifiedContinuous
1212    {
1213        #[inline]
1214        unsafe fn encode(
1215            self,
1216            encoder: &mut fidl::encoding::Encoder<'_, D>,
1217            offset: usize,
1218            _depth: fidl::encoding::Depth,
1219        ) -> fidl::Result<()> {
1220            encoder.debug_check_bounds::<UnspecifiedContinuous>(offset);
1221            encoder.write_num(0u8, offset);
1222            Ok(())
1223        }
1224    }
1225
1226    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for UnspecifiedContinuous {
1227        #[inline(always)]
1228        fn new_empty() -> Self {
1229            Self
1230        }
1231
1232        #[inline]
1233        unsafe fn decode(
1234            &mut self,
1235            decoder: &mut fidl::encoding::Decoder<'_, D>,
1236            offset: usize,
1237            _depth: fidl::encoding::Depth,
1238        ) -> fidl::Result<()> {
1239            decoder.debug_check_bounds::<Self>(offset);
1240            match decoder.read_num::<u8>(offset) {
1241                0 => Ok(()),
1242                _ => Err(fidl::Error::Invalid),
1243            }
1244        }
1245    }
1246
1247    impl Compression {
1248        #[inline(always)]
1249        fn max_ordinal_present(&self) -> u64 {
1250            if let Some(_) = self.oob_parameters {
1251                return 2;
1252            }
1253            if let Some(_) = self.type_ {
1254                return 1;
1255            }
1256            0
1257        }
1258    }
1259
1260    impl fidl::encoding::ValueTypeMarker for Compression {
1261        type Borrowed<'a> = &'a Self;
1262        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1263            value
1264        }
1265    }
1266
1267    unsafe impl fidl::encoding::TypeMarker for Compression {
1268        type Owned = Self;
1269
1270        #[inline(always)]
1271        fn inline_align(_context: fidl::encoding::Context) -> usize {
1272            8
1273        }
1274
1275        #[inline(always)]
1276        fn inline_size(_context: fidl::encoding::Context) -> usize {
1277            16
1278        }
1279    }
1280
1281    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Compression, D>
1282        for &Compression
1283    {
1284        unsafe fn encode(
1285            self,
1286            encoder: &mut fidl::encoding::Encoder<'_, D>,
1287            offset: usize,
1288            mut depth: fidl::encoding::Depth,
1289        ) -> fidl::Result<()> {
1290            encoder.debug_check_bounds::<Compression>(offset);
1291            // Vector header
1292            let max_ordinal: u64 = self.max_ordinal_present();
1293            encoder.write_num(max_ordinal, offset);
1294            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1295            // Calling encoder.out_of_line_offset(0) is not allowed.
1296            if max_ordinal == 0 {
1297                return Ok(());
1298            }
1299            depth.increment()?;
1300            let envelope_size = 8;
1301            let bytes_len = max_ordinal as usize * envelope_size;
1302            #[allow(unused_variables)]
1303            let offset = encoder.out_of_line_offset(bytes_len);
1304            let mut _prev_end_offset: usize = 0;
1305            if 1 > max_ordinal {
1306                return Ok(());
1307            }
1308
1309            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1310            // are envelope_size bytes.
1311            let cur_offset: usize = (1 - 1) * envelope_size;
1312
1313            // Zero reserved fields.
1314            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1315
1316            // Safety:
1317            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1318            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1319            //   envelope_size bytes, there is always sufficient room.
1320            fidl::encoding::encode_in_envelope_optional::<CompressionType, D>(
1321                self.type_
1322                    .as_ref()
1323                    .map(<CompressionType as fidl::encoding::ValueTypeMarker>::borrow),
1324                encoder,
1325                offset + cur_offset,
1326                depth,
1327            )?;
1328
1329            _prev_end_offset = cur_offset + envelope_size;
1330            if 2 > max_ordinal {
1331                return Ok(());
1332            }
1333
1334            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1335            // are envelope_size bytes.
1336            let cur_offset: usize = (2 - 1) * envelope_size;
1337
1338            // Zero reserved fields.
1339            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1340
1341            // Safety:
1342            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1343            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1344            //   envelope_size bytes, there is always sufficient room.
1345            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<u8, 32768>, D>(
1346                self.oob_parameters.as_ref().map(
1347                    <fidl::encoding::Vector<u8, 32768> as fidl::encoding::ValueTypeMarker>::borrow,
1348                ),
1349                encoder,
1350                offset + cur_offset,
1351                depth,
1352            )?;
1353
1354            _prev_end_offset = cur_offset + envelope_size;
1355
1356            Ok(())
1357        }
1358    }
1359
1360    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Compression {
1361        #[inline(always)]
1362        fn new_empty() -> Self {
1363            Self::default()
1364        }
1365
1366        unsafe fn decode(
1367            &mut self,
1368            decoder: &mut fidl::encoding::Decoder<'_, D>,
1369            offset: usize,
1370            mut depth: fidl::encoding::Depth,
1371        ) -> fidl::Result<()> {
1372            decoder.debug_check_bounds::<Self>(offset);
1373            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1374                None => return Err(fidl::Error::NotNullable),
1375                Some(len) => len,
1376            };
1377            // Calling decoder.out_of_line_offset(0) is not allowed.
1378            if len == 0 {
1379                return Ok(());
1380            };
1381            depth.increment()?;
1382            let envelope_size = 8;
1383            let bytes_len = len * envelope_size;
1384            let offset = decoder.out_of_line_offset(bytes_len)?;
1385            // Decode the envelope for each type.
1386            let mut _next_ordinal_to_read = 0;
1387            let mut next_offset = offset;
1388            let end_offset = offset + bytes_len;
1389            _next_ordinal_to_read += 1;
1390            if next_offset >= end_offset {
1391                return Ok(());
1392            }
1393
1394            // Decode unknown envelopes for gaps in ordinals.
1395            while _next_ordinal_to_read < 1 {
1396                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1397                _next_ordinal_to_read += 1;
1398                next_offset += envelope_size;
1399            }
1400
1401            let next_out_of_line = decoder.next_out_of_line();
1402            let handles_before = decoder.remaining_handles();
1403            if let Some((inlined, num_bytes, num_handles)) =
1404                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1405            {
1406                let member_inline_size =
1407                    <CompressionType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1408                if inlined != (member_inline_size <= 4) {
1409                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1410                }
1411                let inner_offset;
1412                let mut inner_depth = depth.clone();
1413                if inlined {
1414                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1415                    inner_offset = next_offset;
1416                } else {
1417                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1418                    inner_depth.increment()?;
1419                }
1420                let val_ref =
1421                    self.type_.get_or_insert_with(|| fidl::new_empty!(CompressionType, D));
1422                fidl::decode!(CompressionType, D, val_ref, decoder, inner_offset, inner_depth)?;
1423                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1424                {
1425                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1426                }
1427                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1428                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1429                }
1430            }
1431
1432            next_offset += envelope_size;
1433            _next_ordinal_to_read += 1;
1434            if next_offset >= end_offset {
1435                return Ok(());
1436            }
1437
1438            // Decode unknown envelopes for gaps in ordinals.
1439            while _next_ordinal_to_read < 2 {
1440                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1441                _next_ordinal_to_read += 1;
1442                next_offset += envelope_size;
1443            }
1444
1445            let next_out_of_line = decoder.next_out_of_line();
1446            let handles_before = decoder.remaining_handles();
1447            if let Some((inlined, num_bytes, num_handles)) =
1448                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1449            {
1450                let member_inline_size =
1451                    <fidl::encoding::Vector<u8, 32768> as fidl::encoding::TypeMarker>::inline_size(
1452                        decoder.context,
1453                    );
1454                if inlined != (member_inline_size <= 4) {
1455                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1456                }
1457                let inner_offset;
1458                let mut inner_depth = depth.clone();
1459                if inlined {
1460                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1461                    inner_offset = next_offset;
1462                } else {
1463                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1464                    inner_depth.increment()?;
1465                }
1466                let val_ref = self
1467                    .oob_parameters
1468                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 32768>, D));
1469                fidl::decode!(fidl::encoding::Vector<u8, 32768>, D, val_ref, decoder, inner_offset, inner_depth)?;
1470                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1471                {
1472                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1473                }
1474                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1475                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1476                }
1477            }
1478
1479            next_offset += envelope_size;
1480
1481            // Decode the remaining unknown envelopes.
1482            while next_offset < end_offset {
1483                _next_ordinal_to_read += 1;
1484                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1485                next_offset += envelope_size;
1486            }
1487
1488            Ok(())
1489        }
1490    }
1491
1492    impl DelayWatcherWatchDelayRequest {
1493        #[inline(always)]
1494        fn max_ordinal_present(&self) -> u64 {
1495            0
1496        }
1497    }
1498
1499    impl fidl::encoding::ValueTypeMarker for DelayWatcherWatchDelayRequest {
1500        type Borrowed<'a> = &'a Self;
1501        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1502            value
1503        }
1504    }
1505
1506    unsafe impl fidl::encoding::TypeMarker for DelayWatcherWatchDelayRequest {
1507        type Owned = Self;
1508
1509        #[inline(always)]
1510        fn inline_align(_context: fidl::encoding::Context) -> usize {
1511            8
1512        }
1513
1514        #[inline(always)]
1515        fn inline_size(_context: fidl::encoding::Context) -> usize {
1516            16
1517        }
1518    }
1519
1520    unsafe impl<D: fidl::encoding::ResourceDialect>
1521        fidl::encoding::Encode<DelayWatcherWatchDelayRequest, D>
1522        for &DelayWatcherWatchDelayRequest
1523    {
1524        unsafe fn encode(
1525            self,
1526            encoder: &mut fidl::encoding::Encoder<'_, D>,
1527            offset: usize,
1528            mut depth: fidl::encoding::Depth,
1529        ) -> fidl::Result<()> {
1530            encoder.debug_check_bounds::<DelayWatcherWatchDelayRequest>(offset);
1531            // Vector header
1532            let max_ordinal: u64 = self.max_ordinal_present();
1533            encoder.write_num(max_ordinal, offset);
1534            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1535            // Calling encoder.out_of_line_offset(0) is not allowed.
1536            if max_ordinal == 0 {
1537                return Ok(());
1538            }
1539            depth.increment()?;
1540            let envelope_size = 8;
1541            let bytes_len = max_ordinal as usize * envelope_size;
1542            #[allow(unused_variables)]
1543            let offset = encoder.out_of_line_offset(bytes_len);
1544            let mut _prev_end_offset: usize = 0;
1545
1546            Ok(())
1547        }
1548    }
1549
1550    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1551        for DelayWatcherWatchDelayRequest
1552    {
1553        #[inline(always)]
1554        fn new_empty() -> Self {
1555            Self::default()
1556        }
1557
1558        unsafe fn decode(
1559            &mut self,
1560            decoder: &mut fidl::encoding::Decoder<'_, D>,
1561            offset: usize,
1562            mut depth: fidl::encoding::Depth,
1563        ) -> fidl::Result<()> {
1564            decoder.debug_check_bounds::<Self>(offset);
1565            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1566                None => return Err(fidl::Error::NotNullable),
1567                Some(len) => len,
1568            };
1569            // Calling decoder.out_of_line_offset(0) is not allowed.
1570            if len == 0 {
1571                return Ok(());
1572            };
1573            depth.increment()?;
1574            let envelope_size = 8;
1575            let bytes_len = len * envelope_size;
1576            let offset = decoder.out_of_line_offset(bytes_len)?;
1577            // Decode the envelope for each type.
1578            let mut _next_ordinal_to_read = 0;
1579            let mut next_offset = offset;
1580            let end_offset = offset + bytes_len;
1581
1582            // Decode the remaining unknown envelopes.
1583            while next_offset < end_offset {
1584                _next_ordinal_to_read += 1;
1585                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1586                next_offset += envelope_size;
1587            }
1588
1589            Ok(())
1590        }
1591    }
1592
1593    impl DelayWatcherWatchDelayResponse {
1594        #[inline(always)]
1595        fn max_ordinal_present(&self) -> u64 {
1596            if let Some(_) = self.delay {
1597                return 1;
1598            }
1599            0
1600        }
1601    }
1602
1603    impl fidl::encoding::ValueTypeMarker for DelayWatcherWatchDelayResponse {
1604        type Borrowed<'a> = &'a Self;
1605        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1606            value
1607        }
1608    }
1609
1610    unsafe impl fidl::encoding::TypeMarker for DelayWatcherWatchDelayResponse {
1611        type Owned = Self;
1612
1613        #[inline(always)]
1614        fn inline_align(_context: fidl::encoding::Context) -> usize {
1615            8
1616        }
1617
1618        #[inline(always)]
1619        fn inline_size(_context: fidl::encoding::Context) -> usize {
1620            16
1621        }
1622    }
1623
1624    unsafe impl<D: fidl::encoding::ResourceDialect>
1625        fidl::encoding::Encode<DelayWatcherWatchDelayResponse, D>
1626        for &DelayWatcherWatchDelayResponse
1627    {
1628        unsafe fn encode(
1629            self,
1630            encoder: &mut fidl::encoding::Encoder<'_, D>,
1631            offset: usize,
1632            mut depth: fidl::encoding::Depth,
1633        ) -> fidl::Result<()> {
1634            encoder.debug_check_bounds::<DelayWatcherWatchDelayResponse>(offset);
1635            // Vector header
1636            let max_ordinal: u64 = self.max_ordinal_present();
1637            encoder.write_num(max_ordinal, offset);
1638            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1639            // Calling encoder.out_of_line_offset(0) is not allowed.
1640            if max_ordinal == 0 {
1641                return Ok(());
1642            }
1643            depth.increment()?;
1644            let envelope_size = 8;
1645            let bytes_len = max_ordinal as usize * envelope_size;
1646            #[allow(unused_variables)]
1647            let offset = encoder.out_of_line_offset(bytes_len);
1648            let mut _prev_end_offset: usize = 0;
1649            if 1 > max_ordinal {
1650                return Ok(());
1651            }
1652
1653            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1654            // are envelope_size bytes.
1655            let cur_offset: usize = (1 - 1) * envelope_size;
1656
1657            // Zero reserved fields.
1658            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1659
1660            // Safety:
1661            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1662            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1663            //   envelope_size bytes, there is always sufficient room.
1664            fidl::encoding::encode_in_envelope_optional::<i64, D>(
1665                self.delay.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
1666                encoder,
1667                offset + cur_offset,
1668                depth,
1669            )?;
1670
1671            _prev_end_offset = cur_offset + envelope_size;
1672
1673            Ok(())
1674        }
1675    }
1676
1677    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1678        for DelayWatcherWatchDelayResponse
1679    {
1680        #[inline(always)]
1681        fn new_empty() -> Self {
1682            Self::default()
1683        }
1684
1685        unsafe fn decode(
1686            &mut self,
1687            decoder: &mut fidl::encoding::Decoder<'_, D>,
1688            offset: usize,
1689            mut depth: fidl::encoding::Depth,
1690        ) -> fidl::Result<()> {
1691            decoder.debug_check_bounds::<Self>(offset);
1692            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1693                None => return Err(fidl::Error::NotNullable),
1694                Some(len) => len,
1695            };
1696            // Calling decoder.out_of_line_offset(0) is not allowed.
1697            if len == 0 {
1698                return Ok(());
1699            };
1700            depth.increment()?;
1701            let envelope_size = 8;
1702            let bytes_len = len * envelope_size;
1703            let offset = decoder.out_of_line_offset(bytes_len)?;
1704            // Decode the envelope for each type.
1705            let mut _next_ordinal_to_read = 0;
1706            let mut next_offset = offset;
1707            let end_offset = offset + bytes_len;
1708            _next_ordinal_to_read += 1;
1709            if next_offset >= end_offset {
1710                return Ok(());
1711            }
1712
1713            // Decode unknown envelopes for gaps in ordinals.
1714            while _next_ordinal_to_read < 1 {
1715                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1716                _next_ordinal_to_read += 1;
1717                next_offset += envelope_size;
1718            }
1719
1720            let next_out_of_line = decoder.next_out_of_line();
1721            let handles_before = decoder.remaining_handles();
1722            if let Some((inlined, num_bytes, num_handles)) =
1723                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1724            {
1725                let member_inline_size =
1726                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1727                if inlined != (member_inline_size <= 4) {
1728                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1729                }
1730                let inner_offset;
1731                let mut inner_depth = depth.clone();
1732                if inlined {
1733                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1734                    inner_offset = next_offset;
1735                } else {
1736                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1737                    inner_depth.increment()?;
1738                }
1739                let val_ref = self.delay.get_or_insert_with(|| fidl::new_empty!(i64, D));
1740                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
1741                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1742                {
1743                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1744                }
1745                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1746                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1747                }
1748            }
1749
1750            next_offset += envelope_size;
1751
1752            // Decode the remaining unknown envelopes.
1753            while next_offset < end_offset {
1754                _next_ordinal_to_read += 1;
1755                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1756                next_offset += envelope_size;
1757            }
1758
1759            Ok(())
1760        }
1761    }
1762
1763    impl Format {
1764        #[inline(always)]
1765        fn max_ordinal_present(&self) -> u64 {
1766            if let Some(_) = self.channel_layout {
1767                return 4;
1768            }
1769            if let Some(_) = self.frames_per_second {
1770                return 3;
1771            }
1772            if let Some(_) = self.channel_count {
1773                return 2;
1774            }
1775            if let Some(_) = self.sample_type {
1776                return 1;
1777            }
1778            0
1779        }
1780    }
1781
1782    impl fidl::encoding::ValueTypeMarker for Format {
1783        type Borrowed<'a> = &'a Self;
1784        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1785            value
1786        }
1787    }
1788
1789    unsafe impl fidl::encoding::TypeMarker for Format {
1790        type Owned = Self;
1791
1792        #[inline(always)]
1793        fn inline_align(_context: fidl::encoding::Context) -> usize {
1794            8
1795        }
1796
1797        #[inline(always)]
1798        fn inline_size(_context: fidl::encoding::Context) -> usize {
1799            16
1800        }
1801    }
1802
1803    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Format, D> for &Format {
1804        unsafe fn encode(
1805            self,
1806            encoder: &mut fidl::encoding::Encoder<'_, D>,
1807            offset: usize,
1808            mut depth: fidl::encoding::Depth,
1809        ) -> fidl::Result<()> {
1810            encoder.debug_check_bounds::<Format>(offset);
1811            // Vector header
1812            let max_ordinal: u64 = self.max_ordinal_present();
1813            encoder.write_num(max_ordinal, offset);
1814            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1815            // Calling encoder.out_of_line_offset(0) is not allowed.
1816            if max_ordinal == 0 {
1817                return Ok(());
1818            }
1819            depth.increment()?;
1820            let envelope_size = 8;
1821            let bytes_len = max_ordinal as usize * envelope_size;
1822            #[allow(unused_variables)]
1823            let offset = encoder.out_of_line_offset(bytes_len);
1824            let mut _prev_end_offset: usize = 0;
1825            if 1 > max_ordinal {
1826                return Ok(());
1827            }
1828
1829            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1830            // are envelope_size bytes.
1831            let cur_offset: usize = (1 - 1) * envelope_size;
1832
1833            // Zero reserved fields.
1834            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1835
1836            // Safety:
1837            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1838            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1839            //   envelope_size bytes, there is always sufficient room.
1840            fidl::encoding::encode_in_envelope_optional::<SampleType, D>(
1841                self.sample_type
1842                    .as_ref()
1843                    .map(<SampleType as fidl::encoding::ValueTypeMarker>::borrow),
1844                encoder,
1845                offset + cur_offset,
1846                depth,
1847            )?;
1848
1849            _prev_end_offset = cur_offset + envelope_size;
1850            if 2 > max_ordinal {
1851                return Ok(());
1852            }
1853
1854            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1855            // are envelope_size bytes.
1856            let cur_offset: usize = (2 - 1) * envelope_size;
1857
1858            // Zero reserved fields.
1859            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1860
1861            // Safety:
1862            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1863            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1864            //   envelope_size bytes, there is always sufficient room.
1865            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1866                self.channel_count.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1867                encoder,
1868                offset + cur_offset,
1869                depth,
1870            )?;
1871
1872            _prev_end_offset = cur_offset + envelope_size;
1873            if 3 > max_ordinal {
1874                return Ok(());
1875            }
1876
1877            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1878            // are envelope_size bytes.
1879            let cur_offset: usize = (3 - 1) * envelope_size;
1880
1881            // Zero reserved fields.
1882            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1883
1884            // Safety:
1885            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1886            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1887            //   envelope_size bytes, there is always sufficient room.
1888            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1889                self.frames_per_second
1890                    .as_ref()
1891                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1892                encoder,
1893                offset + cur_offset,
1894                depth,
1895            )?;
1896
1897            _prev_end_offset = cur_offset + envelope_size;
1898            if 4 > max_ordinal {
1899                return Ok(());
1900            }
1901
1902            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1903            // are envelope_size bytes.
1904            let cur_offset: usize = (4 - 1) * envelope_size;
1905
1906            // Zero reserved fields.
1907            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1908
1909            // Safety:
1910            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1911            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1912            //   envelope_size bytes, there is always sufficient room.
1913            fidl::encoding::encode_in_envelope_optional::<ChannelLayout, D>(
1914                self.channel_layout
1915                    .as_ref()
1916                    .map(<ChannelLayout as fidl::encoding::ValueTypeMarker>::borrow),
1917                encoder,
1918                offset + cur_offset,
1919                depth,
1920            )?;
1921
1922            _prev_end_offset = cur_offset + envelope_size;
1923
1924            Ok(())
1925        }
1926    }
1927
1928    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Format {
1929        #[inline(always)]
1930        fn new_empty() -> Self {
1931            Self::default()
1932        }
1933
1934        unsafe fn decode(
1935            &mut self,
1936            decoder: &mut fidl::encoding::Decoder<'_, D>,
1937            offset: usize,
1938            mut depth: fidl::encoding::Depth,
1939        ) -> fidl::Result<()> {
1940            decoder.debug_check_bounds::<Self>(offset);
1941            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1942                None => return Err(fidl::Error::NotNullable),
1943                Some(len) => len,
1944            };
1945            // Calling decoder.out_of_line_offset(0) is not allowed.
1946            if len == 0 {
1947                return Ok(());
1948            };
1949            depth.increment()?;
1950            let envelope_size = 8;
1951            let bytes_len = len * envelope_size;
1952            let offset = decoder.out_of_line_offset(bytes_len)?;
1953            // Decode the envelope for each type.
1954            let mut _next_ordinal_to_read = 0;
1955            let mut next_offset = offset;
1956            let end_offset = offset + bytes_len;
1957            _next_ordinal_to_read += 1;
1958            if next_offset >= end_offset {
1959                return Ok(());
1960            }
1961
1962            // Decode unknown envelopes for gaps in ordinals.
1963            while _next_ordinal_to_read < 1 {
1964                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1965                _next_ordinal_to_read += 1;
1966                next_offset += envelope_size;
1967            }
1968
1969            let next_out_of_line = decoder.next_out_of_line();
1970            let handles_before = decoder.remaining_handles();
1971            if let Some((inlined, num_bytes, num_handles)) =
1972                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1973            {
1974                let member_inline_size =
1975                    <SampleType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1976                if inlined != (member_inline_size <= 4) {
1977                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1978                }
1979                let inner_offset;
1980                let mut inner_depth = depth.clone();
1981                if inlined {
1982                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1983                    inner_offset = next_offset;
1984                } else {
1985                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1986                    inner_depth.increment()?;
1987                }
1988                let val_ref =
1989                    self.sample_type.get_or_insert_with(|| fidl::new_empty!(SampleType, D));
1990                fidl::decode!(SampleType, D, val_ref, decoder, inner_offset, inner_depth)?;
1991                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1992                {
1993                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1994                }
1995                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1996                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1997                }
1998            }
1999
2000            next_offset += envelope_size;
2001            _next_ordinal_to_read += 1;
2002            if next_offset >= end_offset {
2003                return Ok(());
2004            }
2005
2006            // Decode unknown envelopes for gaps in ordinals.
2007            while _next_ordinal_to_read < 2 {
2008                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2009                _next_ordinal_to_read += 1;
2010                next_offset += envelope_size;
2011            }
2012
2013            let next_out_of_line = decoder.next_out_of_line();
2014            let handles_before = decoder.remaining_handles();
2015            if let Some((inlined, num_bytes, num_handles)) =
2016                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2017            {
2018                let member_inline_size =
2019                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2020                if inlined != (member_inline_size <= 4) {
2021                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2022                }
2023                let inner_offset;
2024                let mut inner_depth = depth.clone();
2025                if inlined {
2026                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2027                    inner_offset = next_offset;
2028                } else {
2029                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2030                    inner_depth.increment()?;
2031                }
2032                let val_ref = self.channel_count.get_or_insert_with(|| fidl::new_empty!(u32, D));
2033                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2034                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2035                {
2036                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2037                }
2038                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2039                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2040                }
2041            }
2042
2043            next_offset += envelope_size;
2044            _next_ordinal_to_read += 1;
2045            if next_offset >= end_offset {
2046                return Ok(());
2047            }
2048
2049            // Decode unknown envelopes for gaps in ordinals.
2050            while _next_ordinal_to_read < 3 {
2051                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2052                _next_ordinal_to_read += 1;
2053                next_offset += envelope_size;
2054            }
2055
2056            let next_out_of_line = decoder.next_out_of_line();
2057            let handles_before = decoder.remaining_handles();
2058            if let Some((inlined, num_bytes, num_handles)) =
2059                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2060            {
2061                let member_inline_size =
2062                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2063                if inlined != (member_inline_size <= 4) {
2064                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2065                }
2066                let inner_offset;
2067                let mut inner_depth = depth.clone();
2068                if inlined {
2069                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2070                    inner_offset = next_offset;
2071                } else {
2072                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2073                    inner_depth.increment()?;
2074                }
2075                let val_ref =
2076                    self.frames_per_second.get_or_insert_with(|| fidl::new_empty!(u32, D));
2077                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2078                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2079                {
2080                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2081                }
2082                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2083                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2084                }
2085            }
2086
2087            next_offset += envelope_size;
2088            _next_ordinal_to_read += 1;
2089            if next_offset >= end_offset {
2090                return Ok(());
2091            }
2092
2093            // Decode unknown envelopes for gaps in ordinals.
2094            while _next_ordinal_to_read < 4 {
2095                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2096                _next_ordinal_to_read += 1;
2097                next_offset += envelope_size;
2098            }
2099
2100            let next_out_of_line = decoder.next_out_of_line();
2101            let handles_before = decoder.remaining_handles();
2102            if let Some((inlined, num_bytes, num_handles)) =
2103                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2104            {
2105                let member_inline_size =
2106                    <ChannelLayout as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2107                if inlined != (member_inline_size <= 4) {
2108                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2109                }
2110                let inner_offset;
2111                let mut inner_depth = depth.clone();
2112                if inlined {
2113                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2114                    inner_offset = next_offset;
2115                } else {
2116                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2117                    inner_depth.increment()?;
2118                }
2119                let val_ref =
2120                    self.channel_layout.get_or_insert_with(|| fidl::new_empty!(ChannelLayout, D));
2121                fidl::decode!(ChannelLayout, D, val_ref, decoder, inner_offset, inner_depth)?;
2122                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2123                {
2124                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2125                }
2126                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2127                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2128                }
2129            }
2130
2131            next_offset += envelope_size;
2132
2133            // Decode the remaining unknown envelopes.
2134            while next_offset < end_offset {
2135                _next_ordinal_to_read += 1;
2136                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2137                next_offset += envelope_size;
2138            }
2139
2140            Ok(())
2141        }
2142    }
2143
2144    impl GainControlSetGainRequest {
2145        #[inline(always)]
2146        fn max_ordinal_present(&self) -> u64 {
2147            if let Some(_) = self.when {
2148                return 2;
2149            }
2150            if let Some(_) = self.how {
2151                return 1;
2152            }
2153            0
2154        }
2155    }
2156
2157    impl fidl::encoding::ValueTypeMarker for GainControlSetGainRequest {
2158        type Borrowed<'a> = &'a Self;
2159        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2160            value
2161        }
2162    }
2163
2164    unsafe impl fidl::encoding::TypeMarker for GainControlSetGainRequest {
2165        type Owned = Self;
2166
2167        #[inline(always)]
2168        fn inline_align(_context: fidl::encoding::Context) -> usize {
2169            8
2170        }
2171
2172        #[inline(always)]
2173        fn inline_size(_context: fidl::encoding::Context) -> usize {
2174            16
2175        }
2176    }
2177
2178    unsafe impl<D: fidl::encoding::ResourceDialect>
2179        fidl::encoding::Encode<GainControlSetGainRequest, D> for &GainControlSetGainRequest
2180    {
2181        unsafe fn encode(
2182            self,
2183            encoder: &mut fidl::encoding::Encoder<'_, D>,
2184            offset: usize,
2185            mut depth: fidl::encoding::Depth,
2186        ) -> fidl::Result<()> {
2187            encoder.debug_check_bounds::<GainControlSetGainRequest>(offset);
2188            // Vector header
2189            let max_ordinal: u64 = self.max_ordinal_present();
2190            encoder.write_num(max_ordinal, offset);
2191            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2192            // Calling encoder.out_of_line_offset(0) is not allowed.
2193            if max_ordinal == 0 {
2194                return Ok(());
2195            }
2196            depth.increment()?;
2197            let envelope_size = 8;
2198            let bytes_len = max_ordinal as usize * envelope_size;
2199            #[allow(unused_variables)]
2200            let offset = encoder.out_of_line_offset(bytes_len);
2201            let mut _prev_end_offset: usize = 0;
2202            if 1 > max_ordinal {
2203                return Ok(());
2204            }
2205
2206            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2207            // are envelope_size bytes.
2208            let cur_offset: usize = (1 - 1) * envelope_size;
2209
2210            // Zero reserved fields.
2211            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2212
2213            // Safety:
2214            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2215            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2216            //   envelope_size bytes, there is always sufficient room.
2217            fidl::encoding::encode_in_envelope_optional::<GainUpdateMethod, D>(
2218                self.how
2219                    .as_ref()
2220                    .map(<GainUpdateMethod as fidl::encoding::ValueTypeMarker>::borrow),
2221                encoder,
2222                offset + cur_offset,
2223                depth,
2224            )?;
2225
2226            _prev_end_offset = cur_offset + envelope_size;
2227            if 2 > max_ordinal {
2228                return Ok(());
2229            }
2230
2231            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2232            // are envelope_size bytes.
2233            let cur_offset: usize = (2 - 1) * envelope_size;
2234
2235            // Zero reserved fields.
2236            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2237
2238            // Safety:
2239            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2240            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2241            //   envelope_size bytes, there is always sufficient room.
2242            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media2__common::RealTime, D>(
2243            self.when.as_ref().map(<fidl_fuchsia_media2__common::RealTime as fidl::encoding::ValueTypeMarker>::borrow),
2244            encoder, offset + cur_offset, depth
2245        )?;
2246
2247            _prev_end_offset = cur_offset + envelope_size;
2248
2249            Ok(())
2250        }
2251    }
2252
2253    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2254        for GainControlSetGainRequest
2255    {
2256        #[inline(always)]
2257        fn new_empty() -> Self {
2258            Self::default()
2259        }
2260
2261        unsafe fn decode(
2262            &mut self,
2263            decoder: &mut fidl::encoding::Decoder<'_, D>,
2264            offset: usize,
2265            mut depth: fidl::encoding::Depth,
2266        ) -> fidl::Result<()> {
2267            decoder.debug_check_bounds::<Self>(offset);
2268            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2269                None => return Err(fidl::Error::NotNullable),
2270                Some(len) => len,
2271            };
2272            // Calling decoder.out_of_line_offset(0) is not allowed.
2273            if len == 0 {
2274                return Ok(());
2275            };
2276            depth.increment()?;
2277            let envelope_size = 8;
2278            let bytes_len = len * envelope_size;
2279            let offset = decoder.out_of_line_offset(bytes_len)?;
2280            // Decode the envelope for each type.
2281            let mut _next_ordinal_to_read = 0;
2282            let mut next_offset = offset;
2283            let end_offset = offset + bytes_len;
2284            _next_ordinal_to_read += 1;
2285            if next_offset >= end_offset {
2286                return Ok(());
2287            }
2288
2289            // Decode unknown envelopes for gaps in ordinals.
2290            while _next_ordinal_to_read < 1 {
2291                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2292                _next_ordinal_to_read += 1;
2293                next_offset += envelope_size;
2294            }
2295
2296            let next_out_of_line = decoder.next_out_of_line();
2297            let handles_before = decoder.remaining_handles();
2298            if let Some((inlined, num_bytes, num_handles)) =
2299                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2300            {
2301                let member_inline_size =
2302                    <GainUpdateMethod as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2303                if inlined != (member_inline_size <= 4) {
2304                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2305                }
2306                let inner_offset;
2307                let mut inner_depth = depth.clone();
2308                if inlined {
2309                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2310                    inner_offset = next_offset;
2311                } else {
2312                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2313                    inner_depth.increment()?;
2314                }
2315                let val_ref = self.how.get_or_insert_with(|| fidl::new_empty!(GainUpdateMethod, D));
2316                fidl::decode!(GainUpdateMethod, D, val_ref, decoder, inner_offset, inner_depth)?;
2317                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2318                {
2319                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2320                }
2321                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2322                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2323                }
2324            }
2325
2326            next_offset += envelope_size;
2327            _next_ordinal_to_read += 1;
2328            if next_offset >= end_offset {
2329                return Ok(());
2330            }
2331
2332            // Decode unknown envelopes for gaps in ordinals.
2333            while _next_ordinal_to_read < 2 {
2334                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2335                _next_ordinal_to_read += 1;
2336                next_offset += envelope_size;
2337            }
2338
2339            let next_out_of_line = decoder.next_out_of_line();
2340            let handles_before = decoder.remaining_handles();
2341            if let Some((inlined, num_bytes, num_handles)) =
2342                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2343            {
2344                let member_inline_size = <fidl_fuchsia_media2__common::RealTime as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2345                if inlined != (member_inline_size <= 4) {
2346                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2347                }
2348                let inner_offset;
2349                let mut inner_depth = depth.clone();
2350                if inlined {
2351                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2352                    inner_offset = next_offset;
2353                } else {
2354                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2355                    inner_depth.increment()?;
2356                }
2357                let val_ref = self.when.get_or_insert_with(|| {
2358                    fidl::new_empty!(fidl_fuchsia_media2__common::RealTime, D)
2359                });
2360                fidl::decode!(
2361                    fidl_fuchsia_media2__common::RealTime,
2362                    D,
2363                    val_ref,
2364                    decoder,
2365                    inner_offset,
2366                    inner_depth
2367                )?;
2368                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2369                {
2370                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2371                }
2372                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2373                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2374                }
2375            }
2376
2377            next_offset += envelope_size;
2378
2379            // Decode the remaining unknown envelopes.
2380            while next_offset < end_offset {
2381                _next_ordinal_to_read += 1;
2382                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2383                next_offset += envelope_size;
2384            }
2385
2386            Ok(())
2387        }
2388    }
2389
2390    impl GainControlSetMuteRequest {
2391        #[inline(always)]
2392        fn max_ordinal_present(&self) -> u64 {
2393            if let Some(_) = self.when {
2394                return 2;
2395            }
2396            if let Some(_) = self.muted {
2397                return 1;
2398            }
2399            0
2400        }
2401    }
2402
2403    impl fidl::encoding::ValueTypeMarker for GainControlSetMuteRequest {
2404        type Borrowed<'a> = &'a Self;
2405        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2406            value
2407        }
2408    }
2409
2410    unsafe impl fidl::encoding::TypeMarker for GainControlSetMuteRequest {
2411        type Owned = Self;
2412
2413        #[inline(always)]
2414        fn inline_align(_context: fidl::encoding::Context) -> usize {
2415            8
2416        }
2417
2418        #[inline(always)]
2419        fn inline_size(_context: fidl::encoding::Context) -> usize {
2420            16
2421        }
2422    }
2423
2424    unsafe impl<D: fidl::encoding::ResourceDialect>
2425        fidl::encoding::Encode<GainControlSetMuteRequest, D> for &GainControlSetMuteRequest
2426    {
2427        unsafe fn encode(
2428            self,
2429            encoder: &mut fidl::encoding::Encoder<'_, D>,
2430            offset: usize,
2431            mut depth: fidl::encoding::Depth,
2432        ) -> fidl::Result<()> {
2433            encoder.debug_check_bounds::<GainControlSetMuteRequest>(offset);
2434            // Vector header
2435            let max_ordinal: u64 = self.max_ordinal_present();
2436            encoder.write_num(max_ordinal, offset);
2437            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2438            // Calling encoder.out_of_line_offset(0) is not allowed.
2439            if max_ordinal == 0 {
2440                return Ok(());
2441            }
2442            depth.increment()?;
2443            let envelope_size = 8;
2444            let bytes_len = max_ordinal as usize * envelope_size;
2445            #[allow(unused_variables)]
2446            let offset = encoder.out_of_line_offset(bytes_len);
2447            let mut _prev_end_offset: usize = 0;
2448            if 1 > max_ordinal {
2449                return Ok(());
2450            }
2451
2452            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2453            // are envelope_size bytes.
2454            let cur_offset: usize = (1 - 1) * envelope_size;
2455
2456            // Zero reserved fields.
2457            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2458
2459            // Safety:
2460            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2461            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2462            //   envelope_size bytes, there is always sufficient room.
2463            fidl::encoding::encode_in_envelope_optional::<bool, D>(
2464                self.muted.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
2465                encoder,
2466                offset + cur_offset,
2467                depth,
2468            )?;
2469
2470            _prev_end_offset = cur_offset + envelope_size;
2471            if 2 > max_ordinal {
2472                return Ok(());
2473            }
2474
2475            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2476            // are envelope_size bytes.
2477            let cur_offset: usize = (2 - 1) * envelope_size;
2478
2479            // Zero reserved fields.
2480            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2481
2482            // Safety:
2483            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2484            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2485            //   envelope_size bytes, there is always sufficient room.
2486            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media2__common::RealTime, D>(
2487            self.when.as_ref().map(<fidl_fuchsia_media2__common::RealTime as fidl::encoding::ValueTypeMarker>::borrow),
2488            encoder, offset + cur_offset, depth
2489        )?;
2490
2491            _prev_end_offset = cur_offset + envelope_size;
2492
2493            Ok(())
2494        }
2495    }
2496
2497    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2498        for GainControlSetMuteRequest
2499    {
2500        #[inline(always)]
2501        fn new_empty() -> Self {
2502            Self::default()
2503        }
2504
2505        unsafe fn decode(
2506            &mut self,
2507            decoder: &mut fidl::encoding::Decoder<'_, D>,
2508            offset: usize,
2509            mut depth: fidl::encoding::Depth,
2510        ) -> fidl::Result<()> {
2511            decoder.debug_check_bounds::<Self>(offset);
2512            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2513                None => return Err(fidl::Error::NotNullable),
2514                Some(len) => len,
2515            };
2516            // Calling decoder.out_of_line_offset(0) is not allowed.
2517            if len == 0 {
2518                return Ok(());
2519            };
2520            depth.increment()?;
2521            let envelope_size = 8;
2522            let bytes_len = len * envelope_size;
2523            let offset = decoder.out_of_line_offset(bytes_len)?;
2524            // Decode the envelope for each type.
2525            let mut _next_ordinal_to_read = 0;
2526            let mut next_offset = offset;
2527            let end_offset = offset + bytes_len;
2528            _next_ordinal_to_read += 1;
2529            if next_offset >= end_offset {
2530                return Ok(());
2531            }
2532
2533            // Decode unknown envelopes for gaps in ordinals.
2534            while _next_ordinal_to_read < 1 {
2535                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2536                _next_ordinal_to_read += 1;
2537                next_offset += envelope_size;
2538            }
2539
2540            let next_out_of_line = decoder.next_out_of_line();
2541            let handles_before = decoder.remaining_handles();
2542            if let Some((inlined, num_bytes, num_handles)) =
2543                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2544            {
2545                let member_inline_size =
2546                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2547                if inlined != (member_inline_size <= 4) {
2548                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2549                }
2550                let inner_offset;
2551                let mut inner_depth = depth.clone();
2552                if inlined {
2553                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2554                    inner_offset = next_offset;
2555                } else {
2556                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2557                    inner_depth.increment()?;
2558                }
2559                let val_ref = self.muted.get_or_insert_with(|| fidl::new_empty!(bool, D));
2560                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2561                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2562                {
2563                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2564                }
2565                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2566                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2567                }
2568            }
2569
2570            next_offset += envelope_size;
2571            _next_ordinal_to_read += 1;
2572            if next_offset >= end_offset {
2573                return Ok(());
2574            }
2575
2576            // Decode unknown envelopes for gaps in ordinals.
2577            while _next_ordinal_to_read < 2 {
2578                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2579                _next_ordinal_to_read += 1;
2580                next_offset += envelope_size;
2581            }
2582
2583            let next_out_of_line = decoder.next_out_of_line();
2584            let handles_before = decoder.remaining_handles();
2585            if let Some((inlined, num_bytes, num_handles)) =
2586                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2587            {
2588                let member_inline_size = <fidl_fuchsia_media2__common::RealTime as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2589                if inlined != (member_inline_size <= 4) {
2590                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2591                }
2592                let inner_offset;
2593                let mut inner_depth = depth.clone();
2594                if inlined {
2595                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2596                    inner_offset = next_offset;
2597                } else {
2598                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2599                    inner_depth.increment()?;
2600                }
2601                let val_ref = self.when.get_or_insert_with(|| {
2602                    fidl::new_empty!(fidl_fuchsia_media2__common::RealTime, D)
2603                });
2604                fidl::decode!(
2605                    fidl_fuchsia_media2__common::RealTime,
2606                    D,
2607                    val_ref,
2608                    decoder,
2609                    inner_offset,
2610                    inner_depth
2611                )?;
2612                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2613                {
2614                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2615                }
2616                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2617                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2618                }
2619            }
2620
2621            next_offset += envelope_size;
2622
2623            // Decode the remaining unknown envelopes.
2624            while next_offset < end_offset {
2625                _next_ordinal_to_read += 1;
2626                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2627                next_offset += envelope_size;
2628            }
2629
2630            Ok(())
2631        }
2632    }
2633
2634    impl GainControlSetGainResponse {
2635        #[inline(always)]
2636        fn max_ordinal_present(&self) -> u64 {
2637            0
2638        }
2639    }
2640
2641    impl fidl::encoding::ValueTypeMarker for GainControlSetGainResponse {
2642        type Borrowed<'a> = &'a Self;
2643        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2644            value
2645        }
2646    }
2647
2648    unsafe impl fidl::encoding::TypeMarker for GainControlSetGainResponse {
2649        type Owned = Self;
2650
2651        #[inline(always)]
2652        fn inline_align(_context: fidl::encoding::Context) -> usize {
2653            8
2654        }
2655
2656        #[inline(always)]
2657        fn inline_size(_context: fidl::encoding::Context) -> usize {
2658            16
2659        }
2660    }
2661
2662    unsafe impl<D: fidl::encoding::ResourceDialect>
2663        fidl::encoding::Encode<GainControlSetGainResponse, D> for &GainControlSetGainResponse
2664    {
2665        unsafe fn encode(
2666            self,
2667            encoder: &mut fidl::encoding::Encoder<'_, D>,
2668            offset: usize,
2669            mut depth: fidl::encoding::Depth,
2670        ) -> fidl::Result<()> {
2671            encoder.debug_check_bounds::<GainControlSetGainResponse>(offset);
2672            // Vector header
2673            let max_ordinal: u64 = self.max_ordinal_present();
2674            encoder.write_num(max_ordinal, offset);
2675            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2676            // Calling encoder.out_of_line_offset(0) is not allowed.
2677            if max_ordinal == 0 {
2678                return Ok(());
2679            }
2680            depth.increment()?;
2681            let envelope_size = 8;
2682            let bytes_len = max_ordinal as usize * envelope_size;
2683            #[allow(unused_variables)]
2684            let offset = encoder.out_of_line_offset(bytes_len);
2685            let mut _prev_end_offset: usize = 0;
2686
2687            Ok(())
2688        }
2689    }
2690
2691    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2692        for GainControlSetGainResponse
2693    {
2694        #[inline(always)]
2695        fn new_empty() -> Self {
2696            Self::default()
2697        }
2698
2699        unsafe fn decode(
2700            &mut self,
2701            decoder: &mut fidl::encoding::Decoder<'_, D>,
2702            offset: usize,
2703            mut depth: fidl::encoding::Depth,
2704        ) -> fidl::Result<()> {
2705            decoder.debug_check_bounds::<Self>(offset);
2706            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2707                None => return Err(fidl::Error::NotNullable),
2708                Some(len) => len,
2709            };
2710            // Calling decoder.out_of_line_offset(0) is not allowed.
2711            if len == 0 {
2712                return Ok(());
2713            };
2714            depth.increment()?;
2715            let envelope_size = 8;
2716            let bytes_len = len * envelope_size;
2717            let offset = decoder.out_of_line_offset(bytes_len)?;
2718            // Decode the envelope for each type.
2719            let mut _next_ordinal_to_read = 0;
2720            let mut next_offset = offset;
2721            let end_offset = offset + bytes_len;
2722
2723            // Decode the remaining unknown envelopes.
2724            while next_offset < end_offset {
2725                _next_ordinal_to_read += 1;
2726                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2727                next_offset += envelope_size;
2728            }
2729
2730            Ok(())
2731        }
2732    }
2733
2734    impl GainControlSetMuteResponse {
2735        #[inline(always)]
2736        fn max_ordinal_present(&self) -> u64 {
2737            0
2738        }
2739    }
2740
2741    impl fidl::encoding::ValueTypeMarker for GainControlSetMuteResponse {
2742        type Borrowed<'a> = &'a Self;
2743        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2744            value
2745        }
2746    }
2747
2748    unsafe impl fidl::encoding::TypeMarker for GainControlSetMuteResponse {
2749        type Owned = Self;
2750
2751        #[inline(always)]
2752        fn inline_align(_context: fidl::encoding::Context) -> usize {
2753            8
2754        }
2755
2756        #[inline(always)]
2757        fn inline_size(_context: fidl::encoding::Context) -> usize {
2758            16
2759        }
2760    }
2761
2762    unsafe impl<D: fidl::encoding::ResourceDialect>
2763        fidl::encoding::Encode<GainControlSetMuteResponse, D> for &GainControlSetMuteResponse
2764    {
2765        unsafe fn encode(
2766            self,
2767            encoder: &mut fidl::encoding::Encoder<'_, D>,
2768            offset: usize,
2769            mut depth: fidl::encoding::Depth,
2770        ) -> fidl::Result<()> {
2771            encoder.debug_check_bounds::<GainControlSetMuteResponse>(offset);
2772            // Vector header
2773            let max_ordinal: u64 = self.max_ordinal_present();
2774            encoder.write_num(max_ordinal, offset);
2775            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2776            // Calling encoder.out_of_line_offset(0) is not allowed.
2777            if max_ordinal == 0 {
2778                return Ok(());
2779            }
2780            depth.increment()?;
2781            let envelope_size = 8;
2782            let bytes_len = max_ordinal as usize * envelope_size;
2783            #[allow(unused_variables)]
2784            let offset = encoder.out_of_line_offset(bytes_len);
2785            let mut _prev_end_offset: usize = 0;
2786
2787            Ok(())
2788        }
2789    }
2790
2791    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2792        for GainControlSetMuteResponse
2793    {
2794        #[inline(always)]
2795        fn new_empty() -> Self {
2796            Self::default()
2797        }
2798
2799        unsafe fn decode(
2800            &mut self,
2801            decoder: &mut fidl::encoding::Decoder<'_, D>,
2802            offset: usize,
2803            mut depth: fidl::encoding::Depth,
2804        ) -> fidl::Result<()> {
2805            decoder.debug_check_bounds::<Self>(offset);
2806            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2807                None => return Err(fidl::Error::NotNullable),
2808                Some(len) => len,
2809            };
2810            // Calling decoder.out_of_line_offset(0) is not allowed.
2811            if len == 0 {
2812                return Ok(());
2813            };
2814            depth.increment()?;
2815            let envelope_size = 8;
2816            let bytes_len = len * envelope_size;
2817            let offset = decoder.out_of_line_offset(bytes_len)?;
2818            // Decode the envelope for each type.
2819            let mut _next_ordinal_to_read = 0;
2820            let mut next_offset = offset;
2821            let end_offset = offset + bytes_len;
2822
2823            // Decode the remaining unknown envelopes.
2824            while next_offset < end_offset {
2825                _next_ordinal_to_read += 1;
2826                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2827                next_offset += envelope_size;
2828            }
2829
2830            Ok(())
2831        }
2832    }
2833
2834    impl Packet {
2835        #[inline(always)]
2836        fn max_ordinal_present(&self) -> u64 {
2837            if let Some(_) = self.encryption_properties {
2838                return 7;
2839            }
2840            if let Some(_) = self.back_frames_to_drop {
2841                return 6;
2842            }
2843            if let Some(_) = self.front_frames_to_drop {
2844                return 5;
2845            }
2846            if let Some(_) = self.flags {
2847                return 4;
2848            }
2849            if let Some(_) = self.capture_timestamp {
2850                return 3;
2851            }
2852            if let Some(_) = self.timestamp {
2853                return 2;
2854            }
2855            if let Some(_) = self.payload {
2856                return 1;
2857            }
2858            0
2859        }
2860    }
2861
2862    impl fidl::encoding::ValueTypeMarker for Packet {
2863        type Borrowed<'a> = &'a Self;
2864        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2865            value
2866        }
2867    }
2868
2869    unsafe impl fidl::encoding::TypeMarker for Packet {
2870        type Owned = Self;
2871
2872        #[inline(always)]
2873        fn inline_align(_context: fidl::encoding::Context) -> usize {
2874            8
2875        }
2876
2877        #[inline(always)]
2878        fn inline_size(_context: fidl::encoding::Context) -> usize {
2879            16
2880        }
2881    }
2882
2883    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Packet, D> for &Packet {
2884        unsafe fn encode(
2885            self,
2886            encoder: &mut fidl::encoding::Encoder<'_, D>,
2887            offset: usize,
2888            mut depth: fidl::encoding::Depth,
2889        ) -> fidl::Result<()> {
2890            encoder.debug_check_bounds::<Packet>(offset);
2891            // Vector header
2892            let max_ordinal: u64 = self.max_ordinal_present();
2893            encoder.write_num(max_ordinal, offset);
2894            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2895            // Calling encoder.out_of_line_offset(0) is not allowed.
2896            if max_ordinal == 0 {
2897                return Ok(());
2898            }
2899            depth.increment()?;
2900            let envelope_size = 8;
2901            let bytes_len = max_ordinal as usize * envelope_size;
2902            #[allow(unused_variables)]
2903            let offset = encoder.out_of_line_offset(bytes_len);
2904            let mut _prev_end_offset: usize = 0;
2905            if 1 > max_ordinal {
2906                return Ok(());
2907            }
2908
2909            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2910            // are envelope_size bytes.
2911            let cur_offset: usize = (1 - 1) * envelope_size;
2912
2913            // Zero reserved fields.
2914            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2915
2916            // Safety:
2917            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2918            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2919            //   envelope_size bytes, there is always sufficient room.
2920            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media2__common::PayloadRange, D>(
2921            self.payload.as_ref().map(<fidl_fuchsia_media2__common::PayloadRange as fidl::encoding::ValueTypeMarker>::borrow),
2922            encoder, offset + cur_offset, depth
2923        )?;
2924
2925            _prev_end_offset = cur_offset + envelope_size;
2926            if 2 > max_ordinal {
2927                return Ok(());
2928            }
2929
2930            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2931            // are envelope_size bytes.
2932            let cur_offset: usize = (2 - 1) * envelope_size;
2933
2934            // Zero reserved fields.
2935            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2936
2937            // Safety:
2938            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2939            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2940            //   envelope_size bytes, there is always sufficient room.
2941            fidl::encoding::encode_in_envelope_optional::<Timestamp, D>(
2942                self.timestamp.as_ref().map(<Timestamp as fidl::encoding::ValueTypeMarker>::borrow),
2943                encoder,
2944                offset + cur_offset,
2945                depth,
2946            )?;
2947
2948            _prev_end_offset = cur_offset + envelope_size;
2949            if 3 > max_ordinal {
2950                return Ok(());
2951            }
2952
2953            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2954            // are envelope_size bytes.
2955            let cur_offset: usize = (3 - 1) * envelope_size;
2956
2957            // Zero reserved fields.
2958            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2959
2960            // Safety:
2961            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2962            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2963            //   envelope_size bytes, there is always sufficient room.
2964            fidl::encoding::encode_in_envelope_optional::<i64, D>(
2965                self.capture_timestamp
2966                    .as_ref()
2967                    .map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
2968                encoder,
2969                offset + cur_offset,
2970                depth,
2971            )?;
2972
2973            _prev_end_offset = cur_offset + envelope_size;
2974            if 4 > max_ordinal {
2975                return Ok(());
2976            }
2977
2978            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2979            // are envelope_size bytes.
2980            let cur_offset: usize = (4 - 1) * envelope_size;
2981
2982            // Zero reserved fields.
2983            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2984
2985            // Safety:
2986            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2987            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2988            //   envelope_size bytes, there is always sufficient room.
2989            fidl::encoding::encode_in_envelope_optional::<PacketFlags, D>(
2990                self.flags.as_ref().map(<PacketFlags as fidl::encoding::ValueTypeMarker>::borrow),
2991                encoder,
2992                offset + cur_offset,
2993                depth,
2994            )?;
2995
2996            _prev_end_offset = cur_offset + envelope_size;
2997            if 5 > max_ordinal {
2998                return Ok(());
2999            }
3000
3001            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3002            // are envelope_size bytes.
3003            let cur_offset: usize = (5 - 1) * envelope_size;
3004
3005            // Zero reserved fields.
3006            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3007
3008            // Safety:
3009            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3010            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3011            //   envelope_size bytes, there is always sufficient room.
3012            fidl::encoding::encode_in_envelope_optional::<u32, D>(
3013                self.front_frames_to_drop
3014                    .as_ref()
3015                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
3016                encoder,
3017                offset + cur_offset,
3018                depth,
3019            )?;
3020
3021            _prev_end_offset = cur_offset + envelope_size;
3022            if 6 > max_ordinal {
3023                return Ok(());
3024            }
3025
3026            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3027            // are envelope_size bytes.
3028            let cur_offset: usize = (6 - 1) * envelope_size;
3029
3030            // Zero reserved fields.
3031            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3032
3033            // Safety:
3034            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3035            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3036            //   envelope_size bytes, there is always sufficient room.
3037            fidl::encoding::encode_in_envelope_optional::<u32, D>(
3038                self.back_frames_to_drop
3039                    .as_ref()
3040                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
3041                encoder,
3042                offset + cur_offset,
3043                depth,
3044            )?;
3045
3046            _prev_end_offset = cur_offset + envelope_size;
3047            if 7 > max_ordinal {
3048                return Ok(());
3049            }
3050
3051            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3052            // are envelope_size bytes.
3053            let cur_offset: usize = (7 - 1) * envelope_size;
3054
3055            // Zero reserved fields.
3056            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3057
3058            // Safety:
3059            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3060            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3061            //   envelope_size bytes, there is always sufficient room.
3062            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_drm__common::PacketEncryptionProperties, D>(
3063            self.encryption_properties.as_ref().map(<fidl_fuchsia_drm__common::PacketEncryptionProperties as fidl::encoding::ValueTypeMarker>::borrow),
3064            encoder, offset + cur_offset, depth
3065        )?;
3066
3067            _prev_end_offset = cur_offset + envelope_size;
3068
3069            Ok(())
3070        }
3071    }
3072
3073    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Packet {
3074        #[inline(always)]
3075        fn new_empty() -> Self {
3076            Self::default()
3077        }
3078
3079        unsafe fn decode(
3080            &mut self,
3081            decoder: &mut fidl::encoding::Decoder<'_, D>,
3082            offset: usize,
3083            mut depth: fidl::encoding::Depth,
3084        ) -> fidl::Result<()> {
3085            decoder.debug_check_bounds::<Self>(offset);
3086            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3087                None => return Err(fidl::Error::NotNullable),
3088                Some(len) => len,
3089            };
3090            // Calling decoder.out_of_line_offset(0) is not allowed.
3091            if len == 0 {
3092                return Ok(());
3093            };
3094            depth.increment()?;
3095            let envelope_size = 8;
3096            let bytes_len = len * envelope_size;
3097            let offset = decoder.out_of_line_offset(bytes_len)?;
3098            // Decode the envelope for each type.
3099            let mut _next_ordinal_to_read = 0;
3100            let mut next_offset = offset;
3101            let end_offset = offset + bytes_len;
3102            _next_ordinal_to_read += 1;
3103            if next_offset >= end_offset {
3104                return Ok(());
3105            }
3106
3107            // Decode unknown envelopes for gaps in ordinals.
3108            while _next_ordinal_to_read < 1 {
3109                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3110                _next_ordinal_to_read += 1;
3111                next_offset += envelope_size;
3112            }
3113
3114            let next_out_of_line = decoder.next_out_of_line();
3115            let handles_before = decoder.remaining_handles();
3116            if let Some((inlined, num_bytes, num_handles)) =
3117                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3118            {
3119                let member_inline_size = <fidl_fuchsia_media2__common::PayloadRange as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3120                if inlined != (member_inline_size <= 4) {
3121                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3122                }
3123                let inner_offset;
3124                let mut inner_depth = depth.clone();
3125                if inlined {
3126                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3127                    inner_offset = next_offset;
3128                } else {
3129                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3130                    inner_depth.increment()?;
3131                }
3132                let val_ref = self.payload.get_or_insert_with(|| {
3133                    fidl::new_empty!(fidl_fuchsia_media2__common::PayloadRange, D)
3134                });
3135                fidl::decode!(
3136                    fidl_fuchsia_media2__common::PayloadRange,
3137                    D,
3138                    val_ref,
3139                    decoder,
3140                    inner_offset,
3141                    inner_depth
3142                )?;
3143                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3144                {
3145                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3146                }
3147                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3148                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3149                }
3150            }
3151
3152            next_offset += envelope_size;
3153            _next_ordinal_to_read += 1;
3154            if next_offset >= end_offset {
3155                return Ok(());
3156            }
3157
3158            // Decode unknown envelopes for gaps in ordinals.
3159            while _next_ordinal_to_read < 2 {
3160                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3161                _next_ordinal_to_read += 1;
3162                next_offset += envelope_size;
3163            }
3164
3165            let next_out_of_line = decoder.next_out_of_line();
3166            let handles_before = decoder.remaining_handles();
3167            if let Some((inlined, num_bytes, num_handles)) =
3168                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3169            {
3170                let member_inline_size =
3171                    <Timestamp as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3172                if inlined != (member_inline_size <= 4) {
3173                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3174                }
3175                let inner_offset;
3176                let mut inner_depth = depth.clone();
3177                if inlined {
3178                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3179                    inner_offset = next_offset;
3180                } else {
3181                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3182                    inner_depth.increment()?;
3183                }
3184                let val_ref = self.timestamp.get_or_insert_with(|| fidl::new_empty!(Timestamp, D));
3185                fidl::decode!(Timestamp, D, val_ref, decoder, inner_offset, inner_depth)?;
3186                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3187                {
3188                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3189                }
3190                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3191                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3192                }
3193            }
3194
3195            next_offset += envelope_size;
3196            _next_ordinal_to_read += 1;
3197            if next_offset >= end_offset {
3198                return Ok(());
3199            }
3200
3201            // Decode unknown envelopes for gaps in ordinals.
3202            while _next_ordinal_to_read < 3 {
3203                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3204                _next_ordinal_to_read += 1;
3205                next_offset += envelope_size;
3206            }
3207
3208            let next_out_of_line = decoder.next_out_of_line();
3209            let handles_before = decoder.remaining_handles();
3210            if let Some((inlined, num_bytes, num_handles)) =
3211                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3212            {
3213                let member_inline_size =
3214                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3215                if inlined != (member_inline_size <= 4) {
3216                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3217                }
3218                let inner_offset;
3219                let mut inner_depth = depth.clone();
3220                if inlined {
3221                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3222                    inner_offset = next_offset;
3223                } else {
3224                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3225                    inner_depth.increment()?;
3226                }
3227                let val_ref =
3228                    self.capture_timestamp.get_or_insert_with(|| fidl::new_empty!(i64, D));
3229                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
3230                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3231                {
3232                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3233                }
3234                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3235                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3236                }
3237            }
3238
3239            next_offset += envelope_size;
3240            _next_ordinal_to_read += 1;
3241            if next_offset >= end_offset {
3242                return Ok(());
3243            }
3244
3245            // Decode unknown envelopes for gaps in ordinals.
3246            while _next_ordinal_to_read < 4 {
3247                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3248                _next_ordinal_to_read += 1;
3249                next_offset += envelope_size;
3250            }
3251
3252            let next_out_of_line = decoder.next_out_of_line();
3253            let handles_before = decoder.remaining_handles();
3254            if let Some((inlined, num_bytes, num_handles)) =
3255                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3256            {
3257                let member_inline_size =
3258                    <PacketFlags as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3259                if inlined != (member_inline_size <= 4) {
3260                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3261                }
3262                let inner_offset;
3263                let mut inner_depth = depth.clone();
3264                if inlined {
3265                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3266                    inner_offset = next_offset;
3267                } else {
3268                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3269                    inner_depth.increment()?;
3270                }
3271                let val_ref = self.flags.get_or_insert_with(|| fidl::new_empty!(PacketFlags, D));
3272                fidl::decode!(PacketFlags, D, val_ref, decoder, inner_offset, inner_depth)?;
3273                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3274                {
3275                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3276                }
3277                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3278                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3279                }
3280            }
3281
3282            next_offset += envelope_size;
3283            _next_ordinal_to_read += 1;
3284            if next_offset >= end_offset {
3285                return Ok(());
3286            }
3287
3288            // Decode unknown envelopes for gaps in ordinals.
3289            while _next_ordinal_to_read < 5 {
3290                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3291                _next_ordinal_to_read += 1;
3292                next_offset += envelope_size;
3293            }
3294
3295            let next_out_of_line = decoder.next_out_of_line();
3296            let handles_before = decoder.remaining_handles();
3297            if let Some((inlined, num_bytes, num_handles)) =
3298                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3299            {
3300                let member_inline_size =
3301                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3302                if inlined != (member_inline_size <= 4) {
3303                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3304                }
3305                let inner_offset;
3306                let mut inner_depth = depth.clone();
3307                if inlined {
3308                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3309                    inner_offset = next_offset;
3310                } else {
3311                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3312                    inner_depth.increment()?;
3313                }
3314                let val_ref =
3315                    self.front_frames_to_drop.get_or_insert_with(|| fidl::new_empty!(u32, D));
3316                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3317                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3318                {
3319                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3320                }
3321                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3322                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3323                }
3324            }
3325
3326            next_offset += envelope_size;
3327            _next_ordinal_to_read += 1;
3328            if next_offset >= end_offset {
3329                return Ok(());
3330            }
3331
3332            // Decode unknown envelopes for gaps in ordinals.
3333            while _next_ordinal_to_read < 6 {
3334                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3335                _next_ordinal_to_read += 1;
3336                next_offset += envelope_size;
3337            }
3338
3339            let next_out_of_line = decoder.next_out_of_line();
3340            let handles_before = decoder.remaining_handles();
3341            if let Some((inlined, num_bytes, num_handles)) =
3342                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3343            {
3344                let member_inline_size =
3345                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3346                if inlined != (member_inline_size <= 4) {
3347                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3348                }
3349                let inner_offset;
3350                let mut inner_depth = depth.clone();
3351                if inlined {
3352                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3353                    inner_offset = next_offset;
3354                } else {
3355                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3356                    inner_depth.increment()?;
3357                }
3358                let val_ref =
3359                    self.back_frames_to_drop.get_or_insert_with(|| fidl::new_empty!(u32, D));
3360                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
3361                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3362                {
3363                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3364                }
3365                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3366                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3367                }
3368            }
3369
3370            next_offset += envelope_size;
3371            _next_ordinal_to_read += 1;
3372            if next_offset >= end_offset {
3373                return Ok(());
3374            }
3375
3376            // Decode unknown envelopes for gaps in ordinals.
3377            while _next_ordinal_to_read < 7 {
3378                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3379                _next_ordinal_to_read += 1;
3380                next_offset += envelope_size;
3381            }
3382
3383            let next_out_of_line = decoder.next_out_of_line();
3384            let handles_before = decoder.remaining_handles();
3385            if let Some((inlined, num_bytes, num_handles)) =
3386                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3387            {
3388                let member_inline_size = <fidl_fuchsia_drm__common::PacketEncryptionProperties as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3389                if inlined != (member_inline_size <= 4) {
3390                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3391                }
3392                let inner_offset;
3393                let mut inner_depth = depth.clone();
3394                if inlined {
3395                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3396                    inner_offset = next_offset;
3397                } else {
3398                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3399                    inner_depth.increment()?;
3400                }
3401                let val_ref = self.encryption_properties.get_or_insert_with(|| {
3402                    fidl::new_empty!(fidl_fuchsia_drm__common::PacketEncryptionProperties, D)
3403                });
3404                fidl::decode!(
3405                    fidl_fuchsia_drm__common::PacketEncryptionProperties,
3406                    D,
3407                    val_ref,
3408                    decoder,
3409                    inner_offset,
3410                    inner_depth
3411                )?;
3412                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3413                {
3414                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3415                }
3416                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3417                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3418                }
3419            }
3420
3421            next_offset += envelope_size;
3422
3423            // Decode the remaining unknown envelopes.
3424            while next_offset < end_offset {
3425                _next_ordinal_to_read += 1;
3426                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3427                next_offset += envelope_size;
3428            }
3429
3430            Ok(())
3431        }
3432    }
3433
3434    impl RampFunctionLinearSlope {
3435        #[inline(always)]
3436        fn max_ordinal_present(&self) -> u64 {
3437            0
3438        }
3439    }
3440
3441    impl fidl::encoding::ValueTypeMarker for RampFunctionLinearSlope {
3442        type Borrowed<'a> = &'a Self;
3443        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3444            value
3445        }
3446    }
3447
3448    unsafe impl fidl::encoding::TypeMarker for RampFunctionLinearSlope {
3449        type Owned = Self;
3450
3451        #[inline(always)]
3452        fn inline_align(_context: fidl::encoding::Context) -> usize {
3453            8
3454        }
3455
3456        #[inline(always)]
3457        fn inline_size(_context: fidl::encoding::Context) -> usize {
3458            16
3459        }
3460    }
3461
3462    unsafe impl<D: fidl::encoding::ResourceDialect>
3463        fidl::encoding::Encode<RampFunctionLinearSlope, D> for &RampFunctionLinearSlope
3464    {
3465        unsafe fn encode(
3466            self,
3467            encoder: &mut fidl::encoding::Encoder<'_, D>,
3468            offset: usize,
3469            mut depth: fidl::encoding::Depth,
3470        ) -> fidl::Result<()> {
3471            encoder.debug_check_bounds::<RampFunctionLinearSlope>(offset);
3472            // Vector header
3473            let max_ordinal: u64 = self.max_ordinal_present();
3474            encoder.write_num(max_ordinal, offset);
3475            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3476            // Calling encoder.out_of_line_offset(0) is not allowed.
3477            if max_ordinal == 0 {
3478                return Ok(());
3479            }
3480            depth.increment()?;
3481            let envelope_size = 8;
3482            let bytes_len = max_ordinal as usize * envelope_size;
3483            #[allow(unused_variables)]
3484            let offset = encoder.out_of_line_offset(bytes_len);
3485            let mut _prev_end_offset: usize = 0;
3486
3487            Ok(())
3488        }
3489    }
3490
3491    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3492        for RampFunctionLinearSlope
3493    {
3494        #[inline(always)]
3495        fn new_empty() -> Self {
3496            Self::default()
3497        }
3498
3499        unsafe fn decode(
3500            &mut self,
3501            decoder: &mut fidl::encoding::Decoder<'_, D>,
3502            offset: usize,
3503            mut depth: fidl::encoding::Depth,
3504        ) -> fidl::Result<()> {
3505            decoder.debug_check_bounds::<Self>(offset);
3506            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3507                None => return Err(fidl::Error::NotNullable),
3508                Some(len) => len,
3509            };
3510            // Calling decoder.out_of_line_offset(0) is not allowed.
3511            if len == 0 {
3512                return Ok(());
3513            };
3514            depth.increment()?;
3515            let envelope_size = 8;
3516            let bytes_len = len * envelope_size;
3517            let offset = decoder.out_of_line_offset(bytes_len)?;
3518            // Decode the envelope for each type.
3519            let mut _next_ordinal_to_read = 0;
3520            let mut next_offset = offset;
3521            let end_offset = offset + bytes_len;
3522
3523            // Decode the remaining unknown envelopes.
3524            while next_offset < end_offset {
3525                _next_ordinal_to_read += 1;
3526                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3527                next_offset += envelope_size;
3528            }
3529
3530            Ok(())
3531        }
3532    }
3533
3534    impl RampedGain {
3535        #[inline(always)]
3536        fn max_ordinal_present(&self) -> u64 {
3537            if let Some(_) = self.function {
3538                return 3;
3539            }
3540            if let Some(_) = self.duration {
3541                return 2;
3542            }
3543            if let Some(_) = self.target_gain_db {
3544                return 1;
3545            }
3546            0
3547        }
3548    }
3549
3550    impl fidl::encoding::ValueTypeMarker for RampedGain {
3551        type Borrowed<'a> = &'a Self;
3552        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3553            value
3554        }
3555    }
3556
3557    unsafe impl fidl::encoding::TypeMarker for RampedGain {
3558        type Owned = Self;
3559
3560        #[inline(always)]
3561        fn inline_align(_context: fidl::encoding::Context) -> usize {
3562            8
3563        }
3564
3565        #[inline(always)]
3566        fn inline_size(_context: fidl::encoding::Context) -> usize {
3567            16
3568        }
3569    }
3570
3571    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RampedGain, D>
3572        for &RampedGain
3573    {
3574        unsafe fn encode(
3575            self,
3576            encoder: &mut fidl::encoding::Encoder<'_, D>,
3577            offset: usize,
3578            mut depth: fidl::encoding::Depth,
3579        ) -> fidl::Result<()> {
3580            encoder.debug_check_bounds::<RampedGain>(offset);
3581            // Vector header
3582            let max_ordinal: u64 = self.max_ordinal_present();
3583            encoder.write_num(max_ordinal, offset);
3584            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3585            // Calling encoder.out_of_line_offset(0) is not allowed.
3586            if max_ordinal == 0 {
3587                return Ok(());
3588            }
3589            depth.increment()?;
3590            let envelope_size = 8;
3591            let bytes_len = max_ordinal as usize * envelope_size;
3592            #[allow(unused_variables)]
3593            let offset = encoder.out_of_line_offset(bytes_len);
3594            let mut _prev_end_offset: usize = 0;
3595            if 1 > max_ordinal {
3596                return Ok(());
3597            }
3598
3599            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3600            // are envelope_size bytes.
3601            let cur_offset: usize = (1 - 1) * envelope_size;
3602
3603            // Zero reserved fields.
3604            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3605
3606            // Safety:
3607            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3608            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3609            //   envelope_size bytes, there is always sufficient room.
3610            fidl::encoding::encode_in_envelope_optional::<f32, D>(
3611                self.target_gain_db.as_ref().map(<f32 as fidl::encoding::ValueTypeMarker>::borrow),
3612                encoder,
3613                offset + cur_offset,
3614                depth,
3615            )?;
3616
3617            _prev_end_offset = cur_offset + envelope_size;
3618            if 2 > max_ordinal {
3619                return Ok(());
3620            }
3621
3622            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3623            // are envelope_size bytes.
3624            let cur_offset: usize = (2 - 1) * envelope_size;
3625
3626            // Zero reserved fields.
3627            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3628
3629            // Safety:
3630            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3631            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3632            //   envelope_size bytes, there is always sufficient room.
3633            fidl::encoding::encode_in_envelope_optional::<i64, D>(
3634                self.duration.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
3635                encoder,
3636                offset + cur_offset,
3637                depth,
3638            )?;
3639
3640            _prev_end_offset = cur_offset + envelope_size;
3641            if 3 > max_ordinal {
3642                return Ok(());
3643            }
3644
3645            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3646            // are envelope_size bytes.
3647            let cur_offset: usize = (3 - 1) * envelope_size;
3648
3649            // Zero reserved fields.
3650            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3651
3652            // Safety:
3653            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3654            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3655            //   envelope_size bytes, there is always sufficient room.
3656            fidl::encoding::encode_in_envelope_optional::<RampFunction, D>(
3657                self.function
3658                    .as_ref()
3659                    .map(<RampFunction as fidl::encoding::ValueTypeMarker>::borrow),
3660                encoder,
3661                offset + cur_offset,
3662                depth,
3663            )?;
3664
3665            _prev_end_offset = cur_offset + envelope_size;
3666
3667            Ok(())
3668        }
3669    }
3670
3671    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RampedGain {
3672        #[inline(always)]
3673        fn new_empty() -> Self {
3674            Self::default()
3675        }
3676
3677        unsafe fn decode(
3678            &mut self,
3679            decoder: &mut fidl::encoding::Decoder<'_, D>,
3680            offset: usize,
3681            mut depth: fidl::encoding::Depth,
3682        ) -> fidl::Result<()> {
3683            decoder.debug_check_bounds::<Self>(offset);
3684            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3685                None => return Err(fidl::Error::NotNullable),
3686                Some(len) => len,
3687            };
3688            // Calling decoder.out_of_line_offset(0) is not allowed.
3689            if len == 0 {
3690                return Ok(());
3691            };
3692            depth.increment()?;
3693            let envelope_size = 8;
3694            let bytes_len = len * envelope_size;
3695            let offset = decoder.out_of_line_offset(bytes_len)?;
3696            // Decode the envelope for each type.
3697            let mut _next_ordinal_to_read = 0;
3698            let mut next_offset = offset;
3699            let end_offset = offset + bytes_len;
3700            _next_ordinal_to_read += 1;
3701            if next_offset >= end_offset {
3702                return Ok(());
3703            }
3704
3705            // Decode unknown envelopes for gaps in ordinals.
3706            while _next_ordinal_to_read < 1 {
3707                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3708                _next_ordinal_to_read += 1;
3709                next_offset += envelope_size;
3710            }
3711
3712            let next_out_of_line = decoder.next_out_of_line();
3713            let handles_before = decoder.remaining_handles();
3714            if let Some((inlined, num_bytes, num_handles)) =
3715                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3716            {
3717                let member_inline_size =
3718                    <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3719                if inlined != (member_inline_size <= 4) {
3720                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3721                }
3722                let inner_offset;
3723                let mut inner_depth = depth.clone();
3724                if inlined {
3725                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3726                    inner_offset = next_offset;
3727                } else {
3728                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3729                    inner_depth.increment()?;
3730                }
3731                let val_ref = self.target_gain_db.get_or_insert_with(|| fidl::new_empty!(f32, D));
3732                fidl::decode!(f32, D, val_ref, decoder, inner_offset, inner_depth)?;
3733                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3734                {
3735                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3736                }
3737                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3738                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3739                }
3740            }
3741
3742            next_offset += envelope_size;
3743            _next_ordinal_to_read += 1;
3744            if next_offset >= end_offset {
3745                return Ok(());
3746            }
3747
3748            // Decode unknown envelopes for gaps in ordinals.
3749            while _next_ordinal_to_read < 2 {
3750                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3751                _next_ordinal_to_read += 1;
3752                next_offset += envelope_size;
3753            }
3754
3755            let next_out_of_line = decoder.next_out_of_line();
3756            let handles_before = decoder.remaining_handles();
3757            if let Some((inlined, num_bytes, num_handles)) =
3758                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3759            {
3760                let member_inline_size =
3761                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3762                if inlined != (member_inline_size <= 4) {
3763                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3764                }
3765                let inner_offset;
3766                let mut inner_depth = depth.clone();
3767                if inlined {
3768                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3769                    inner_offset = next_offset;
3770                } else {
3771                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3772                    inner_depth.increment()?;
3773                }
3774                let val_ref = self.duration.get_or_insert_with(|| fidl::new_empty!(i64, D));
3775                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
3776                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3777                {
3778                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3779                }
3780                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3781                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3782                }
3783            }
3784
3785            next_offset += envelope_size;
3786            _next_ordinal_to_read += 1;
3787            if next_offset >= end_offset {
3788                return Ok(());
3789            }
3790
3791            // Decode unknown envelopes for gaps in ordinals.
3792            while _next_ordinal_to_read < 3 {
3793                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3794                _next_ordinal_to_read += 1;
3795                next_offset += envelope_size;
3796            }
3797
3798            let next_out_of_line = decoder.next_out_of_line();
3799            let handles_before = decoder.remaining_handles();
3800            if let Some((inlined, num_bytes, num_handles)) =
3801                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3802            {
3803                let member_inline_size =
3804                    <RampFunction as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3805                if inlined != (member_inline_size <= 4) {
3806                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3807                }
3808                let inner_offset;
3809                let mut inner_depth = depth.clone();
3810                if inlined {
3811                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3812                    inner_offset = next_offset;
3813                } else {
3814                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3815                    inner_depth.increment()?;
3816                }
3817                let val_ref =
3818                    self.function.get_or_insert_with(|| fidl::new_empty!(RampFunction, D));
3819                fidl::decode!(RampFunction, D, val_ref, decoder, inner_offset, inner_depth)?;
3820                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3821                {
3822                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3823                }
3824                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3825                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3826                }
3827            }
3828
3829            next_offset += envelope_size;
3830
3831            // Decode the remaining unknown envelopes.
3832            while next_offset < end_offset {
3833                _next_ordinal_to_read += 1;
3834                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3835                next_offset += envelope_size;
3836            }
3837
3838            Ok(())
3839        }
3840    }
3841
3842    impl StreamSinkOnWillCloseRequest {
3843        #[inline(always)]
3844        fn max_ordinal_present(&self) -> u64 {
3845            if let Some(_) = self.reason {
3846                return 1;
3847            }
3848            0
3849        }
3850    }
3851
3852    impl fidl::encoding::ValueTypeMarker for StreamSinkOnWillCloseRequest {
3853        type Borrowed<'a> = &'a Self;
3854        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3855            value
3856        }
3857    }
3858
3859    unsafe impl fidl::encoding::TypeMarker for StreamSinkOnWillCloseRequest {
3860        type Owned = Self;
3861
3862        #[inline(always)]
3863        fn inline_align(_context: fidl::encoding::Context) -> usize {
3864            8
3865        }
3866
3867        #[inline(always)]
3868        fn inline_size(_context: fidl::encoding::Context) -> usize {
3869            16
3870        }
3871    }
3872
3873    unsafe impl<D: fidl::encoding::ResourceDialect>
3874        fidl::encoding::Encode<StreamSinkOnWillCloseRequest, D> for &StreamSinkOnWillCloseRequest
3875    {
3876        unsafe fn encode(
3877            self,
3878            encoder: &mut fidl::encoding::Encoder<'_, D>,
3879            offset: usize,
3880            mut depth: fidl::encoding::Depth,
3881        ) -> fidl::Result<()> {
3882            encoder.debug_check_bounds::<StreamSinkOnWillCloseRequest>(offset);
3883            // Vector header
3884            let max_ordinal: u64 = self.max_ordinal_present();
3885            encoder.write_num(max_ordinal, offset);
3886            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3887            // Calling encoder.out_of_line_offset(0) is not allowed.
3888            if max_ordinal == 0 {
3889                return Ok(());
3890            }
3891            depth.increment()?;
3892            let envelope_size = 8;
3893            let bytes_len = max_ordinal as usize * envelope_size;
3894            #[allow(unused_variables)]
3895            let offset = encoder.out_of_line_offset(bytes_len);
3896            let mut _prev_end_offset: usize = 0;
3897            if 1 > max_ordinal {
3898                return Ok(());
3899            }
3900
3901            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3902            // are envelope_size bytes.
3903            let cur_offset: usize = (1 - 1) * envelope_size;
3904
3905            // Zero reserved fields.
3906            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3907
3908            // Safety:
3909            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3910            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3911            //   envelope_size bytes, there is always sufficient room.
3912            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media2__common::ConsumerClosedReason, D>(
3913            self.reason.as_ref().map(<fidl_fuchsia_media2__common::ConsumerClosedReason as fidl::encoding::ValueTypeMarker>::borrow),
3914            encoder, offset + cur_offset, depth
3915        )?;
3916
3917            _prev_end_offset = cur_offset + envelope_size;
3918
3919            Ok(())
3920        }
3921    }
3922
3923    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3924        for StreamSinkOnWillCloseRequest
3925    {
3926        #[inline(always)]
3927        fn new_empty() -> Self {
3928            Self::default()
3929        }
3930
3931        unsafe fn decode(
3932            &mut self,
3933            decoder: &mut fidl::encoding::Decoder<'_, D>,
3934            offset: usize,
3935            mut depth: fidl::encoding::Depth,
3936        ) -> fidl::Result<()> {
3937            decoder.debug_check_bounds::<Self>(offset);
3938            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3939                None => return Err(fidl::Error::NotNullable),
3940                Some(len) => len,
3941            };
3942            // Calling decoder.out_of_line_offset(0) is not allowed.
3943            if len == 0 {
3944                return Ok(());
3945            };
3946            depth.increment()?;
3947            let envelope_size = 8;
3948            let bytes_len = len * envelope_size;
3949            let offset = decoder.out_of_line_offset(bytes_len)?;
3950            // Decode the envelope for each type.
3951            let mut _next_ordinal_to_read = 0;
3952            let mut next_offset = offset;
3953            let end_offset = offset + bytes_len;
3954            _next_ordinal_to_read += 1;
3955            if next_offset >= end_offset {
3956                return Ok(());
3957            }
3958
3959            // Decode unknown envelopes for gaps in ordinals.
3960            while _next_ordinal_to_read < 1 {
3961                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3962                _next_ordinal_to_read += 1;
3963                next_offset += envelope_size;
3964            }
3965
3966            let next_out_of_line = decoder.next_out_of_line();
3967            let handles_before = decoder.remaining_handles();
3968            if let Some((inlined, num_bytes, num_handles)) =
3969                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3970            {
3971                let member_inline_size = <fidl_fuchsia_media2__common::ConsumerClosedReason as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3972                if inlined != (member_inline_size <= 4) {
3973                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3974                }
3975                let inner_offset;
3976                let mut inner_depth = depth.clone();
3977                if inlined {
3978                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3979                    inner_offset = next_offset;
3980                } else {
3981                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3982                    inner_depth.increment()?;
3983                }
3984                let val_ref = self.reason.get_or_insert_with(|| {
3985                    fidl::new_empty!(fidl_fuchsia_media2__common::ConsumerClosedReason, D)
3986                });
3987                fidl::decode!(
3988                    fidl_fuchsia_media2__common::ConsumerClosedReason,
3989                    D,
3990                    val_ref,
3991                    decoder,
3992                    inner_offset,
3993                    inner_depth
3994                )?;
3995                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3996                {
3997                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3998                }
3999                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4000                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4001                }
4002            }
4003
4004            next_offset += envelope_size;
4005
4006            // Decode the remaining unknown envelopes.
4007            while next_offset < end_offset {
4008                _next_ordinal_to_read += 1;
4009                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4010                next_offset += envelope_size;
4011            }
4012
4013            Ok(())
4014        }
4015    }
4016
4017    impl StreamSinkStartSegmentRequest {
4018        #[inline(always)]
4019        fn max_ordinal_present(&self) -> u64 {
4020            if let Some(_) = self.segment_id {
4021                return 1;
4022            }
4023            0
4024        }
4025    }
4026
4027    impl fidl::encoding::ValueTypeMarker for StreamSinkStartSegmentRequest {
4028        type Borrowed<'a> = &'a Self;
4029        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4030            value
4031        }
4032    }
4033
4034    unsafe impl fidl::encoding::TypeMarker for StreamSinkStartSegmentRequest {
4035        type Owned = Self;
4036
4037        #[inline(always)]
4038        fn inline_align(_context: fidl::encoding::Context) -> usize {
4039            8
4040        }
4041
4042        #[inline(always)]
4043        fn inline_size(_context: fidl::encoding::Context) -> usize {
4044            16
4045        }
4046    }
4047
4048    unsafe impl<D: fidl::encoding::ResourceDialect>
4049        fidl::encoding::Encode<StreamSinkStartSegmentRequest, D>
4050        for &StreamSinkStartSegmentRequest
4051    {
4052        unsafe fn encode(
4053            self,
4054            encoder: &mut fidl::encoding::Encoder<'_, D>,
4055            offset: usize,
4056            mut depth: fidl::encoding::Depth,
4057        ) -> fidl::Result<()> {
4058            encoder.debug_check_bounds::<StreamSinkStartSegmentRequest>(offset);
4059            // Vector header
4060            let max_ordinal: u64 = self.max_ordinal_present();
4061            encoder.write_num(max_ordinal, offset);
4062            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4063            // Calling encoder.out_of_line_offset(0) is not allowed.
4064            if max_ordinal == 0 {
4065                return Ok(());
4066            }
4067            depth.increment()?;
4068            let envelope_size = 8;
4069            let bytes_len = max_ordinal as usize * envelope_size;
4070            #[allow(unused_variables)]
4071            let offset = encoder.out_of_line_offset(bytes_len);
4072            let mut _prev_end_offset: usize = 0;
4073            if 1 > max_ordinal {
4074                return Ok(());
4075            }
4076
4077            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4078            // are envelope_size bytes.
4079            let cur_offset: usize = (1 - 1) * envelope_size;
4080
4081            // Zero reserved fields.
4082            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4083
4084            // Safety:
4085            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4086            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4087            //   envelope_size bytes, there is always sufficient room.
4088            fidl::encoding::encode_in_envelope_optional::<i64, D>(
4089                self.segment_id.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
4090                encoder,
4091                offset + cur_offset,
4092                depth,
4093            )?;
4094
4095            _prev_end_offset = cur_offset + envelope_size;
4096
4097            Ok(())
4098        }
4099    }
4100
4101    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
4102        for StreamSinkStartSegmentRequest
4103    {
4104        #[inline(always)]
4105        fn new_empty() -> Self {
4106            Self::default()
4107        }
4108
4109        unsafe fn decode(
4110            &mut self,
4111            decoder: &mut fidl::encoding::Decoder<'_, D>,
4112            offset: usize,
4113            mut depth: fidl::encoding::Depth,
4114        ) -> fidl::Result<()> {
4115            decoder.debug_check_bounds::<Self>(offset);
4116            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4117                None => return Err(fidl::Error::NotNullable),
4118                Some(len) => len,
4119            };
4120            // Calling decoder.out_of_line_offset(0) is not allowed.
4121            if len == 0 {
4122                return Ok(());
4123            };
4124            depth.increment()?;
4125            let envelope_size = 8;
4126            let bytes_len = len * envelope_size;
4127            let offset = decoder.out_of_line_offset(bytes_len)?;
4128            // Decode the envelope for each type.
4129            let mut _next_ordinal_to_read = 0;
4130            let mut next_offset = offset;
4131            let end_offset = offset + bytes_len;
4132            _next_ordinal_to_read += 1;
4133            if next_offset >= end_offset {
4134                return Ok(());
4135            }
4136
4137            // Decode unknown envelopes for gaps in ordinals.
4138            while _next_ordinal_to_read < 1 {
4139                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4140                _next_ordinal_to_read += 1;
4141                next_offset += envelope_size;
4142            }
4143
4144            let next_out_of_line = decoder.next_out_of_line();
4145            let handles_before = decoder.remaining_handles();
4146            if let Some((inlined, num_bytes, num_handles)) =
4147                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4148            {
4149                let member_inline_size =
4150                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4151                if inlined != (member_inline_size <= 4) {
4152                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4153                }
4154                let inner_offset;
4155                let mut inner_depth = depth.clone();
4156                if inlined {
4157                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4158                    inner_offset = next_offset;
4159                } else {
4160                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4161                    inner_depth.increment()?;
4162                }
4163                let val_ref = self.segment_id.get_or_insert_with(|| fidl::new_empty!(i64, D));
4164                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
4165                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4166                {
4167                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4168                }
4169                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4170                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4171                }
4172            }
4173
4174            next_offset += envelope_size;
4175
4176            // Decode the remaining unknown envelopes.
4177            while next_offset < end_offset {
4178                _next_ordinal_to_read += 1;
4179                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4180                next_offset += envelope_size;
4181            }
4182
4183            Ok(())
4184        }
4185    }
4186
4187    impl StreamSinkWillCloseRequest {
4188        #[inline(always)]
4189        fn max_ordinal_present(&self) -> u64 {
4190            if let Some(_) = self.reason {
4191                return 1;
4192            }
4193            0
4194        }
4195    }
4196
4197    impl fidl::encoding::ValueTypeMarker for StreamSinkWillCloseRequest {
4198        type Borrowed<'a> = &'a Self;
4199        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4200            value
4201        }
4202    }
4203
4204    unsafe impl fidl::encoding::TypeMarker for StreamSinkWillCloseRequest {
4205        type Owned = Self;
4206
4207        #[inline(always)]
4208        fn inline_align(_context: fidl::encoding::Context) -> usize {
4209            8
4210        }
4211
4212        #[inline(always)]
4213        fn inline_size(_context: fidl::encoding::Context) -> usize {
4214            16
4215        }
4216    }
4217
4218    unsafe impl<D: fidl::encoding::ResourceDialect>
4219        fidl::encoding::Encode<StreamSinkWillCloseRequest, D> for &StreamSinkWillCloseRequest
4220    {
4221        unsafe fn encode(
4222            self,
4223            encoder: &mut fidl::encoding::Encoder<'_, D>,
4224            offset: usize,
4225            mut depth: fidl::encoding::Depth,
4226        ) -> fidl::Result<()> {
4227            encoder.debug_check_bounds::<StreamSinkWillCloseRequest>(offset);
4228            // Vector header
4229            let max_ordinal: u64 = self.max_ordinal_present();
4230            encoder.write_num(max_ordinal, offset);
4231            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4232            // Calling encoder.out_of_line_offset(0) is not allowed.
4233            if max_ordinal == 0 {
4234                return Ok(());
4235            }
4236            depth.increment()?;
4237            let envelope_size = 8;
4238            let bytes_len = max_ordinal as usize * envelope_size;
4239            #[allow(unused_variables)]
4240            let offset = encoder.out_of_line_offset(bytes_len);
4241            let mut _prev_end_offset: usize = 0;
4242            if 1 > max_ordinal {
4243                return Ok(());
4244            }
4245
4246            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4247            // are envelope_size bytes.
4248            let cur_offset: usize = (1 - 1) * envelope_size;
4249
4250            // Zero reserved fields.
4251            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4252
4253            // Safety:
4254            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4255            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4256            //   envelope_size bytes, there is always sufficient room.
4257            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media2__common::ProducerClosedReason, D>(
4258            self.reason.as_ref().map(<fidl_fuchsia_media2__common::ProducerClosedReason as fidl::encoding::ValueTypeMarker>::borrow),
4259            encoder, offset + cur_offset, depth
4260        )?;
4261
4262            _prev_end_offset = cur_offset + envelope_size;
4263
4264            Ok(())
4265        }
4266    }
4267
4268    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
4269        for StreamSinkWillCloseRequest
4270    {
4271        #[inline(always)]
4272        fn new_empty() -> Self {
4273            Self::default()
4274        }
4275
4276        unsafe fn decode(
4277            &mut self,
4278            decoder: &mut fidl::encoding::Decoder<'_, D>,
4279            offset: usize,
4280            mut depth: fidl::encoding::Depth,
4281        ) -> fidl::Result<()> {
4282            decoder.debug_check_bounds::<Self>(offset);
4283            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4284                None => return Err(fidl::Error::NotNullable),
4285                Some(len) => len,
4286            };
4287            // Calling decoder.out_of_line_offset(0) is not allowed.
4288            if len == 0 {
4289                return Ok(());
4290            };
4291            depth.increment()?;
4292            let envelope_size = 8;
4293            let bytes_len = len * envelope_size;
4294            let offset = decoder.out_of_line_offset(bytes_len)?;
4295            // Decode the envelope for each type.
4296            let mut _next_ordinal_to_read = 0;
4297            let mut next_offset = offset;
4298            let end_offset = offset + bytes_len;
4299            _next_ordinal_to_read += 1;
4300            if next_offset >= end_offset {
4301                return Ok(());
4302            }
4303
4304            // Decode unknown envelopes for gaps in ordinals.
4305            while _next_ordinal_to_read < 1 {
4306                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4307                _next_ordinal_to_read += 1;
4308                next_offset += envelope_size;
4309            }
4310
4311            let next_out_of_line = decoder.next_out_of_line();
4312            let handles_before = decoder.remaining_handles();
4313            if let Some((inlined, num_bytes, num_handles)) =
4314                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4315            {
4316                let member_inline_size = <fidl_fuchsia_media2__common::ProducerClosedReason as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4317                if inlined != (member_inline_size <= 4) {
4318                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4319                }
4320                let inner_offset;
4321                let mut inner_depth = depth.clone();
4322                if inlined {
4323                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4324                    inner_offset = next_offset;
4325                } else {
4326                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4327                    inner_depth.increment()?;
4328                }
4329                let val_ref = self.reason.get_or_insert_with(|| {
4330                    fidl::new_empty!(fidl_fuchsia_media2__common::ProducerClosedReason, D)
4331                });
4332                fidl::decode!(
4333                    fidl_fuchsia_media2__common::ProducerClosedReason,
4334                    D,
4335                    val_ref,
4336                    decoder,
4337                    inner_offset,
4338                    inner_depth
4339                )?;
4340                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4341                {
4342                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4343                }
4344                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4345                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4346                }
4347            }
4348
4349            next_offset += envelope_size;
4350
4351            // Decode the remaining unknown envelopes.
4352            while next_offset < end_offset {
4353                _next_ordinal_to_read += 1;
4354                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4355                next_offset += envelope_size;
4356            }
4357
4358            Ok(())
4359        }
4360    }
4361
4362    impl fidl::encoding::ValueTypeMarker for ChannelLayout {
4363        type Borrowed<'a> = &'a Self;
4364        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4365            value
4366        }
4367    }
4368
4369    unsafe impl fidl::encoding::TypeMarker for ChannelLayout {
4370        type Owned = Self;
4371
4372        #[inline(always)]
4373        fn inline_align(_context: fidl::encoding::Context) -> usize {
4374            8
4375        }
4376
4377        #[inline(always)]
4378        fn inline_size(_context: fidl::encoding::Context) -> usize {
4379            16
4380        }
4381    }
4382
4383    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ChannelLayout, D>
4384        for &ChannelLayout
4385    {
4386        #[inline]
4387        unsafe fn encode(
4388            self,
4389            encoder: &mut fidl::encoding::Encoder<'_, D>,
4390            offset: usize,
4391            _depth: fidl::encoding::Depth,
4392        ) -> fidl::Result<()> {
4393            encoder.debug_check_bounds::<ChannelLayout>(offset);
4394            encoder.write_num::<u64>(self.ordinal(), offset);
4395            match self {
4396                ChannelLayout::Config(ref val) => {
4397                    fidl::encoding::encode_in_envelope::<ChannelConfig, D>(
4398                        <ChannelConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
4399                        encoder,
4400                        offset + 8,
4401                        _depth,
4402                    )
4403                }
4404                ChannelLayout::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
4405            }
4406        }
4407    }
4408
4409    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ChannelLayout {
4410        #[inline(always)]
4411        fn new_empty() -> Self {
4412            Self::__SourceBreaking { unknown_ordinal: 0 }
4413        }
4414
4415        #[inline]
4416        unsafe fn decode(
4417            &mut self,
4418            decoder: &mut fidl::encoding::Decoder<'_, D>,
4419            offset: usize,
4420            mut depth: fidl::encoding::Depth,
4421        ) -> fidl::Result<()> {
4422            decoder.debug_check_bounds::<Self>(offset);
4423            #[allow(unused_variables)]
4424            let next_out_of_line = decoder.next_out_of_line();
4425            let handles_before = decoder.remaining_handles();
4426            let (ordinal, inlined, num_bytes, num_handles) =
4427                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
4428
4429            let member_inline_size = match ordinal {
4430                1 => <ChannelConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4431                0 => return Err(fidl::Error::UnknownUnionTag),
4432                _ => num_bytes as usize,
4433            };
4434
4435            if inlined != (member_inline_size <= 4) {
4436                return Err(fidl::Error::InvalidInlineBitInEnvelope);
4437            }
4438            let _inner_offset;
4439            if inlined {
4440                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
4441                _inner_offset = offset + 8;
4442            } else {
4443                depth.increment()?;
4444                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4445            }
4446            match ordinal {
4447                1 => {
4448                    #[allow(irrefutable_let_patterns)]
4449                    if let ChannelLayout::Config(_) = self {
4450                        // Do nothing, read the value into the object
4451                    } else {
4452                        // Initialize `self` to the right variant
4453                        *self = ChannelLayout::Config(fidl::new_empty!(ChannelConfig, D));
4454                    }
4455                    #[allow(irrefutable_let_patterns)]
4456                    if let ChannelLayout::Config(ref mut val) = self {
4457                        fidl::decode!(ChannelConfig, D, val, decoder, _inner_offset, depth)?;
4458                    } else {
4459                        unreachable!()
4460                    }
4461                }
4462                #[allow(deprecated)]
4463                ordinal => {
4464                    for _ in 0..num_handles {
4465                        decoder.drop_next_handle()?;
4466                    }
4467                    *self = ChannelLayout::__SourceBreaking { unknown_ordinal: ordinal };
4468                }
4469            }
4470            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
4471                return Err(fidl::Error::InvalidNumBytesInEnvelope);
4472            }
4473            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4474                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4475            }
4476            Ok(())
4477        }
4478    }
4479
4480    impl fidl::encoding::ValueTypeMarker for GainUpdateMethod {
4481        type Borrowed<'a> = &'a Self;
4482        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4483            value
4484        }
4485    }
4486
4487    unsafe impl fidl::encoding::TypeMarker for GainUpdateMethod {
4488        type Owned = Self;
4489
4490        #[inline(always)]
4491        fn inline_align(_context: fidl::encoding::Context) -> usize {
4492            8
4493        }
4494
4495        #[inline(always)]
4496        fn inline_size(_context: fidl::encoding::Context) -> usize {
4497            16
4498        }
4499    }
4500
4501    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<GainUpdateMethod, D>
4502        for &GainUpdateMethod
4503    {
4504        #[inline]
4505        unsafe fn encode(
4506            self,
4507            encoder: &mut fidl::encoding::Encoder<'_, D>,
4508            offset: usize,
4509            _depth: fidl::encoding::Depth,
4510        ) -> fidl::Result<()> {
4511            encoder.debug_check_bounds::<GainUpdateMethod>(offset);
4512            encoder.write_num::<u64>(self.ordinal(), offset);
4513            match self {
4514                GainUpdateMethod::GainDb(ref val) => fidl::encoding::encode_in_envelope::<f32, D>(
4515                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(val),
4516                    encoder,
4517                    offset + 8,
4518                    _depth,
4519                ),
4520                GainUpdateMethod::Ramped(ref val) => {
4521                    fidl::encoding::encode_in_envelope::<RampedGain, D>(
4522                        <RampedGain as fidl::encoding::ValueTypeMarker>::borrow(val),
4523                        encoder,
4524                        offset + 8,
4525                        _depth,
4526                    )
4527                }
4528                GainUpdateMethod::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
4529            }
4530        }
4531    }
4532
4533    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for GainUpdateMethod {
4534        #[inline(always)]
4535        fn new_empty() -> Self {
4536            Self::__SourceBreaking { unknown_ordinal: 0 }
4537        }
4538
4539        #[inline]
4540        unsafe fn decode(
4541            &mut self,
4542            decoder: &mut fidl::encoding::Decoder<'_, D>,
4543            offset: usize,
4544            mut depth: fidl::encoding::Depth,
4545        ) -> fidl::Result<()> {
4546            decoder.debug_check_bounds::<Self>(offset);
4547            #[allow(unused_variables)]
4548            let next_out_of_line = decoder.next_out_of_line();
4549            let handles_before = decoder.remaining_handles();
4550            let (ordinal, inlined, num_bytes, num_handles) =
4551                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
4552
4553            let member_inline_size = match ordinal {
4554                1 => <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4555                2 => <RampedGain as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4556                0 => return Err(fidl::Error::UnknownUnionTag),
4557                _ => num_bytes as usize,
4558            };
4559
4560            if inlined != (member_inline_size <= 4) {
4561                return Err(fidl::Error::InvalidInlineBitInEnvelope);
4562            }
4563            let _inner_offset;
4564            if inlined {
4565                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
4566                _inner_offset = offset + 8;
4567            } else {
4568                depth.increment()?;
4569                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4570            }
4571            match ordinal {
4572                1 => {
4573                    #[allow(irrefutable_let_patterns)]
4574                    if let GainUpdateMethod::GainDb(_) = self {
4575                        // Do nothing, read the value into the object
4576                    } else {
4577                        // Initialize `self` to the right variant
4578                        *self = GainUpdateMethod::GainDb(fidl::new_empty!(f32, D));
4579                    }
4580                    #[allow(irrefutable_let_patterns)]
4581                    if let GainUpdateMethod::GainDb(ref mut val) = self {
4582                        fidl::decode!(f32, D, val, decoder, _inner_offset, depth)?;
4583                    } else {
4584                        unreachable!()
4585                    }
4586                }
4587                2 => {
4588                    #[allow(irrefutable_let_patterns)]
4589                    if let GainUpdateMethod::Ramped(_) = self {
4590                        // Do nothing, read the value into the object
4591                    } else {
4592                        // Initialize `self` to the right variant
4593                        *self = GainUpdateMethod::Ramped(fidl::new_empty!(RampedGain, D));
4594                    }
4595                    #[allow(irrefutable_let_patterns)]
4596                    if let GainUpdateMethod::Ramped(ref mut val) = self {
4597                        fidl::decode!(RampedGain, D, val, decoder, _inner_offset, depth)?;
4598                    } else {
4599                        unreachable!()
4600                    }
4601                }
4602                #[allow(deprecated)]
4603                ordinal => {
4604                    for _ in 0..num_handles {
4605                        decoder.drop_next_handle()?;
4606                    }
4607                    *self = GainUpdateMethod::__SourceBreaking { unknown_ordinal: ordinal };
4608                }
4609            }
4610            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
4611                return Err(fidl::Error::InvalidNumBytesInEnvelope);
4612            }
4613            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4614                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4615            }
4616            Ok(())
4617        }
4618    }
4619
4620    impl fidl::encoding::ValueTypeMarker for RampFunction {
4621        type Borrowed<'a> = &'a Self;
4622        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4623            value
4624        }
4625    }
4626
4627    unsafe impl fidl::encoding::TypeMarker for RampFunction {
4628        type Owned = Self;
4629
4630        #[inline(always)]
4631        fn inline_align(_context: fidl::encoding::Context) -> usize {
4632            8
4633        }
4634
4635        #[inline(always)]
4636        fn inline_size(_context: fidl::encoding::Context) -> usize {
4637            16
4638        }
4639    }
4640
4641    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RampFunction, D>
4642        for &RampFunction
4643    {
4644        #[inline]
4645        unsafe fn encode(
4646            self,
4647            encoder: &mut fidl::encoding::Encoder<'_, D>,
4648            offset: usize,
4649            _depth: fidl::encoding::Depth,
4650        ) -> fidl::Result<()> {
4651            encoder.debug_check_bounds::<RampFunction>(offset);
4652            encoder.write_num::<u64>(self.ordinal(), offset);
4653            match self {
4654                RampFunction::LinearSlope(ref val) => {
4655                    fidl::encoding::encode_in_envelope::<RampFunctionLinearSlope, D>(
4656                        <RampFunctionLinearSlope as fidl::encoding::ValueTypeMarker>::borrow(val),
4657                        encoder,
4658                        offset + 8,
4659                        _depth,
4660                    )
4661                }
4662                RampFunction::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
4663            }
4664        }
4665    }
4666
4667    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RampFunction {
4668        #[inline(always)]
4669        fn new_empty() -> Self {
4670            Self::__SourceBreaking { unknown_ordinal: 0 }
4671        }
4672
4673        #[inline]
4674        unsafe fn decode(
4675            &mut self,
4676            decoder: &mut fidl::encoding::Decoder<'_, D>,
4677            offset: usize,
4678            mut depth: fidl::encoding::Depth,
4679        ) -> fidl::Result<()> {
4680            decoder.debug_check_bounds::<Self>(offset);
4681            #[allow(unused_variables)]
4682            let next_out_of_line = decoder.next_out_of_line();
4683            let handles_before = decoder.remaining_handles();
4684            let (ordinal, inlined, num_bytes, num_handles) =
4685                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
4686
4687            let member_inline_size = match ordinal {
4688                1 => <RampFunctionLinearSlope as fidl::encoding::TypeMarker>::inline_size(
4689                    decoder.context,
4690                ),
4691                0 => return Err(fidl::Error::UnknownUnionTag),
4692                _ => num_bytes as usize,
4693            };
4694
4695            if inlined != (member_inline_size <= 4) {
4696                return Err(fidl::Error::InvalidInlineBitInEnvelope);
4697            }
4698            let _inner_offset;
4699            if inlined {
4700                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
4701                _inner_offset = offset + 8;
4702            } else {
4703                depth.increment()?;
4704                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4705            }
4706            match ordinal {
4707                1 => {
4708                    #[allow(irrefutable_let_patterns)]
4709                    if let RampFunction::LinearSlope(_) = self {
4710                        // Do nothing, read the value into the object
4711                    } else {
4712                        // Initialize `self` to the right variant
4713                        *self =
4714                            RampFunction::LinearSlope(fidl::new_empty!(RampFunctionLinearSlope, D));
4715                    }
4716                    #[allow(irrefutable_let_patterns)]
4717                    if let RampFunction::LinearSlope(ref mut val) = self {
4718                        fidl::decode!(
4719                            RampFunctionLinearSlope,
4720                            D,
4721                            val,
4722                            decoder,
4723                            _inner_offset,
4724                            depth
4725                        )?;
4726                    } else {
4727                        unreachable!()
4728                    }
4729                }
4730                #[allow(deprecated)]
4731                ordinal => {
4732                    for _ in 0..num_handles {
4733                        decoder.drop_next_handle()?;
4734                    }
4735                    *self = RampFunction::__SourceBreaking { unknown_ordinal: ordinal };
4736                }
4737            }
4738            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
4739                return Err(fidl::Error::InvalidNumBytesInEnvelope);
4740            }
4741            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4742                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4743            }
4744            Ok(())
4745        }
4746    }
4747
4748    impl fidl::encoding::ValueTypeMarker for Timestamp {
4749        type Borrowed<'a> = &'a Self;
4750        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4751            value
4752        }
4753    }
4754
4755    unsafe impl fidl::encoding::TypeMarker for Timestamp {
4756        type Owned = Self;
4757
4758        #[inline(always)]
4759        fn inline_align(_context: fidl::encoding::Context) -> usize {
4760            8
4761        }
4762
4763        #[inline(always)]
4764        fn inline_size(_context: fidl::encoding::Context) -> usize {
4765            16
4766        }
4767    }
4768
4769    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Timestamp, D>
4770        for &Timestamp
4771    {
4772        #[inline]
4773        unsafe fn encode(
4774            self,
4775            encoder: &mut fidl::encoding::Encoder<'_, D>,
4776            offset: usize,
4777            _depth: fidl::encoding::Depth,
4778        ) -> fidl::Result<()> {
4779            encoder.debug_check_bounds::<Timestamp>(offset);
4780            encoder.write_num::<u64>(self.ordinal(), offset);
4781            match self {
4782                Timestamp::Specified(ref val) => fidl::encoding::encode_in_envelope::<i64, D>(
4783                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
4784                    encoder,
4785                    offset + 8,
4786                    _depth,
4787                ),
4788                Timestamp::UnspecifiedContinuous(ref val) => {
4789                    fidl::encoding::encode_in_envelope::<UnspecifiedContinuous, D>(
4790                        <UnspecifiedContinuous as fidl::encoding::ValueTypeMarker>::borrow(val),
4791                        encoder,
4792                        offset + 8,
4793                        _depth,
4794                    )
4795                }
4796                Timestamp::UnspecifiedBestEffort(ref val) => {
4797                    fidl::encoding::encode_in_envelope::<UnspecifiedBestEffort, D>(
4798                        <UnspecifiedBestEffort as fidl::encoding::ValueTypeMarker>::borrow(val),
4799                        encoder,
4800                        offset + 8,
4801                        _depth,
4802                    )
4803                }
4804                Timestamp::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
4805            }
4806        }
4807    }
4808
4809    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Timestamp {
4810        #[inline(always)]
4811        fn new_empty() -> Self {
4812            Self::__SourceBreaking { unknown_ordinal: 0 }
4813        }
4814
4815        #[inline]
4816        unsafe fn decode(
4817            &mut self,
4818            decoder: &mut fidl::encoding::Decoder<'_, D>,
4819            offset: usize,
4820            mut depth: fidl::encoding::Depth,
4821        ) -> fidl::Result<()> {
4822            decoder.debug_check_bounds::<Self>(offset);
4823            #[allow(unused_variables)]
4824            let next_out_of_line = decoder.next_out_of_line();
4825            let handles_before = decoder.remaining_handles();
4826            let (ordinal, inlined, num_bytes, num_handles) =
4827                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
4828
4829            let member_inline_size = match ordinal {
4830                1 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4831                2 => <UnspecifiedContinuous as fidl::encoding::TypeMarker>::inline_size(
4832                    decoder.context,
4833                ),
4834                3 => <UnspecifiedBestEffort as fidl::encoding::TypeMarker>::inline_size(
4835                    decoder.context,
4836                ),
4837                0 => return Err(fidl::Error::UnknownUnionTag),
4838                _ => num_bytes as usize,
4839            };
4840
4841            if inlined != (member_inline_size <= 4) {
4842                return Err(fidl::Error::InvalidInlineBitInEnvelope);
4843            }
4844            let _inner_offset;
4845            if inlined {
4846                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
4847                _inner_offset = offset + 8;
4848            } else {
4849                depth.increment()?;
4850                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4851            }
4852            match ordinal {
4853                1 => {
4854                    #[allow(irrefutable_let_patterns)]
4855                    if let Timestamp::Specified(_) = self {
4856                        // Do nothing, read the value into the object
4857                    } else {
4858                        // Initialize `self` to the right variant
4859                        *self = Timestamp::Specified(fidl::new_empty!(i64, D));
4860                    }
4861                    #[allow(irrefutable_let_patterns)]
4862                    if let Timestamp::Specified(ref mut val) = self {
4863                        fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
4864                    } else {
4865                        unreachable!()
4866                    }
4867                }
4868                2 => {
4869                    #[allow(irrefutable_let_patterns)]
4870                    if let Timestamp::UnspecifiedContinuous(_) = self {
4871                        // Do nothing, read the value into the object
4872                    } else {
4873                        // Initialize `self` to the right variant
4874                        *self = Timestamp::UnspecifiedContinuous(fidl::new_empty!(
4875                            UnspecifiedContinuous,
4876                            D
4877                        ));
4878                    }
4879                    #[allow(irrefutable_let_patterns)]
4880                    if let Timestamp::UnspecifiedContinuous(ref mut val) = self {
4881                        fidl::decode!(
4882                            UnspecifiedContinuous,
4883                            D,
4884                            val,
4885                            decoder,
4886                            _inner_offset,
4887                            depth
4888                        )?;
4889                    } else {
4890                        unreachable!()
4891                    }
4892                }
4893                3 => {
4894                    #[allow(irrefutable_let_patterns)]
4895                    if let Timestamp::UnspecifiedBestEffort(_) = self {
4896                        // Do nothing, read the value into the object
4897                    } else {
4898                        // Initialize `self` to the right variant
4899                        *self = Timestamp::UnspecifiedBestEffort(fidl::new_empty!(
4900                            UnspecifiedBestEffort,
4901                            D
4902                        ));
4903                    }
4904                    #[allow(irrefutable_let_patterns)]
4905                    if let Timestamp::UnspecifiedBestEffort(ref mut val) = self {
4906                        fidl::decode!(
4907                            UnspecifiedBestEffort,
4908                            D,
4909                            val,
4910                            decoder,
4911                            _inner_offset,
4912                            depth
4913                        )?;
4914                    } else {
4915                        unreachable!()
4916                    }
4917                }
4918                #[allow(deprecated)]
4919                ordinal => {
4920                    for _ in 0..num_handles {
4921                        decoder.drop_next_handle()?;
4922                    }
4923                    *self = Timestamp::__SourceBreaking { unknown_ordinal: ordinal };
4924                }
4925            }
4926            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
4927                return Err(fidl::Error::InvalidNumBytesInEnvelope);
4928            }
4929            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4930                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4931            }
4932            Ok(())
4933        }
4934    }
4935}