Skip to main content

fidl_fuchsia_audio_device/
fidl_fuchsia_audio_device.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::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_audio_device__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Default, PartialEq)]
15pub struct ControlCreatePacketStreamRequest {
16    /// The element ID for an `ENDPOINT` of type `PACKET_STREAM`.
17    ///
18    /// Required.
19    pub element_id: Option<u64>,
20    /// Additional configuration options for the packet stream being created.
21    ///
22    /// Required.
23    pub options: Option<PacketStreamOptions>,
24    /// The server_end of the `PacketStream` control protocol.
25    /// The client keeps the client_end to control the stream (Start/Stop/etc).
26    ///
27    /// Required.
28    pub packet_stream_server: Option<fidl::endpoints::ServerEnd<PacketStreamMarker>>,
29    #[doc(hidden)]
30    pub __source_breaking: fidl::marker::SourceBreaking,
31}
32
33impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
34    for ControlCreatePacketStreamRequest
35{
36}
37
38#[derive(Debug, Default, PartialEq)]
39pub struct ControlCreateRingBufferRequest {
40    /// The ID for an element of type `RING_BUFFER`.
41    ///
42    /// Required.
43    pub element_id: Option<u64>,
44    /// Additional requirements about the actual ring buffer being created.
45    ///
46    /// Required.
47    pub options: Option<RingBufferOptions>,
48    /// The server_end of the `RingBuffer` to be created.
49    ///
50    /// Required.
51    pub ring_buffer_server: Option<fidl::endpoints::ServerEnd<RingBufferMarker>>,
52    #[doc(hidden)]
53    pub __source_breaking: fidl::marker::SourceBreaking,
54}
55
56impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
57    for ControlCreateRingBufferRequest
58{
59}
60
61#[derive(Debug, Default, PartialEq)]
62pub struct ControlCreatorCreateRequest {
63    /// The token id for the device to be controlled.
64    ///
65    /// Required.
66    pub token_id: Option<u64>,
67    /// The server_end of the `Control` to be created.
68    ///
69    /// Required.
70    pub control_server: Option<fidl::endpoints::ServerEnd<ControlMarker>>,
71    #[doc(hidden)]
72    pub __source_breaking: fidl::marker::SourceBreaking,
73}
74
75impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
76    for ControlCreatorCreateRequest
77{
78}
79
80#[derive(Debug, Default, PartialEq)]
81pub struct ControlCreatePacketStreamResponse {
82    /// Properties of the created packet stream.
83    pub properties: Option<PacketStreamProperties>,
84    #[doc(hidden)]
85    pub __source_breaking: fidl::marker::SourceBreaking,
86}
87
88impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
89    for ControlCreatePacketStreamResponse
90{
91}
92
93#[derive(Debug, Default, PartialEq)]
94pub struct ControlCreateRingBufferResponse {
95    /// Properties about the ring buffer and active audio stream as created.
96    pub properties: Option<RingBufferProperties>,
97    /// An object that represents the audio stream and ring memory itself.
98    /// Note: ring-buffer VMO memory ranges must be cache-invalidated before
99    /// each read, and cache-flushed after each write.
100    pub ring_buffer: Option<fidl_fuchsia_audio::RingBuffer>,
101    #[doc(hidden)]
102    pub __source_breaking: fidl::marker::SourceBreaking,
103}
104
105impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
106    for ControlCreateRingBufferResponse
107{
108}
109
110#[derive(Debug, Default, PartialEq)]
111pub struct ObserverGetReferenceClockResponse {
112    /// The device's reference clock.
113    pub reference_clock: Option<fidl::Clock>,
114    #[doc(hidden)]
115    pub __source_breaking: fidl::marker::SourceBreaking,
116}
117
118impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
119    for ObserverGetReferenceClockResponse
120{
121}
122
123#[derive(Debug, Default, PartialEq)]
124pub struct PacketStreamBuffers {
125    /// Information about the VMOs used for this stream.
126    /// Populated if `allocate_info` was requested or if `register_info` was
127    /// passed in options.
128    ///
129    /// Optional.
130    pub vmo_infos: Option<Vec<fidl_fuchsia_hardware_audio::VmoInfo>>,
131    #[doc(hidden)]
132    pub __source_breaking: fidl::marker::SourceBreaking,
133}
134
135impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PacketStreamBuffers {}
136
137/// Parameters specified by a caller when creating a packet stream.
138#[derive(Debug, Default, PartialEq)]
139pub struct PacketStreamOptions {
140    /// The format (sample format, channelization, frame rate, encoding) of the
141    /// packet stream to be created.
142    ///
143    /// Required.
144    pub format: Option<PacketStreamFormat>,
145    #[doc(hidden)]
146    pub __source_breaking: fidl::marker::SourceBreaking,
147}
148
149impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PacketStreamOptions {}
150
151/// Information about the associated audio stream.
152#[derive(Debug, Default, PartialEq)]
153pub struct PacketStreamProperties {
154    /// The channel used to transmit audio data packets.
155    ///
156    /// Required.
157    pub data_sink:
158        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::PacketStreamSinkMarker>>,
159    /// The negotiated format of the audio data in the buffer.
160    ///
161    /// Required.
162    pub format: Option<PacketStreamFormat>,
163    /// The number of valid bits per sample.
164    ///
165    /// Required, if `format.pcm_format` is set.
166    pub valid_bits_per_sample: Option<u8>,
167    /// The memory ownership models supported by the driver for this stream.
168    ///
169    /// Required.
170    pub supported_buffer_types: Option<fidl_fuchsia_hardware_audio::BufferType>,
171    #[doc(hidden)]
172    pub __source_breaking: fidl::marker::SourceBreaking,
173}
174
175impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PacketStreamProperties {}
176
177#[derive(Debug, Default, PartialEq)]
178pub struct PacketStreamSetBuffersRequest {
179    /// Setup information for audio data transfer.
180    /// The options chosen should be supported by the driver as reported
181    /// in `PacketStreamProperties.supported_buffer_types`.
182    ///
183    /// Required.
184    pub vmo_info: Option<PacketStreamSetupVmoInfo>,
185    #[doc(hidden)]
186    pub __source_breaking: fidl::marker::SourceBreaking,
187}
188
189impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
190    for PacketStreamSetBuffersRequest
191{
192}
193
194#[derive(Debug, Default, PartialEq)]
195pub struct PacketStreamSetBuffersResponse {
196    /// An object that contains shared memory buffers required to transfer audio data.
197    ///
198    /// Note: The client must ensure proper cache coherency for the VMOs contained
199    /// within this struct. Memory ranges must be cache-invalidated before reads
200    /// (for capture) and cache-flushed after writes (for playback) if the
201    /// properties indicate a non-coherent domain.
202    pub packet_stream: Option<PacketStreamBuffers>,
203    #[doc(hidden)]
204    pub __source_breaking: fidl::marker::SourceBreaking,
205}
206
207impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
208    for PacketStreamSetBuffersResponse
209{
210}
211
212#[derive(Debug, Default, PartialEq)]
213pub struct ProviderAddDeviceRequest {
214    /// The device's high-level name. Must not be an empty string.
215    ///
216    /// Required.
217    pub device_name: Option<String>,
218    /// Indicates the protocol used by the device.
219    ///
220    /// Required.
221    pub device_type: Option<DeviceType>,
222    /// The client_end of the protocol channel (Codec or Composite)
223    /// that this service will use to configure/observe the device.
224    ///
225    /// Required.
226    /// # Deprecation
227    ///
228    /// Codec is not supported anymore, instead use an
229    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
230    /// , see
231    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
232    pub driver_client: Option<DriverClient>,
233    #[doc(hidden)]
234    pub __source_breaking: fidl::marker::SourceBreaking,
235}
236
237impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ProviderAddDeviceRequest {}
238
239#[derive(Debug, Default, PartialEq)]
240pub struct RegistryCreateObserverRequest {
241    /// The token of the device to be observed.
242    ///
243    /// Required.
244    pub token_id: Option<u64>,
245    /// The server end of the `Observer` that will be created.
246    ///
247    /// Required.
248    pub observer_server: Option<fidl::endpoints::ServerEnd<ObserverMarker>>,
249    #[doc(hidden)]
250    pub __source_breaking: fidl::marker::SourceBreaking,
251}
252
253impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
254    for RegistryCreateObserverRequest
255{
256}
257
258/// The protocol channel used to configure and observe a device.
259/// # Deprecation
260///
261/// Codec drivers are not supported anymore, instead use an
262/// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite), see
263/// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
264#[derive(Debug)]
265pub enum DriverClient {
266    /// Populated for drivers that use the `fuchsia_hardware_audio.Codec` interface.
267    Codec(fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CodecMarker>),
268    /// Populated for drivers that use the `fuchsia_hardware_audio.Composite` interface.
269    Composite(fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CompositeMarker>),
270    #[doc(hidden)]
271    __SourceBreaking { unknown_ordinal: u64 },
272}
273
274/// Pattern that matches an unknown `DriverClient` member.
275#[macro_export]
276macro_rules! DriverClientUnknown {
277    () => {
278        _
279    };
280}
281
282// Custom PartialEq so that unknown variants are not equal to themselves.
283impl PartialEq for DriverClient {
284    fn eq(&self, other: &Self) -> bool {
285        match (self, other) {
286            (Self::Codec(x), Self::Codec(y)) => *x == *y,
287            (Self::Composite(x), Self::Composite(y)) => *x == *y,
288            _ => false,
289        }
290    }
291}
292
293impl DriverClient {
294    #[inline]
295    pub fn ordinal(&self) -> u64 {
296        match *self {
297            Self::Codec(_) => 1,
298            Self::Composite(_) => 2,
299            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
300        }
301    }
302
303    #[inline]
304    pub fn unknown_variant_for_testing() -> Self {
305        Self::__SourceBreaking { unknown_ordinal: 0 }
306    }
307
308    #[inline]
309    pub fn is_unknown(&self) -> bool {
310        match self {
311            Self::__SourceBreaking { .. } => true,
312            _ => false,
313        }
314    }
315}
316
317impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DriverClient {}
318
319/// Configuration for VMO allocation or registration.
320#[derive(Debug)]
321pub enum PacketStreamSetupVmoInfo {
322    /// Configuration for driver-allocated VMOs.
323    AllocateInfo(fidl_fuchsia_hardware_audio::AllocateVmosConfig),
324    /// Configuration for client-allocated (registered) VMOs.
325    RegisterInfo(fidl_fuchsia_hardware_audio::RegisterVmosConfig),
326    #[doc(hidden)]
327    __SourceBreaking { unknown_ordinal: u64 },
328}
329
330/// Pattern that matches an unknown `PacketStreamSetupVmoInfo` member.
331#[macro_export]
332macro_rules! PacketStreamSetupVmoInfoUnknown {
333    () => {
334        _
335    };
336}
337
338// Custom PartialEq so that unknown variants are not equal to themselves.
339impl PartialEq for PacketStreamSetupVmoInfo {
340    fn eq(&self, other: &Self) -> bool {
341        match (self, other) {
342            (Self::AllocateInfo(x), Self::AllocateInfo(y)) => *x == *y,
343            (Self::RegisterInfo(x), Self::RegisterInfo(y)) => *x == *y,
344            _ => false,
345        }
346    }
347}
348
349impl PacketStreamSetupVmoInfo {
350    #[inline]
351    pub fn ordinal(&self) -> u64 {
352        match *self {
353            Self::AllocateInfo(_) => 1,
354            Self::RegisterInfo(_) => 2,
355            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
356        }
357    }
358
359    #[inline]
360    pub fn unknown_variant_for_testing() -> Self {
361        Self::__SourceBreaking { unknown_ordinal: 0 }
362    }
363
364    #[inline]
365    pub fn is_unknown(&self) -> bool {
366        match self {
367            Self::__SourceBreaking { .. } => true,
368            _ => false,
369        }
370    }
371}
372
373impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PacketStreamSetupVmoInfo {}
374
375#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
376pub struct ControlMarker;
377
378impl fidl::endpoints::ProtocolMarker for ControlMarker {
379    type Proxy = ControlProxy;
380    type RequestStream = ControlRequestStream;
381    #[cfg(target_os = "fuchsia")]
382    type SynchronousProxy = ControlSynchronousProxy;
383
384    const DEBUG_NAME: &'static str = "(anonymous) Control";
385}
386pub type ControlCreateRingBufferResult =
387    Result<ControlCreateRingBufferResponse, ControlCreateRingBufferError>;
388pub type ControlCreatePacketStreamResult =
389    Result<ControlCreatePacketStreamResponse, ControlCreatePacketStreamError>;
390pub type ControlSetDaiFormatResult = Result<ControlSetDaiFormatResponse, ControlSetDaiFormatError>;
391pub type ControlCodecStartResult = Result<ControlCodecStartResponse, ControlCodecStartError>;
392pub type ControlCodecStopResult = Result<ControlCodecStopResponse, ControlCodecStopError>;
393pub type ControlResetResult = Result<ControlResetResponse, ControlResetError>;
394
395pub trait ControlProxyInterface: Send + Sync {
396    type GetElementsResponseFut: std::future::Future<
397            Output = Result<
398                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
399                fidl::Error,
400            >,
401        > + Send;
402    fn r#get_elements(&self) -> Self::GetElementsResponseFut;
403    type WatchElementStateResponseFut: std::future::Future<
404            Output = Result<
405                fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
406                fidl::Error,
407            >,
408        > + Send;
409    fn r#watch_element_state(
410        &self,
411        processing_element_id: u64,
412    ) -> Self::WatchElementStateResponseFut;
413    type GetTopologiesResponseFut: std::future::Future<
414            Output = Result<
415                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
416                fidl::Error,
417            >,
418        > + Send;
419    fn r#get_topologies(&self) -> Self::GetTopologiesResponseFut;
420    type WatchTopologyResponseFut: std::future::Future<Output = Result<u64, fidl::Error>> + Send;
421    fn r#watch_topology(&self) -> Self::WatchTopologyResponseFut;
422    type SetTopologyResponseFut: std::future::Future<
423            Output = Result<
424                fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyResult,
425                fidl::Error,
426            >,
427        > + Send;
428    fn r#set_topology(&self, topology_id: u64) -> Self::SetTopologyResponseFut;
429    type SetElementStateResponseFut: std::future::Future<
430            Output = Result<
431                fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateResult,
432                fidl::Error,
433            >,
434        > + Send;
435    fn r#set_element_state(
436        &self,
437        processing_element_id: u64,
438        state: &fidl_fuchsia_hardware_audio_signalprocessing::SettableElementState,
439    ) -> Self::SetElementStateResponseFut;
440    type CreateRingBufferResponseFut: std::future::Future<Output = Result<ControlCreateRingBufferResult, fidl::Error>>
441        + Send;
442    fn r#create_ring_buffer(
443        &self,
444        payload: ControlCreateRingBufferRequest,
445    ) -> Self::CreateRingBufferResponseFut;
446    type CreatePacketStreamResponseFut: std::future::Future<Output = Result<ControlCreatePacketStreamResult, fidl::Error>>
447        + Send;
448    fn r#create_packet_stream(
449        &self,
450        payload: ControlCreatePacketStreamRequest,
451    ) -> Self::CreatePacketStreamResponseFut;
452    type SetDaiFormatResponseFut: std::future::Future<Output = Result<ControlSetDaiFormatResult, fidl::Error>>
453        + Send;
454    fn r#set_dai_format(
455        &self,
456        payload: &ControlSetDaiFormatRequest,
457    ) -> Self::SetDaiFormatResponseFut;
458    type CodecStartResponseFut: std::future::Future<Output = Result<ControlCodecStartResult, fidl::Error>>
459        + Send;
460    fn r#codec_start(&self) -> Self::CodecStartResponseFut;
461    type CodecStopResponseFut: std::future::Future<Output = Result<ControlCodecStopResult, fidl::Error>>
462        + Send;
463    fn r#codec_stop(&self) -> Self::CodecStopResponseFut;
464    type ResetResponseFut: std::future::Future<Output = Result<ControlResetResult, fidl::Error>>
465        + Send;
466    fn r#reset(&self) -> Self::ResetResponseFut;
467}
468#[derive(Debug)]
469#[cfg(target_os = "fuchsia")]
470pub struct ControlSynchronousProxy {
471    client: fidl::client::sync::Client,
472}
473
474#[cfg(target_os = "fuchsia")]
475impl fidl::endpoints::SynchronousProxy for ControlSynchronousProxy {
476    type Proxy = ControlProxy;
477    type Protocol = ControlMarker;
478
479    fn from_channel(inner: fidl::Channel) -> Self {
480        Self::new(inner)
481    }
482
483    fn into_channel(self) -> fidl::Channel {
484        self.client.into_channel()
485    }
486
487    fn as_channel(&self) -> &fidl::Channel {
488        self.client.as_channel()
489    }
490}
491
492#[cfg(target_os = "fuchsia")]
493impl ControlSynchronousProxy {
494    pub fn new(channel: fidl::Channel) -> Self {
495        Self { client: fidl::client::sync::Client::new(channel) }
496    }
497
498    pub fn into_channel(self) -> fidl::Channel {
499        self.client.into_channel()
500    }
501
502    /// Waits until an event arrives and returns it. It is safe for other
503    /// threads to make concurrent requests while waiting for an event.
504    pub fn wait_for_event(
505        &self,
506        deadline: zx::MonotonicInstant,
507    ) -> Result<ControlEvent, fidl::Error> {
508        ControlEvent::decode(self.client.wait_for_event::<ControlMarker>(deadline)?)
509    }
510
511    /// Returns a vector of supported processing elements.
512    /// This vector must include one or more processing elements.
513    pub fn r#get_elements(
514        &self,
515        ___deadline: zx::MonotonicInstant,
516    ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult, fidl::Error>
517    {
518        let _response =
519            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
520                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResponse,
521                i32,
522            >, ControlMarker>(
523                (),
524                0x1b14ff4adf5dc6f8,
525                fidl::encoding::DynamicFlags::empty(),
526                ___deadline,
527            )?;
528        Ok(_response.map(|x| x.processing_elements))
529    }
530
531    /// Get the processing element state via a hanging get.
532    /// For a given `processing_element_id`, the driver will immediately reply to the first
533    /// `WatchElementState` sent by the client. The driver will not respond to subsequent client
534    /// `WatchElementState` calls for that `processing_element_id` until any portion of the
535    /// `ElementState` has changed from what was most recently reported for that element.
536    ///
537    /// The driver will close the protocol channel with an error of `ZX_ERR_INVALID_ARGS`, if
538    /// `processing_element_id` does not match an ElementId returned by `GetElements`.
539    ///
540    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
541    /// method is called again while there is already a pending `WatchElementState` for this client
542    /// and `processing_element_id`.
543    pub fn r#watch_element_state(
544        &self,
545        mut processing_element_id: u64,
546        ___deadline: zx::MonotonicInstant,
547    ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ElementState, fidl::Error> {
548        let _response = self.client.send_query::<
549            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest,
550            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateResponse,
551            ControlMarker,
552        >(
553            (processing_element_id,),
554            0x524da8772a69056f,
555            fidl::encoding::DynamicFlags::empty(),
556            ___deadline,
557        )?;
558        Ok(_response.state)
559    }
560
561    /// Returns a vector of supported topologies.
562    /// This vector must include one or more topologies.
563    /// If more than one topology is returned, then the client may select any topology from the
564    /// list by calling `SetTopology`.
565    /// If only one topology is returned, `SetTopology` can still be called but causes no change.
566    ///
567    /// Each Element must be included in at least one Topology, but need not be included in every
568    /// Topology.
569    pub fn r#get_topologies(
570        &self,
571        ___deadline: zx::MonotonicInstant,
572    ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult, fidl::Error>
573    {
574        let _response =
575            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
576                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResponse,
577                i32,
578            >, ControlMarker>(
579                (),
580                0x73ffb73af24d30b6,
581                fidl::encoding::DynamicFlags::empty(),
582                ___deadline,
583            )?;
584        Ok(_response.map(|x| x.topologies))
585    }
586
587    /// Get the current topology via a hanging get.
588    /// The driver will immediately reply to the first `WatchTopology` sent by each client.
589    /// The driver will not respond to subsequent `WatchTopology` calls from that client until the
590    /// signal processing topology changes; this occurs as a result of a `SetTopology` call.
591    ///
592    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
593    /// method is called again while there is already a pending `WatchTopology` for this client.
594    pub fn r#watch_topology(&self, ___deadline: zx::MonotonicInstant) -> Result<u64, fidl::Error> {
595        let _response = self
596            .client
597            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleType<
598                fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchTopologyResponse,
599            >, ControlMarker>(
600                (),
601                0x66d172acdb36a729,
602                fidl::encoding::DynamicFlags::FLEXIBLE,
603                ___deadline,
604            )?
605            .into_result::<ControlMarker>("watch_topology")?;
606        Ok(_response.topology_id)
607    }
608
609    /// Sets the currently active topology by specifying a `topology_id`, which matches to an entry
610    /// in the vector returned by `GetTopologies`.
611    /// The currently active topology is communicated by `WatchTopology` responses. To change which
612    /// topology is active, a client uses `SetTopology`.
613    ///
614    /// If `GetTopologies` returns only one `Topology`, `SetTopology` is optional and has no effect.
615    ///
616    /// This call will fail and return `ZX_ERR_INVALID_ARGS` if the specified `topology_id` is not
617    /// found within the`topologies` returned by `GetTopologies`.
618    ///
619    /// `SetTopology` may be called before or after non-`SignalProcessing` protocol calls.
620    /// If called after non-`SignalProcessing` protocol calls, then `SetTopology` may return
621    /// `ZX_ERR_BAD_STATE` to indicate that the operation can not proceed without renegotiation of
622    /// the driver state. See `SetElementState` for further discussion.
623    pub fn r#set_topology(
624        &self,
625        mut topology_id: u64,
626        ___deadline: zx::MonotonicInstant,
627    ) -> Result<
628        fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyResult,
629        fidl::Error,
630    > {
631        let _response = self.client.send_query::<
632            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyRequest,
633            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
634            ControlMarker,
635        >(
636            (topology_id,),
637            0x1d9a7f9b8fee790c,
638            fidl::encoding::DynamicFlags::empty(),
639            ___deadline,
640        )?;
641        Ok(_response.map(|x| x))
642    }
643
644    /// Controls the processing element specified by `processing_element_id`, a unique ElementId
645    /// returned by `GetElements`.
646    /// The `state` specified in calls to `SetElementState` is a `SettableElementState`. This is a
647    /// subset of `ElementState` because some fields returned by `WatchElementState` (e.g. `latency`
648    /// or `plug_state`) can only be observed (not set) by the client.
649    ///
650    /// Returns `ZX_ERR_INVALID_ARGS` if `processing_element_id` does not match a known ElementId
651    /// returned by `GetElements`, or if `state` is not valid for the element. This entails any
652    /// violation of the rules specified in this protocol.
653    ///
654    /// Examples:
655    /// `state` specifies that an element should be stopped or bypassed, but the corresponding
656    ///     element does not specify (or explicitly set to false) `can_stop` or `can_bypass`.
657    /// `state` includes a `type_specific` entry, but that `SettableTypeSpecificElementState` does
658    ///     not match the `ElementType` of the element corresponding to `processing_element_id`.
659    /// `state` changes an `EqualizerBandState` for an `EQUALIZER` element (so far so good), but
660    ///     specifies a change to `frequency` when this element did not set `CAN_CONTROL_FREQUENCY`
661    ///     in its `supported_controls`.
662    /// `state` specifies a `GainElementState` for a `GAIN` element with a `gain` value that is
663    ///     -infinity, NAN, or outside the Element's stated [`min_gain`, `max_gain`] range.
664    ///
665    /// Callers may intersperse method calls to the `SignalProcessing` protocol with calls to other
666    /// driver protocols. Some non-`SignalProcessing` configuration changes may require a
667    /// renegotiation of the driver state before certain elements can receive a `SetElementState`.
668    /// For example, if a `DaiFormat` is changed, then `SetElementState` changing an `AGL` element's
669    /// parameters may not require renegotiation of driver state because changing gain parameters
670    /// usually does not change the set of supported audio formats.
671    /// By contrast, following the same `DaiFormat` change, before `SetElementState` can be called
672    /// on a `CONNECTION_POINT` element, the driver state may need to be reestablished because the
673    /// format change may invalidate the set of supported formats returned in a previous
674    /// `GetDaiFormats` protocol call for another part of the Topology.
675    ///
676    /// It is the driver's job to determine when renegotiation is required. When this is needed,
677    /// the related `SetElementState` call must return `ZX_ERR_BAD_STATE` and the client must
678    /// close the protocol channel entirely, such that the protocol negotiations are started over.
679    /// The client then must re-invoke the `SetElementState` call that returned
680    /// `ZX_ERR_BAD_STATE` before any non-`SignalProcessing` protocol calls.
681    pub fn r#set_element_state(
682        &self,
683        mut processing_element_id: u64,
684        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::SettableElementState,
685        ___deadline: zx::MonotonicInstant,
686    ) -> Result<
687        fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateResult,
688        fidl::Error,
689    > {
690        let _response = self.client.send_query::<
691            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateRequest,
692            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
693            ControlMarker,
694        >(
695            (processing_element_id, state,),
696            0x38c3b2d4bae698f4,
697            fidl::encoding::DynamicFlags::empty(),
698            ___deadline,
699        )?;
700        Ok(_response.map(|x| x))
701    }
702
703    /// Create the ring buffer used to pass audio to/from this device. If the device is
704    /// Composite, then the targeted RING_BUFFER element must be identified by `element_id`.
705    ///
706    /// Should only be called for Composite devices.
707    pub fn r#create_ring_buffer(
708        &self,
709        mut payload: ControlCreateRingBufferRequest,
710        ___deadline: zx::MonotonicInstant,
711    ) -> Result<ControlCreateRingBufferResult, fidl::Error> {
712        let _response = self
713            .client
714            .send_query::<ControlCreateRingBufferRequest, fidl::encoding::FlexibleResultType<
715                ControlCreateRingBufferResponse,
716                ControlCreateRingBufferError,
717            >, ControlMarker>(
718                &mut payload,
719                0x7462941cedb333db,
720                fidl::encoding::DynamicFlags::FLEXIBLE,
721                ___deadline,
722            )?
723            .into_result::<ControlMarker>("create_ring_buffer")?;
724        Ok(_response.map(|x| x))
725    }
726
727    /// Set the wire format for the digital interconnect associated with this element.
728    /// Creates a packet stream on the specified element.
729    pub fn r#create_packet_stream(
730        &self,
731        mut payload: ControlCreatePacketStreamRequest,
732        ___deadline: zx::MonotonicInstant,
733    ) -> Result<ControlCreatePacketStreamResult, fidl::Error> {
734        let _response = self
735            .client
736            .send_query::<ControlCreatePacketStreamRequest, fidl::encoding::FlexibleResultType<
737                ControlCreatePacketStreamResponse,
738                ControlCreatePacketStreamError,
739            >, ControlMarker>(
740                &mut payload,
741                0x5b2eacb5ad7df289,
742                fidl::encoding::DynamicFlags::FLEXIBLE,
743                ___deadline,
744            )?
745            .into_result::<ControlMarker>("create_packet_stream")?;
746        Ok(_response.map(|x| x))
747    }
748
749    /// Set the wire format for the digital interconnect connected to this Codec endpoint.
750    /// This method returns information related to the format that was set, including delay values.
751    /// If the device is Composite, then the targeted DAI_INTERCONNECT element must be identified
752    /// by `element_id`.
753    ///
754    /// Should only be called for Codec and Composite devices.
755    pub fn r#set_dai_format(
756        &self,
757        mut payload: &ControlSetDaiFormatRequest,
758        ___deadline: zx::MonotonicInstant,
759    ) -> Result<ControlSetDaiFormatResult, fidl::Error> {
760        let _response = self
761            .client
762            .send_query::<ControlSetDaiFormatRequest, fidl::encoding::FlexibleResultType<
763                ControlSetDaiFormatResponse,
764                ControlSetDaiFormatError,
765            >, ControlMarker>(
766                payload,
767                0x1d84f5a456a92216,
768                fidl::encoding::DynamicFlags::FLEXIBLE,
769                ___deadline,
770            )?
771            .into_result::<ControlMarker>("set_dai_format")?;
772        Ok(_response.map(|x| x))
773    }
774
775    /// Start the Codec hardware. If successful, this returns after the Codec was started and
776    /// `start_time` indicates the time when the hardware started. Note that the Codec's DaiFormat
777    /// must be set (by a successful `SetDaiFormat` call) before calling this method.
778    ///
779    /// Should only be called for Codec devices.
780    pub fn r#codec_start(
781        &self,
782        ___deadline: zx::MonotonicInstant,
783    ) -> Result<ControlCodecStartResult, fidl::Error> {
784        let _response =
785            self.client
786                .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
787                    ControlCodecStartResponse,
788                    ControlCodecStartError,
789                >, ControlMarker>(
790                    (),
791                    0x2a90a9d2958b997b,
792                    fidl::encoding::DynamicFlags::FLEXIBLE,
793                    ___deadline,
794                )?
795                .into_result::<ControlMarker>("codec_start")?;
796        Ok(_response.map(|x| x))
797    }
798
799    /// Stop the Codec hardware. If successful, this returns after the Codec was stopped and
800    /// `stop_time` indicates the time when the hardware stopped. Note that the Codec's DaiFormat
801    /// must be set (by a successful `SetDaiFormat` call) before calling this method.
802    ///
803    /// Should only be called for Codec devices.
804    pub fn r#codec_stop(
805        &self,
806        ___deadline: zx::MonotonicInstant,
807    ) -> Result<ControlCodecStopResult, fidl::Error> {
808        let _response = self.client.send_query::<
809            fidl::encoding::EmptyPayload,
810            fidl::encoding::FlexibleResultType<ControlCodecStopResponse, ControlCodecStopError>,
811            ControlMarker,
812        >(
813            (),
814            0x387297bb6bcad25f,
815            fidl::encoding::DynamicFlags::FLEXIBLE,
816            ___deadline,
817        )?
818        .into_result::<ControlMarker>("codec_stop")?;
819        Ok(_response.map(|x| x))
820    }
821
822    /// Reset the hardware -- stopping the hardware, releasing any ring buffers, and clearing any
823    /// DaiFormats or RingBufferFormats that were set.
824    ///
825    /// This method returns when the hardware reset is complete.
826    /// After calling this method, the device is still controlled, but any ring buffers must be
827    /// re-created and re-started.
828    /// For devices with DAI_INTERCONNECTs (such as Codecs and some Composites), `SetDaiFormat` and
829    /// `CodecStart` must be called again (in that order) to return the interconnect to the active
830    /// operational mode.
831    /// As applicable, `SetTopology` and `SetElementState` must also be called.
832    ///
833    /// Should only be called for Codec and Composite devices.
834    pub fn r#reset(
835        &self,
836        ___deadline: zx::MonotonicInstant,
837    ) -> Result<ControlResetResult, fidl::Error> {
838        let _response = self.client.send_query::<
839            fidl::encoding::EmptyPayload,
840            fidl::encoding::FlexibleResultType<ControlResetResponse, ControlResetError>,
841            ControlMarker,
842        >(
843            (),
844            0x49840db00a698996,
845            fidl::encoding::DynamicFlags::FLEXIBLE,
846            ___deadline,
847        )?
848        .into_result::<ControlMarker>("reset")?;
849        Ok(_response.map(|x| x))
850    }
851}
852
853#[cfg(target_os = "fuchsia")]
854impl From<ControlSynchronousProxy> for zx::NullableHandle {
855    fn from(value: ControlSynchronousProxy) -> Self {
856        value.into_channel().into()
857    }
858}
859
860#[cfg(target_os = "fuchsia")]
861impl From<fidl::Channel> for ControlSynchronousProxy {
862    fn from(value: fidl::Channel) -> Self {
863        Self::new(value)
864    }
865}
866
867#[cfg(target_os = "fuchsia")]
868impl fidl::endpoints::FromClient for ControlSynchronousProxy {
869    type Protocol = ControlMarker;
870
871    fn from_client(value: fidl::endpoints::ClientEnd<ControlMarker>) -> Self {
872        Self::new(value.into_channel())
873    }
874}
875
876#[derive(Debug, Clone)]
877pub struct ControlProxy {
878    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
879}
880
881impl fidl::endpoints::Proxy for ControlProxy {
882    type Protocol = ControlMarker;
883
884    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
885        Self::new(inner)
886    }
887
888    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
889        self.client.into_channel().map_err(|client| Self { client })
890    }
891
892    fn as_channel(&self) -> &::fidl::AsyncChannel {
893        self.client.as_channel()
894    }
895}
896
897impl ControlProxy {
898    /// Create a new Proxy for fuchsia.audio.device/Control.
899    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
900        let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
901        Self { client: fidl::client::Client::new(channel, protocol_name) }
902    }
903
904    /// Get a Stream of events from the remote end of the protocol.
905    ///
906    /// # Panics
907    ///
908    /// Panics if the event stream was already taken.
909    pub fn take_event_stream(&self) -> ControlEventStream {
910        ControlEventStream { event_receiver: self.client.take_event_receiver() }
911    }
912
913    /// Returns a vector of supported processing elements.
914    /// This vector must include one or more processing elements.
915    pub fn r#get_elements(
916        &self,
917    ) -> fidl::client::QueryResponseFut<
918        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
919        fidl::encoding::DefaultFuchsiaResourceDialect,
920    > {
921        ControlProxyInterface::r#get_elements(self)
922    }
923
924    /// Get the processing element state via a hanging get.
925    /// For a given `processing_element_id`, the driver will immediately reply to the first
926    /// `WatchElementState` sent by the client. The driver will not respond to subsequent client
927    /// `WatchElementState` calls for that `processing_element_id` until any portion of the
928    /// `ElementState` has changed from what was most recently reported for that element.
929    ///
930    /// The driver will close the protocol channel with an error of `ZX_ERR_INVALID_ARGS`, if
931    /// `processing_element_id` does not match an ElementId returned by `GetElements`.
932    ///
933    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
934    /// method is called again while there is already a pending `WatchElementState` for this client
935    /// and `processing_element_id`.
936    pub fn r#watch_element_state(
937        &self,
938        mut processing_element_id: u64,
939    ) -> fidl::client::QueryResponseFut<
940        fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
941        fidl::encoding::DefaultFuchsiaResourceDialect,
942    > {
943        ControlProxyInterface::r#watch_element_state(self, processing_element_id)
944    }
945
946    /// Returns a vector of supported topologies.
947    /// This vector must include one or more topologies.
948    /// If more than one topology is returned, then the client may select any topology from the
949    /// list by calling `SetTopology`.
950    /// If only one topology is returned, `SetTopology` can still be called but causes no change.
951    ///
952    /// Each Element must be included in at least one Topology, but need not be included in every
953    /// Topology.
954    pub fn r#get_topologies(
955        &self,
956    ) -> fidl::client::QueryResponseFut<
957        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
958        fidl::encoding::DefaultFuchsiaResourceDialect,
959    > {
960        ControlProxyInterface::r#get_topologies(self)
961    }
962
963    /// Get the current topology via a hanging get.
964    /// The driver will immediately reply to the first `WatchTopology` sent by each client.
965    /// The driver will not respond to subsequent `WatchTopology` calls from that client until the
966    /// signal processing topology changes; this occurs as a result of a `SetTopology` call.
967    ///
968    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
969    /// method is called again while there is already a pending `WatchTopology` for this client.
970    pub fn r#watch_topology(
971        &self,
972    ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
973        ControlProxyInterface::r#watch_topology(self)
974    }
975
976    /// Sets the currently active topology by specifying a `topology_id`, which matches to an entry
977    /// in the vector returned by `GetTopologies`.
978    /// The currently active topology is communicated by `WatchTopology` responses. To change which
979    /// topology is active, a client uses `SetTopology`.
980    ///
981    /// If `GetTopologies` returns only one `Topology`, `SetTopology` is optional and has no effect.
982    ///
983    /// This call will fail and return `ZX_ERR_INVALID_ARGS` if the specified `topology_id` is not
984    /// found within the`topologies` returned by `GetTopologies`.
985    ///
986    /// `SetTopology` may be called before or after non-`SignalProcessing` protocol calls.
987    /// If called after non-`SignalProcessing` protocol calls, then `SetTopology` may return
988    /// `ZX_ERR_BAD_STATE` to indicate that the operation can not proceed without renegotiation of
989    /// the driver state. See `SetElementState` for further discussion.
990    pub fn r#set_topology(
991        &self,
992        mut topology_id: u64,
993    ) -> fidl::client::QueryResponseFut<
994        fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyResult,
995        fidl::encoding::DefaultFuchsiaResourceDialect,
996    > {
997        ControlProxyInterface::r#set_topology(self, topology_id)
998    }
999
1000    /// Controls the processing element specified by `processing_element_id`, a unique ElementId
1001    /// returned by `GetElements`.
1002    /// The `state` specified in calls to `SetElementState` is a `SettableElementState`. This is a
1003    /// subset of `ElementState` because some fields returned by `WatchElementState` (e.g. `latency`
1004    /// or `plug_state`) can only be observed (not set) by the client.
1005    ///
1006    /// Returns `ZX_ERR_INVALID_ARGS` if `processing_element_id` does not match a known ElementId
1007    /// returned by `GetElements`, or if `state` is not valid for the element. This entails any
1008    /// violation of the rules specified in this protocol.
1009    ///
1010    /// Examples:
1011    /// `state` specifies that an element should be stopped or bypassed, but the corresponding
1012    ///     element does not specify (or explicitly set to false) `can_stop` or `can_bypass`.
1013    /// `state` includes a `type_specific` entry, but that `SettableTypeSpecificElementState` does
1014    ///     not match the `ElementType` of the element corresponding to `processing_element_id`.
1015    /// `state` changes an `EqualizerBandState` for an `EQUALIZER` element (so far so good), but
1016    ///     specifies a change to `frequency` when this element did not set `CAN_CONTROL_FREQUENCY`
1017    ///     in its `supported_controls`.
1018    /// `state` specifies a `GainElementState` for a `GAIN` element with a `gain` value that is
1019    ///     -infinity, NAN, or outside the Element's stated [`min_gain`, `max_gain`] range.
1020    ///
1021    /// Callers may intersperse method calls to the `SignalProcessing` protocol with calls to other
1022    /// driver protocols. Some non-`SignalProcessing` configuration changes may require a
1023    /// renegotiation of the driver state before certain elements can receive a `SetElementState`.
1024    /// For example, if a `DaiFormat` is changed, then `SetElementState` changing an `AGL` element's
1025    /// parameters may not require renegotiation of driver state because changing gain parameters
1026    /// usually does not change the set of supported audio formats.
1027    /// By contrast, following the same `DaiFormat` change, before `SetElementState` can be called
1028    /// on a `CONNECTION_POINT` element, the driver state may need to be reestablished because the
1029    /// format change may invalidate the set of supported formats returned in a previous
1030    /// `GetDaiFormats` protocol call for another part of the Topology.
1031    ///
1032    /// It is the driver's job to determine when renegotiation is required. When this is needed,
1033    /// the related `SetElementState` call must return `ZX_ERR_BAD_STATE` and the client must
1034    /// close the protocol channel entirely, such that the protocol negotiations are started over.
1035    /// The client then must re-invoke the `SetElementState` call that returned
1036    /// `ZX_ERR_BAD_STATE` before any non-`SignalProcessing` protocol calls.
1037    pub fn r#set_element_state(
1038        &self,
1039        mut processing_element_id: u64,
1040        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::SettableElementState,
1041    ) -> fidl::client::QueryResponseFut<
1042        fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateResult,
1043        fidl::encoding::DefaultFuchsiaResourceDialect,
1044    > {
1045        ControlProxyInterface::r#set_element_state(self, processing_element_id, state)
1046    }
1047
1048    /// Create the ring buffer used to pass audio to/from this device. If the device is
1049    /// Composite, then the targeted RING_BUFFER element must be identified by `element_id`.
1050    ///
1051    /// Should only be called for Composite devices.
1052    pub fn r#create_ring_buffer(
1053        &self,
1054        mut payload: ControlCreateRingBufferRequest,
1055    ) -> fidl::client::QueryResponseFut<
1056        ControlCreateRingBufferResult,
1057        fidl::encoding::DefaultFuchsiaResourceDialect,
1058    > {
1059        ControlProxyInterface::r#create_ring_buffer(self, payload)
1060    }
1061
1062    /// Set the wire format for the digital interconnect associated with this element.
1063    /// Creates a packet stream on the specified element.
1064    pub fn r#create_packet_stream(
1065        &self,
1066        mut payload: ControlCreatePacketStreamRequest,
1067    ) -> fidl::client::QueryResponseFut<
1068        ControlCreatePacketStreamResult,
1069        fidl::encoding::DefaultFuchsiaResourceDialect,
1070    > {
1071        ControlProxyInterface::r#create_packet_stream(self, payload)
1072    }
1073
1074    /// Set the wire format for the digital interconnect connected to this Codec endpoint.
1075    /// This method returns information related to the format that was set, including delay values.
1076    /// If the device is Composite, then the targeted DAI_INTERCONNECT element must be identified
1077    /// by `element_id`.
1078    ///
1079    /// Should only be called for Codec and Composite devices.
1080    pub fn r#set_dai_format(
1081        &self,
1082        mut payload: &ControlSetDaiFormatRequest,
1083    ) -> fidl::client::QueryResponseFut<
1084        ControlSetDaiFormatResult,
1085        fidl::encoding::DefaultFuchsiaResourceDialect,
1086    > {
1087        ControlProxyInterface::r#set_dai_format(self, payload)
1088    }
1089
1090    /// Start the Codec hardware. If successful, this returns after the Codec was started and
1091    /// `start_time` indicates the time when the hardware started. Note that the Codec's DaiFormat
1092    /// must be set (by a successful `SetDaiFormat` call) before calling this method.
1093    ///
1094    /// Should only be called for Codec devices.
1095    pub fn r#codec_start(
1096        &self,
1097    ) -> fidl::client::QueryResponseFut<
1098        ControlCodecStartResult,
1099        fidl::encoding::DefaultFuchsiaResourceDialect,
1100    > {
1101        ControlProxyInterface::r#codec_start(self)
1102    }
1103
1104    /// Stop the Codec hardware. If successful, this returns after the Codec was stopped and
1105    /// `stop_time` indicates the time when the hardware stopped. Note that the Codec's DaiFormat
1106    /// must be set (by a successful `SetDaiFormat` call) before calling this method.
1107    ///
1108    /// Should only be called for Codec devices.
1109    pub fn r#codec_stop(
1110        &self,
1111    ) -> fidl::client::QueryResponseFut<
1112        ControlCodecStopResult,
1113        fidl::encoding::DefaultFuchsiaResourceDialect,
1114    > {
1115        ControlProxyInterface::r#codec_stop(self)
1116    }
1117
1118    /// Reset the hardware -- stopping the hardware, releasing any ring buffers, and clearing any
1119    /// DaiFormats or RingBufferFormats that were set.
1120    ///
1121    /// This method returns when the hardware reset is complete.
1122    /// After calling this method, the device is still controlled, but any ring buffers must be
1123    /// re-created and re-started.
1124    /// For devices with DAI_INTERCONNECTs (such as Codecs and some Composites), `SetDaiFormat` and
1125    /// `CodecStart` must be called again (in that order) to return the interconnect to the active
1126    /// operational mode.
1127    /// As applicable, `SetTopology` and `SetElementState` must also be called.
1128    ///
1129    /// Should only be called for Codec and Composite devices.
1130    pub fn r#reset(
1131        &self,
1132    ) -> fidl::client::QueryResponseFut<
1133        ControlResetResult,
1134        fidl::encoding::DefaultFuchsiaResourceDialect,
1135    > {
1136        ControlProxyInterface::r#reset(self)
1137    }
1138}
1139
1140impl ControlProxyInterface for ControlProxy {
1141    type GetElementsResponseFut = fidl::client::QueryResponseFut<
1142        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
1143        fidl::encoding::DefaultFuchsiaResourceDialect,
1144    >;
1145    fn r#get_elements(&self) -> Self::GetElementsResponseFut {
1146        fn _decode(
1147            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1148        ) -> Result<
1149            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
1150            fidl::Error,
1151        > {
1152            let _response = fidl::client::decode_transaction_body::<
1153                fidl::encoding::ResultType<
1154                    fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResponse,
1155                    i32,
1156                >,
1157                fidl::encoding::DefaultFuchsiaResourceDialect,
1158                0x1b14ff4adf5dc6f8,
1159            >(_buf?)?;
1160            Ok(_response.map(|x| x.processing_elements))
1161        }
1162        self.client.send_query_and_decode::<
1163            fidl::encoding::EmptyPayload,
1164            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
1165        >(
1166            (),
1167            0x1b14ff4adf5dc6f8,
1168            fidl::encoding::DynamicFlags::empty(),
1169            _decode,
1170        )
1171    }
1172
1173    type WatchElementStateResponseFut = fidl::client::QueryResponseFut<
1174        fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
1175        fidl::encoding::DefaultFuchsiaResourceDialect,
1176    >;
1177    fn r#watch_element_state(
1178        &self,
1179        mut processing_element_id: u64,
1180    ) -> Self::WatchElementStateResponseFut {
1181        fn _decode(
1182            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1183        ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ElementState, fidl::Error>
1184        {
1185            let _response = fidl::client::decode_transaction_body::<
1186                fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateResponse,
1187                fidl::encoding::DefaultFuchsiaResourceDialect,
1188                0x524da8772a69056f,
1189            >(_buf?)?;
1190            Ok(_response.state)
1191        }
1192        self.client.send_query_and_decode::<
1193            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest,
1194            fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
1195        >(
1196            (processing_element_id,),
1197            0x524da8772a69056f,
1198            fidl::encoding::DynamicFlags::empty(),
1199            _decode,
1200        )
1201    }
1202
1203    type GetTopologiesResponseFut = fidl::client::QueryResponseFut<
1204        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
1205        fidl::encoding::DefaultFuchsiaResourceDialect,
1206    >;
1207    fn r#get_topologies(&self) -> Self::GetTopologiesResponseFut {
1208        fn _decode(
1209            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1210        ) -> Result<
1211            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
1212            fidl::Error,
1213        > {
1214            let _response = fidl::client::decode_transaction_body::<
1215                fidl::encoding::ResultType<
1216                    fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResponse,
1217                    i32,
1218                >,
1219                fidl::encoding::DefaultFuchsiaResourceDialect,
1220                0x73ffb73af24d30b6,
1221            >(_buf?)?;
1222            Ok(_response.map(|x| x.topologies))
1223        }
1224        self.client.send_query_and_decode::<
1225            fidl::encoding::EmptyPayload,
1226            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
1227        >(
1228            (),
1229            0x73ffb73af24d30b6,
1230            fidl::encoding::DynamicFlags::empty(),
1231            _decode,
1232        )
1233    }
1234
1235    type WatchTopologyResponseFut =
1236        fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
1237    fn r#watch_topology(&self) -> Self::WatchTopologyResponseFut {
1238        fn _decode(
1239            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1240        ) -> Result<u64, fidl::Error> {
1241            let _response = fidl::client::decode_transaction_body::<
1242                fidl::encoding::FlexibleType<
1243                    fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchTopologyResponse,
1244                >,
1245                fidl::encoding::DefaultFuchsiaResourceDialect,
1246                0x66d172acdb36a729,
1247            >(_buf?)?
1248            .into_result::<ControlMarker>("watch_topology")?;
1249            Ok(_response.topology_id)
1250        }
1251        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u64>(
1252            (),
1253            0x66d172acdb36a729,
1254            fidl::encoding::DynamicFlags::FLEXIBLE,
1255            _decode,
1256        )
1257    }
1258
1259    type SetTopologyResponseFut = fidl::client::QueryResponseFut<
1260        fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyResult,
1261        fidl::encoding::DefaultFuchsiaResourceDialect,
1262    >;
1263    fn r#set_topology(&self, mut topology_id: u64) -> Self::SetTopologyResponseFut {
1264        fn _decode(
1265            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1266        ) -> Result<
1267            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyResult,
1268            fidl::Error,
1269        > {
1270            let _response = fidl::client::decode_transaction_body::<
1271                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1272                fidl::encoding::DefaultFuchsiaResourceDialect,
1273                0x1d9a7f9b8fee790c,
1274            >(_buf?)?;
1275            Ok(_response.map(|x| x))
1276        }
1277        self.client.send_query_and_decode::<
1278            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyRequest,
1279            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyResult,
1280        >(
1281            (topology_id,),
1282            0x1d9a7f9b8fee790c,
1283            fidl::encoding::DynamicFlags::empty(),
1284            _decode,
1285        )
1286    }
1287
1288    type SetElementStateResponseFut = fidl::client::QueryResponseFut<
1289        fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateResult,
1290        fidl::encoding::DefaultFuchsiaResourceDialect,
1291    >;
1292    fn r#set_element_state(
1293        &self,
1294        mut processing_element_id: u64,
1295        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::SettableElementState,
1296    ) -> Self::SetElementStateResponseFut {
1297        fn _decode(
1298            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1299        ) -> Result<
1300            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateResult,
1301            fidl::Error,
1302        > {
1303            let _response = fidl::client::decode_transaction_body::<
1304                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1305                fidl::encoding::DefaultFuchsiaResourceDialect,
1306                0x38c3b2d4bae698f4,
1307            >(_buf?)?;
1308            Ok(_response.map(|x| x))
1309        }
1310        self.client.send_query_and_decode::<
1311            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateRequest,
1312            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateResult,
1313        >(
1314            (processing_element_id, state,),
1315            0x38c3b2d4bae698f4,
1316            fidl::encoding::DynamicFlags::empty(),
1317            _decode,
1318        )
1319    }
1320
1321    type CreateRingBufferResponseFut = fidl::client::QueryResponseFut<
1322        ControlCreateRingBufferResult,
1323        fidl::encoding::DefaultFuchsiaResourceDialect,
1324    >;
1325    fn r#create_ring_buffer(
1326        &self,
1327        mut payload: ControlCreateRingBufferRequest,
1328    ) -> Self::CreateRingBufferResponseFut {
1329        fn _decode(
1330            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1331        ) -> Result<ControlCreateRingBufferResult, fidl::Error> {
1332            let _response = fidl::client::decode_transaction_body::<
1333                fidl::encoding::FlexibleResultType<
1334                    ControlCreateRingBufferResponse,
1335                    ControlCreateRingBufferError,
1336                >,
1337                fidl::encoding::DefaultFuchsiaResourceDialect,
1338                0x7462941cedb333db,
1339            >(_buf?)?
1340            .into_result::<ControlMarker>("create_ring_buffer")?;
1341            Ok(_response.map(|x| x))
1342        }
1343        self.client
1344            .send_query_and_decode::<ControlCreateRingBufferRequest, ControlCreateRingBufferResult>(
1345                &mut payload,
1346                0x7462941cedb333db,
1347                fidl::encoding::DynamicFlags::FLEXIBLE,
1348                _decode,
1349            )
1350    }
1351
1352    type CreatePacketStreamResponseFut = fidl::client::QueryResponseFut<
1353        ControlCreatePacketStreamResult,
1354        fidl::encoding::DefaultFuchsiaResourceDialect,
1355    >;
1356    fn r#create_packet_stream(
1357        &self,
1358        mut payload: ControlCreatePacketStreamRequest,
1359    ) -> Self::CreatePacketStreamResponseFut {
1360        fn _decode(
1361            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1362        ) -> Result<ControlCreatePacketStreamResult, fidl::Error> {
1363            let _response = fidl::client::decode_transaction_body::<
1364                fidl::encoding::FlexibleResultType<
1365                    ControlCreatePacketStreamResponse,
1366                    ControlCreatePacketStreamError,
1367                >,
1368                fidl::encoding::DefaultFuchsiaResourceDialect,
1369                0x5b2eacb5ad7df289,
1370            >(_buf?)?
1371            .into_result::<ControlMarker>("create_packet_stream")?;
1372            Ok(_response.map(|x| x))
1373        }
1374        self.client.send_query_and_decode::<
1375            ControlCreatePacketStreamRequest,
1376            ControlCreatePacketStreamResult,
1377        >(
1378            &mut payload,
1379            0x5b2eacb5ad7df289,
1380            fidl::encoding::DynamicFlags::FLEXIBLE,
1381            _decode,
1382        )
1383    }
1384
1385    type SetDaiFormatResponseFut = fidl::client::QueryResponseFut<
1386        ControlSetDaiFormatResult,
1387        fidl::encoding::DefaultFuchsiaResourceDialect,
1388    >;
1389    fn r#set_dai_format(
1390        &self,
1391        mut payload: &ControlSetDaiFormatRequest,
1392    ) -> Self::SetDaiFormatResponseFut {
1393        fn _decode(
1394            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1395        ) -> Result<ControlSetDaiFormatResult, fidl::Error> {
1396            let _response = fidl::client::decode_transaction_body::<
1397                fidl::encoding::FlexibleResultType<
1398                    ControlSetDaiFormatResponse,
1399                    ControlSetDaiFormatError,
1400                >,
1401                fidl::encoding::DefaultFuchsiaResourceDialect,
1402                0x1d84f5a456a92216,
1403            >(_buf?)?
1404            .into_result::<ControlMarker>("set_dai_format")?;
1405            Ok(_response.map(|x| x))
1406        }
1407        self.client.send_query_and_decode::<ControlSetDaiFormatRequest, ControlSetDaiFormatResult>(
1408            payload,
1409            0x1d84f5a456a92216,
1410            fidl::encoding::DynamicFlags::FLEXIBLE,
1411            _decode,
1412        )
1413    }
1414
1415    type CodecStartResponseFut = fidl::client::QueryResponseFut<
1416        ControlCodecStartResult,
1417        fidl::encoding::DefaultFuchsiaResourceDialect,
1418    >;
1419    fn r#codec_start(&self) -> Self::CodecStartResponseFut {
1420        fn _decode(
1421            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1422        ) -> Result<ControlCodecStartResult, fidl::Error> {
1423            let _response = fidl::client::decode_transaction_body::<
1424                fidl::encoding::FlexibleResultType<
1425                    ControlCodecStartResponse,
1426                    ControlCodecStartError,
1427                >,
1428                fidl::encoding::DefaultFuchsiaResourceDialect,
1429                0x2a90a9d2958b997b,
1430            >(_buf?)?
1431            .into_result::<ControlMarker>("codec_start")?;
1432            Ok(_response.map(|x| x))
1433        }
1434        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ControlCodecStartResult>(
1435            (),
1436            0x2a90a9d2958b997b,
1437            fidl::encoding::DynamicFlags::FLEXIBLE,
1438            _decode,
1439        )
1440    }
1441
1442    type CodecStopResponseFut = fidl::client::QueryResponseFut<
1443        ControlCodecStopResult,
1444        fidl::encoding::DefaultFuchsiaResourceDialect,
1445    >;
1446    fn r#codec_stop(&self) -> Self::CodecStopResponseFut {
1447        fn _decode(
1448            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1449        ) -> Result<ControlCodecStopResult, fidl::Error> {
1450            let _response = fidl::client::decode_transaction_body::<
1451                fidl::encoding::FlexibleResultType<ControlCodecStopResponse, ControlCodecStopError>,
1452                fidl::encoding::DefaultFuchsiaResourceDialect,
1453                0x387297bb6bcad25f,
1454            >(_buf?)?
1455            .into_result::<ControlMarker>("codec_stop")?;
1456            Ok(_response.map(|x| x))
1457        }
1458        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ControlCodecStopResult>(
1459            (),
1460            0x387297bb6bcad25f,
1461            fidl::encoding::DynamicFlags::FLEXIBLE,
1462            _decode,
1463        )
1464    }
1465
1466    type ResetResponseFut = fidl::client::QueryResponseFut<
1467        ControlResetResult,
1468        fidl::encoding::DefaultFuchsiaResourceDialect,
1469    >;
1470    fn r#reset(&self) -> Self::ResetResponseFut {
1471        fn _decode(
1472            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1473        ) -> Result<ControlResetResult, fidl::Error> {
1474            let _response = fidl::client::decode_transaction_body::<
1475                fidl::encoding::FlexibleResultType<ControlResetResponse, ControlResetError>,
1476                fidl::encoding::DefaultFuchsiaResourceDialect,
1477                0x49840db00a698996,
1478            >(_buf?)?
1479            .into_result::<ControlMarker>("reset")?;
1480            Ok(_response.map(|x| x))
1481        }
1482        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ControlResetResult>(
1483            (),
1484            0x49840db00a698996,
1485            fidl::encoding::DynamicFlags::FLEXIBLE,
1486            _decode,
1487        )
1488    }
1489}
1490
1491pub struct ControlEventStream {
1492    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1493}
1494
1495impl std::marker::Unpin for ControlEventStream {}
1496
1497impl futures::stream::FusedStream for ControlEventStream {
1498    fn is_terminated(&self) -> bool {
1499        self.event_receiver.is_terminated()
1500    }
1501}
1502
1503impl futures::Stream for ControlEventStream {
1504    type Item = Result<ControlEvent, fidl::Error>;
1505
1506    fn poll_next(
1507        mut self: std::pin::Pin<&mut Self>,
1508        cx: &mut std::task::Context<'_>,
1509    ) -> std::task::Poll<Option<Self::Item>> {
1510        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1511            &mut self.event_receiver,
1512            cx
1513        )?) {
1514            Some(buf) => std::task::Poll::Ready(Some(ControlEvent::decode(buf))),
1515            None => std::task::Poll::Ready(None),
1516        }
1517    }
1518}
1519
1520#[derive(Debug)]
1521pub enum ControlEvent {
1522    #[non_exhaustive]
1523    _UnknownEvent {
1524        /// Ordinal of the event that was sent.
1525        ordinal: u64,
1526    },
1527}
1528
1529impl ControlEvent {
1530    /// Decodes a message buffer as a [`ControlEvent`].
1531    fn decode(
1532        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1533    ) -> Result<ControlEvent, fidl::Error> {
1534        let (bytes, _handles) = buf.split_mut();
1535        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1536        debug_assert_eq!(tx_header.tx_id, 0);
1537        match tx_header.ordinal {
1538            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1539                Ok(ControlEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1540            }
1541            _ => Err(fidl::Error::UnknownOrdinal {
1542                ordinal: tx_header.ordinal,
1543                protocol_name: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1544            }),
1545        }
1546    }
1547}
1548
1549/// A Stream of incoming requests for fuchsia.audio.device/Control.
1550pub struct ControlRequestStream {
1551    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1552    is_terminated: bool,
1553}
1554
1555impl std::marker::Unpin for ControlRequestStream {}
1556
1557impl futures::stream::FusedStream for ControlRequestStream {
1558    fn is_terminated(&self) -> bool {
1559        self.is_terminated
1560    }
1561}
1562
1563impl fidl::endpoints::RequestStream for ControlRequestStream {
1564    type Protocol = ControlMarker;
1565    type ControlHandle = ControlControlHandle;
1566
1567    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1568        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1569    }
1570
1571    fn control_handle(&self) -> Self::ControlHandle {
1572        ControlControlHandle { inner: self.inner.clone() }
1573    }
1574
1575    fn into_inner(
1576        self,
1577    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1578    {
1579        (self.inner, self.is_terminated)
1580    }
1581
1582    fn from_inner(
1583        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1584        is_terminated: bool,
1585    ) -> Self {
1586        Self { inner, is_terminated }
1587    }
1588}
1589
1590impl futures::Stream for ControlRequestStream {
1591    type Item = Result<ControlRequest, fidl::Error>;
1592
1593    fn poll_next(
1594        mut self: std::pin::Pin<&mut Self>,
1595        cx: &mut std::task::Context<'_>,
1596    ) -> std::task::Poll<Option<Self::Item>> {
1597        let this = &mut *self;
1598        if this.inner.check_shutdown(cx) {
1599            this.is_terminated = true;
1600            return std::task::Poll::Ready(None);
1601        }
1602        if this.is_terminated {
1603            panic!("polled ControlRequestStream after completion");
1604        }
1605        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1606            |bytes, handles| {
1607                match this.inner.channel().read_etc(cx, bytes, handles) {
1608                    std::task::Poll::Ready(Ok(())) => {}
1609                    std::task::Poll::Pending => return std::task::Poll::Pending,
1610                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1611                        this.is_terminated = true;
1612                        return std::task::Poll::Ready(None);
1613                    }
1614                    std::task::Poll::Ready(Err(e)) => {
1615                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1616                            e.into(),
1617                        ))));
1618                    }
1619                }
1620
1621                // A message has been received from the channel
1622                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1623
1624                std::task::Poll::Ready(Some(match header.ordinal {
1625                    0x1b14ff4adf5dc6f8 => {
1626                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1627                        let mut req = fidl::new_empty!(
1628                            fidl::encoding::EmptyPayload,
1629                            fidl::encoding::DefaultFuchsiaResourceDialect
1630                        );
1631                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1632                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1633                        Ok(ControlRequest::GetElements {
1634                            responder: ControlGetElementsResponder {
1635                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1636                                tx_id: header.tx_id,
1637                            },
1638                        })
1639                    }
1640                    0x524da8772a69056f => {
1641                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1642                        let mut req = fidl::new_empty!(fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1643                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest>(&header, _body_bytes, handles, &mut req)?;
1644                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1645                        Ok(ControlRequest::WatchElementState {
1646                            processing_element_id: req.processing_element_id,
1647
1648                            responder: ControlWatchElementStateResponder {
1649                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1650                                tx_id: header.tx_id,
1651                            },
1652                        })
1653                    }
1654                    0x73ffb73af24d30b6 => {
1655                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1656                        let mut req = fidl::new_empty!(
1657                            fidl::encoding::EmptyPayload,
1658                            fidl::encoding::DefaultFuchsiaResourceDialect
1659                        );
1660                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1661                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1662                        Ok(ControlRequest::GetTopologies {
1663                            responder: ControlGetTopologiesResponder {
1664                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1665                                tx_id: header.tx_id,
1666                            },
1667                        })
1668                    }
1669                    0x66d172acdb36a729 => {
1670                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1671                        let mut req = fidl::new_empty!(
1672                            fidl::encoding::EmptyPayload,
1673                            fidl::encoding::DefaultFuchsiaResourceDialect
1674                        );
1675                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1676                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1677                        Ok(ControlRequest::WatchTopology {
1678                            responder: ControlWatchTopologyResponder {
1679                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1680                                tx_id: header.tx_id,
1681                            },
1682                        })
1683                    }
1684                    0x1d9a7f9b8fee790c => {
1685                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1686                        let mut req = fidl::new_empty!(fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1687                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyRequest>(&header, _body_bytes, handles, &mut req)?;
1688                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1689                        Ok(ControlRequest::SetTopology {
1690                            topology_id: req.topology_id,
1691
1692                            responder: ControlSetTopologyResponder {
1693                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1694                                tx_id: header.tx_id,
1695                            },
1696                        })
1697                    }
1698                    0x38c3b2d4bae698f4 => {
1699                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1700                        let mut req = fidl::new_empty!(fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1701                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateRequest>(&header, _body_bytes, handles, &mut req)?;
1702                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1703                        Ok(ControlRequest::SetElementState {
1704                            processing_element_id: req.processing_element_id,
1705                            state: req.state,
1706
1707                            responder: ControlSetElementStateResponder {
1708                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1709                                tx_id: header.tx_id,
1710                            },
1711                        })
1712                    }
1713                    0x7462941cedb333db => {
1714                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1715                        let mut req = fidl::new_empty!(
1716                            ControlCreateRingBufferRequest,
1717                            fidl::encoding::DefaultFuchsiaResourceDialect
1718                        );
1719                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlCreateRingBufferRequest>(&header, _body_bytes, handles, &mut req)?;
1720                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1721                        Ok(ControlRequest::CreateRingBuffer {
1722                            payload: req,
1723                            responder: ControlCreateRingBufferResponder {
1724                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1725                                tx_id: header.tx_id,
1726                            },
1727                        })
1728                    }
1729                    0x5b2eacb5ad7df289 => {
1730                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1731                        let mut req = fidl::new_empty!(
1732                            ControlCreatePacketStreamRequest,
1733                            fidl::encoding::DefaultFuchsiaResourceDialect
1734                        );
1735                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlCreatePacketStreamRequest>(&header, _body_bytes, handles, &mut req)?;
1736                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1737                        Ok(ControlRequest::CreatePacketStream {
1738                            payload: req,
1739                            responder: ControlCreatePacketStreamResponder {
1740                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1741                                tx_id: header.tx_id,
1742                            },
1743                        })
1744                    }
1745                    0x1d84f5a456a92216 => {
1746                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1747                        let mut req = fidl::new_empty!(
1748                            ControlSetDaiFormatRequest,
1749                            fidl::encoding::DefaultFuchsiaResourceDialect
1750                        );
1751                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetDaiFormatRequest>(&header, _body_bytes, handles, &mut req)?;
1752                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1753                        Ok(ControlRequest::SetDaiFormat {
1754                            payload: req,
1755                            responder: ControlSetDaiFormatResponder {
1756                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1757                                tx_id: header.tx_id,
1758                            },
1759                        })
1760                    }
1761                    0x2a90a9d2958b997b => {
1762                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1763                        let mut req = fidl::new_empty!(
1764                            fidl::encoding::EmptyPayload,
1765                            fidl::encoding::DefaultFuchsiaResourceDialect
1766                        );
1767                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1768                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1769                        Ok(ControlRequest::CodecStart {
1770                            responder: ControlCodecStartResponder {
1771                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1772                                tx_id: header.tx_id,
1773                            },
1774                        })
1775                    }
1776                    0x387297bb6bcad25f => {
1777                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1778                        let mut req = fidl::new_empty!(
1779                            fidl::encoding::EmptyPayload,
1780                            fidl::encoding::DefaultFuchsiaResourceDialect
1781                        );
1782                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1783                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1784                        Ok(ControlRequest::CodecStop {
1785                            responder: ControlCodecStopResponder {
1786                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1787                                tx_id: header.tx_id,
1788                            },
1789                        })
1790                    }
1791                    0x49840db00a698996 => {
1792                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1793                        let mut req = fidl::new_empty!(
1794                            fidl::encoding::EmptyPayload,
1795                            fidl::encoding::DefaultFuchsiaResourceDialect
1796                        );
1797                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1798                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1799                        Ok(ControlRequest::Reset {
1800                            responder: ControlResetResponder {
1801                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1802                                tx_id: header.tx_id,
1803                            },
1804                        })
1805                    }
1806                    _ if header.tx_id == 0
1807                        && header
1808                            .dynamic_flags()
1809                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1810                    {
1811                        Ok(ControlRequest::_UnknownMethod {
1812                            ordinal: header.ordinal,
1813                            control_handle: ControlControlHandle { inner: this.inner.clone() },
1814                            method_type: fidl::MethodType::OneWay,
1815                        })
1816                    }
1817                    _ if header
1818                        .dynamic_flags()
1819                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1820                    {
1821                        this.inner.send_framework_err(
1822                            fidl::encoding::FrameworkErr::UnknownMethod,
1823                            header.tx_id,
1824                            header.ordinal,
1825                            header.dynamic_flags(),
1826                            (bytes, handles),
1827                        )?;
1828                        Ok(ControlRequest::_UnknownMethod {
1829                            ordinal: header.ordinal,
1830                            control_handle: ControlControlHandle { inner: this.inner.clone() },
1831                            method_type: fidl::MethodType::TwoWay,
1832                        })
1833                    }
1834                    _ => Err(fidl::Error::UnknownOrdinal {
1835                        ordinal: header.ordinal,
1836                        protocol_name:
1837                            <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1838                    }),
1839                }))
1840            },
1841        )
1842    }
1843}
1844
1845/// A `Control` instance is used to change the settings or state of an audio
1846/// device. It also creates the ring buffer used to pass audio data between
1847/// client and device. Each `Control` is associated with an initialized audio
1848/// device; conversely each device is associated with either zero or one
1849/// `Control` at any time.
1850#[derive(Debug)]
1851pub enum ControlRequest {
1852    /// Returns a vector of supported processing elements.
1853    /// This vector must include one or more processing elements.
1854    GetElements { responder: ControlGetElementsResponder },
1855    /// Get the processing element state via a hanging get.
1856    /// For a given `processing_element_id`, the driver will immediately reply to the first
1857    /// `WatchElementState` sent by the client. The driver will not respond to subsequent client
1858    /// `WatchElementState` calls for that `processing_element_id` until any portion of the
1859    /// `ElementState` has changed from what was most recently reported for that element.
1860    ///
1861    /// The driver will close the protocol channel with an error of `ZX_ERR_INVALID_ARGS`, if
1862    /// `processing_element_id` does not match an ElementId returned by `GetElements`.
1863    ///
1864    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
1865    /// method is called again while there is already a pending `WatchElementState` for this client
1866    /// and `processing_element_id`.
1867    WatchElementState { processing_element_id: u64, responder: ControlWatchElementStateResponder },
1868    /// Returns a vector of supported topologies.
1869    /// This vector must include one or more topologies.
1870    /// If more than one topology is returned, then the client may select any topology from the
1871    /// list by calling `SetTopology`.
1872    /// If only one topology is returned, `SetTopology` can still be called but causes no change.
1873    ///
1874    /// Each Element must be included in at least one Topology, but need not be included in every
1875    /// Topology.
1876    GetTopologies { responder: ControlGetTopologiesResponder },
1877    /// Get the current topology via a hanging get.
1878    /// The driver will immediately reply to the first `WatchTopology` sent by each client.
1879    /// The driver will not respond to subsequent `WatchTopology` calls from that client until the
1880    /// signal processing topology changes; this occurs as a result of a `SetTopology` call.
1881    ///
1882    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
1883    /// method is called again while there is already a pending `WatchTopology` for this client.
1884    WatchTopology { responder: ControlWatchTopologyResponder },
1885    /// Sets the currently active topology by specifying a `topology_id`, which matches to an entry
1886    /// in the vector returned by `GetTopologies`.
1887    /// The currently active topology is communicated by `WatchTopology` responses. To change which
1888    /// topology is active, a client uses `SetTopology`.
1889    ///
1890    /// If `GetTopologies` returns only one `Topology`, `SetTopology` is optional and has no effect.
1891    ///
1892    /// This call will fail and return `ZX_ERR_INVALID_ARGS` if the specified `topology_id` is not
1893    /// found within the`topologies` returned by `GetTopologies`.
1894    ///
1895    /// `SetTopology` may be called before or after non-`SignalProcessing` protocol calls.
1896    /// If called after non-`SignalProcessing` protocol calls, then `SetTopology` may return
1897    /// `ZX_ERR_BAD_STATE` to indicate that the operation can not proceed without renegotiation of
1898    /// the driver state. See `SetElementState` for further discussion.
1899    SetTopology { topology_id: u64, responder: ControlSetTopologyResponder },
1900    /// Controls the processing element specified by `processing_element_id`, a unique ElementId
1901    /// returned by `GetElements`.
1902    /// The `state` specified in calls to `SetElementState` is a `SettableElementState`. This is a
1903    /// subset of `ElementState` because some fields returned by `WatchElementState` (e.g. `latency`
1904    /// or `plug_state`) can only be observed (not set) by the client.
1905    ///
1906    /// Returns `ZX_ERR_INVALID_ARGS` if `processing_element_id` does not match a known ElementId
1907    /// returned by `GetElements`, or if `state` is not valid for the element. This entails any
1908    /// violation of the rules specified in this protocol.
1909    ///
1910    /// Examples:
1911    /// `state` specifies that an element should be stopped or bypassed, but the corresponding
1912    ///     element does not specify (or explicitly set to false) `can_stop` or `can_bypass`.
1913    /// `state` includes a `type_specific` entry, but that `SettableTypeSpecificElementState` does
1914    ///     not match the `ElementType` of the element corresponding to `processing_element_id`.
1915    /// `state` changes an `EqualizerBandState` for an `EQUALIZER` element (so far so good), but
1916    ///     specifies a change to `frequency` when this element did not set `CAN_CONTROL_FREQUENCY`
1917    ///     in its `supported_controls`.
1918    /// `state` specifies a `GainElementState` for a `GAIN` element with a `gain` value that is
1919    ///     -infinity, NAN, or outside the Element's stated [`min_gain`, `max_gain`] range.
1920    ///
1921    /// Callers may intersperse method calls to the `SignalProcessing` protocol with calls to other
1922    /// driver protocols. Some non-`SignalProcessing` configuration changes may require a
1923    /// renegotiation of the driver state before certain elements can receive a `SetElementState`.
1924    /// For example, if a `DaiFormat` is changed, then `SetElementState` changing an `AGL` element's
1925    /// parameters may not require renegotiation of driver state because changing gain parameters
1926    /// usually does not change the set of supported audio formats.
1927    /// By contrast, following the same `DaiFormat` change, before `SetElementState` can be called
1928    /// on a `CONNECTION_POINT` element, the driver state may need to be reestablished because the
1929    /// format change may invalidate the set of supported formats returned in a previous
1930    /// `GetDaiFormats` protocol call for another part of the Topology.
1931    ///
1932    /// It is the driver's job to determine when renegotiation is required. When this is needed,
1933    /// the related `SetElementState` call must return `ZX_ERR_BAD_STATE` and the client must
1934    /// close the protocol channel entirely, such that the protocol negotiations are started over.
1935    /// The client then must re-invoke the `SetElementState` call that returned
1936    /// `ZX_ERR_BAD_STATE` before any non-`SignalProcessing` protocol calls.
1937    SetElementState {
1938        processing_element_id: u64,
1939        state: fidl_fuchsia_hardware_audio_signalprocessing::SettableElementState,
1940        responder: ControlSetElementStateResponder,
1941    },
1942    /// Create the ring buffer used to pass audio to/from this device. If the device is
1943    /// Composite, then the targeted RING_BUFFER element must be identified by `element_id`.
1944    ///
1945    /// Should only be called for Composite devices.
1946    CreateRingBuffer {
1947        payload: ControlCreateRingBufferRequest,
1948        responder: ControlCreateRingBufferResponder,
1949    },
1950    /// Set the wire format for the digital interconnect associated with this element.
1951    /// Creates a packet stream on the specified element.
1952    CreatePacketStream {
1953        payload: ControlCreatePacketStreamRequest,
1954        responder: ControlCreatePacketStreamResponder,
1955    },
1956    /// Set the wire format for the digital interconnect connected to this Codec endpoint.
1957    /// This method returns information related to the format that was set, including delay values.
1958    /// If the device is Composite, then the targeted DAI_INTERCONNECT element must be identified
1959    /// by `element_id`.
1960    ///
1961    /// Should only be called for Codec and Composite devices.
1962    SetDaiFormat { payload: ControlSetDaiFormatRequest, responder: ControlSetDaiFormatResponder },
1963    /// Start the Codec hardware. If successful, this returns after the Codec was started and
1964    /// `start_time` indicates the time when the hardware started. Note that the Codec's DaiFormat
1965    /// must be set (by a successful `SetDaiFormat` call) before calling this method.
1966    ///
1967    /// Should only be called for Codec devices.
1968    CodecStart { responder: ControlCodecStartResponder },
1969    /// Stop the Codec hardware. If successful, this returns after the Codec was stopped and
1970    /// `stop_time` indicates the time when the hardware stopped. Note that the Codec's DaiFormat
1971    /// must be set (by a successful `SetDaiFormat` call) before calling this method.
1972    ///
1973    /// Should only be called for Codec devices.
1974    CodecStop { responder: ControlCodecStopResponder },
1975    /// Reset the hardware -- stopping the hardware, releasing any ring buffers, and clearing any
1976    /// DaiFormats or RingBufferFormats that were set.
1977    ///
1978    /// This method returns when the hardware reset is complete.
1979    /// After calling this method, the device is still controlled, but any ring buffers must be
1980    /// re-created and re-started.
1981    /// For devices with DAI_INTERCONNECTs (such as Codecs and some Composites), `SetDaiFormat` and
1982    /// `CodecStart` must be called again (in that order) to return the interconnect to the active
1983    /// operational mode.
1984    /// As applicable, `SetTopology` and `SetElementState` must also be called.
1985    ///
1986    /// Should only be called for Codec and Composite devices.
1987    Reset { responder: ControlResetResponder },
1988    /// An interaction was received which does not match any known method.
1989    #[non_exhaustive]
1990    _UnknownMethod {
1991        /// Ordinal of the method that was called.
1992        ordinal: u64,
1993        control_handle: ControlControlHandle,
1994        method_type: fidl::MethodType,
1995    },
1996}
1997
1998impl ControlRequest {
1999    #[allow(irrefutable_let_patterns)]
2000    pub fn into_get_elements(self) -> Option<(ControlGetElementsResponder)> {
2001        if let ControlRequest::GetElements { responder } = self { Some((responder)) } else { None }
2002    }
2003
2004    #[allow(irrefutable_let_patterns)]
2005    pub fn into_watch_element_state(self) -> Option<(u64, ControlWatchElementStateResponder)> {
2006        if let ControlRequest::WatchElementState { processing_element_id, responder } = self {
2007            Some((processing_element_id, responder))
2008        } else {
2009            None
2010        }
2011    }
2012
2013    #[allow(irrefutable_let_patterns)]
2014    pub fn into_get_topologies(self) -> Option<(ControlGetTopologiesResponder)> {
2015        if let ControlRequest::GetTopologies { responder } = self {
2016            Some((responder))
2017        } else {
2018            None
2019        }
2020    }
2021
2022    #[allow(irrefutable_let_patterns)]
2023    pub fn into_watch_topology(self) -> Option<(ControlWatchTopologyResponder)> {
2024        if let ControlRequest::WatchTopology { responder } = self {
2025            Some((responder))
2026        } else {
2027            None
2028        }
2029    }
2030
2031    #[allow(irrefutable_let_patterns)]
2032    pub fn into_set_topology(self) -> Option<(u64, ControlSetTopologyResponder)> {
2033        if let ControlRequest::SetTopology { topology_id, responder } = self {
2034            Some((topology_id, responder))
2035        } else {
2036            None
2037        }
2038    }
2039
2040    #[allow(irrefutable_let_patterns)]
2041    pub fn into_set_element_state(
2042        self,
2043    ) -> Option<(
2044        u64,
2045        fidl_fuchsia_hardware_audio_signalprocessing::SettableElementState,
2046        ControlSetElementStateResponder,
2047    )> {
2048        if let ControlRequest::SetElementState { processing_element_id, state, responder } = self {
2049            Some((processing_element_id, state, responder))
2050        } else {
2051            None
2052        }
2053    }
2054
2055    #[allow(irrefutable_let_patterns)]
2056    pub fn into_create_ring_buffer(
2057        self,
2058    ) -> Option<(ControlCreateRingBufferRequest, ControlCreateRingBufferResponder)> {
2059        if let ControlRequest::CreateRingBuffer { payload, responder } = self {
2060            Some((payload, responder))
2061        } else {
2062            None
2063        }
2064    }
2065
2066    #[allow(irrefutable_let_patterns)]
2067    pub fn into_create_packet_stream(
2068        self,
2069    ) -> Option<(ControlCreatePacketStreamRequest, ControlCreatePacketStreamResponder)> {
2070        if let ControlRequest::CreatePacketStream { payload, responder } = self {
2071            Some((payload, responder))
2072        } else {
2073            None
2074        }
2075    }
2076
2077    #[allow(irrefutable_let_patterns)]
2078    pub fn into_set_dai_format(
2079        self,
2080    ) -> Option<(ControlSetDaiFormatRequest, ControlSetDaiFormatResponder)> {
2081        if let ControlRequest::SetDaiFormat { payload, responder } = self {
2082            Some((payload, responder))
2083        } else {
2084            None
2085        }
2086    }
2087
2088    #[allow(irrefutable_let_patterns)]
2089    pub fn into_codec_start(self) -> Option<(ControlCodecStartResponder)> {
2090        if let ControlRequest::CodecStart { responder } = self { Some((responder)) } else { None }
2091    }
2092
2093    #[allow(irrefutable_let_patterns)]
2094    pub fn into_codec_stop(self) -> Option<(ControlCodecStopResponder)> {
2095        if let ControlRequest::CodecStop { responder } = self { Some((responder)) } else { None }
2096    }
2097
2098    #[allow(irrefutable_let_patterns)]
2099    pub fn into_reset(self) -> Option<(ControlResetResponder)> {
2100        if let ControlRequest::Reset { responder } = self { Some((responder)) } else { None }
2101    }
2102
2103    /// Name of the method defined in FIDL
2104    pub fn method_name(&self) -> &'static str {
2105        match *self {
2106            ControlRequest::GetElements { .. } => "get_elements",
2107            ControlRequest::WatchElementState { .. } => "watch_element_state",
2108            ControlRequest::GetTopologies { .. } => "get_topologies",
2109            ControlRequest::WatchTopology { .. } => "watch_topology",
2110            ControlRequest::SetTopology { .. } => "set_topology",
2111            ControlRequest::SetElementState { .. } => "set_element_state",
2112            ControlRequest::CreateRingBuffer { .. } => "create_ring_buffer",
2113            ControlRequest::CreatePacketStream { .. } => "create_packet_stream",
2114            ControlRequest::SetDaiFormat { .. } => "set_dai_format",
2115            ControlRequest::CodecStart { .. } => "codec_start",
2116            ControlRequest::CodecStop { .. } => "codec_stop",
2117            ControlRequest::Reset { .. } => "reset",
2118            ControlRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2119                "unknown one-way method"
2120            }
2121            ControlRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2122                "unknown two-way method"
2123            }
2124        }
2125    }
2126}
2127
2128#[derive(Debug, Clone)]
2129pub struct ControlControlHandle {
2130    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2131}
2132
2133impl fidl::endpoints::ControlHandle for ControlControlHandle {
2134    fn shutdown(&self) {
2135        self.inner.shutdown()
2136    }
2137
2138    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2139        self.inner.shutdown_with_epitaph(status)
2140    }
2141
2142    fn is_closed(&self) -> bool {
2143        self.inner.channel().is_closed()
2144    }
2145    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2146        self.inner.channel().on_closed()
2147    }
2148
2149    #[cfg(target_os = "fuchsia")]
2150    fn signal_peer(
2151        &self,
2152        clear_mask: zx::Signals,
2153        set_mask: zx::Signals,
2154    ) -> Result<(), zx_status::Status> {
2155        use fidl::Peered;
2156        self.inner.channel().signal_peer(clear_mask, set_mask)
2157    }
2158}
2159
2160impl ControlControlHandle {}
2161
2162#[must_use = "FIDL methods require a response to be sent"]
2163#[derive(Debug)]
2164pub struct ControlGetElementsResponder {
2165    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2166    tx_id: u32,
2167}
2168
2169/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2170/// if the responder is dropped without sending a response, so that the client
2171/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2172impl std::ops::Drop for ControlGetElementsResponder {
2173    fn drop(&mut self) {
2174        self.control_handle.shutdown();
2175        // Safety: drops once, never accessed again
2176        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2177    }
2178}
2179
2180impl fidl::endpoints::Responder for ControlGetElementsResponder {
2181    type ControlHandle = ControlControlHandle;
2182
2183    fn control_handle(&self) -> &ControlControlHandle {
2184        &self.control_handle
2185    }
2186
2187    fn drop_without_shutdown(mut self) {
2188        // Safety: drops once, never accessed again due to mem::forget
2189        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2190        // Prevent Drop from running (which would shut down the channel)
2191        std::mem::forget(self);
2192    }
2193}
2194
2195impl ControlGetElementsResponder {
2196    /// Sends a response to the FIDL transaction.
2197    ///
2198    /// Sets the channel to shutdown if an error occurs.
2199    pub fn send(
2200        self,
2201        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Element], i32>,
2202    ) -> Result<(), fidl::Error> {
2203        let _result = self.send_raw(result);
2204        if _result.is_err() {
2205            self.control_handle.shutdown();
2206        }
2207        self.drop_without_shutdown();
2208        _result
2209    }
2210
2211    /// Similar to "send" but does not shutdown the channel if an error occurs.
2212    pub fn send_no_shutdown_on_err(
2213        self,
2214        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Element], i32>,
2215    ) -> Result<(), fidl::Error> {
2216        let _result = self.send_raw(result);
2217        self.drop_without_shutdown();
2218        _result
2219    }
2220
2221    fn send_raw(
2222        &self,
2223        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Element], i32>,
2224    ) -> Result<(), fidl::Error> {
2225        self.control_handle.inner.send::<fidl::encoding::ResultType<
2226            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResponse,
2227            i32,
2228        >>(
2229            result.map(|processing_elements| (processing_elements,)),
2230            self.tx_id,
2231            0x1b14ff4adf5dc6f8,
2232            fidl::encoding::DynamicFlags::empty(),
2233        )
2234    }
2235}
2236
2237#[must_use = "FIDL methods require a response to be sent"]
2238#[derive(Debug)]
2239pub struct ControlWatchElementStateResponder {
2240    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2241    tx_id: u32,
2242}
2243
2244/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2245/// if the responder is dropped without sending a response, so that the client
2246/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2247impl std::ops::Drop for ControlWatchElementStateResponder {
2248    fn drop(&mut self) {
2249        self.control_handle.shutdown();
2250        // Safety: drops once, never accessed again
2251        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2252    }
2253}
2254
2255impl fidl::endpoints::Responder for ControlWatchElementStateResponder {
2256    type ControlHandle = ControlControlHandle;
2257
2258    fn control_handle(&self) -> &ControlControlHandle {
2259        &self.control_handle
2260    }
2261
2262    fn drop_without_shutdown(mut self) {
2263        // Safety: drops once, never accessed again due to mem::forget
2264        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2265        // Prevent Drop from running (which would shut down the channel)
2266        std::mem::forget(self);
2267    }
2268}
2269
2270impl ControlWatchElementStateResponder {
2271    /// Sends a response to the FIDL transaction.
2272    ///
2273    /// Sets the channel to shutdown if an error occurs.
2274    pub fn send(
2275        self,
2276        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
2277    ) -> Result<(), fidl::Error> {
2278        let _result = self.send_raw(state);
2279        if _result.is_err() {
2280            self.control_handle.shutdown();
2281        }
2282        self.drop_without_shutdown();
2283        _result
2284    }
2285
2286    /// Similar to "send" but does not shutdown the channel if an error occurs.
2287    pub fn send_no_shutdown_on_err(
2288        self,
2289        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
2290    ) -> Result<(), fidl::Error> {
2291        let _result = self.send_raw(state);
2292        self.drop_without_shutdown();
2293        _result
2294    }
2295
2296    fn send_raw(
2297        &self,
2298        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
2299    ) -> Result<(), fidl::Error> {
2300        self.control_handle
2301            .inner
2302            .send::<fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateResponse>(
2303            (state,),
2304            self.tx_id,
2305            0x524da8772a69056f,
2306            fidl::encoding::DynamicFlags::empty(),
2307        )
2308    }
2309}
2310
2311#[must_use = "FIDL methods require a response to be sent"]
2312#[derive(Debug)]
2313pub struct ControlGetTopologiesResponder {
2314    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2315    tx_id: u32,
2316}
2317
2318/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2319/// if the responder is dropped without sending a response, so that the client
2320/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2321impl std::ops::Drop for ControlGetTopologiesResponder {
2322    fn drop(&mut self) {
2323        self.control_handle.shutdown();
2324        // Safety: drops once, never accessed again
2325        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2326    }
2327}
2328
2329impl fidl::endpoints::Responder for ControlGetTopologiesResponder {
2330    type ControlHandle = ControlControlHandle;
2331
2332    fn control_handle(&self) -> &ControlControlHandle {
2333        &self.control_handle
2334    }
2335
2336    fn drop_without_shutdown(mut self) {
2337        // Safety: drops once, never accessed again due to mem::forget
2338        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2339        // Prevent Drop from running (which would shut down the channel)
2340        std::mem::forget(self);
2341    }
2342}
2343
2344impl ControlGetTopologiesResponder {
2345    /// Sends a response to the FIDL transaction.
2346    ///
2347    /// Sets the channel to shutdown if an error occurs.
2348    pub fn send(
2349        self,
2350        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Topology], i32>,
2351    ) -> Result<(), fidl::Error> {
2352        let _result = self.send_raw(result);
2353        if _result.is_err() {
2354            self.control_handle.shutdown();
2355        }
2356        self.drop_without_shutdown();
2357        _result
2358    }
2359
2360    /// Similar to "send" but does not shutdown the channel if an error occurs.
2361    pub fn send_no_shutdown_on_err(
2362        self,
2363        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Topology], i32>,
2364    ) -> Result<(), fidl::Error> {
2365        let _result = self.send_raw(result);
2366        self.drop_without_shutdown();
2367        _result
2368    }
2369
2370    fn send_raw(
2371        &self,
2372        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Topology], i32>,
2373    ) -> Result<(), fidl::Error> {
2374        self.control_handle.inner.send::<fidl::encoding::ResultType<
2375            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResponse,
2376            i32,
2377        >>(
2378            result.map(|topologies| (topologies,)),
2379            self.tx_id,
2380            0x73ffb73af24d30b6,
2381            fidl::encoding::DynamicFlags::empty(),
2382        )
2383    }
2384}
2385
2386#[must_use = "FIDL methods require a response to be sent"]
2387#[derive(Debug)]
2388pub struct ControlWatchTopologyResponder {
2389    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2390    tx_id: u32,
2391}
2392
2393/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2394/// if the responder is dropped without sending a response, so that the client
2395/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2396impl std::ops::Drop for ControlWatchTopologyResponder {
2397    fn drop(&mut self) {
2398        self.control_handle.shutdown();
2399        // Safety: drops once, never accessed again
2400        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2401    }
2402}
2403
2404impl fidl::endpoints::Responder for ControlWatchTopologyResponder {
2405    type ControlHandle = ControlControlHandle;
2406
2407    fn control_handle(&self) -> &ControlControlHandle {
2408        &self.control_handle
2409    }
2410
2411    fn drop_without_shutdown(mut self) {
2412        // Safety: drops once, never accessed again due to mem::forget
2413        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2414        // Prevent Drop from running (which would shut down the channel)
2415        std::mem::forget(self);
2416    }
2417}
2418
2419impl ControlWatchTopologyResponder {
2420    /// Sends a response to the FIDL transaction.
2421    ///
2422    /// Sets the channel to shutdown if an error occurs.
2423    pub fn send(self, mut topology_id: u64) -> Result<(), fidl::Error> {
2424        let _result = self.send_raw(topology_id);
2425        if _result.is_err() {
2426            self.control_handle.shutdown();
2427        }
2428        self.drop_without_shutdown();
2429        _result
2430    }
2431
2432    /// Similar to "send" but does not shutdown the channel if an error occurs.
2433    pub fn send_no_shutdown_on_err(self, mut topology_id: u64) -> Result<(), fidl::Error> {
2434        let _result = self.send_raw(topology_id);
2435        self.drop_without_shutdown();
2436        _result
2437    }
2438
2439    fn send_raw(&self, mut topology_id: u64) -> Result<(), fidl::Error> {
2440        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
2441            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchTopologyResponse,
2442        >>(
2443            fidl::encoding::Flexible::new((topology_id,)),
2444            self.tx_id,
2445            0x66d172acdb36a729,
2446            fidl::encoding::DynamicFlags::FLEXIBLE,
2447        )
2448    }
2449}
2450
2451#[must_use = "FIDL methods require a response to be sent"]
2452#[derive(Debug)]
2453pub struct ControlSetTopologyResponder {
2454    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2455    tx_id: u32,
2456}
2457
2458/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2459/// if the responder is dropped without sending a response, so that the client
2460/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2461impl std::ops::Drop for ControlSetTopologyResponder {
2462    fn drop(&mut self) {
2463        self.control_handle.shutdown();
2464        // Safety: drops once, never accessed again
2465        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2466    }
2467}
2468
2469impl fidl::endpoints::Responder for ControlSetTopologyResponder {
2470    type ControlHandle = ControlControlHandle;
2471
2472    fn control_handle(&self) -> &ControlControlHandle {
2473        &self.control_handle
2474    }
2475
2476    fn drop_without_shutdown(mut self) {
2477        // Safety: drops once, never accessed again due to mem::forget
2478        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2479        // Prevent Drop from running (which would shut down the channel)
2480        std::mem::forget(self);
2481    }
2482}
2483
2484impl ControlSetTopologyResponder {
2485    /// Sends a response to the FIDL transaction.
2486    ///
2487    /// Sets the channel to shutdown if an error occurs.
2488    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2489        let _result = self.send_raw(result);
2490        if _result.is_err() {
2491            self.control_handle.shutdown();
2492        }
2493        self.drop_without_shutdown();
2494        _result
2495    }
2496
2497    /// Similar to "send" but does not shutdown the channel if an error occurs.
2498    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2499        let _result = self.send_raw(result);
2500        self.drop_without_shutdown();
2501        _result
2502    }
2503
2504    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2505        self.control_handle
2506            .inner
2507            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2508                result,
2509                self.tx_id,
2510                0x1d9a7f9b8fee790c,
2511                fidl::encoding::DynamicFlags::empty(),
2512            )
2513    }
2514}
2515
2516#[must_use = "FIDL methods require a response to be sent"]
2517#[derive(Debug)]
2518pub struct ControlSetElementStateResponder {
2519    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2520    tx_id: u32,
2521}
2522
2523/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2524/// if the responder is dropped without sending a response, so that the client
2525/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2526impl std::ops::Drop for ControlSetElementStateResponder {
2527    fn drop(&mut self) {
2528        self.control_handle.shutdown();
2529        // Safety: drops once, never accessed again
2530        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2531    }
2532}
2533
2534impl fidl::endpoints::Responder for ControlSetElementStateResponder {
2535    type ControlHandle = ControlControlHandle;
2536
2537    fn control_handle(&self) -> &ControlControlHandle {
2538        &self.control_handle
2539    }
2540
2541    fn drop_without_shutdown(mut self) {
2542        // Safety: drops once, never accessed again due to mem::forget
2543        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2544        // Prevent Drop from running (which would shut down the channel)
2545        std::mem::forget(self);
2546    }
2547}
2548
2549impl ControlSetElementStateResponder {
2550    /// Sends a response to the FIDL transaction.
2551    ///
2552    /// Sets the channel to shutdown if an error occurs.
2553    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2554        let _result = self.send_raw(result);
2555        if _result.is_err() {
2556            self.control_handle.shutdown();
2557        }
2558        self.drop_without_shutdown();
2559        _result
2560    }
2561
2562    /// Similar to "send" but does not shutdown the channel if an error occurs.
2563    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2564        let _result = self.send_raw(result);
2565        self.drop_without_shutdown();
2566        _result
2567    }
2568
2569    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2570        self.control_handle
2571            .inner
2572            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2573                result,
2574                self.tx_id,
2575                0x38c3b2d4bae698f4,
2576                fidl::encoding::DynamicFlags::empty(),
2577            )
2578    }
2579}
2580
2581#[must_use = "FIDL methods require a response to be sent"]
2582#[derive(Debug)]
2583pub struct ControlCreateRingBufferResponder {
2584    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2585    tx_id: u32,
2586}
2587
2588/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2589/// if the responder is dropped without sending a response, so that the client
2590/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2591impl std::ops::Drop for ControlCreateRingBufferResponder {
2592    fn drop(&mut self) {
2593        self.control_handle.shutdown();
2594        // Safety: drops once, never accessed again
2595        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2596    }
2597}
2598
2599impl fidl::endpoints::Responder for ControlCreateRingBufferResponder {
2600    type ControlHandle = ControlControlHandle;
2601
2602    fn control_handle(&self) -> &ControlControlHandle {
2603        &self.control_handle
2604    }
2605
2606    fn drop_without_shutdown(mut self) {
2607        // Safety: drops once, never accessed again due to mem::forget
2608        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2609        // Prevent Drop from running (which would shut down the channel)
2610        std::mem::forget(self);
2611    }
2612}
2613
2614impl ControlCreateRingBufferResponder {
2615    /// Sends a response to the FIDL transaction.
2616    ///
2617    /// Sets the channel to shutdown if an error occurs.
2618    pub fn send(
2619        self,
2620        mut result: Result<ControlCreateRingBufferResponse, ControlCreateRingBufferError>,
2621    ) -> Result<(), fidl::Error> {
2622        let _result = self.send_raw(result);
2623        if _result.is_err() {
2624            self.control_handle.shutdown();
2625        }
2626        self.drop_without_shutdown();
2627        _result
2628    }
2629
2630    /// Similar to "send" but does not shutdown the channel if an error occurs.
2631    pub fn send_no_shutdown_on_err(
2632        self,
2633        mut result: Result<ControlCreateRingBufferResponse, ControlCreateRingBufferError>,
2634    ) -> Result<(), fidl::Error> {
2635        let _result = self.send_raw(result);
2636        self.drop_without_shutdown();
2637        _result
2638    }
2639
2640    fn send_raw(
2641        &self,
2642        mut result: Result<ControlCreateRingBufferResponse, ControlCreateRingBufferError>,
2643    ) -> Result<(), fidl::Error> {
2644        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2645            ControlCreateRingBufferResponse,
2646            ControlCreateRingBufferError,
2647        >>(
2648            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
2649            self.tx_id,
2650            0x7462941cedb333db,
2651            fidl::encoding::DynamicFlags::FLEXIBLE,
2652        )
2653    }
2654}
2655
2656#[must_use = "FIDL methods require a response to be sent"]
2657#[derive(Debug)]
2658pub struct ControlCreatePacketStreamResponder {
2659    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2660    tx_id: u32,
2661}
2662
2663/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2664/// if the responder is dropped without sending a response, so that the client
2665/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2666impl std::ops::Drop for ControlCreatePacketStreamResponder {
2667    fn drop(&mut self) {
2668        self.control_handle.shutdown();
2669        // Safety: drops once, never accessed again
2670        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2671    }
2672}
2673
2674impl fidl::endpoints::Responder for ControlCreatePacketStreamResponder {
2675    type ControlHandle = ControlControlHandle;
2676
2677    fn control_handle(&self) -> &ControlControlHandle {
2678        &self.control_handle
2679    }
2680
2681    fn drop_without_shutdown(mut self) {
2682        // Safety: drops once, never accessed again due to mem::forget
2683        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2684        // Prevent Drop from running (which would shut down the channel)
2685        std::mem::forget(self);
2686    }
2687}
2688
2689impl ControlCreatePacketStreamResponder {
2690    /// Sends a response to the FIDL transaction.
2691    ///
2692    /// Sets the channel to shutdown if an error occurs.
2693    pub fn send(
2694        self,
2695        mut result: Result<ControlCreatePacketStreamResponse, ControlCreatePacketStreamError>,
2696    ) -> Result<(), fidl::Error> {
2697        let _result = self.send_raw(result);
2698        if _result.is_err() {
2699            self.control_handle.shutdown();
2700        }
2701        self.drop_without_shutdown();
2702        _result
2703    }
2704
2705    /// Similar to "send" but does not shutdown the channel if an error occurs.
2706    pub fn send_no_shutdown_on_err(
2707        self,
2708        mut result: Result<ControlCreatePacketStreamResponse, ControlCreatePacketStreamError>,
2709    ) -> Result<(), fidl::Error> {
2710        let _result = self.send_raw(result);
2711        self.drop_without_shutdown();
2712        _result
2713    }
2714
2715    fn send_raw(
2716        &self,
2717        mut result: Result<ControlCreatePacketStreamResponse, ControlCreatePacketStreamError>,
2718    ) -> Result<(), fidl::Error> {
2719        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2720            ControlCreatePacketStreamResponse,
2721            ControlCreatePacketStreamError,
2722        >>(
2723            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
2724            self.tx_id,
2725            0x5b2eacb5ad7df289,
2726            fidl::encoding::DynamicFlags::FLEXIBLE,
2727        )
2728    }
2729}
2730
2731#[must_use = "FIDL methods require a response to be sent"]
2732#[derive(Debug)]
2733pub struct ControlSetDaiFormatResponder {
2734    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2735    tx_id: u32,
2736}
2737
2738/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2739/// if the responder is dropped without sending a response, so that the client
2740/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2741impl std::ops::Drop for ControlSetDaiFormatResponder {
2742    fn drop(&mut self) {
2743        self.control_handle.shutdown();
2744        // Safety: drops once, never accessed again
2745        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2746    }
2747}
2748
2749impl fidl::endpoints::Responder for ControlSetDaiFormatResponder {
2750    type ControlHandle = ControlControlHandle;
2751
2752    fn control_handle(&self) -> &ControlControlHandle {
2753        &self.control_handle
2754    }
2755
2756    fn drop_without_shutdown(mut self) {
2757        // Safety: drops once, never accessed again due to mem::forget
2758        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2759        // Prevent Drop from running (which would shut down the channel)
2760        std::mem::forget(self);
2761    }
2762}
2763
2764impl ControlSetDaiFormatResponder {
2765    /// Sends a response to the FIDL transaction.
2766    ///
2767    /// Sets the channel to shutdown if an error occurs.
2768    pub fn send(
2769        self,
2770        mut result: Result<&ControlSetDaiFormatResponse, ControlSetDaiFormatError>,
2771    ) -> Result<(), fidl::Error> {
2772        let _result = self.send_raw(result);
2773        if _result.is_err() {
2774            self.control_handle.shutdown();
2775        }
2776        self.drop_without_shutdown();
2777        _result
2778    }
2779
2780    /// Similar to "send" but does not shutdown the channel if an error occurs.
2781    pub fn send_no_shutdown_on_err(
2782        self,
2783        mut result: Result<&ControlSetDaiFormatResponse, ControlSetDaiFormatError>,
2784    ) -> Result<(), fidl::Error> {
2785        let _result = self.send_raw(result);
2786        self.drop_without_shutdown();
2787        _result
2788    }
2789
2790    fn send_raw(
2791        &self,
2792        mut result: Result<&ControlSetDaiFormatResponse, ControlSetDaiFormatError>,
2793    ) -> Result<(), fidl::Error> {
2794        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2795            ControlSetDaiFormatResponse,
2796            ControlSetDaiFormatError,
2797        >>(
2798            fidl::encoding::FlexibleResult::new(result),
2799            self.tx_id,
2800            0x1d84f5a456a92216,
2801            fidl::encoding::DynamicFlags::FLEXIBLE,
2802        )
2803    }
2804}
2805
2806#[must_use = "FIDL methods require a response to be sent"]
2807#[derive(Debug)]
2808pub struct ControlCodecStartResponder {
2809    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2810    tx_id: u32,
2811}
2812
2813/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2814/// if the responder is dropped without sending a response, so that the client
2815/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2816impl std::ops::Drop for ControlCodecStartResponder {
2817    fn drop(&mut self) {
2818        self.control_handle.shutdown();
2819        // Safety: drops once, never accessed again
2820        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2821    }
2822}
2823
2824impl fidl::endpoints::Responder for ControlCodecStartResponder {
2825    type ControlHandle = ControlControlHandle;
2826
2827    fn control_handle(&self) -> &ControlControlHandle {
2828        &self.control_handle
2829    }
2830
2831    fn drop_without_shutdown(mut self) {
2832        // Safety: drops once, never accessed again due to mem::forget
2833        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2834        // Prevent Drop from running (which would shut down the channel)
2835        std::mem::forget(self);
2836    }
2837}
2838
2839impl ControlCodecStartResponder {
2840    /// Sends a response to the FIDL transaction.
2841    ///
2842    /// Sets the channel to shutdown if an error occurs.
2843    pub fn send(
2844        self,
2845        mut result: Result<&ControlCodecStartResponse, ControlCodecStartError>,
2846    ) -> Result<(), fidl::Error> {
2847        let _result = self.send_raw(result);
2848        if _result.is_err() {
2849            self.control_handle.shutdown();
2850        }
2851        self.drop_without_shutdown();
2852        _result
2853    }
2854
2855    /// Similar to "send" but does not shutdown the channel if an error occurs.
2856    pub fn send_no_shutdown_on_err(
2857        self,
2858        mut result: Result<&ControlCodecStartResponse, ControlCodecStartError>,
2859    ) -> Result<(), fidl::Error> {
2860        let _result = self.send_raw(result);
2861        self.drop_without_shutdown();
2862        _result
2863    }
2864
2865    fn send_raw(
2866        &self,
2867        mut result: Result<&ControlCodecStartResponse, ControlCodecStartError>,
2868    ) -> Result<(), fidl::Error> {
2869        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2870            ControlCodecStartResponse,
2871            ControlCodecStartError,
2872        >>(
2873            fidl::encoding::FlexibleResult::new(result),
2874            self.tx_id,
2875            0x2a90a9d2958b997b,
2876            fidl::encoding::DynamicFlags::FLEXIBLE,
2877        )
2878    }
2879}
2880
2881#[must_use = "FIDL methods require a response to be sent"]
2882#[derive(Debug)]
2883pub struct ControlCodecStopResponder {
2884    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2885    tx_id: u32,
2886}
2887
2888/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2889/// if the responder is dropped without sending a response, so that the client
2890/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2891impl std::ops::Drop for ControlCodecStopResponder {
2892    fn drop(&mut self) {
2893        self.control_handle.shutdown();
2894        // Safety: drops once, never accessed again
2895        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2896    }
2897}
2898
2899impl fidl::endpoints::Responder for ControlCodecStopResponder {
2900    type ControlHandle = ControlControlHandle;
2901
2902    fn control_handle(&self) -> &ControlControlHandle {
2903        &self.control_handle
2904    }
2905
2906    fn drop_without_shutdown(mut self) {
2907        // Safety: drops once, never accessed again due to mem::forget
2908        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2909        // Prevent Drop from running (which would shut down the channel)
2910        std::mem::forget(self);
2911    }
2912}
2913
2914impl ControlCodecStopResponder {
2915    /// Sends a response to the FIDL transaction.
2916    ///
2917    /// Sets the channel to shutdown if an error occurs.
2918    pub fn send(
2919        self,
2920        mut result: Result<&ControlCodecStopResponse, ControlCodecStopError>,
2921    ) -> Result<(), fidl::Error> {
2922        let _result = self.send_raw(result);
2923        if _result.is_err() {
2924            self.control_handle.shutdown();
2925        }
2926        self.drop_without_shutdown();
2927        _result
2928    }
2929
2930    /// Similar to "send" but does not shutdown the channel if an error occurs.
2931    pub fn send_no_shutdown_on_err(
2932        self,
2933        mut result: Result<&ControlCodecStopResponse, ControlCodecStopError>,
2934    ) -> Result<(), fidl::Error> {
2935        let _result = self.send_raw(result);
2936        self.drop_without_shutdown();
2937        _result
2938    }
2939
2940    fn send_raw(
2941        &self,
2942        mut result: Result<&ControlCodecStopResponse, ControlCodecStopError>,
2943    ) -> Result<(), fidl::Error> {
2944        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2945            ControlCodecStopResponse,
2946            ControlCodecStopError,
2947        >>(
2948            fidl::encoding::FlexibleResult::new(result),
2949            self.tx_id,
2950            0x387297bb6bcad25f,
2951            fidl::encoding::DynamicFlags::FLEXIBLE,
2952        )
2953    }
2954}
2955
2956#[must_use = "FIDL methods require a response to be sent"]
2957#[derive(Debug)]
2958pub struct ControlResetResponder {
2959    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2960    tx_id: u32,
2961}
2962
2963/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2964/// if the responder is dropped without sending a response, so that the client
2965/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2966impl std::ops::Drop for ControlResetResponder {
2967    fn drop(&mut self) {
2968        self.control_handle.shutdown();
2969        // Safety: drops once, never accessed again
2970        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2971    }
2972}
2973
2974impl fidl::endpoints::Responder for ControlResetResponder {
2975    type ControlHandle = ControlControlHandle;
2976
2977    fn control_handle(&self) -> &ControlControlHandle {
2978        &self.control_handle
2979    }
2980
2981    fn drop_without_shutdown(mut self) {
2982        // Safety: drops once, never accessed again due to mem::forget
2983        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2984        // Prevent Drop from running (which would shut down the channel)
2985        std::mem::forget(self);
2986    }
2987}
2988
2989impl ControlResetResponder {
2990    /// Sends a response to the FIDL transaction.
2991    ///
2992    /// Sets the channel to shutdown if an error occurs.
2993    pub fn send(
2994        self,
2995        mut result: Result<&ControlResetResponse, ControlResetError>,
2996    ) -> Result<(), fidl::Error> {
2997        let _result = self.send_raw(result);
2998        if _result.is_err() {
2999            self.control_handle.shutdown();
3000        }
3001        self.drop_without_shutdown();
3002        _result
3003    }
3004
3005    /// Similar to "send" but does not shutdown the channel if an error occurs.
3006    pub fn send_no_shutdown_on_err(
3007        self,
3008        mut result: Result<&ControlResetResponse, ControlResetError>,
3009    ) -> Result<(), fidl::Error> {
3010        let _result = self.send_raw(result);
3011        self.drop_without_shutdown();
3012        _result
3013    }
3014
3015    fn send_raw(
3016        &self,
3017        mut result: Result<&ControlResetResponse, ControlResetError>,
3018    ) -> Result<(), fidl::Error> {
3019        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3020            ControlResetResponse,
3021            ControlResetError,
3022        >>(
3023            fidl::encoding::FlexibleResult::new(result),
3024            self.tx_id,
3025            0x49840db00a698996,
3026            fidl::encoding::DynamicFlags::FLEXIBLE,
3027        )
3028    }
3029}
3030
3031#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3032pub struct ControlCreatorMarker;
3033
3034impl fidl::endpoints::ProtocolMarker for ControlCreatorMarker {
3035    type Proxy = ControlCreatorProxy;
3036    type RequestStream = ControlCreatorRequestStream;
3037    #[cfg(target_os = "fuchsia")]
3038    type SynchronousProxy = ControlCreatorSynchronousProxy;
3039
3040    const DEBUG_NAME: &'static str = "fuchsia.audio.device.ControlCreator";
3041}
3042impl fidl::endpoints::DiscoverableProtocolMarker for ControlCreatorMarker {}
3043pub type ControlCreatorCreateResult = Result<ControlCreatorCreateResponse, ControlCreatorError>;
3044
3045pub trait ControlCreatorProxyInterface: Send + Sync {
3046    type CreateResponseFut: std::future::Future<Output = Result<ControlCreatorCreateResult, fidl::Error>>
3047        + Send;
3048    fn r#create(&self, payload: ControlCreatorCreateRequest) -> Self::CreateResponseFut;
3049}
3050#[derive(Debug)]
3051#[cfg(target_os = "fuchsia")]
3052pub struct ControlCreatorSynchronousProxy {
3053    client: fidl::client::sync::Client,
3054}
3055
3056#[cfg(target_os = "fuchsia")]
3057impl fidl::endpoints::SynchronousProxy for ControlCreatorSynchronousProxy {
3058    type Proxy = ControlCreatorProxy;
3059    type Protocol = ControlCreatorMarker;
3060
3061    fn from_channel(inner: fidl::Channel) -> Self {
3062        Self::new(inner)
3063    }
3064
3065    fn into_channel(self) -> fidl::Channel {
3066        self.client.into_channel()
3067    }
3068
3069    fn as_channel(&self) -> &fidl::Channel {
3070        self.client.as_channel()
3071    }
3072}
3073
3074#[cfg(target_os = "fuchsia")]
3075impl ControlCreatorSynchronousProxy {
3076    pub fn new(channel: fidl::Channel) -> Self {
3077        Self { client: fidl::client::sync::Client::new(channel) }
3078    }
3079
3080    pub fn into_channel(self) -> fidl::Channel {
3081        self.client.into_channel()
3082    }
3083
3084    /// Waits until an event arrives and returns it. It is safe for other
3085    /// threads to make concurrent requests while waiting for an event.
3086    pub fn wait_for_event(
3087        &self,
3088        deadline: zx::MonotonicInstant,
3089    ) -> Result<ControlCreatorEvent, fidl::Error> {
3090        ControlCreatorEvent::decode(self.client.wait_for_event::<ControlCreatorMarker>(deadline)?)
3091    }
3092
3093    /// Create a `Control` for the specified device.
3094    pub fn r#create(
3095        &self,
3096        mut payload: ControlCreatorCreateRequest,
3097        ___deadline: zx::MonotonicInstant,
3098    ) -> Result<ControlCreatorCreateResult, fidl::Error> {
3099        let _response =
3100            self.client
3101                .send_query::<ControlCreatorCreateRequest, fidl::encoding::FlexibleResultType<
3102                    ControlCreatorCreateResponse,
3103                    ControlCreatorError,
3104                >, ControlCreatorMarker>(
3105                    &mut payload,
3106                    0x341bdc9f49103a31,
3107                    fidl::encoding::DynamicFlags::FLEXIBLE,
3108                    ___deadline,
3109                )?
3110                .into_result::<ControlCreatorMarker>("create")?;
3111        Ok(_response.map(|x| x))
3112    }
3113}
3114
3115#[cfg(target_os = "fuchsia")]
3116impl From<ControlCreatorSynchronousProxy> for zx::NullableHandle {
3117    fn from(value: ControlCreatorSynchronousProxy) -> Self {
3118        value.into_channel().into()
3119    }
3120}
3121
3122#[cfg(target_os = "fuchsia")]
3123impl From<fidl::Channel> for ControlCreatorSynchronousProxy {
3124    fn from(value: fidl::Channel) -> Self {
3125        Self::new(value)
3126    }
3127}
3128
3129#[cfg(target_os = "fuchsia")]
3130impl fidl::endpoints::FromClient for ControlCreatorSynchronousProxy {
3131    type Protocol = ControlCreatorMarker;
3132
3133    fn from_client(value: fidl::endpoints::ClientEnd<ControlCreatorMarker>) -> Self {
3134        Self::new(value.into_channel())
3135    }
3136}
3137
3138#[derive(Debug, Clone)]
3139pub struct ControlCreatorProxy {
3140    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3141}
3142
3143impl fidl::endpoints::Proxy for ControlCreatorProxy {
3144    type Protocol = ControlCreatorMarker;
3145
3146    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3147        Self::new(inner)
3148    }
3149
3150    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3151        self.client.into_channel().map_err(|client| Self { client })
3152    }
3153
3154    fn as_channel(&self) -> &::fidl::AsyncChannel {
3155        self.client.as_channel()
3156    }
3157}
3158
3159impl ControlCreatorProxy {
3160    /// Create a new Proxy for fuchsia.audio.device/ControlCreator.
3161    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3162        let protocol_name = <ControlCreatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3163        Self { client: fidl::client::Client::new(channel, protocol_name) }
3164    }
3165
3166    /// Get a Stream of events from the remote end of the protocol.
3167    ///
3168    /// # Panics
3169    ///
3170    /// Panics if the event stream was already taken.
3171    pub fn take_event_stream(&self) -> ControlCreatorEventStream {
3172        ControlCreatorEventStream { event_receiver: self.client.take_event_receiver() }
3173    }
3174
3175    /// Create a `Control` for the specified device.
3176    pub fn r#create(
3177        &self,
3178        mut payload: ControlCreatorCreateRequest,
3179    ) -> fidl::client::QueryResponseFut<
3180        ControlCreatorCreateResult,
3181        fidl::encoding::DefaultFuchsiaResourceDialect,
3182    > {
3183        ControlCreatorProxyInterface::r#create(self, payload)
3184    }
3185}
3186
3187impl ControlCreatorProxyInterface for ControlCreatorProxy {
3188    type CreateResponseFut = fidl::client::QueryResponseFut<
3189        ControlCreatorCreateResult,
3190        fidl::encoding::DefaultFuchsiaResourceDialect,
3191    >;
3192    fn r#create(&self, mut payload: ControlCreatorCreateRequest) -> Self::CreateResponseFut {
3193        fn _decode(
3194            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3195        ) -> Result<ControlCreatorCreateResult, fidl::Error> {
3196            let _response = fidl::client::decode_transaction_body::<
3197                fidl::encoding::FlexibleResultType<
3198                    ControlCreatorCreateResponse,
3199                    ControlCreatorError,
3200                >,
3201                fidl::encoding::DefaultFuchsiaResourceDialect,
3202                0x341bdc9f49103a31,
3203            >(_buf?)?
3204            .into_result::<ControlCreatorMarker>("create")?;
3205            Ok(_response.map(|x| x))
3206        }
3207        self.client
3208            .send_query_and_decode::<ControlCreatorCreateRequest, ControlCreatorCreateResult>(
3209                &mut payload,
3210                0x341bdc9f49103a31,
3211                fidl::encoding::DynamicFlags::FLEXIBLE,
3212                _decode,
3213            )
3214    }
3215}
3216
3217pub struct ControlCreatorEventStream {
3218    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3219}
3220
3221impl std::marker::Unpin for ControlCreatorEventStream {}
3222
3223impl futures::stream::FusedStream for ControlCreatorEventStream {
3224    fn is_terminated(&self) -> bool {
3225        self.event_receiver.is_terminated()
3226    }
3227}
3228
3229impl futures::Stream for ControlCreatorEventStream {
3230    type Item = Result<ControlCreatorEvent, fidl::Error>;
3231
3232    fn poll_next(
3233        mut self: std::pin::Pin<&mut Self>,
3234        cx: &mut std::task::Context<'_>,
3235    ) -> std::task::Poll<Option<Self::Item>> {
3236        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3237            &mut self.event_receiver,
3238            cx
3239        )?) {
3240            Some(buf) => std::task::Poll::Ready(Some(ControlCreatorEvent::decode(buf))),
3241            None => std::task::Poll::Ready(None),
3242        }
3243    }
3244}
3245
3246#[derive(Debug)]
3247pub enum ControlCreatorEvent {
3248    #[non_exhaustive]
3249    _UnknownEvent {
3250        /// Ordinal of the event that was sent.
3251        ordinal: u64,
3252    },
3253}
3254
3255impl ControlCreatorEvent {
3256    /// Decodes a message buffer as a [`ControlCreatorEvent`].
3257    fn decode(
3258        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3259    ) -> Result<ControlCreatorEvent, fidl::Error> {
3260        let (bytes, _handles) = buf.split_mut();
3261        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3262        debug_assert_eq!(tx_header.tx_id, 0);
3263        match tx_header.ordinal {
3264            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3265                Ok(ControlCreatorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3266            }
3267            _ => Err(fidl::Error::UnknownOrdinal {
3268                ordinal: tx_header.ordinal,
3269                protocol_name:
3270                    <ControlCreatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3271            }),
3272        }
3273    }
3274}
3275
3276/// A Stream of incoming requests for fuchsia.audio.device/ControlCreator.
3277pub struct ControlCreatorRequestStream {
3278    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3279    is_terminated: bool,
3280}
3281
3282impl std::marker::Unpin for ControlCreatorRequestStream {}
3283
3284impl futures::stream::FusedStream for ControlCreatorRequestStream {
3285    fn is_terminated(&self) -> bool {
3286        self.is_terminated
3287    }
3288}
3289
3290impl fidl::endpoints::RequestStream for ControlCreatorRequestStream {
3291    type Protocol = ControlCreatorMarker;
3292    type ControlHandle = ControlCreatorControlHandle;
3293
3294    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3295        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3296    }
3297
3298    fn control_handle(&self) -> Self::ControlHandle {
3299        ControlCreatorControlHandle { inner: self.inner.clone() }
3300    }
3301
3302    fn into_inner(
3303        self,
3304    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3305    {
3306        (self.inner, self.is_terminated)
3307    }
3308
3309    fn from_inner(
3310        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3311        is_terminated: bool,
3312    ) -> Self {
3313        Self { inner, is_terminated }
3314    }
3315}
3316
3317impl futures::Stream for ControlCreatorRequestStream {
3318    type Item = Result<ControlCreatorRequest, fidl::Error>;
3319
3320    fn poll_next(
3321        mut self: std::pin::Pin<&mut Self>,
3322        cx: &mut std::task::Context<'_>,
3323    ) -> std::task::Poll<Option<Self::Item>> {
3324        let this = &mut *self;
3325        if this.inner.check_shutdown(cx) {
3326            this.is_terminated = true;
3327            return std::task::Poll::Ready(None);
3328        }
3329        if this.is_terminated {
3330            panic!("polled ControlCreatorRequestStream after completion");
3331        }
3332        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3333            |bytes, handles| {
3334                match this.inner.channel().read_etc(cx, bytes, handles) {
3335                    std::task::Poll::Ready(Ok(())) => {}
3336                    std::task::Poll::Pending => return std::task::Poll::Pending,
3337                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3338                        this.is_terminated = true;
3339                        return std::task::Poll::Ready(None);
3340                    }
3341                    std::task::Poll::Ready(Err(e)) => {
3342                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3343                            e.into(),
3344                        ))));
3345                    }
3346                }
3347
3348                // A message has been received from the channel
3349                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3350
3351                std::task::Poll::Ready(Some(match header.ordinal {
3352                    0x341bdc9f49103a31 => {
3353                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3354                        let mut req = fidl::new_empty!(
3355                            ControlCreatorCreateRequest,
3356                            fidl::encoding::DefaultFuchsiaResourceDialect
3357                        );
3358                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlCreatorCreateRequest>(&header, _body_bytes, handles, &mut req)?;
3359                        let control_handle =
3360                            ControlCreatorControlHandle { inner: this.inner.clone() };
3361                        Ok(ControlCreatorRequest::Create {
3362                            payload: req,
3363                            responder: ControlCreatorCreateResponder {
3364                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3365                                tx_id: header.tx_id,
3366                            },
3367                        })
3368                    }
3369                    _ if header.tx_id == 0
3370                        && header
3371                            .dynamic_flags()
3372                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3373                    {
3374                        Ok(ControlCreatorRequest::_UnknownMethod {
3375                            ordinal: header.ordinal,
3376                            control_handle: ControlCreatorControlHandle {
3377                                inner: this.inner.clone(),
3378                            },
3379                            method_type: fidl::MethodType::OneWay,
3380                        })
3381                    }
3382                    _ if header
3383                        .dynamic_flags()
3384                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3385                    {
3386                        this.inner.send_framework_err(
3387                            fidl::encoding::FrameworkErr::UnknownMethod,
3388                            header.tx_id,
3389                            header.ordinal,
3390                            header.dynamic_flags(),
3391                            (bytes, handles),
3392                        )?;
3393                        Ok(ControlCreatorRequest::_UnknownMethod {
3394                            ordinal: header.ordinal,
3395                            control_handle: ControlCreatorControlHandle {
3396                                inner: this.inner.clone(),
3397                            },
3398                            method_type: fidl::MethodType::TwoWay,
3399                        })
3400                    }
3401                    _ => Err(fidl::Error::UnknownOrdinal {
3402                        ordinal: header.ordinal,
3403                        protocol_name:
3404                            <ControlCreatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3405                    }),
3406                }))
3407            },
3408        )
3409    }
3410}
3411
3412/// A `ControlCreator` interface creates `Control` instances. Each `Control` binds
3413/// to a single device. A device can only be bound to one `Control` at any time.
3414#[derive(Debug)]
3415pub enum ControlCreatorRequest {
3416    /// Create a `Control` for the specified device.
3417    Create { payload: ControlCreatorCreateRequest, responder: ControlCreatorCreateResponder },
3418    /// An interaction was received which does not match any known method.
3419    #[non_exhaustive]
3420    _UnknownMethod {
3421        /// Ordinal of the method that was called.
3422        ordinal: u64,
3423        control_handle: ControlCreatorControlHandle,
3424        method_type: fidl::MethodType,
3425    },
3426}
3427
3428impl ControlCreatorRequest {
3429    #[allow(irrefutable_let_patterns)]
3430    pub fn into_create(
3431        self,
3432    ) -> Option<(ControlCreatorCreateRequest, ControlCreatorCreateResponder)> {
3433        if let ControlCreatorRequest::Create { payload, responder } = self {
3434            Some((payload, responder))
3435        } else {
3436            None
3437        }
3438    }
3439
3440    /// Name of the method defined in FIDL
3441    pub fn method_name(&self) -> &'static str {
3442        match *self {
3443            ControlCreatorRequest::Create { .. } => "create",
3444            ControlCreatorRequest::_UnknownMethod {
3445                method_type: fidl::MethodType::OneWay, ..
3446            } => "unknown one-way method",
3447            ControlCreatorRequest::_UnknownMethod {
3448                method_type: fidl::MethodType::TwoWay, ..
3449            } => "unknown two-way method",
3450        }
3451    }
3452}
3453
3454#[derive(Debug, Clone)]
3455pub struct ControlCreatorControlHandle {
3456    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3457}
3458
3459impl fidl::endpoints::ControlHandle for ControlCreatorControlHandle {
3460    fn shutdown(&self) {
3461        self.inner.shutdown()
3462    }
3463
3464    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3465        self.inner.shutdown_with_epitaph(status)
3466    }
3467
3468    fn is_closed(&self) -> bool {
3469        self.inner.channel().is_closed()
3470    }
3471    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3472        self.inner.channel().on_closed()
3473    }
3474
3475    #[cfg(target_os = "fuchsia")]
3476    fn signal_peer(
3477        &self,
3478        clear_mask: zx::Signals,
3479        set_mask: zx::Signals,
3480    ) -> Result<(), zx_status::Status> {
3481        use fidl::Peered;
3482        self.inner.channel().signal_peer(clear_mask, set_mask)
3483    }
3484}
3485
3486impl ControlCreatorControlHandle {}
3487
3488#[must_use = "FIDL methods require a response to be sent"]
3489#[derive(Debug)]
3490pub struct ControlCreatorCreateResponder {
3491    control_handle: std::mem::ManuallyDrop<ControlCreatorControlHandle>,
3492    tx_id: u32,
3493}
3494
3495/// Set the the channel to be shutdown (see [`ControlCreatorControlHandle::shutdown`])
3496/// if the responder is dropped without sending a response, so that the client
3497/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3498impl std::ops::Drop for ControlCreatorCreateResponder {
3499    fn drop(&mut self) {
3500        self.control_handle.shutdown();
3501        // Safety: drops once, never accessed again
3502        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3503    }
3504}
3505
3506impl fidl::endpoints::Responder for ControlCreatorCreateResponder {
3507    type ControlHandle = ControlCreatorControlHandle;
3508
3509    fn control_handle(&self) -> &ControlCreatorControlHandle {
3510        &self.control_handle
3511    }
3512
3513    fn drop_without_shutdown(mut self) {
3514        // Safety: drops once, never accessed again due to mem::forget
3515        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3516        // Prevent Drop from running (which would shut down the channel)
3517        std::mem::forget(self);
3518    }
3519}
3520
3521impl ControlCreatorCreateResponder {
3522    /// Sends a response to the FIDL transaction.
3523    ///
3524    /// Sets the channel to shutdown if an error occurs.
3525    pub fn send(
3526        self,
3527        mut result: Result<&ControlCreatorCreateResponse, ControlCreatorError>,
3528    ) -> Result<(), fidl::Error> {
3529        let _result = self.send_raw(result);
3530        if _result.is_err() {
3531            self.control_handle.shutdown();
3532        }
3533        self.drop_without_shutdown();
3534        _result
3535    }
3536
3537    /// Similar to "send" but does not shutdown the channel if an error occurs.
3538    pub fn send_no_shutdown_on_err(
3539        self,
3540        mut result: Result<&ControlCreatorCreateResponse, ControlCreatorError>,
3541    ) -> Result<(), fidl::Error> {
3542        let _result = self.send_raw(result);
3543        self.drop_without_shutdown();
3544        _result
3545    }
3546
3547    fn send_raw(
3548        &self,
3549        mut result: Result<&ControlCreatorCreateResponse, ControlCreatorError>,
3550    ) -> Result<(), fidl::Error> {
3551        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3552            ControlCreatorCreateResponse,
3553            ControlCreatorError,
3554        >>(
3555            fidl::encoding::FlexibleResult::new(result),
3556            self.tx_id,
3557            0x341bdc9f49103a31,
3558            fidl::encoding::DynamicFlags::FLEXIBLE,
3559        )
3560    }
3561}
3562
3563#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3564pub struct ObserverMarker;
3565
3566impl fidl::endpoints::ProtocolMarker for ObserverMarker {
3567    type Proxy = ObserverProxy;
3568    type RequestStream = ObserverRequestStream;
3569    #[cfg(target_os = "fuchsia")]
3570    type SynchronousProxy = ObserverSynchronousProxy;
3571
3572    const DEBUG_NAME: &'static str = "(anonymous) Observer";
3573}
3574pub type ObserverWatchPlugStateResult =
3575    Result<ObserverWatchPlugStateResponse, ObserverWatchPlugStateError>;
3576pub type ObserverGetReferenceClockResult =
3577    Result<ObserverGetReferenceClockResponse, ObserverGetReferenceClockError>;
3578
3579pub trait ObserverProxyInterface: Send + Sync {
3580    type GetElementsResponseFut: std::future::Future<
3581            Output = Result<
3582                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
3583                fidl::Error,
3584            >,
3585        > + Send;
3586    fn r#get_elements(&self) -> Self::GetElementsResponseFut;
3587    type WatchElementStateResponseFut: std::future::Future<
3588            Output = Result<
3589                fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
3590                fidl::Error,
3591            >,
3592        > + Send;
3593    fn r#watch_element_state(
3594        &self,
3595        processing_element_id: u64,
3596    ) -> Self::WatchElementStateResponseFut;
3597    type GetTopologiesResponseFut: std::future::Future<
3598            Output = Result<
3599                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
3600                fidl::Error,
3601            >,
3602        > + Send;
3603    fn r#get_topologies(&self) -> Self::GetTopologiesResponseFut;
3604    type WatchTopologyResponseFut: std::future::Future<Output = Result<u64, fidl::Error>> + Send;
3605    fn r#watch_topology(&self) -> Self::WatchTopologyResponseFut;
3606    type WatchPlugStateResponseFut: std::future::Future<Output = Result<ObserverWatchPlugStateResult, fidl::Error>>
3607        + Send;
3608    fn r#watch_plug_state(&self) -> Self::WatchPlugStateResponseFut;
3609    type GetReferenceClockResponseFut: std::future::Future<Output = Result<ObserverGetReferenceClockResult, fidl::Error>>
3610        + Send;
3611    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
3612}
3613#[derive(Debug)]
3614#[cfg(target_os = "fuchsia")]
3615pub struct ObserverSynchronousProxy {
3616    client: fidl::client::sync::Client,
3617}
3618
3619#[cfg(target_os = "fuchsia")]
3620impl fidl::endpoints::SynchronousProxy for ObserverSynchronousProxy {
3621    type Proxy = ObserverProxy;
3622    type Protocol = ObserverMarker;
3623
3624    fn from_channel(inner: fidl::Channel) -> Self {
3625        Self::new(inner)
3626    }
3627
3628    fn into_channel(self) -> fidl::Channel {
3629        self.client.into_channel()
3630    }
3631
3632    fn as_channel(&self) -> &fidl::Channel {
3633        self.client.as_channel()
3634    }
3635}
3636
3637#[cfg(target_os = "fuchsia")]
3638impl ObserverSynchronousProxy {
3639    pub fn new(channel: fidl::Channel) -> Self {
3640        Self { client: fidl::client::sync::Client::new(channel) }
3641    }
3642
3643    pub fn into_channel(self) -> fidl::Channel {
3644        self.client.into_channel()
3645    }
3646
3647    /// Waits until an event arrives and returns it. It is safe for other
3648    /// threads to make concurrent requests while waiting for an event.
3649    pub fn wait_for_event(
3650        &self,
3651        deadline: zx::MonotonicInstant,
3652    ) -> Result<ObserverEvent, fidl::Error> {
3653        ObserverEvent::decode(self.client.wait_for_event::<ObserverMarker>(deadline)?)
3654    }
3655
3656    /// Returns a vector of supported processing elements.
3657    /// This vector must include one or more processing elements.
3658    pub fn r#get_elements(
3659        &self,
3660        ___deadline: zx::MonotonicInstant,
3661    ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult, fidl::Error>
3662    {
3663        let _response =
3664            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
3665                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResponse,
3666                i32,
3667            >, ObserverMarker>(
3668                (),
3669                0x1b14ff4adf5dc6f8,
3670                fidl::encoding::DynamicFlags::empty(),
3671                ___deadline,
3672            )?;
3673        Ok(_response.map(|x| x.processing_elements))
3674    }
3675
3676    /// Get the processing element state via a hanging get.
3677    /// For a given `processing_element_id`, the driver will immediately reply to the first
3678    /// `WatchElementState` sent by the client. The driver will not respond to subsequent client
3679    /// `WatchElementState` calls for that `processing_element_id` until any portion of the
3680    /// `ElementState` has changed from what was most recently reported for that element.
3681    ///
3682    /// The driver will close the protocol channel with an error of `ZX_ERR_INVALID_ARGS`, if
3683    /// `processing_element_id` does not match an ElementId returned by `GetElements`.
3684    ///
3685    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
3686    /// method is called again while there is already a pending `WatchElementState` for this client
3687    /// and `processing_element_id`.
3688    pub fn r#watch_element_state(
3689        &self,
3690        mut processing_element_id: u64,
3691        ___deadline: zx::MonotonicInstant,
3692    ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ElementState, fidl::Error> {
3693        let _response = self.client.send_query::<
3694            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest,
3695            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateResponse,
3696            ObserverMarker,
3697        >(
3698            (processing_element_id,),
3699            0x524da8772a69056f,
3700            fidl::encoding::DynamicFlags::empty(),
3701            ___deadline,
3702        )?;
3703        Ok(_response.state)
3704    }
3705
3706    /// Returns a vector of supported topologies.
3707    /// This vector must include one or more topologies.
3708    /// If more than one topology is returned, then the client may select any topology from the
3709    /// list by calling `SetTopology`.
3710    /// If only one topology is returned, `SetTopology` can still be called but causes no change.
3711    ///
3712    /// Each Element must be included in at least one Topology, but need not be included in every
3713    /// Topology.
3714    pub fn r#get_topologies(
3715        &self,
3716        ___deadline: zx::MonotonicInstant,
3717    ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult, fidl::Error>
3718    {
3719        let _response =
3720            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
3721                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResponse,
3722                i32,
3723            >, ObserverMarker>(
3724                (),
3725                0x73ffb73af24d30b6,
3726                fidl::encoding::DynamicFlags::empty(),
3727                ___deadline,
3728            )?;
3729        Ok(_response.map(|x| x.topologies))
3730    }
3731
3732    /// Get the current topology via a hanging get.
3733    /// The driver will immediately reply to the first `WatchTopology` sent by each client.
3734    /// The driver will not respond to subsequent `WatchTopology` calls from that client until the
3735    /// signal processing topology changes; this occurs as a result of a `SetTopology` call.
3736    ///
3737    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
3738    /// method is called again while there is already a pending `WatchTopology` for this client.
3739    pub fn r#watch_topology(&self, ___deadline: zx::MonotonicInstant) -> Result<u64, fidl::Error> {
3740        let _response = self
3741            .client
3742            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleType<
3743                fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchTopologyResponse,
3744            >, ObserverMarker>(
3745                (),
3746                0x66d172acdb36a729,
3747                fidl::encoding::DynamicFlags::FLEXIBLE,
3748                ___deadline,
3749            )?
3750            .into_result::<ObserverMarker>("watch_topology")?;
3751        Ok(_response.topology_id)
3752    }
3753
3754    /// Request notification of any change to the device's plug state. When
3755    /// called for the first time, it will return immediately.
3756    ///
3757    /// Should only be called for Codec devices.
3758    pub fn r#watch_plug_state(
3759        &self,
3760        ___deadline: zx::MonotonicInstant,
3761    ) -> Result<ObserverWatchPlugStateResult, fidl::Error> {
3762        let _response = self
3763            .client
3764            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
3765                ObserverWatchPlugStateResponse,
3766                ObserverWatchPlugStateError,
3767            >, ObserverMarker>(
3768                (),
3769                0x6312bce495d2907a,
3770                fidl::encoding::DynamicFlags::FLEXIBLE,
3771                ___deadline,
3772            )?
3773            .into_result::<ObserverMarker>("watch_plug_state")?;
3774        Ok(_response.map(|x| x))
3775    }
3776
3777    /// Retrieve the device's reference clock.
3778    ///
3779    /// This clock will be in the domain specified in the device's `Info` table.
3780    ///
3781    /// Should only be called for Composite devices.
3782    pub fn r#get_reference_clock(
3783        &self,
3784        ___deadline: zx::MonotonicInstant,
3785    ) -> Result<ObserverGetReferenceClockResult, fidl::Error> {
3786        let _response = self
3787            .client
3788            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
3789                ObserverGetReferenceClockResponse,
3790                ObserverGetReferenceClockError,
3791            >, ObserverMarker>(
3792                (),
3793                0x3819c5e0f9574c39,
3794                fidl::encoding::DynamicFlags::FLEXIBLE,
3795                ___deadline,
3796            )?
3797            .into_result::<ObserverMarker>("get_reference_clock")?;
3798        Ok(_response.map(|x| x))
3799    }
3800}
3801
3802#[cfg(target_os = "fuchsia")]
3803impl From<ObserverSynchronousProxy> for zx::NullableHandle {
3804    fn from(value: ObserverSynchronousProxy) -> Self {
3805        value.into_channel().into()
3806    }
3807}
3808
3809#[cfg(target_os = "fuchsia")]
3810impl From<fidl::Channel> for ObserverSynchronousProxy {
3811    fn from(value: fidl::Channel) -> Self {
3812        Self::new(value)
3813    }
3814}
3815
3816#[cfg(target_os = "fuchsia")]
3817impl fidl::endpoints::FromClient for ObserverSynchronousProxy {
3818    type Protocol = ObserverMarker;
3819
3820    fn from_client(value: fidl::endpoints::ClientEnd<ObserverMarker>) -> Self {
3821        Self::new(value.into_channel())
3822    }
3823}
3824
3825#[derive(Debug, Clone)]
3826pub struct ObserverProxy {
3827    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3828}
3829
3830impl fidl::endpoints::Proxy for ObserverProxy {
3831    type Protocol = ObserverMarker;
3832
3833    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3834        Self::new(inner)
3835    }
3836
3837    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3838        self.client.into_channel().map_err(|client| Self { client })
3839    }
3840
3841    fn as_channel(&self) -> &::fidl::AsyncChannel {
3842        self.client.as_channel()
3843    }
3844}
3845
3846impl ObserverProxy {
3847    /// Create a new Proxy for fuchsia.audio.device/Observer.
3848    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3849        let protocol_name = <ObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3850        Self { client: fidl::client::Client::new(channel, protocol_name) }
3851    }
3852
3853    /// Get a Stream of events from the remote end of the protocol.
3854    ///
3855    /// # Panics
3856    ///
3857    /// Panics if the event stream was already taken.
3858    pub fn take_event_stream(&self) -> ObserverEventStream {
3859        ObserverEventStream { event_receiver: self.client.take_event_receiver() }
3860    }
3861
3862    /// Returns a vector of supported processing elements.
3863    /// This vector must include one or more processing elements.
3864    pub fn r#get_elements(
3865        &self,
3866    ) -> fidl::client::QueryResponseFut<
3867        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
3868        fidl::encoding::DefaultFuchsiaResourceDialect,
3869    > {
3870        ObserverProxyInterface::r#get_elements(self)
3871    }
3872
3873    /// Get the processing element state via a hanging get.
3874    /// For a given `processing_element_id`, the driver will immediately reply to the first
3875    /// `WatchElementState` sent by the client. The driver will not respond to subsequent client
3876    /// `WatchElementState` calls for that `processing_element_id` until any portion of the
3877    /// `ElementState` has changed from what was most recently reported for that element.
3878    ///
3879    /// The driver will close the protocol channel with an error of `ZX_ERR_INVALID_ARGS`, if
3880    /// `processing_element_id` does not match an ElementId returned by `GetElements`.
3881    ///
3882    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
3883    /// method is called again while there is already a pending `WatchElementState` for this client
3884    /// and `processing_element_id`.
3885    pub fn r#watch_element_state(
3886        &self,
3887        mut processing_element_id: u64,
3888    ) -> fidl::client::QueryResponseFut<
3889        fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
3890        fidl::encoding::DefaultFuchsiaResourceDialect,
3891    > {
3892        ObserverProxyInterface::r#watch_element_state(self, processing_element_id)
3893    }
3894
3895    /// Returns a vector of supported topologies.
3896    /// This vector must include one or more topologies.
3897    /// If more than one topology is returned, then the client may select any topology from the
3898    /// list by calling `SetTopology`.
3899    /// If only one topology is returned, `SetTopology` can still be called but causes no change.
3900    ///
3901    /// Each Element must be included in at least one Topology, but need not be included in every
3902    /// Topology.
3903    pub fn r#get_topologies(
3904        &self,
3905    ) -> fidl::client::QueryResponseFut<
3906        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
3907        fidl::encoding::DefaultFuchsiaResourceDialect,
3908    > {
3909        ObserverProxyInterface::r#get_topologies(self)
3910    }
3911
3912    /// Get the current topology via a hanging get.
3913    /// The driver will immediately reply to the first `WatchTopology` sent by each client.
3914    /// The driver will not respond to subsequent `WatchTopology` calls from that client until the
3915    /// signal processing topology changes; this occurs as a result of a `SetTopology` call.
3916    ///
3917    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
3918    /// method is called again while there is already a pending `WatchTopology` for this client.
3919    pub fn r#watch_topology(
3920        &self,
3921    ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
3922        ObserverProxyInterface::r#watch_topology(self)
3923    }
3924
3925    /// Request notification of any change to the device's plug state. When
3926    /// called for the first time, it will return immediately.
3927    ///
3928    /// Should only be called for Codec devices.
3929    pub fn r#watch_plug_state(
3930        &self,
3931    ) -> fidl::client::QueryResponseFut<
3932        ObserverWatchPlugStateResult,
3933        fidl::encoding::DefaultFuchsiaResourceDialect,
3934    > {
3935        ObserverProxyInterface::r#watch_plug_state(self)
3936    }
3937
3938    /// Retrieve the device's reference clock.
3939    ///
3940    /// This clock will be in the domain specified in the device's `Info` table.
3941    ///
3942    /// Should only be called for Composite devices.
3943    pub fn r#get_reference_clock(
3944        &self,
3945    ) -> fidl::client::QueryResponseFut<
3946        ObserverGetReferenceClockResult,
3947        fidl::encoding::DefaultFuchsiaResourceDialect,
3948    > {
3949        ObserverProxyInterface::r#get_reference_clock(self)
3950    }
3951}
3952
3953impl ObserverProxyInterface for ObserverProxy {
3954    type GetElementsResponseFut = fidl::client::QueryResponseFut<
3955        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
3956        fidl::encoding::DefaultFuchsiaResourceDialect,
3957    >;
3958    fn r#get_elements(&self) -> Self::GetElementsResponseFut {
3959        fn _decode(
3960            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3961        ) -> Result<
3962            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
3963            fidl::Error,
3964        > {
3965            let _response = fidl::client::decode_transaction_body::<
3966                fidl::encoding::ResultType<
3967                    fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResponse,
3968                    i32,
3969                >,
3970                fidl::encoding::DefaultFuchsiaResourceDialect,
3971                0x1b14ff4adf5dc6f8,
3972            >(_buf?)?;
3973            Ok(_response.map(|x| x.processing_elements))
3974        }
3975        self.client.send_query_and_decode::<
3976            fidl::encoding::EmptyPayload,
3977            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
3978        >(
3979            (),
3980            0x1b14ff4adf5dc6f8,
3981            fidl::encoding::DynamicFlags::empty(),
3982            _decode,
3983        )
3984    }
3985
3986    type WatchElementStateResponseFut = fidl::client::QueryResponseFut<
3987        fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
3988        fidl::encoding::DefaultFuchsiaResourceDialect,
3989    >;
3990    fn r#watch_element_state(
3991        &self,
3992        mut processing_element_id: u64,
3993    ) -> Self::WatchElementStateResponseFut {
3994        fn _decode(
3995            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3996        ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ElementState, fidl::Error>
3997        {
3998            let _response = fidl::client::decode_transaction_body::<
3999                fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateResponse,
4000                fidl::encoding::DefaultFuchsiaResourceDialect,
4001                0x524da8772a69056f,
4002            >(_buf?)?;
4003            Ok(_response.state)
4004        }
4005        self.client.send_query_and_decode::<
4006            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest,
4007            fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
4008        >(
4009            (processing_element_id,),
4010            0x524da8772a69056f,
4011            fidl::encoding::DynamicFlags::empty(),
4012            _decode,
4013        )
4014    }
4015
4016    type GetTopologiesResponseFut = fidl::client::QueryResponseFut<
4017        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
4018        fidl::encoding::DefaultFuchsiaResourceDialect,
4019    >;
4020    fn r#get_topologies(&self) -> Self::GetTopologiesResponseFut {
4021        fn _decode(
4022            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4023        ) -> Result<
4024            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
4025            fidl::Error,
4026        > {
4027            let _response = fidl::client::decode_transaction_body::<
4028                fidl::encoding::ResultType<
4029                    fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResponse,
4030                    i32,
4031                >,
4032                fidl::encoding::DefaultFuchsiaResourceDialect,
4033                0x73ffb73af24d30b6,
4034            >(_buf?)?;
4035            Ok(_response.map(|x| x.topologies))
4036        }
4037        self.client.send_query_and_decode::<
4038            fidl::encoding::EmptyPayload,
4039            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
4040        >(
4041            (),
4042            0x73ffb73af24d30b6,
4043            fidl::encoding::DynamicFlags::empty(),
4044            _decode,
4045        )
4046    }
4047
4048    type WatchTopologyResponseFut =
4049        fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
4050    fn r#watch_topology(&self) -> Self::WatchTopologyResponseFut {
4051        fn _decode(
4052            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4053        ) -> Result<u64, fidl::Error> {
4054            let _response = fidl::client::decode_transaction_body::<
4055                fidl::encoding::FlexibleType<
4056                    fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchTopologyResponse,
4057                >,
4058                fidl::encoding::DefaultFuchsiaResourceDialect,
4059                0x66d172acdb36a729,
4060            >(_buf?)?
4061            .into_result::<ObserverMarker>("watch_topology")?;
4062            Ok(_response.topology_id)
4063        }
4064        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u64>(
4065            (),
4066            0x66d172acdb36a729,
4067            fidl::encoding::DynamicFlags::FLEXIBLE,
4068            _decode,
4069        )
4070    }
4071
4072    type WatchPlugStateResponseFut = fidl::client::QueryResponseFut<
4073        ObserverWatchPlugStateResult,
4074        fidl::encoding::DefaultFuchsiaResourceDialect,
4075    >;
4076    fn r#watch_plug_state(&self) -> Self::WatchPlugStateResponseFut {
4077        fn _decode(
4078            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4079        ) -> Result<ObserverWatchPlugStateResult, fidl::Error> {
4080            let _response = fidl::client::decode_transaction_body::<
4081                fidl::encoding::FlexibleResultType<
4082                    ObserverWatchPlugStateResponse,
4083                    ObserverWatchPlugStateError,
4084                >,
4085                fidl::encoding::DefaultFuchsiaResourceDialect,
4086                0x6312bce495d2907a,
4087            >(_buf?)?
4088            .into_result::<ObserverMarker>("watch_plug_state")?;
4089            Ok(_response.map(|x| x))
4090        }
4091        self.client
4092            .send_query_and_decode::<fidl::encoding::EmptyPayload, ObserverWatchPlugStateResult>(
4093                (),
4094                0x6312bce495d2907a,
4095                fidl::encoding::DynamicFlags::FLEXIBLE,
4096                _decode,
4097            )
4098    }
4099
4100    type GetReferenceClockResponseFut = fidl::client::QueryResponseFut<
4101        ObserverGetReferenceClockResult,
4102        fidl::encoding::DefaultFuchsiaResourceDialect,
4103    >;
4104    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
4105        fn _decode(
4106            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4107        ) -> Result<ObserverGetReferenceClockResult, fidl::Error> {
4108            let _response = fidl::client::decode_transaction_body::<
4109                fidl::encoding::FlexibleResultType<
4110                    ObserverGetReferenceClockResponse,
4111                    ObserverGetReferenceClockError,
4112                >,
4113                fidl::encoding::DefaultFuchsiaResourceDialect,
4114                0x3819c5e0f9574c39,
4115            >(_buf?)?
4116            .into_result::<ObserverMarker>("get_reference_clock")?;
4117            Ok(_response.map(|x| x))
4118        }
4119        self.client
4120            .send_query_and_decode::<fidl::encoding::EmptyPayload, ObserverGetReferenceClockResult>(
4121                (),
4122                0x3819c5e0f9574c39,
4123                fidl::encoding::DynamicFlags::FLEXIBLE,
4124                _decode,
4125            )
4126    }
4127}
4128
4129pub struct ObserverEventStream {
4130    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4131}
4132
4133impl std::marker::Unpin for ObserverEventStream {}
4134
4135impl futures::stream::FusedStream for ObserverEventStream {
4136    fn is_terminated(&self) -> bool {
4137        self.event_receiver.is_terminated()
4138    }
4139}
4140
4141impl futures::Stream for ObserverEventStream {
4142    type Item = Result<ObserverEvent, fidl::Error>;
4143
4144    fn poll_next(
4145        mut self: std::pin::Pin<&mut Self>,
4146        cx: &mut std::task::Context<'_>,
4147    ) -> std::task::Poll<Option<Self::Item>> {
4148        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4149            &mut self.event_receiver,
4150            cx
4151        )?) {
4152            Some(buf) => std::task::Poll::Ready(Some(ObserverEvent::decode(buf))),
4153            None => std::task::Poll::Ready(None),
4154        }
4155    }
4156}
4157
4158#[derive(Debug)]
4159pub enum ObserverEvent {
4160    #[non_exhaustive]
4161    _UnknownEvent {
4162        /// Ordinal of the event that was sent.
4163        ordinal: u64,
4164    },
4165}
4166
4167impl ObserverEvent {
4168    /// Decodes a message buffer as a [`ObserverEvent`].
4169    fn decode(
4170        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4171    ) -> Result<ObserverEvent, fidl::Error> {
4172        let (bytes, _handles) = buf.split_mut();
4173        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4174        debug_assert_eq!(tx_header.tx_id, 0);
4175        match tx_header.ordinal {
4176            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4177                Ok(ObserverEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4178            }
4179            _ => Err(fidl::Error::UnknownOrdinal {
4180                ordinal: tx_header.ordinal,
4181                protocol_name: <ObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4182            }),
4183        }
4184    }
4185}
4186
4187/// A Stream of incoming requests for fuchsia.audio.device/Observer.
4188pub struct ObserverRequestStream {
4189    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4190    is_terminated: bool,
4191}
4192
4193impl std::marker::Unpin for ObserverRequestStream {}
4194
4195impl futures::stream::FusedStream for ObserverRequestStream {
4196    fn is_terminated(&self) -> bool {
4197        self.is_terminated
4198    }
4199}
4200
4201impl fidl::endpoints::RequestStream for ObserverRequestStream {
4202    type Protocol = ObserverMarker;
4203    type ControlHandle = ObserverControlHandle;
4204
4205    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4206        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4207    }
4208
4209    fn control_handle(&self) -> Self::ControlHandle {
4210        ObserverControlHandle { inner: self.inner.clone() }
4211    }
4212
4213    fn into_inner(
4214        self,
4215    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4216    {
4217        (self.inner, self.is_terminated)
4218    }
4219
4220    fn from_inner(
4221        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4222        is_terminated: bool,
4223    ) -> Self {
4224        Self { inner, is_terminated }
4225    }
4226}
4227
4228impl futures::Stream for ObserverRequestStream {
4229    type Item = Result<ObserverRequest, fidl::Error>;
4230
4231    fn poll_next(
4232        mut self: std::pin::Pin<&mut Self>,
4233        cx: &mut std::task::Context<'_>,
4234    ) -> std::task::Poll<Option<Self::Item>> {
4235        let this = &mut *self;
4236        if this.inner.check_shutdown(cx) {
4237            this.is_terminated = true;
4238            return std::task::Poll::Ready(None);
4239        }
4240        if this.is_terminated {
4241            panic!("polled ObserverRequestStream after completion");
4242        }
4243        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4244            |bytes, handles| {
4245                match this.inner.channel().read_etc(cx, bytes, handles) {
4246                    std::task::Poll::Ready(Ok(())) => {}
4247                    std::task::Poll::Pending => return std::task::Poll::Pending,
4248                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4249                        this.is_terminated = true;
4250                        return std::task::Poll::Ready(None);
4251                    }
4252                    std::task::Poll::Ready(Err(e)) => {
4253                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4254                            e.into(),
4255                        ))));
4256                    }
4257                }
4258
4259                // A message has been received from the channel
4260                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4261
4262                std::task::Poll::Ready(Some(match header.ordinal {
4263                    0x1b14ff4adf5dc6f8 => {
4264                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4265                        let mut req = fidl::new_empty!(
4266                            fidl::encoding::EmptyPayload,
4267                            fidl::encoding::DefaultFuchsiaResourceDialect
4268                        );
4269                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4270                        let control_handle = ObserverControlHandle { inner: this.inner.clone() };
4271                        Ok(ObserverRequest::GetElements {
4272                            responder: ObserverGetElementsResponder {
4273                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4274                                tx_id: header.tx_id,
4275                            },
4276                        })
4277                    }
4278                    0x524da8772a69056f => {
4279                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4280                        let mut req = fidl::new_empty!(fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
4281                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest>(&header, _body_bytes, handles, &mut req)?;
4282                        let control_handle = ObserverControlHandle { inner: this.inner.clone() };
4283                        Ok(ObserverRequest::WatchElementState {
4284                            processing_element_id: req.processing_element_id,
4285
4286                            responder: ObserverWatchElementStateResponder {
4287                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4288                                tx_id: header.tx_id,
4289                            },
4290                        })
4291                    }
4292                    0x73ffb73af24d30b6 => {
4293                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4294                        let mut req = fidl::new_empty!(
4295                            fidl::encoding::EmptyPayload,
4296                            fidl::encoding::DefaultFuchsiaResourceDialect
4297                        );
4298                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4299                        let control_handle = ObserverControlHandle { inner: this.inner.clone() };
4300                        Ok(ObserverRequest::GetTopologies {
4301                            responder: ObserverGetTopologiesResponder {
4302                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4303                                tx_id: header.tx_id,
4304                            },
4305                        })
4306                    }
4307                    0x66d172acdb36a729 => {
4308                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4309                        let mut req = fidl::new_empty!(
4310                            fidl::encoding::EmptyPayload,
4311                            fidl::encoding::DefaultFuchsiaResourceDialect
4312                        );
4313                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4314                        let control_handle = ObserverControlHandle { inner: this.inner.clone() };
4315                        Ok(ObserverRequest::WatchTopology {
4316                            responder: ObserverWatchTopologyResponder {
4317                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4318                                tx_id: header.tx_id,
4319                            },
4320                        })
4321                    }
4322                    0x6312bce495d2907a => {
4323                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4324                        let mut req = fidl::new_empty!(
4325                            fidl::encoding::EmptyPayload,
4326                            fidl::encoding::DefaultFuchsiaResourceDialect
4327                        );
4328                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4329                        let control_handle = ObserverControlHandle { inner: this.inner.clone() };
4330                        Ok(ObserverRequest::WatchPlugState {
4331                            responder: ObserverWatchPlugStateResponder {
4332                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4333                                tx_id: header.tx_id,
4334                            },
4335                        })
4336                    }
4337                    0x3819c5e0f9574c39 => {
4338                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4339                        let mut req = fidl::new_empty!(
4340                            fidl::encoding::EmptyPayload,
4341                            fidl::encoding::DefaultFuchsiaResourceDialect
4342                        );
4343                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4344                        let control_handle = ObserverControlHandle { inner: this.inner.clone() };
4345                        Ok(ObserverRequest::GetReferenceClock {
4346                            responder: ObserverGetReferenceClockResponder {
4347                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4348                                tx_id: header.tx_id,
4349                            },
4350                        })
4351                    }
4352                    _ if header.tx_id == 0
4353                        && header
4354                            .dynamic_flags()
4355                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4356                    {
4357                        Ok(ObserverRequest::_UnknownMethod {
4358                            ordinal: header.ordinal,
4359                            control_handle: ObserverControlHandle { inner: this.inner.clone() },
4360                            method_type: fidl::MethodType::OneWay,
4361                        })
4362                    }
4363                    _ if header
4364                        .dynamic_flags()
4365                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4366                    {
4367                        this.inner.send_framework_err(
4368                            fidl::encoding::FrameworkErr::UnknownMethod,
4369                            header.tx_id,
4370                            header.ordinal,
4371                            header.dynamic_flags(),
4372                            (bytes, handles),
4373                        )?;
4374                        Ok(ObserverRequest::_UnknownMethod {
4375                            ordinal: header.ordinal,
4376                            control_handle: ObserverControlHandle { inner: this.inner.clone() },
4377                            method_type: fidl::MethodType::TwoWay,
4378                        })
4379                    }
4380                    _ => Err(fidl::Error::UnknownOrdinal {
4381                        ordinal: header.ordinal,
4382                        protocol_name:
4383                            <ObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4384                    }),
4385                }))
4386            },
4387        )
4388    }
4389}
4390
4391/// `Observer` instances are used to learn the capabilities and state of an
4392/// audio device, and to stay informed as its state changes over time. Each
4393/// `Observer` is associated with an initialized audio device. An audio device
4394/// may be observed by multiple `Observer` instances.
4395#[derive(Debug)]
4396pub enum ObserverRequest {
4397    /// Returns a vector of supported processing elements.
4398    /// This vector must include one or more processing elements.
4399    GetElements { responder: ObserverGetElementsResponder },
4400    /// Get the processing element state via a hanging get.
4401    /// For a given `processing_element_id`, the driver will immediately reply to the first
4402    /// `WatchElementState` sent by the client. The driver will not respond to subsequent client
4403    /// `WatchElementState` calls for that `processing_element_id` until any portion of the
4404    /// `ElementState` has changed from what was most recently reported for that element.
4405    ///
4406    /// The driver will close the protocol channel with an error of `ZX_ERR_INVALID_ARGS`, if
4407    /// `processing_element_id` does not match an ElementId returned by `GetElements`.
4408    ///
4409    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
4410    /// method is called again while there is already a pending `WatchElementState` for this client
4411    /// and `processing_element_id`.
4412    WatchElementState { processing_element_id: u64, responder: ObserverWatchElementStateResponder },
4413    /// Returns a vector of supported topologies.
4414    /// This vector must include one or more topologies.
4415    /// If more than one topology is returned, then the client may select any topology from the
4416    /// list by calling `SetTopology`.
4417    /// If only one topology is returned, `SetTopology` can still be called but causes no change.
4418    ///
4419    /// Each Element must be included in at least one Topology, but need not be included in every
4420    /// Topology.
4421    GetTopologies { responder: ObserverGetTopologiesResponder },
4422    /// Get the current topology via a hanging get.
4423    /// The driver will immediately reply to the first `WatchTopology` sent by each client.
4424    /// The driver will not respond to subsequent `WatchTopology` calls from that client until the
4425    /// signal processing topology changes; this occurs as a result of a `SetTopology` call.
4426    ///
4427    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
4428    /// method is called again while there is already a pending `WatchTopology` for this client.
4429    WatchTopology { responder: ObserverWatchTopologyResponder },
4430    /// Request notification of any change to the device's plug state. When
4431    /// called for the first time, it will return immediately.
4432    ///
4433    /// Should only be called for Codec devices.
4434    WatchPlugState { responder: ObserverWatchPlugStateResponder },
4435    /// Retrieve the device's reference clock.
4436    ///
4437    /// This clock will be in the domain specified in the device's `Info` table.
4438    ///
4439    /// Should only be called for Composite devices.
4440    GetReferenceClock { responder: ObserverGetReferenceClockResponder },
4441    /// An interaction was received which does not match any known method.
4442    #[non_exhaustive]
4443    _UnknownMethod {
4444        /// Ordinal of the method that was called.
4445        ordinal: u64,
4446        control_handle: ObserverControlHandle,
4447        method_type: fidl::MethodType,
4448    },
4449}
4450
4451impl ObserverRequest {
4452    #[allow(irrefutable_let_patterns)]
4453    pub fn into_get_elements(self) -> Option<(ObserverGetElementsResponder)> {
4454        if let ObserverRequest::GetElements { responder } = self { Some((responder)) } else { None }
4455    }
4456
4457    #[allow(irrefutable_let_patterns)]
4458    pub fn into_watch_element_state(self) -> Option<(u64, ObserverWatchElementStateResponder)> {
4459        if let ObserverRequest::WatchElementState { processing_element_id, responder } = self {
4460            Some((processing_element_id, responder))
4461        } else {
4462            None
4463        }
4464    }
4465
4466    #[allow(irrefutable_let_patterns)]
4467    pub fn into_get_topologies(self) -> Option<(ObserverGetTopologiesResponder)> {
4468        if let ObserverRequest::GetTopologies { responder } = self {
4469            Some((responder))
4470        } else {
4471            None
4472        }
4473    }
4474
4475    #[allow(irrefutable_let_patterns)]
4476    pub fn into_watch_topology(self) -> Option<(ObserverWatchTopologyResponder)> {
4477        if let ObserverRequest::WatchTopology { responder } = self {
4478            Some((responder))
4479        } else {
4480            None
4481        }
4482    }
4483
4484    #[allow(irrefutable_let_patterns)]
4485    pub fn into_watch_plug_state(self) -> Option<(ObserverWatchPlugStateResponder)> {
4486        if let ObserverRequest::WatchPlugState { responder } = self {
4487            Some((responder))
4488        } else {
4489            None
4490        }
4491    }
4492
4493    #[allow(irrefutable_let_patterns)]
4494    pub fn into_get_reference_clock(self) -> Option<(ObserverGetReferenceClockResponder)> {
4495        if let ObserverRequest::GetReferenceClock { responder } = self {
4496            Some((responder))
4497        } else {
4498            None
4499        }
4500    }
4501
4502    /// Name of the method defined in FIDL
4503    pub fn method_name(&self) -> &'static str {
4504        match *self {
4505            ObserverRequest::GetElements { .. } => "get_elements",
4506            ObserverRequest::WatchElementState { .. } => "watch_element_state",
4507            ObserverRequest::GetTopologies { .. } => "get_topologies",
4508            ObserverRequest::WatchTopology { .. } => "watch_topology",
4509            ObserverRequest::WatchPlugState { .. } => "watch_plug_state",
4510            ObserverRequest::GetReferenceClock { .. } => "get_reference_clock",
4511            ObserverRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
4512                "unknown one-way method"
4513            }
4514            ObserverRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
4515                "unknown two-way method"
4516            }
4517        }
4518    }
4519}
4520
4521#[derive(Debug, Clone)]
4522pub struct ObserverControlHandle {
4523    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4524}
4525
4526impl fidl::endpoints::ControlHandle for ObserverControlHandle {
4527    fn shutdown(&self) {
4528        self.inner.shutdown()
4529    }
4530
4531    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4532        self.inner.shutdown_with_epitaph(status)
4533    }
4534
4535    fn is_closed(&self) -> bool {
4536        self.inner.channel().is_closed()
4537    }
4538    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4539        self.inner.channel().on_closed()
4540    }
4541
4542    #[cfg(target_os = "fuchsia")]
4543    fn signal_peer(
4544        &self,
4545        clear_mask: zx::Signals,
4546        set_mask: zx::Signals,
4547    ) -> Result<(), zx_status::Status> {
4548        use fidl::Peered;
4549        self.inner.channel().signal_peer(clear_mask, set_mask)
4550    }
4551}
4552
4553impl ObserverControlHandle {}
4554
4555#[must_use = "FIDL methods require a response to be sent"]
4556#[derive(Debug)]
4557pub struct ObserverGetElementsResponder {
4558    control_handle: std::mem::ManuallyDrop<ObserverControlHandle>,
4559    tx_id: u32,
4560}
4561
4562/// Set the the channel to be shutdown (see [`ObserverControlHandle::shutdown`])
4563/// if the responder is dropped without sending a response, so that the client
4564/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4565impl std::ops::Drop for ObserverGetElementsResponder {
4566    fn drop(&mut self) {
4567        self.control_handle.shutdown();
4568        // Safety: drops once, never accessed again
4569        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4570    }
4571}
4572
4573impl fidl::endpoints::Responder for ObserverGetElementsResponder {
4574    type ControlHandle = ObserverControlHandle;
4575
4576    fn control_handle(&self) -> &ObserverControlHandle {
4577        &self.control_handle
4578    }
4579
4580    fn drop_without_shutdown(mut self) {
4581        // Safety: drops once, never accessed again due to mem::forget
4582        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4583        // Prevent Drop from running (which would shut down the channel)
4584        std::mem::forget(self);
4585    }
4586}
4587
4588impl ObserverGetElementsResponder {
4589    /// Sends a response to the FIDL transaction.
4590    ///
4591    /// Sets the channel to shutdown if an error occurs.
4592    pub fn send(
4593        self,
4594        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Element], i32>,
4595    ) -> Result<(), fidl::Error> {
4596        let _result = self.send_raw(result);
4597        if _result.is_err() {
4598            self.control_handle.shutdown();
4599        }
4600        self.drop_without_shutdown();
4601        _result
4602    }
4603
4604    /// Similar to "send" but does not shutdown the channel if an error occurs.
4605    pub fn send_no_shutdown_on_err(
4606        self,
4607        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Element], i32>,
4608    ) -> Result<(), fidl::Error> {
4609        let _result = self.send_raw(result);
4610        self.drop_without_shutdown();
4611        _result
4612    }
4613
4614    fn send_raw(
4615        &self,
4616        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Element], i32>,
4617    ) -> Result<(), fidl::Error> {
4618        self.control_handle.inner.send::<fidl::encoding::ResultType<
4619            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResponse,
4620            i32,
4621        >>(
4622            result.map(|processing_elements| (processing_elements,)),
4623            self.tx_id,
4624            0x1b14ff4adf5dc6f8,
4625            fidl::encoding::DynamicFlags::empty(),
4626        )
4627    }
4628}
4629
4630#[must_use = "FIDL methods require a response to be sent"]
4631#[derive(Debug)]
4632pub struct ObserverWatchElementStateResponder {
4633    control_handle: std::mem::ManuallyDrop<ObserverControlHandle>,
4634    tx_id: u32,
4635}
4636
4637/// Set the the channel to be shutdown (see [`ObserverControlHandle::shutdown`])
4638/// if the responder is dropped without sending a response, so that the client
4639/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4640impl std::ops::Drop for ObserverWatchElementStateResponder {
4641    fn drop(&mut self) {
4642        self.control_handle.shutdown();
4643        // Safety: drops once, never accessed again
4644        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4645    }
4646}
4647
4648impl fidl::endpoints::Responder for ObserverWatchElementStateResponder {
4649    type ControlHandle = ObserverControlHandle;
4650
4651    fn control_handle(&self) -> &ObserverControlHandle {
4652        &self.control_handle
4653    }
4654
4655    fn drop_without_shutdown(mut self) {
4656        // Safety: drops once, never accessed again due to mem::forget
4657        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4658        // Prevent Drop from running (which would shut down the channel)
4659        std::mem::forget(self);
4660    }
4661}
4662
4663impl ObserverWatchElementStateResponder {
4664    /// Sends a response to the FIDL transaction.
4665    ///
4666    /// Sets the channel to shutdown if an error occurs.
4667    pub fn send(
4668        self,
4669        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
4670    ) -> Result<(), fidl::Error> {
4671        let _result = self.send_raw(state);
4672        if _result.is_err() {
4673            self.control_handle.shutdown();
4674        }
4675        self.drop_without_shutdown();
4676        _result
4677    }
4678
4679    /// Similar to "send" but does not shutdown the channel if an error occurs.
4680    pub fn send_no_shutdown_on_err(
4681        self,
4682        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
4683    ) -> Result<(), fidl::Error> {
4684        let _result = self.send_raw(state);
4685        self.drop_without_shutdown();
4686        _result
4687    }
4688
4689    fn send_raw(
4690        &self,
4691        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
4692    ) -> Result<(), fidl::Error> {
4693        self.control_handle
4694            .inner
4695            .send::<fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateResponse>(
4696            (state,),
4697            self.tx_id,
4698            0x524da8772a69056f,
4699            fidl::encoding::DynamicFlags::empty(),
4700        )
4701    }
4702}
4703
4704#[must_use = "FIDL methods require a response to be sent"]
4705#[derive(Debug)]
4706pub struct ObserverGetTopologiesResponder {
4707    control_handle: std::mem::ManuallyDrop<ObserverControlHandle>,
4708    tx_id: u32,
4709}
4710
4711/// Set the the channel to be shutdown (see [`ObserverControlHandle::shutdown`])
4712/// if the responder is dropped without sending a response, so that the client
4713/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4714impl std::ops::Drop for ObserverGetTopologiesResponder {
4715    fn drop(&mut self) {
4716        self.control_handle.shutdown();
4717        // Safety: drops once, never accessed again
4718        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4719    }
4720}
4721
4722impl fidl::endpoints::Responder for ObserverGetTopologiesResponder {
4723    type ControlHandle = ObserverControlHandle;
4724
4725    fn control_handle(&self) -> &ObserverControlHandle {
4726        &self.control_handle
4727    }
4728
4729    fn drop_without_shutdown(mut self) {
4730        // Safety: drops once, never accessed again due to mem::forget
4731        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4732        // Prevent Drop from running (which would shut down the channel)
4733        std::mem::forget(self);
4734    }
4735}
4736
4737impl ObserverGetTopologiesResponder {
4738    /// Sends a response to the FIDL transaction.
4739    ///
4740    /// Sets the channel to shutdown if an error occurs.
4741    pub fn send(
4742        self,
4743        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Topology], i32>,
4744    ) -> Result<(), fidl::Error> {
4745        let _result = self.send_raw(result);
4746        if _result.is_err() {
4747            self.control_handle.shutdown();
4748        }
4749        self.drop_without_shutdown();
4750        _result
4751    }
4752
4753    /// Similar to "send" but does not shutdown the channel if an error occurs.
4754    pub fn send_no_shutdown_on_err(
4755        self,
4756        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Topology], i32>,
4757    ) -> Result<(), fidl::Error> {
4758        let _result = self.send_raw(result);
4759        self.drop_without_shutdown();
4760        _result
4761    }
4762
4763    fn send_raw(
4764        &self,
4765        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Topology], i32>,
4766    ) -> Result<(), fidl::Error> {
4767        self.control_handle.inner.send::<fidl::encoding::ResultType<
4768            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResponse,
4769            i32,
4770        >>(
4771            result.map(|topologies| (topologies,)),
4772            self.tx_id,
4773            0x73ffb73af24d30b6,
4774            fidl::encoding::DynamicFlags::empty(),
4775        )
4776    }
4777}
4778
4779#[must_use = "FIDL methods require a response to be sent"]
4780#[derive(Debug)]
4781pub struct ObserverWatchTopologyResponder {
4782    control_handle: std::mem::ManuallyDrop<ObserverControlHandle>,
4783    tx_id: u32,
4784}
4785
4786/// Set the the channel to be shutdown (see [`ObserverControlHandle::shutdown`])
4787/// if the responder is dropped without sending a response, so that the client
4788/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4789impl std::ops::Drop for ObserverWatchTopologyResponder {
4790    fn drop(&mut self) {
4791        self.control_handle.shutdown();
4792        // Safety: drops once, never accessed again
4793        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4794    }
4795}
4796
4797impl fidl::endpoints::Responder for ObserverWatchTopologyResponder {
4798    type ControlHandle = ObserverControlHandle;
4799
4800    fn control_handle(&self) -> &ObserverControlHandle {
4801        &self.control_handle
4802    }
4803
4804    fn drop_without_shutdown(mut self) {
4805        // Safety: drops once, never accessed again due to mem::forget
4806        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4807        // Prevent Drop from running (which would shut down the channel)
4808        std::mem::forget(self);
4809    }
4810}
4811
4812impl ObserverWatchTopologyResponder {
4813    /// Sends a response to the FIDL transaction.
4814    ///
4815    /// Sets the channel to shutdown if an error occurs.
4816    pub fn send(self, mut topology_id: u64) -> Result<(), fidl::Error> {
4817        let _result = self.send_raw(topology_id);
4818        if _result.is_err() {
4819            self.control_handle.shutdown();
4820        }
4821        self.drop_without_shutdown();
4822        _result
4823    }
4824
4825    /// Similar to "send" but does not shutdown the channel if an error occurs.
4826    pub fn send_no_shutdown_on_err(self, mut topology_id: u64) -> Result<(), fidl::Error> {
4827        let _result = self.send_raw(topology_id);
4828        self.drop_without_shutdown();
4829        _result
4830    }
4831
4832    fn send_raw(&self, mut topology_id: u64) -> Result<(), fidl::Error> {
4833        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
4834            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchTopologyResponse,
4835        >>(
4836            fidl::encoding::Flexible::new((topology_id,)),
4837            self.tx_id,
4838            0x66d172acdb36a729,
4839            fidl::encoding::DynamicFlags::FLEXIBLE,
4840        )
4841    }
4842}
4843
4844#[must_use = "FIDL methods require a response to be sent"]
4845#[derive(Debug)]
4846pub struct ObserverWatchPlugStateResponder {
4847    control_handle: std::mem::ManuallyDrop<ObserverControlHandle>,
4848    tx_id: u32,
4849}
4850
4851/// Set the the channel to be shutdown (see [`ObserverControlHandle::shutdown`])
4852/// if the responder is dropped without sending a response, so that the client
4853/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4854impl std::ops::Drop for ObserverWatchPlugStateResponder {
4855    fn drop(&mut self) {
4856        self.control_handle.shutdown();
4857        // Safety: drops once, never accessed again
4858        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4859    }
4860}
4861
4862impl fidl::endpoints::Responder for ObserverWatchPlugStateResponder {
4863    type ControlHandle = ObserverControlHandle;
4864
4865    fn control_handle(&self) -> &ObserverControlHandle {
4866        &self.control_handle
4867    }
4868
4869    fn drop_without_shutdown(mut self) {
4870        // Safety: drops once, never accessed again due to mem::forget
4871        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4872        // Prevent Drop from running (which would shut down the channel)
4873        std::mem::forget(self);
4874    }
4875}
4876
4877impl ObserverWatchPlugStateResponder {
4878    /// Sends a response to the FIDL transaction.
4879    ///
4880    /// Sets the channel to shutdown if an error occurs.
4881    pub fn send(
4882        self,
4883        mut result: Result<&ObserverWatchPlugStateResponse, ObserverWatchPlugStateError>,
4884    ) -> Result<(), fidl::Error> {
4885        let _result = self.send_raw(result);
4886        if _result.is_err() {
4887            self.control_handle.shutdown();
4888        }
4889        self.drop_without_shutdown();
4890        _result
4891    }
4892
4893    /// Similar to "send" but does not shutdown the channel if an error occurs.
4894    pub fn send_no_shutdown_on_err(
4895        self,
4896        mut result: Result<&ObserverWatchPlugStateResponse, ObserverWatchPlugStateError>,
4897    ) -> Result<(), fidl::Error> {
4898        let _result = self.send_raw(result);
4899        self.drop_without_shutdown();
4900        _result
4901    }
4902
4903    fn send_raw(
4904        &self,
4905        mut result: Result<&ObserverWatchPlugStateResponse, ObserverWatchPlugStateError>,
4906    ) -> Result<(), fidl::Error> {
4907        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4908            ObserverWatchPlugStateResponse,
4909            ObserverWatchPlugStateError,
4910        >>(
4911            fidl::encoding::FlexibleResult::new(result),
4912            self.tx_id,
4913            0x6312bce495d2907a,
4914            fidl::encoding::DynamicFlags::FLEXIBLE,
4915        )
4916    }
4917}
4918
4919#[must_use = "FIDL methods require a response to be sent"]
4920#[derive(Debug)]
4921pub struct ObserverGetReferenceClockResponder {
4922    control_handle: std::mem::ManuallyDrop<ObserverControlHandle>,
4923    tx_id: u32,
4924}
4925
4926/// Set the the channel to be shutdown (see [`ObserverControlHandle::shutdown`])
4927/// if the responder is dropped without sending a response, so that the client
4928/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4929impl std::ops::Drop for ObserverGetReferenceClockResponder {
4930    fn drop(&mut self) {
4931        self.control_handle.shutdown();
4932        // Safety: drops once, never accessed again
4933        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4934    }
4935}
4936
4937impl fidl::endpoints::Responder for ObserverGetReferenceClockResponder {
4938    type ControlHandle = ObserverControlHandle;
4939
4940    fn control_handle(&self) -> &ObserverControlHandle {
4941        &self.control_handle
4942    }
4943
4944    fn drop_without_shutdown(mut self) {
4945        // Safety: drops once, never accessed again due to mem::forget
4946        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4947        // Prevent Drop from running (which would shut down the channel)
4948        std::mem::forget(self);
4949    }
4950}
4951
4952impl ObserverGetReferenceClockResponder {
4953    /// Sends a response to the FIDL transaction.
4954    ///
4955    /// Sets the channel to shutdown if an error occurs.
4956    pub fn send(
4957        self,
4958        mut result: Result<ObserverGetReferenceClockResponse, ObserverGetReferenceClockError>,
4959    ) -> Result<(), fidl::Error> {
4960        let _result = self.send_raw(result);
4961        if _result.is_err() {
4962            self.control_handle.shutdown();
4963        }
4964        self.drop_without_shutdown();
4965        _result
4966    }
4967
4968    /// Similar to "send" but does not shutdown the channel if an error occurs.
4969    pub fn send_no_shutdown_on_err(
4970        self,
4971        mut result: Result<ObserverGetReferenceClockResponse, ObserverGetReferenceClockError>,
4972    ) -> Result<(), fidl::Error> {
4973        let _result = self.send_raw(result);
4974        self.drop_without_shutdown();
4975        _result
4976    }
4977
4978    fn send_raw(
4979        &self,
4980        mut result: Result<ObserverGetReferenceClockResponse, ObserverGetReferenceClockError>,
4981    ) -> Result<(), fidl::Error> {
4982        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4983            ObserverGetReferenceClockResponse,
4984            ObserverGetReferenceClockError,
4985        >>(
4986            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
4987            self.tx_id,
4988            0x3819c5e0f9574c39,
4989            fidl::encoding::DynamicFlags::FLEXIBLE,
4990        )
4991    }
4992}
4993
4994#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4995pub struct PacketStreamMarker;
4996
4997impl fidl::endpoints::ProtocolMarker for PacketStreamMarker {
4998    type Proxy = PacketStreamProxy;
4999    type RequestStream = PacketStreamRequestStream;
5000    #[cfg(target_os = "fuchsia")]
5001    type SynchronousProxy = PacketStreamSynchronousProxy;
5002
5003    const DEBUG_NAME: &'static str = "(anonymous) PacketStream";
5004}
5005pub type PacketStreamSetBuffersResult =
5006    Result<PacketStreamSetBuffersResponse, PacketStreamSetBufferError>;
5007pub type PacketStreamStartResult = Result<PacketStreamStartResponse, PacketStreamStartError>;
5008pub type PacketStreamStopResult = Result<PacketStreamStopResponse, PacketStreamStopError>;
5009
5010pub trait PacketStreamProxyInterface: Send + Sync {
5011    type SetBuffersResponseFut: std::future::Future<Output = Result<PacketStreamSetBuffersResult, fidl::Error>>
5012        + Send;
5013    fn r#set_buffers(&self, payload: PacketStreamSetBuffersRequest) -> Self::SetBuffersResponseFut;
5014    type StartResponseFut: std::future::Future<Output = Result<PacketStreamStartResult, fidl::Error>>
5015        + Send;
5016    fn r#start(&self, payload: &PacketStreamStartRequest) -> Self::StartResponseFut;
5017    type StopResponseFut: std::future::Future<Output = Result<PacketStreamStopResult, fidl::Error>>
5018        + Send;
5019    fn r#stop(&self, payload: &PacketStreamStopRequest) -> Self::StopResponseFut;
5020}
5021#[derive(Debug)]
5022#[cfg(target_os = "fuchsia")]
5023pub struct PacketStreamSynchronousProxy {
5024    client: fidl::client::sync::Client,
5025}
5026
5027#[cfg(target_os = "fuchsia")]
5028impl fidl::endpoints::SynchronousProxy for PacketStreamSynchronousProxy {
5029    type Proxy = PacketStreamProxy;
5030    type Protocol = PacketStreamMarker;
5031
5032    fn from_channel(inner: fidl::Channel) -> Self {
5033        Self::new(inner)
5034    }
5035
5036    fn into_channel(self) -> fidl::Channel {
5037        self.client.into_channel()
5038    }
5039
5040    fn as_channel(&self) -> &fidl::Channel {
5041        self.client.as_channel()
5042    }
5043}
5044
5045#[cfg(target_os = "fuchsia")]
5046impl PacketStreamSynchronousProxy {
5047    pub fn new(channel: fidl::Channel) -> Self {
5048        Self { client: fidl::client::sync::Client::new(channel) }
5049    }
5050
5051    pub fn into_channel(self) -> fidl::Channel {
5052        self.client.into_channel()
5053    }
5054
5055    /// Waits until an event arrives and returns it. It is safe for other
5056    /// threads to make concurrent requests while waiting for an event.
5057    pub fn wait_for_event(
5058        &self,
5059        deadline: zx::MonotonicInstant,
5060    ) -> Result<PacketStreamEvent, fidl::Error> {
5061        PacketStreamEvent::decode(self.client.wait_for_event::<PacketStreamMarker>(deadline)?)
5062    }
5063
5064    /// Configures the shared memory buffers used to transfer audio data.
5065    ///
5066    /// This method must be called before `Start` unless INLINE buffer type is supported
5067    /// and the client intends to exclusively use inline data transfer.
5068    pub fn r#set_buffers(
5069        &self,
5070        mut payload: PacketStreamSetBuffersRequest,
5071        ___deadline: zx::MonotonicInstant,
5072    ) -> Result<PacketStreamSetBuffersResult, fidl::Error> {
5073        let _response = self
5074            .client
5075            .send_query::<PacketStreamSetBuffersRequest, fidl::encoding::FlexibleResultType<
5076                PacketStreamSetBuffersResponse,
5077                PacketStreamSetBufferError,
5078            >, PacketStreamMarker>(
5079                &mut payload,
5080                0x5ccdec88e71cf564,
5081                fidl::encoding::DynamicFlags::FLEXIBLE,
5082                ___deadline,
5083            )?
5084            .into_result::<PacketStreamMarker>("set_buffers")?;
5085        Ok(_response.map(|x| x))
5086    }
5087
5088    /// Start the packet stream.
5089    pub fn r#start(
5090        &self,
5091        mut payload: &PacketStreamStartRequest,
5092        ___deadline: zx::MonotonicInstant,
5093    ) -> Result<PacketStreamStartResult, fidl::Error> {
5094        let _response =
5095            self.client
5096                .send_query::<PacketStreamStartRequest, fidl::encoding::FlexibleResultType<
5097                    PacketStreamStartResponse,
5098                    PacketStreamStartError,
5099                >, PacketStreamMarker>(
5100                    payload,
5101                    0x70710dba352debdd,
5102                    fidl::encoding::DynamicFlags::FLEXIBLE,
5103                    ___deadline,
5104                )?
5105                .into_result::<PacketStreamMarker>("start")?;
5106        Ok(_response.map(|x| x))
5107    }
5108
5109    /// Stop the packet stream.
5110    pub fn r#stop(
5111        &self,
5112        mut payload: &PacketStreamStopRequest,
5113        ___deadline: zx::MonotonicInstant,
5114    ) -> Result<PacketStreamStopResult, fidl::Error> {
5115        let _response = self.client.send_query::<
5116            PacketStreamStopRequest,
5117            fidl::encoding::FlexibleResultType<PacketStreamStopResponse, PacketStreamStopError>,
5118            PacketStreamMarker,
5119        >(
5120            payload,
5121            0x11db078485b7d51e,
5122            fidl::encoding::DynamicFlags::FLEXIBLE,
5123            ___deadline,
5124        )?
5125        .into_result::<PacketStreamMarker>("stop")?;
5126        Ok(_response.map(|x| x))
5127    }
5128}
5129
5130#[cfg(target_os = "fuchsia")]
5131impl From<PacketStreamSynchronousProxy> for zx::NullableHandle {
5132    fn from(value: PacketStreamSynchronousProxy) -> Self {
5133        value.into_channel().into()
5134    }
5135}
5136
5137#[cfg(target_os = "fuchsia")]
5138impl From<fidl::Channel> for PacketStreamSynchronousProxy {
5139    fn from(value: fidl::Channel) -> Self {
5140        Self::new(value)
5141    }
5142}
5143
5144#[cfg(target_os = "fuchsia")]
5145impl fidl::endpoints::FromClient for PacketStreamSynchronousProxy {
5146    type Protocol = PacketStreamMarker;
5147
5148    fn from_client(value: fidl::endpoints::ClientEnd<PacketStreamMarker>) -> Self {
5149        Self::new(value.into_channel())
5150    }
5151}
5152
5153#[derive(Debug, Clone)]
5154pub struct PacketStreamProxy {
5155    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5156}
5157
5158impl fidl::endpoints::Proxy for PacketStreamProxy {
5159    type Protocol = PacketStreamMarker;
5160
5161    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5162        Self::new(inner)
5163    }
5164
5165    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5166        self.client.into_channel().map_err(|client| Self { client })
5167    }
5168
5169    fn as_channel(&self) -> &::fidl::AsyncChannel {
5170        self.client.as_channel()
5171    }
5172}
5173
5174impl PacketStreamProxy {
5175    /// Create a new Proxy for fuchsia.audio.device/PacketStream.
5176    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5177        let protocol_name = <PacketStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5178        Self { client: fidl::client::Client::new(channel, protocol_name) }
5179    }
5180
5181    /// Get a Stream of events from the remote end of the protocol.
5182    ///
5183    /// # Panics
5184    ///
5185    /// Panics if the event stream was already taken.
5186    pub fn take_event_stream(&self) -> PacketStreamEventStream {
5187        PacketStreamEventStream { event_receiver: self.client.take_event_receiver() }
5188    }
5189
5190    /// Configures the shared memory buffers used to transfer audio data.
5191    ///
5192    /// This method must be called before `Start` unless INLINE buffer type is supported
5193    /// and the client intends to exclusively use inline data transfer.
5194    pub fn r#set_buffers(
5195        &self,
5196        mut payload: PacketStreamSetBuffersRequest,
5197    ) -> fidl::client::QueryResponseFut<
5198        PacketStreamSetBuffersResult,
5199        fidl::encoding::DefaultFuchsiaResourceDialect,
5200    > {
5201        PacketStreamProxyInterface::r#set_buffers(self, payload)
5202    }
5203
5204    /// Start the packet stream.
5205    pub fn r#start(
5206        &self,
5207        mut payload: &PacketStreamStartRequest,
5208    ) -> fidl::client::QueryResponseFut<
5209        PacketStreamStartResult,
5210        fidl::encoding::DefaultFuchsiaResourceDialect,
5211    > {
5212        PacketStreamProxyInterface::r#start(self, payload)
5213    }
5214
5215    /// Stop the packet stream.
5216    pub fn r#stop(
5217        &self,
5218        mut payload: &PacketStreamStopRequest,
5219    ) -> fidl::client::QueryResponseFut<
5220        PacketStreamStopResult,
5221        fidl::encoding::DefaultFuchsiaResourceDialect,
5222    > {
5223        PacketStreamProxyInterface::r#stop(self, payload)
5224    }
5225}
5226
5227impl PacketStreamProxyInterface for PacketStreamProxy {
5228    type SetBuffersResponseFut = fidl::client::QueryResponseFut<
5229        PacketStreamSetBuffersResult,
5230        fidl::encoding::DefaultFuchsiaResourceDialect,
5231    >;
5232    fn r#set_buffers(
5233        &self,
5234        mut payload: PacketStreamSetBuffersRequest,
5235    ) -> Self::SetBuffersResponseFut {
5236        fn _decode(
5237            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5238        ) -> Result<PacketStreamSetBuffersResult, fidl::Error> {
5239            let _response = fidl::client::decode_transaction_body::<
5240                fidl::encoding::FlexibleResultType<
5241                    PacketStreamSetBuffersResponse,
5242                    PacketStreamSetBufferError,
5243                >,
5244                fidl::encoding::DefaultFuchsiaResourceDialect,
5245                0x5ccdec88e71cf564,
5246            >(_buf?)?
5247            .into_result::<PacketStreamMarker>("set_buffers")?;
5248            Ok(_response.map(|x| x))
5249        }
5250        self.client
5251            .send_query_and_decode::<PacketStreamSetBuffersRequest, PacketStreamSetBuffersResult>(
5252                &mut payload,
5253                0x5ccdec88e71cf564,
5254                fidl::encoding::DynamicFlags::FLEXIBLE,
5255                _decode,
5256            )
5257    }
5258
5259    type StartResponseFut = fidl::client::QueryResponseFut<
5260        PacketStreamStartResult,
5261        fidl::encoding::DefaultFuchsiaResourceDialect,
5262    >;
5263    fn r#start(&self, mut payload: &PacketStreamStartRequest) -> Self::StartResponseFut {
5264        fn _decode(
5265            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5266        ) -> Result<PacketStreamStartResult, fidl::Error> {
5267            let _response = fidl::client::decode_transaction_body::<
5268                fidl::encoding::FlexibleResultType<
5269                    PacketStreamStartResponse,
5270                    PacketStreamStartError,
5271                >,
5272                fidl::encoding::DefaultFuchsiaResourceDialect,
5273                0x70710dba352debdd,
5274            >(_buf?)?
5275            .into_result::<PacketStreamMarker>("start")?;
5276            Ok(_response.map(|x| x))
5277        }
5278        self.client.send_query_and_decode::<PacketStreamStartRequest, PacketStreamStartResult>(
5279            payload,
5280            0x70710dba352debdd,
5281            fidl::encoding::DynamicFlags::FLEXIBLE,
5282            _decode,
5283        )
5284    }
5285
5286    type StopResponseFut = fidl::client::QueryResponseFut<
5287        PacketStreamStopResult,
5288        fidl::encoding::DefaultFuchsiaResourceDialect,
5289    >;
5290    fn r#stop(&self, mut payload: &PacketStreamStopRequest) -> Self::StopResponseFut {
5291        fn _decode(
5292            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5293        ) -> Result<PacketStreamStopResult, fidl::Error> {
5294            let _response = fidl::client::decode_transaction_body::<
5295                fidl::encoding::FlexibleResultType<PacketStreamStopResponse, PacketStreamStopError>,
5296                fidl::encoding::DefaultFuchsiaResourceDialect,
5297                0x11db078485b7d51e,
5298            >(_buf?)?
5299            .into_result::<PacketStreamMarker>("stop")?;
5300            Ok(_response.map(|x| x))
5301        }
5302        self.client.send_query_and_decode::<PacketStreamStopRequest, PacketStreamStopResult>(
5303            payload,
5304            0x11db078485b7d51e,
5305            fidl::encoding::DynamicFlags::FLEXIBLE,
5306            _decode,
5307        )
5308    }
5309}
5310
5311pub struct PacketStreamEventStream {
5312    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5313}
5314
5315impl std::marker::Unpin for PacketStreamEventStream {}
5316
5317impl futures::stream::FusedStream for PacketStreamEventStream {
5318    fn is_terminated(&self) -> bool {
5319        self.event_receiver.is_terminated()
5320    }
5321}
5322
5323impl futures::Stream for PacketStreamEventStream {
5324    type Item = Result<PacketStreamEvent, fidl::Error>;
5325
5326    fn poll_next(
5327        mut self: std::pin::Pin<&mut Self>,
5328        cx: &mut std::task::Context<'_>,
5329    ) -> std::task::Poll<Option<Self::Item>> {
5330        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5331            &mut self.event_receiver,
5332            cx
5333        )?) {
5334            Some(buf) => std::task::Poll::Ready(Some(PacketStreamEvent::decode(buf))),
5335            None => std::task::Poll::Ready(None),
5336        }
5337    }
5338}
5339
5340#[derive(Debug)]
5341pub enum PacketStreamEvent {
5342    #[non_exhaustive]
5343    _UnknownEvent {
5344        /// Ordinal of the event that was sent.
5345        ordinal: u64,
5346    },
5347}
5348
5349impl PacketStreamEvent {
5350    /// Decodes a message buffer as a [`PacketStreamEvent`].
5351    fn decode(
5352        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5353    ) -> Result<PacketStreamEvent, fidl::Error> {
5354        let (bytes, _handles) = buf.split_mut();
5355        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5356        debug_assert_eq!(tx_header.tx_id, 0);
5357        match tx_header.ordinal {
5358            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5359                Ok(PacketStreamEvent::_UnknownEvent { ordinal: tx_header.ordinal })
5360            }
5361            _ => Err(fidl::Error::UnknownOrdinal {
5362                ordinal: tx_header.ordinal,
5363                protocol_name: <PacketStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5364            }),
5365        }
5366    }
5367}
5368
5369/// A Stream of incoming requests for fuchsia.audio.device/PacketStream.
5370pub struct PacketStreamRequestStream {
5371    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5372    is_terminated: bool,
5373}
5374
5375impl std::marker::Unpin for PacketStreamRequestStream {}
5376
5377impl futures::stream::FusedStream for PacketStreamRequestStream {
5378    fn is_terminated(&self) -> bool {
5379        self.is_terminated
5380    }
5381}
5382
5383impl fidl::endpoints::RequestStream for PacketStreamRequestStream {
5384    type Protocol = PacketStreamMarker;
5385    type ControlHandle = PacketStreamControlHandle;
5386
5387    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5388        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5389    }
5390
5391    fn control_handle(&self) -> Self::ControlHandle {
5392        PacketStreamControlHandle { inner: self.inner.clone() }
5393    }
5394
5395    fn into_inner(
5396        self,
5397    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5398    {
5399        (self.inner, self.is_terminated)
5400    }
5401
5402    fn from_inner(
5403        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5404        is_terminated: bool,
5405    ) -> Self {
5406        Self { inner, is_terminated }
5407    }
5408}
5409
5410impl futures::Stream for PacketStreamRequestStream {
5411    type Item = Result<PacketStreamRequest, fidl::Error>;
5412
5413    fn poll_next(
5414        mut self: std::pin::Pin<&mut Self>,
5415        cx: &mut std::task::Context<'_>,
5416    ) -> std::task::Poll<Option<Self::Item>> {
5417        let this = &mut *self;
5418        if this.inner.check_shutdown(cx) {
5419            this.is_terminated = true;
5420            return std::task::Poll::Ready(None);
5421        }
5422        if this.is_terminated {
5423            panic!("polled PacketStreamRequestStream after completion");
5424        }
5425        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5426            |bytes, handles| {
5427                match this.inner.channel().read_etc(cx, bytes, handles) {
5428                    std::task::Poll::Ready(Ok(())) => {}
5429                    std::task::Poll::Pending => return std::task::Poll::Pending,
5430                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5431                        this.is_terminated = true;
5432                        return std::task::Poll::Ready(None);
5433                    }
5434                    std::task::Poll::Ready(Err(e)) => {
5435                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5436                            e.into(),
5437                        ))));
5438                    }
5439                }
5440
5441                // A message has been received from the channel
5442                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5443
5444                std::task::Poll::Ready(Some(match header.ordinal {
5445                    0x5ccdec88e71cf564 => {
5446                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5447                        let mut req = fidl::new_empty!(
5448                            PacketStreamSetBuffersRequest,
5449                            fidl::encoding::DefaultFuchsiaResourceDialect
5450                        );
5451                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PacketStreamSetBuffersRequest>(&header, _body_bytes, handles, &mut req)?;
5452                        let control_handle =
5453                            PacketStreamControlHandle { inner: this.inner.clone() };
5454                        Ok(PacketStreamRequest::SetBuffers {
5455                            payload: req,
5456                            responder: PacketStreamSetBuffersResponder {
5457                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5458                                tx_id: header.tx_id,
5459                            },
5460                        })
5461                    }
5462                    0x70710dba352debdd => {
5463                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5464                        let mut req = fidl::new_empty!(
5465                            PacketStreamStartRequest,
5466                            fidl::encoding::DefaultFuchsiaResourceDialect
5467                        );
5468                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PacketStreamStartRequest>(&header, _body_bytes, handles, &mut req)?;
5469                        let control_handle =
5470                            PacketStreamControlHandle { inner: this.inner.clone() };
5471                        Ok(PacketStreamRequest::Start {
5472                            payload: req,
5473                            responder: PacketStreamStartResponder {
5474                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5475                                tx_id: header.tx_id,
5476                            },
5477                        })
5478                    }
5479                    0x11db078485b7d51e => {
5480                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5481                        let mut req = fidl::new_empty!(
5482                            PacketStreamStopRequest,
5483                            fidl::encoding::DefaultFuchsiaResourceDialect
5484                        );
5485                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PacketStreamStopRequest>(&header, _body_bytes, handles, &mut req)?;
5486                        let control_handle =
5487                            PacketStreamControlHandle { inner: this.inner.clone() };
5488                        Ok(PacketStreamRequest::Stop {
5489                            payload: req,
5490                            responder: PacketStreamStopResponder {
5491                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5492                                tx_id: header.tx_id,
5493                            },
5494                        })
5495                    }
5496                    _ if header.tx_id == 0
5497                        && header
5498                            .dynamic_flags()
5499                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5500                    {
5501                        Ok(PacketStreamRequest::_UnknownMethod {
5502                            ordinal: header.ordinal,
5503                            control_handle: PacketStreamControlHandle { inner: this.inner.clone() },
5504                            method_type: fidl::MethodType::OneWay,
5505                        })
5506                    }
5507                    _ if header
5508                        .dynamic_flags()
5509                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5510                    {
5511                        this.inner.send_framework_err(
5512                            fidl::encoding::FrameworkErr::UnknownMethod,
5513                            header.tx_id,
5514                            header.ordinal,
5515                            header.dynamic_flags(),
5516                            (bytes, handles),
5517                        )?;
5518                        Ok(PacketStreamRequest::_UnknownMethod {
5519                            ordinal: header.ordinal,
5520                            control_handle: PacketStreamControlHandle { inner: this.inner.clone() },
5521                            method_type: fidl::MethodType::TwoWay,
5522                        })
5523                    }
5524                    _ => Err(fidl::Error::UnknownOrdinal {
5525                        ordinal: header.ordinal,
5526                        protocol_name:
5527                            <PacketStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5528                    }),
5529                }))
5530            },
5531        )
5532    }
5533}
5534
5535/// A `PacketStream` instance controls data flow for the associated audio stream.
5536#[derive(Debug)]
5537pub enum PacketStreamRequest {
5538    /// Configures the shared memory buffers used to transfer audio data.
5539    ///
5540    /// This method must be called before `Start` unless INLINE buffer type is supported
5541    /// and the client intends to exclusively use inline data transfer.
5542    SetBuffers {
5543        payload: PacketStreamSetBuffersRequest,
5544        responder: PacketStreamSetBuffersResponder,
5545    },
5546    /// Start the packet stream.
5547    Start { payload: PacketStreamStartRequest, responder: PacketStreamStartResponder },
5548    /// Stop the packet stream.
5549    Stop { payload: PacketStreamStopRequest, responder: PacketStreamStopResponder },
5550    /// An interaction was received which does not match any known method.
5551    #[non_exhaustive]
5552    _UnknownMethod {
5553        /// Ordinal of the method that was called.
5554        ordinal: u64,
5555        control_handle: PacketStreamControlHandle,
5556        method_type: fidl::MethodType,
5557    },
5558}
5559
5560impl PacketStreamRequest {
5561    #[allow(irrefutable_let_patterns)]
5562    pub fn into_set_buffers(
5563        self,
5564    ) -> Option<(PacketStreamSetBuffersRequest, PacketStreamSetBuffersResponder)> {
5565        if let PacketStreamRequest::SetBuffers { payload, responder } = self {
5566            Some((payload, responder))
5567        } else {
5568            None
5569        }
5570    }
5571
5572    #[allow(irrefutable_let_patterns)]
5573    pub fn into_start(self) -> Option<(PacketStreamStartRequest, PacketStreamStartResponder)> {
5574        if let PacketStreamRequest::Start { payload, responder } = self {
5575            Some((payload, responder))
5576        } else {
5577            None
5578        }
5579    }
5580
5581    #[allow(irrefutable_let_patterns)]
5582    pub fn into_stop(self) -> Option<(PacketStreamStopRequest, PacketStreamStopResponder)> {
5583        if let PacketStreamRequest::Stop { payload, responder } = self {
5584            Some((payload, responder))
5585        } else {
5586            None
5587        }
5588    }
5589
5590    /// Name of the method defined in FIDL
5591    pub fn method_name(&self) -> &'static str {
5592        match *self {
5593            PacketStreamRequest::SetBuffers { .. } => "set_buffers",
5594            PacketStreamRequest::Start { .. } => "start",
5595            PacketStreamRequest::Stop { .. } => "stop",
5596            PacketStreamRequest::_UnknownMethod {
5597                method_type: fidl::MethodType::OneWay, ..
5598            } => "unknown one-way method",
5599            PacketStreamRequest::_UnknownMethod {
5600                method_type: fidl::MethodType::TwoWay, ..
5601            } => "unknown two-way method",
5602        }
5603    }
5604}
5605
5606#[derive(Debug, Clone)]
5607pub struct PacketStreamControlHandle {
5608    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5609}
5610
5611impl fidl::endpoints::ControlHandle for PacketStreamControlHandle {
5612    fn shutdown(&self) {
5613        self.inner.shutdown()
5614    }
5615
5616    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5617        self.inner.shutdown_with_epitaph(status)
5618    }
5619
5620    fn is_closed(&self) -> bool {
5621        self.inner.channel().is_closed()
5622    }
5623    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5624        self.inner.channel().on_closed()
5625    }
5626
5627    #[cfg(target_os = "fuchsia")]
5628    fn signal_peer(
5629        &self,
5630        clear_mask: zx::Signals,
5631        set_mask: zx::Signals,
5632    ) -> Result<(), zx_status::Status> {
5633        use fidl::Peered;
5634        self.inner.channel().signal_peer(clear_mask, set_mask)
5635    }
5636}
5637
5638impl PacketStreamControlHandle {}
5639
5640#[must_use = "FIDL methods require a response to be sent"]
5641#[derive(Debug)]
5642pub struct PacketStreamSetBuffersResponder {
5643    control_handle: std::mem::ManuallyDrop<PacketStreamControlHandle>,
5644    tx_id: u32,
5645}
5646
5647/// Set the the channel to be shutdown (see [`PacketStreamControlHandle::shutdown`])
5648/// if the responder is dropped without sending a response, so that the client
5649/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5650impl std::ops::Drop for PacketStreamSetBuffersResponder {
5651    fn drop(&mut self) {
5652        self.control_handle.shutdown();
5653        // Safety: drops once, never accessed again
5654        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5655    }
5656}
5657
5658impl fidl::endpoints::Responder for PacketStreamSetBuffersResponder {
5659    type ControlHandle = PacketStreamControlHandle;
5660
5661    fn control_handle(&self) -> &PacketStreamControlHandle {
5662        &self.control_handle
5663    }
5664
5665    fn drop_without_shutdown(mut self) {
5666        // Safety: drops once, never accessed again due to mem::forget
5667        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5668        // Prevent Drop from running (which would shut down the channel)
5669        std::mem::forget(self);
5670    }
5671}
5672
5673impl PacketStreamSetBuffersResponder {
5674    /// Sends a response to the FIDL transaction.
5675    ///
5676    /// Sets the channel to shutdown if an error occurs.
5677    pub fn send(
5678        self,
5679        mut result: Result<PacketStreamSetBuffersResponse, PacketStreamSetBufferError>,
5680    ) -> Result<(), fidl::Error> {
5681        let _result = self.send_raw(result);
5682        if _result.is_err() {
5683            self.control_handle.shutdown();
5684        }
5685        self.drop_without_shutdown();
5686        _result
5687    }
5688
5689    /// Similar to "send" but does not shutdown the channel if an error occurs.
5690    pub fn send_no_shutdown_on_err(
5691        self,
5692        mut result: Result<PacketStreamSetBuffersResponse, PacketStreamSetBufferError>,
5693    ) -> Result<(), fidl::Error> {
5694        let _result = self.send_raw(result);
5695        self.drop_without_shutdown();
5696        _result
5697    }
5698
5699    fn send_raw(
5700        &self,
5701        mut result: Result<PacketStreamSetBuffersResponse, PacketStreamSetBufferError>,
5702    ) -> Result<(), fidl::Error> {
5703        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5704            PacketStreamSetBuffersResponse,
5705            PacketStreamSetBufferError,
5706        >>(
5707            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
5708            self.tx_id,
5709            0x5ccdec88e71cf564,
5710            fidl::encoding::DynamicFlags::FLEXIBLE,
5711        )
5712    }
5713}
5714
5715#[must_use = "FIDL methods require a response to be sent"]
5716#[derive(Debug)]
5717pub struct PacketStreamStartResponder {
5718    control_handle: std::mem::ManuallyDrop<PacketStreamControlHandle>,
5719    tx_id: u32,
5720}
5721
5722/// Set the the channel to be shutdown (see [`PacketStreamControlHandle::shutdown`])
5723/// if the responder is dropped without sending a response, so that the client
5724/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5725impl std::ops::Drop for PacketStreamStartResponder {
5726    fn drop(&mut self) {
5727        self.control_handle.shutdown();
5728        // Safety: drops once, never accessed again
5729        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5730    }
5731}
5732
5733impl fidl::endpoints::Responder for PacketStreamStartResponder {
5734    type ControlHandle = PacketStreamControlHandle;
5735
5736    fn control_handle(&self) -> &PacketStreamControlHandle {
5737        &self.control_handle
5738    }
5739
5740    fn drop_without_shutdown(mut self) {
5741        // Safety: drops once, never accessed again due to mem::forget
5742        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5743        // Prevent Drop from running (which would shut down the channel)
5744        std::mem::forget(self);
5745    }
5746}
5747
5748impl PacketStreamStartResponder {
5749    /// Sends a response to the FIDL transaction.
5750    ///
5751    /// Sets the channel to shutdown if an error occurs.
5752    pub fn send(
5753        self,
5754        mut result: Result<&PacketStreamStartResponse, PacketStreamStartError>,
5755    ) -> Result<(), fidl::Error> {
5756        let _result = self.send_raw(result);
5757        if _result.is_err() {
5758            self.control_handle.shutdown();
5759        }
5760        self.drop_without_shutdown();
5761        _result
5762    }
5763
5764    /// Similar to "send" but does not shutdown the channel if an error occurs.
5765    pub fn send_no_shutdown_on_err(
5766        self,
5767        mut result: Result<&PacketStreamStartResponse, PacketStreamStartError>,
5768    ) -> Result<(), fidl::Error> {
5769        let _result = self.send_raw(result);
5770        self.drop_without_shutdown();
5771        _result
5772    }
5773
5774    fn send_raw(
5775        &self,
5776        mut result: Result<&PacketStreamStartResponse, PacketStreamStartError>,
5777    ) -> Result<(), fidl::Error> {
5778        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5779            PacketStreamStartResponse,
5780            PacketStreamStartError,
5781        >>(
5782            fidl::encoding::FlexibleResult::new(result),
5783            self.tx_id,
5784            0x70710dba352debdd,
5785            fidl::encoding::DynamicFlags::FLEXIBLE,
5786        )
5787    }
5788}
5789
5790#[must_use = "FIDL methods require a response to be sent"]
5791#[derive(Debug)]
5792pub struct PacketStreamStopResponder {
5793    control_handle: std::mem::ManuallyDrop<PacketStreamControlHandle>,
5794    tx_id: u32,
5795}
5796
5797/// Set the the channel to be shutdown (see [`PacketStreamControlHandle::shutdown`])
5798/// if the responder is dropped without sending a response, so that the client
5799/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5800impl std::ops::Drop for PacketStreamStopResponder {
5801    fn drop(&mut self) {
5802        self.control_handle.shutdown();
5803        // Safety: drops once, never accessed again
5804        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5805    }
5806}
5807
5808impl fidl::endpoints::Responder for PacketStreamStopResponder {
5809    type ControlHandle = PacketStreamControlHandle;
5810
5811    fn control_handle(&self) -> &PacketStreamControlHandle {
5812        &self.control_handle
5813    }
5814
5815    fn drop_without_shutdown(mut self) {
5816        // Safety: drops once, never accessed again due to mem::forget
5817        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5818        // Prevent Drop from running (which would shut down the channel)
5819        std::mem::forget(self);
5820    }
5821}
5822
5823impl PacketStreamStopResponder {
5824    /// Sends a response to the FIDL transaction.
5825    ///
5826    /// Sets the channel to shutdown if an error occurs.
5827    pub fn send(
5828        self,
5829        mut result: Result<&PacketStreamStopResponse, PacketStreamStopError>,
5830    ) -> Result<(), fidl::Error> {
5831        let _result = self.send_raw(result);
5832        if _result.is_err() {
5833            self.control_handle.shutdown();
5834        }
5835        self.drop_without_shutdown();
5836        _result
5837    }
5838
5839    /// Similar to "send" but does not shutdown the channel if an error occurs.
5840    pub fn send_no_shutdown_on_err(
5841        self,
5842        mut result: Result<&PacketStreamStopResponse, PacketStreamStopError>,
5843    ) -> Result<(), fidl::Error> {
5844        let _result = self.send_raw(result);
5845        self.drop_without_shutdown();
5846        _result
5847    }
5848
5849    fn send_raw(
5850        &self,
5851        mut result: Result<&PacketStreamStopResponse, PacketStreamStopError>,
5852    ) -> Result<(), fidl::Error> {
5853        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5854            PacketStreamStopResponse,
5855            PacketStreamStopError,
5856        >>(
5857            fidl::encoding::FlexibleResult::new(result),
5858            self.tx_id,
5859            0x11db078485b7d51e,
5860            fidl::encoding::DynamicFlags::FLEXIBLE,
5861        )
5862    }
5863}
5864
5865#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5866pub struct ProviderMarker;
5867
5868impl fidl::endpoints::ProtocolMarker for ProviderMarker {
5869    type Proxy = ProviderProxy;
5870    type RequestStream = ProviderRequestStream;
5871    #[cfg(target_os = "fuchsia")]
5872    type SynchronousProxy = ProviderSynchronousProxy;
5873
5874    const DEBUG_NAME: &'static str = "fuchsia.audio.device.Provider";
5875}
5876impl fidl::endpoints::DiscoverableProtocolMarker for ProviderMarker {}
5877pub type ProviderAddDeviceResult = Result<ProviderAddDeviceResponse, ProviderAddDeviceError>;
5878
5879pub trait ProviderProxyInterface: Send + Sync {
5880    type AddDeviceResponseFut: std::future::Future<Output = Result<ProviderAddDeviceResult, fidl::Error>>
5881        + Send;
5882    fn r#add_device(&self, payload: ProviderAddDeviceRequest) -> Self::AddDeviceResponseFut;
5883}
5884#[derive(Debug)]
5885#[cfg(target_os = "fuchsia")]
5886pub struct ProviderSynchronousProxy {
5887    client: fidl::client::sync::Client,
5888}
5889
5890#[cfg(target_os = "fuchsia")]
5891impl fidl::endpoints::SynchronousProxy for ProviderSynchronousProxy {
5892    type Proxy = ProviderProxy;
5893    type Protocol = ProviderMarker;
5894
5895    fn from_channel(inner: fidl::Channel) -> Self {
5896        Self::new(inner)
5897    }
5898
5899    fn into_channel(self) -> fidl::Channel {
5900        self.client.into_channel()
5901    }
5902
5903    fn as_channel(&self) -> &fidl::Channel {
5904        self.client.as_channel()
5905    }
5906}
5907
5908#[cfg(target_os = "fuchsia")]
5909impl ProviderSynchronousProxy {
5910    pub fn new(channel: fidl::Channel) -> Self {
5911        Self { client: fidl::client::sync::Client::new(channel) }
5912    }
5913
5914    pub fn into_channel(self) -> fidl::Channel {
5915        self.client.into_channel()
5916    }
5917
5918    /// Waits until an event arrives and returns it. It is safe for other
5919    /// threads to make concurrent requests while waiting for an event.
5920    pub fn wait_for_event(
5921        &self,
5922        deadline: zx::MonotonicInstant,
5923    ) -> Result<ProviderEvent, fidl::Error> {
5924        ProviderEvent::decode(self.client.wait_for_event::<ProviderMarker>(deadline)?)
5925    }
5926
5927    pub fn r#add_device(
5928        &self,
5929        mut payload: ProviderAddDeviceRequest,
5930        ___deadline: zx::MonotonicInstant,
5931    ) -> Result<ProviderAddDeviceResult, fidl::Error> {
5932        let _response =
5933            self.client
5934                .send_query::<ProviderAddDeviceRequest, fidl::encoding::FlexibleResultType<
5935                    ProviderAddDeviceResponse,
5936                    ProviderAddDeviceError,
5937                >, ProviderMarker>(
5938                    &mut payload,
5939                    0x685fdfd91937758b,
5940                    fidl::encoding::DynamicFlags::FLEXIBLE,
5941                    ___deadline,
5942                )?
5943                .into_result::<ProviderMarker>("add_device")?;
5944        Ok(_response.map(|x| x))
5945    }
5946}
5947
5948#[cfg(target_os = "fuchsia")]
5949impl From<ProviderSynchronousProxy> for zx::NullableHandle {
5950    fn from(value: ProviderSynchronousProxy) -> Self {
5951        value.into_channel().into()
5952    }
5953}
5954
5955#[cfg(target_os = "fuchsia")]
5956impl From<fidl::Channel> for ProviderSynchronousProxy {
5957    fn from(value: fidl::Channel) -> Self {
5958        Self::new(value)
5959    }
5960}
5961
5962#[cfg(target_os = "fuchsia")]
5963impl fidl::endpoints::FromClient for ProviderSynchronousProxy {
5964    type Protocol = ProviderMarker;
5965
5966    fn from_client(value: fidl::endpoints::ClientEnd<ProviderMarker>) -> Self {
5967        Self::new(value.into_channel())
5968    }
5969}
5970
5971#[derive(Debug, Clone)]
5972pub struct ProviderProxy {
5973    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5974}
5975
5976impl fidl::endpoints::Proxy for ProviderProxy {
5977    type Protocol = ProviderMarker;
5978
5979    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5980        Self::new(inner)
5981    }
5982
5983    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5984        self.client.into_channel().map_err(|client| Self { client })
5985    }
5986
5987    fn as_channel(&self) -> &::fidl::AsyncChannel {
5988        self.client.as_channel()
5989    }
5990}
5991
5992impl ProviderProxy {
5993    /// Create a new Proxy for fuchsia.audio.device/Provider.
5994    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5995        let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5996        Self { client: fidl::client::Client::new(channel, protocol_name) }
5997    }
5998
5999    /// Get a Stream of events from the remote end of the protocol.
6000    ///
6001    /// # Panics
6002    ///
6003    /// Panics if the event stream was already taken.
6004    pub fn take_event_stream(&self) -> ProviderEventStream {
6005        ProviderEventStream { event_receiver: self.client.take_event_receiver() }
6006    }
6007
6008    pub fn r#add_device(
6009        &self,
6010        mut payload: ProviderAddDeviceRequest,
6011    ) -> fidl::client::QueryResponseFut<
6012        ProviderAddDeviceResult,
6013        fidl::encoding::DefaultFuchsiaResourceDialect,
6014    > {
6015        ProviderProxyInterface::r#add_device(self, payload)
6016    }
6017}
6018
6019impl ProviderProxyInterface for ProviderProxy {
6020    type AddDeviceResponseFut = fidl::client::QueryResponseFut<
6021        ProviderAddDeviceResult,
6022        fidl::encoding::DefaultFuchsiaResourceDialect,
6023    >;
6024    fn r#add_device(&self, mut payload: ProviderAddDeviceRequest) -> Self::AddDeviceResponseFut {
6025        fn _decode(
6026            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6027        ) -> Result<ProviderAddDeviceResult, fidl::Error> {
6028            let _response = fidl::client::decode_transaction_body::<
6029                fidl::encoding::FlexibleResultType<
6030                    ProviderAddDeviceResponse,
6031                    ProviderAddDeviceError,
6032                >,
6033                fidl::encoding::DefaultFuchsiaResourceDialect,
6034                0x685fdfd91937758b,
6035            >(_buf?)?
6036            .into_result::<ProviderMarker>("add_device")?;
6037            Ok(_response.map(|x| x))
6038        }
6039        self.client.send_query_and_decode::<ProviderAddDeviceRequest, ProviderAddDeviceResult>(
6040            &mut payload,
6041            0x685fdfd91937758b,
6042            fidl::encoding::DynamicFlags::FLEXIBLE,
6043            _decode,
6044        )
6045    }
6046}
6047
6048pub struct ProviderEventStream {
6049    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6050}
6051
6052impl std::marker::Unpin for ProviderEventStream {}
6053
6054impl futures::stream::FusedStream for ProviderEventStream {
6055    fn is_terminated(&self) -> bool {
6056        self.event_receiver.is_terminated()
6057    }
6058}
6059
6060impl futures::Stream for ProviderEventStream {
6061    type Item = Result<ProviderEvent, fidl::Error>;
6062
6063    fn poll_next(
6064        mut self: std::pin::Pin<&mut Self>,
6065        cx: &mut std::task::Context<'_>,
6066    ) -> std::task::Poll<Option<Self::Item>> {
6067        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6068            &mut self.event_receiver,
6069            cx
6070        )?) {
6071            Some(buf) => std::task::Poll::Ready(Some(ProviderEvent::decode(buf))),
6072            None => std::task::Poll::Ready(None),
6073        }
6074    }
6075}
6076
6077#[derive(Debug)]
6078pub enum ProviderEvent {
6079    #[non_exhaustive]
6080    _UnknownEvent {
6081        /// Ordinal of the event that was sent.
6082        ordinal: u64,
6083    },
6084}
6085
6086impl ProviderEvent {
6087    /// Decodes a message buffer as a [`ProviderEvent`].
6088    fn decode(
6089        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6090    ) -> Result<ProviderEvent, fidl::Error> {
6091        let (bytes, _handles) = buf.split_mut();
6092        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6093        debug_assert_eq!(tx_header.tx_id, 0);
6094        match tx_header.ordinal {
6095            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
6096                Ok(ProviderEvent::_UnknownEvent { ordinal: tx_header.ordinal })
6097            }
6098            _ => Err(fidl::Error::UnknownOrdinal {
6099                ordinal: tx_header.ordinal,
6100                protocol_name: <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6101            }),
6102        }
6103    }
6104}
6105
6106/// A Stream of incoming requests for fuchsia.audio.device/Provider.
6107pub struct ProviderRequestStream {
6108    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6109    is_terminated: bool,
6110}
6111
6112impl std::marker::Unpin for ProviderRequestStream {}
6113
6114impl futures::stream::FusedStream for ProviderRequestStream {
6115    fn is_terminated(&self) -> bool {
6116        self.is_terminated
6117    }
6118}
6119
6120impl fidl::endpoints::RequestStream for ProviderRequestStream {
6121    type Protocol = ProviderMarker;
6122    type ControlHandle = ProviderControlHandle;
6123
6124    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6125        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6126    }
6127
6128    fn control_handle(&self) -> Self::ControlHandle {
6129        ProviderControlHandle { inner: self.inner.clone() }
6130    }
6131
6132    fn into_inner(
6133        self,
6134    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6135    {
6136        (self.inner, self.is_terminated)
6137    }
6138
6139    fn from_inner(
6140        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6141        is_terminated: bool,
6142    ) -> Self {
6143        Self { inner, is_terminated }
6144    }
6145}
6146
6147impl futures::Stream for ProviderRequestStream {
6148    type Item = Result<ProviderRequest, fidl::Error>;
6149
6150    fn poll_next(
6151        mut self: std::pin::Pin<&mut Self>,
6152        cx: &mut std::task::Context<'_>,
6153    ) -> std::task::Poll<Option<Self::Item>> {
6154        let this = &mut *self;
6155        if this.inner.check_shutdown(cx) {
6156            this.is_terminated = true;
6157            return std::task::Poll::Ready(None);
6158        }
6159        if this.is_terminated {
6160            panic!("polled ProviderRequestStream after completion");
6161        }
6162        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6163            |bytes, handles| {
6164                match this.inner.channel().read_etc(cx, bytes, handles) {
6165                    std::task::Poll::Ready(Ok(())) => {}
6166                    std::task::Poll::Pending => return std::task::Poll::Pending,
6167                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6168                        this.is_terminated = true;
6169                        return std::task::Poll::Ready(None);
6170                    }
6171                    std::task::Poll::Ready(Err(e)) => {
6172                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6173                            e.into(),
6174                        ))));
6175                    }
6176                }
6177
6178                // A message has been received from the channel
6179                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6180
6181                std::task::Poll::Ready(Some(match header.ordinal {
6182                    0x685fdfd91937758b => {
6183                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6184                        let mut req = fidl::new_empty!(
6185                            ProviderAddDeviceRequest,
6186                            fidl::encoding::DefaultFuchsiaResourceDialect
6187                        );
6188                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderAddDeviceRequest>(&header, _body_bytes, handles, &mut req)?;
6189                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
6190                        Ok(ProviderRequest::AddDevice {
6191                            payload: req,
6192                            responder: ProviderAddDeviceResponder {
6193                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6194                                tx_id: header.tx_id,
6195                            },
6196                        })
6197                    }
6198                    _ if header.tx_id == 0
6199                        && header
6200                            .dynamic_flags()
6201                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6202                    {
6203                        Ok(ProviderRequest::_UnknownMethod {
6204                            ordinal: header.ordinal,
6205                            control_handle: ProviderControlHandle { inner: this.inner.clone() },
6206                            method_type: fidl::MethodType::OneWay,
6207                        })
6208                    }
6209                    _ if header
6210                        .dynamic_flags()
6211                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6212                    {
6213                        this.inner.send_framework_err(
6214                            fidl::encoding::FrameworkErr::UnknownMethod,
6215                            header.tx_id,
6216                            header.ordinal,
6217                            header.dynamic_flags(),
6218                            (bytes, handles),
6219                        )?;
6220                        Ok(ProviderRequest::_UnknownMethod {
6221                            ordinal: header.ordinal,
6222                            control_handle: ProviderControlHandle { inner: this.inner.clone() },
6223                            method_type: fidl::MethodType::TwoWay,
6224                        })
6225                    }
6226                    _ => Err(fidl::Error::UnknownOrdinal {
6227                        ordinal: header.ordinal,
6228                        protocol_name:
6229                            <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6230                    }),
6231                }))
6232            },
6233        )
6234    }
6235}
6236
6237/// Use the `Provider` interface to manually add devices that do not use the devfs
6238/// mechanism. (Devices that use devfs are automatically added, upon detection.)
6239#[derive(Debug)]
6240pub enum ProviderRequest {
6241    AddDevice {
6242        payload: ProviderAddDeviceRequest,
6243        responder: ProviderAddDeviceResponder,
6244    },
6245    /// An interaction was received which does not match any known method.
6246    #[non_exhaustive]
6247    _UnknownMethod {
6248        /// Ordinal of the method that was called.
6249        ordinal: u64,
6250        control_handle: ProviderControlHandle,
6251        method_type: fidl::MethodType,
6252    },
6253}
6254
6255impl ProviderRequest {
6256    #[allow(irrefutable_let_patterns)]
6257    pub fn into_add_device(self) -> Option<(ProviderAddDeviceRequest, ProviderAddDeviceResponder)> {
6258        if let ProviderRequest::AddDevice { payload, responder } = self {
6259            Some((payload, responder))
6260        } else {
6261            None
6262        }
6263    }
6264
6265    /// Name of the method defined in FIDL
6266    pub fn method_name(&self) -> &'static str {
6267        match *self {
6268            ProviderRequest::AddDevice { .. } => "add_device",
6269            ProviderRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
6270                "unknown one-way method"
6271            }
6272            ProviderRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
6273                "unknown two-way method"
6274            }
6275        }
6276    }
6277}
6278
6279#[derive(Debug, Clone)]
6280pub struct ProviderControlHandle {
6281    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6282}
6283
6284impl fidl::endpoints::ControlHandle for ProviderControlHandle {
6285    fn shutdown(&self) {
6286        self.inner.shutdown()
6287    }
6288
6289    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6290        self.inner.shutdown_with_epitaph(status)
6291    }
6292
6293    fn is_closed(&self) -> bool {
6294        self.inner.channel().is_closed()
6295    }
6296    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6297        self.inner.channel().on_closed()
6298    }
6299
6300    #[cfg(target_os = "fuchsia")]
6301    fn signal_peer(
6302        &self,
6303        clear_mask: zx::Signals,
6304        set_mask: zx::Signals,
6305    ) -> Result<(), zx_status::Status> {
6306        use fidl::Peered;
6307        self.inner.channel().signal_peer(clear_mask, set_mask)
6308    }
6309}
6310
6311impl ProviderControlHandle {}
6312
6313#[must_use = "FIDL methods require a response to be sent"]
6314#[derive(Debug)]
6315pub struct ProviderAddDeviceResponder {
6316    control_handle: std::mem::ManuallyDrop<ProviderControlHandle>,
6317    tx_id: u32,
6318}
6319
6320/// Set the the channel to be shutdown (see [`ProviderControlHandle::shutdown`])
6321/// if the responder is dropped without sending a response, so that the client
6322/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6323impl std::ops::Drop for ProviderAddDeviceResponder {
6324    fn drop(&mut self) {
6325        self.control_handle.shutdown();
6326        // Safety: drops once, never accessed again
6327        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6328    }
6329}
6330
6331impl fidl::endpoints::Responder for ProviderAddDeviceResponder {
6332    type ControlHandle = ProviderControlHandle;
6333
6334    fn control_handle(&self) -> &ProviderControlHandle {
6335        &self.control_handle
6336    }
6337
6338    fn drop_without_shutdown(mut self) {
6339        // Safety: drops once, never accessed again due to mem::forget
6340        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6341        // Prevent Drop from running (which would shut down the channel)
6342        std::mem::forget(self);
6343    }
6344}
6345
6346impl ProviderAddDeviceResponder {
6347    /// Sends a response to the FIDL transaction.
6348    ///
6349    /// Sets the channel to shutdown if an error occurs.
6350    pub fn send(
6351        self,
6352        mut result: Result<&ProviderAddDeviceResponse, ProviderAddDeviceError>,
6353    ) -> Result<(), fidl::Error> {
6354        let _result = self.send_raw(result);
6355        if _result.is_err() {
6356            self.control_handle.shutdown();
6357        }
6358        self.drop_without_shutdown();
6359        _result
6360    }
6361
6362    /// Similar to "send" but does not shutdown the channel if an error occurs.
6363    pub fn send_no_shutdown_on_err(
6364        self,
6365        mut result: Result<&ProviderAddDeviceResponse, ProviderAddDeviceError>,
6366    ) -> Result<(), fidl::Error> {
6367        let _result = self.send_raw(result);
6368        self.drop_without_shutdown();
6369        _result
6370    }
6371
6372    fn send_raw(
6373        &self,
6374        mut result: Result<&ProviderAddDeviceResponse, ProviderAddDeviceError>,
6375    ) -> Result<(), fidl::Error> {
6376        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6377            ProviderAddDeviceResponse,
6378            ProviderAddDeviceError,
6379        >>(
6380            fidl::encoding::FlexibleResult::new(result),
6381            self.tx_id,
6382            0x685fdfd91937758b,
6383            fidl::encoding::DynamicFlags::FLEXIBLE,
6384        )
6385    }
6386}
6387
6388#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6389pub struct RegistryMarker;
6390
6391impl fidl::endpoints::ProtocolMarker for RegistryMarker {
6392    type Proxy = RegistryProxy;
6393    type RequestStream = RegistryRequestStream;
6394    #[cfg(target_os = "fuchsia")]
6395    type SynchronousProxy = RegistrySynchronousProxy;
6396
6397    const DEBUG_NAME: &'static str = "fuchsia.audio.device.Registry";
6398}
6399impl fidl::endpoints::DiscoverableProtocolMarker for RegistryMarker {}
6400pub type RegistryWatchDevicesAddedResult =
6401    Result<RegistryWatchDevicesAddedResponse, RegistryWatchDevicesAddedError>;
6402pub type RegistryWatchDeviceRemovedResult =
6403    Result<RegistryWatchDeviceRemovedResponse, RegistryWatchDeviceRemovedError>;
6404pub type RegistryCreateObserverResult =
6405    Result<RegistryCreateObserverResponse, RegistryCreateObserverError>;
6406
6407pub trait RegistryProxyInterface: Send + Sync {
6408    type WatchDevicesAddedResponseFut: std::future::Future<Output = Result<RegistryWatchDevicesAddedResult, fidl::Error>>
6409        + Send;
6410    fn r#watch_devices_added(&self) -> Self::WatchDevicesAddedResponseFut;
6411    type WatchDeviceRemovedResponseFut: std::future::Future<Output = Result<RegistryWatchDeviceRemovedResult, fidl::Error>>
6412        + Send;
6413    fn r#watch_device_removed(&self) -> Self::WatchDeviceRemovedResponseFut;
6414    type CreateObserverResponseFut: std::future::Future<Output = Result<RegistryCreateObserverResult, fidl::Error>>
6415        + Send;
6416    fn r#create_observer(
6417        &self,
6418        payload: RegistryCreateObserverRequest,
6419    ) -> Self::CreateObserverResponseFut;
6420}
6421#[derive(Debug)]
6422#[cfg(target_os = "fuchsia")]
6423pub struct RegistrySynchronousProxy {
6424    client: fidl::client::sync::Client,
6425}
6426
6427#[cfg(target_os = "fuchsia")]
6428impl fidl::endpoints::SynchronousProxy for RegistrySynchronousProxy {
6429    type Proxy = RegistryProxy;
6430    type Protocol = RegistryMarker;
6431
6432    fn from_channel(inner: fidl::Channel) -> Self {
6433        Self::new(inner)
6434    }
6435
6436    fn into_channel(self) -> fidl::Channel {
6437        self.client.into_channel()
6438    }
6439
6440    fn as_channel(&self) -> &fidl::Channel {
6441        self.client.as_channel()
6442    }
6443}
6444
6445#[cfg(target_os = "fuchsia")]
6446impl RegistrySynchronousProxy {
6447    pub fn new(channel: fidl::Channel) -> Self {
6448        Self { client: fidl::client::sync::Client::new(channel) }
6449    }
6450
6451    pub fn into_channel(self) -> fidl::Channel {
6452        self.client.into_channel()
6453    }
6454
6455    /// Waits until an event arrives and returns it. It is safe for other
6456    /// threads to make concurrent requests while waiting for an event.
6457    pub fn wait_for_event(
6458        &self,
6459        deadline: zx::MonotonicInstant,
6460    ) -> Result<RegistryEvent, fidl::Error> {
6461        RegistryEvent::decode(self.client.wait_for_event::<RegistryMarker>(deadline)?)
6462    }
6463
6464    /// Register for notification when one or more devices are added.
6465    /// The `devices` vector will always contain at least one `Info` entry.
6466    pub fn r#watch_devices_added(
6467        &self,
6468        ___deadline: zx::MonotonicInstant,
6469    ) -> Result<RegistryWatchDevicesAddedResult, fidl::Error> {
6470        let _response = self
6471            .client
6472            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
6473                RegistryWatchDevicesAddedResponse,
6474                RegistryWatchDevicesAddedError,
6475            >, RegistryMarker>(
6476                (),
6477                0x562ca31f7c149def,
6478                fidl::encoding::DynamicFlags::FLEXIBLE,
6479                ___deadline,
6480            )?
6481            .into_result::<RegistryMarker>("watch_devices_added")?;
6482        Ok(_response.map(|x| x))
6483    }
6484
6485    /// Register for notification when an (active, added) device is removed.
6486    /// Because the method only notifies of one removal, upon completion it
6487    /// should immediately be re-called, in case other removals have occurred.
6488    /// Calls to this method will pend until the removal of a device that was
6489    /// included in a previous `WatchDevicesAdded` response.
6490    pub fn r#watch_device_removed(
6491        &self,
6492        ___deadline: zx::MonotonicInstant,
6493    ) -> Result<RegistryWatchDeviceRemovedResult, fidl::Error> {
6494        let _response = self
6495            .client
6496            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
6497                RegistryWatchDeviceRemovedResponse,
6498                RegistryWatchDeviceRemovedError,
6499            >, RegistryMarker>(
6500                (),
6501                0x6e67aabc99a502af,
6502                fidl::encoding::DynamicFlags::FLEXIBLE,
6503                ___deadline,
6504            )?
6505            .into_result::<RegistryMarker>("watch_device_removed")?;
6506        Ok(_response.map(|x| x))
6507    }
6508
6509    /// Request an `Observer` for the specified device.
6510    pub fn r#create_observer(
6511        &self,
6512        mut payload: RegistryCreateObserverRequest,
6513        ___deadline: zx::MonotonicInstant,
6514    ) -> Result<RegistryCreateObserverResult, fidl::Error> {
6515        let _response = self
6516            .client
6517            .send_query::<RegistryCreateObserverRequest, fidl::encoding::FlexibleResultType<
6518                RegistryCreateObserverResponse,
6519                RegistryCreateObserverError,
6520            >, RegistryMarker>(
6521                &mut payload,
6522                0x577bc322eb8d2bd1,
6523                fidl::encoding::DynamicFlags::FLEXIBLE,
6524                ___deadline,
6525            )?
6526            .into_result::<RegistryMarker>("create_observer")?;
6527        Ok(_response.map(|x| x))
6528    }
6529}
6530
6531#[cfg(target_os = "fuchsia")]
6532impl From<RegistrySynchronousProxy> for zx::NullableHandle {
6533    fn from(value: RegistrySynchronousProxy) -> Self {
6534        value.into_channel().into()
6535    }
6536}
6537
6538#[cfg(target_os = "fuchsia")]
6539impl From<fidl::Channel> for RegistrySynchronousProxy {
6540    fn from(value: fidl::Channel) -> Self {
6541        Self::new(value)
6542    }
6543}
6544
6545#[cfg(target_os = "fuchsia")]
6546impl fidl::endpoints::FromClient for RegistrySynchronousProxy {
6547    type Protocol = RegistryMarker;
6548
6549    fn from_client(value: fidl::endpoints::ClientEnd<RegistryMarker>) -> Self {
6550        Self::new(value.into_channel())
6551    }
6552}
6553
6554#[derive(Debug, Clone)]
6555pub struct RegistryProxy {
6556    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6557}
6558
6559impl fidl::endpoints::Proxy for RegistryProxy {
6560    type Protocol = RegistryMarker;
6561
6562    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6563        Self::new(inner)
6564    }
6565
6566    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6567        self.client.into_channel().map_err(|client| Self { client })
6568    }
6569
6570    fn as_channel(&self) -> &::fidl::AsyncChannel {
6571        self.client.as_channel()
6572    }
6573}
6574
6575impl RegistryProxy {
6576    /// Create a new Proxy for fuchsia.audio.device/Registry.
6577    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6578        let protocol_name = <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6579        Self { client: fidl::client::Client::new(channel, protocol_name) }
6580    }
6581
6582    /// Get a Stream of events from the remote end of the protocol.
6583    ///
6584    /// # Panics
6585    ///
6586    /// Panics if the event stream was already taken.
6587    pub fn take_event_stream(&self) -> RegistryEventStream {
6588        RegistryEventStream { event_receiver: self.client.take_event_receiver() }
6589    }
6590
6591    /// Register for notification when one or more devices are added.
6592    /// The `devices` vector will always contain at least one `Info` entry.
6593    pub fn r#watch_devices_added(
6594        &self,
6595    ) -> fidl::client::QueryResponseFut<
6596        RegistryWatchDevicesAddedResult,
6597        fidl::encoding::DefaultFuchsiaResourceDialect,
6598    > {
6599        RegistryProxyInterface::r#watch_devices_added(self)
6600    }
6601
6602    /// Register for notification when an (active, added) device is removed.
6603    /// Because the method only notifies of one removal, upon completion it
6604    /// should immediately be re-called, in case other removals have occurred.
6605    /// Calls to this method will pend until the removal of a device that was
6606    /// included in a previous `WatchDevicesAdded` response.
6607    pub fn r#watch_device_removed(
6608        &self,
6609    ) -> fidl::client::QueryResponseFut<
6610        RegistryWatchDeviceRemovedResult,
6611        fidl::encoding::DefaultFuchsiaResourceDialect,
6612    > {
6613        RegistryProxyInterface::r#watch_device_removed(self)
6614    }
6615
6616    /// Request an `Observer` for the specified device.
6617    pub fn r#create_observer(
6618        &self,
6619        mut payload: RegistryCreateObserverRequest,
6620    ) -> fidl::client::QueryResponseFut<
6621        RegistryCreateObserverResult,
6622        fidl::encoding::DefaultFuchsiaResourceDialect,
6623    > {
6624        RegistryProxyInterface::r#create_observer(self, payload)
6625    }
6626}
6627
6628impl RegistryProxyInterface for RegistryProxy {
6629    type WatchDevicesAddedResponseFut = fidl::client::QueryResponseFut<
6630        RegistryWatchDevicesAddedResult,
6631        fidl::encoding::DefaultFuchsiaResourceDialect,
6632    >;
6633    fn r#watch_devices_added(&self) -> Self::WatchDevicesAddedResponseFut {
6634        fn _decode(
6635            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6636        ) -> Result<RegistryWatchDevicesAddedResult, fidl::Error> {
6637            let _response = fidl::client::decode_transaction_body::<
6638                fidl::encoding::FlexibleResultType<
6639                    RegistryWatchDevicesAddedResponse,
6640                    RegistryWatchDevicesAddedError,
6641                >,
6642                fidl::encoding::DefaultFuchsiaResourceDialect,
6643                0x562ca31f7c149def,
6644            >(_buf?)?
6645            .into_result::<RegistryMarker>("watch_devices_added")?;
6646            Ok(_response.map(|x| x))
6647        }
6648        self.client
6649            .send_query_and_decode::<fidl::encoding::EmptyPayload, RegistryWatchDevicesAddedResult>(
6650                (),
6651                0x562ca31f7c149def,
6652                fidl::encoding::DynamicFlags::FLEXIBLE,
6653                _decode,
6654            )
6655    }
6656
6657    type WatchDeviceRemovedResponseFut = fidl::client::QueryResponseFut<
6658        RegistryWatchDeviceRemovedResult,
6659        fidl::encoding::DefaultFuchsiaResourceDialect,
6660    >;
6661    fn r#watch_device_removed(&self) -> Self::WatchDeviceRemovedResponseFut {
6662        fn _decode(
6663            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6664        ) -> Result<RegistryWatchDeviceRemovedResult, fidl::Error> {
6665            let _response = fidl::client::decode_transaction_body::<
6666                fidl::encoding::FlexibleResultType<
6667                    RegistryWatchDeviceRemovedResponse,
6668                    RegistryWatchDeviceRemovedError,
6669                >,
6670                fidl::encoding::DefaultFuchsiaResourceDialect,
6671                0x6e67aabc99a502af,
6672            >(_buf?)?
6673            .into_result::<RegistryMarker>("watch_device_removed")?;
6674            Ok(_response.map(|x| x))
6675        }
6676        self.client.send_query_and_decode::<
6677            fidl::encoding::EmptyPayload,
6678            RegistryWatchDeviceRemovedResult,
6679        >(
6680            (),
6681            0x6e67aabc99a502af,
6682            fidl::encoding::DynamicFlags::FLEXIBLE,
6683            _decode,
6684        )
6685    }
6686
6687    type CreateObserverResponseFut = fidl::client::QueryResponseFut<
6688        RegistryCreateObserverResult,
6689        fidl::encoding::DefaultFuchsiaResourceDialect,
6690    >;
6691    fn r#create_observer(
6692        &self,
6693        mut payload: RegistryCreateObserverRequest,
6694    ) -> Self::CreateObserverResponseFut {
6695        fn _decode(
6696            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6697        ) -> Result<RegistryCreateObserverResult, fidl::Error> {
6698            let _response = fidl::client::decode_transaction_body::<
6699                fidl::encoding::FlexibleResultType<
6700                    RegistryCreateObserverResponse,
6701                    RegistryCreateObserverError,
6702                >,
6703                fidl::encoding::DefaultFuchsiaResourceDialect,
6704                0x577bc322eb8d2bd1,
6705            >(_buf?)?
6706            .into_result::<RegistryMarker>("create_observer")?;
6707            Ok(_response.map(|x| x))
6708        }
6709        self.client
6710            .send_query_and_decode::<RegistryCreateObserverRequest, RegistryCreateObserverResult>(
6711                &mut payload,
6712                0x577bc322eb8d2bd1,
6713                fidl::encoding::DynamicFlags::FLEXIBLE,
6714                _decode,
6715            )
6716    }
6717}
6718
6719pub struct RegistryEventStream {
6720    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6721}
6722
6723impl std::marker::Unpin for RegistryEventStream {}
6724
6725impl futures::stream::FusedStream for RegistryEventStream {
6726    fn is_terminated(&self) -> bool {
6727        self.event_receiver.is_terminated()
6728    }
6729}
6730
6731impl futures::Stream for RegistryEventStream {
6732    type Item = Result<RegistryEvent, fidl::Error>;
6733
6734    fn poll_next(
6735        mut self: std::pin::Pin<&mut Self>,
6736        cx: &mut std::task::Context<'_>,
6737    ) -> std::task::Poll<Option<Self::Item>> {
6738        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6739            &mut self.event_receiver,
6740            cx
6741        )?) {
6742            Some(buf) => std::task::Poll::Ready(Some(RegistryEvent::decode(buf))),
6743            None => std::task::Poll::Ready(None),
6744        }
6745    }
6746}
6747
6748#[derive(Debug)]
6749pub enum RegistryEvent {
6750    #[non_exhaustive]
6751    _UnknownEvent {
6752        /// Ordinal of the event that was sent.
6753        ordinal: u64,
6754    },
6755}
6756
6757impl RegistryEvent {
6758    /// Decodes a message buffer as a [`RegistryEvent`].
6759    fn decode(
6760        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6761    ) -> Result<RegistryEvent, fidl::Error> {
6762        let (bytes, _handles) = buf.split_mut();
6763        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6764        debug_assert_eq!(tx_header.tx_id, 0);
6765        match tx_header.ordinal {
6766            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
6767                Ok(RegistryEvent::_UnknownEvent { ordinal: tx_header.ordinal })
6768            }
6769            _ => Err(fidl::Error::UnknownOrdinal {
6770                ordinal: tx_header.ordinal,
6771                protocol_name: <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6772            }),
6773        }
6774    }
6775}
6776
6777/// A Stream of incoming requests for fuchsia.audio.device/Registry.
6778pub struct RegistryRequestStream {
6779    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6780    is_terminated: bool,
6781}
6782
6783impl std::marker::Unpin for RegistryRequestStream {}
6784
6785impl futures::stream::FusedStream for RegistryRequestStream {
6786    fn is_terminated(&self) -> bool {
6787        self.is_terminated
6788    }
6789}
6790
6791impl fidl::endpoints::RequestStream for RegistryRequestStream {
6792    type Protocol = RegistryMarker;
6793    type ControlHandle = RegistryControlHandle;
6794
6795    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6796        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6797    }
6798
6799    fn control_handle(&self) -> Self::ControlHandle {
6800        RegistryControlHandle { inner: self.inner.clone() }
6801    }
6802
6803    fn into_inner(
6804        self,
6805    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6806    {
6807        (self.inner, self.is_terminated)
6808    }
6809
6810    fn from_inner(
6811        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6812        is_terminated: bool,
6813    ) -> Self {
6814        Self { inner, is_terminated }
6815    }
6816}
6817
6818impl futures::Stream for RegistryRequestStream {
6819    type Item = Result<RegistryRequest, fidl::Error>;
6820
6821    fn poll_next(
6822        mut self: std::pin::Pin<&mut Self>,
6823        cx: &mut std::task::Context<'_>,
6824    ) -> std::task::Poll<Option<Self::Item>> {
6825        let this = &mut *self;
6826        if this.inner.check_shutdown(cx) {
6827            this.is_terminated = true;
6828            return std::task::Poll::Ready(None);
6829        }
6830        if this.is_terminated {
6831            panic!("polled RegistryRequestStream after completion");
6832        }
6833        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6834            |bytes, handles| {
6835                match this.inner.channel().read_etc(cx, bytes, handles) {
6836                    std::task::Poll::Ready(Ok(())) => {}
6837                    std::task::Poll::Pending => return std::task::Poll::Pending,
6838                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6839                        this.is_terminated = true;
6840                        return std::task::Poll::Ready(None);
6841                    }
6842                    std::task::Poll::Ready(Err(e)) => {
6843                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6844                            e.into(),
6845                        ))));
6846                    }
6847                }
6848
6849                // A message has been received from the channel
6850                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6851
6852                std::task::Poll::Ready(Some(match header.ordinal {
6853                    0x562ca31f7c149def => {
6854                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6855                        let mut req = fidl::new_empty!(
6856                            fidl::encoding::EmptyPayload,
6857                            fidl::encoding::DefaultFuchsiaResourceDialect
6858                        );
6859                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6860                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
6861                        Ok(RegistryRequest::WatchDevicesAdded {
6862                            responder: RegistryWatchDevicesAddedResponder {
6863                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6864                                tx_id: header.tx_id,
6865                            },
6866                        })
6867                    }
6868                    0x6e67aabc99a502af => {
6869                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6870                        let mut req = fidl::new_empty!(
6871                            fidl::encoding::EmptyPayload,
6872                            fidl::encoding::DefaultFuchsiaResourceDialect
6873                        );
6874                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6875                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
6876                        Ok(RegistryRequest::WatchDeviceRemoved {
6877                            responder: RegistryWatchDeviceRemovedResponder {
6878                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6879                                tx_id: header.tx_id,
6880                            },
6881                        })
6882                    }
6883                    0x577bc322eb8d2bd1 => {
6884                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6885                        let mut req = fidl::new_empty!(
6886                            RegistryCreateObserverRequest,
6887                            fidl::encoding::DefaultFuchsiaResourceDialect
6888                        );
6889                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RegistryCreateObserverRequest>(&header, _body_bytes, handles, &mut req)?;
6890                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
6891                        Ok(RegistryRequest::CreateObserver {
6892                            payload: req,
6893                            responder: RegistryCreateObserverResponder {
6894                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6895                                tx_id: header.tx_id,
6896                            },
6897                        })
6898                    }
6899                    _ if header.tx_id == 0
6900                        && header
6901                            .dynamic_flags()
6902                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6903                    {
6904                        Ok(RegistryRequest::_UnknownMethod {
6905                            ordinal: header.ordinal,
6906                            control_handle: RegistryControlHandle { inner: this.inner.clone() },
6907                            method_type: fidl::MethodType::OneWay,
6908                        })
6909                    }
6910                    _ if header
6911                        .dynamic_flags()
6912                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6913                    {
6914                        this.inner.send_framework_err(
6915                            fidl::encoding::FrameworkErr::UnknownMethod,
6916                            header.tx_id,
6917                            header.ordinal,
6918                            header.dynamic_flags(),
6919                            (bytes, handles),
6920                        )?;
6921                        Ok(RegistryRequest::_UnknownMethod {
6922                            ordinal: header.ordinal,
6923                            control_handle: RegistryControlHandle { inner: this.inner.clone() },
6924                            method_type: fidl::MethodType::TwoWay,
6925                        })
6926                    }
6927                    _ => Err(fidl::Error::UnknownOrdinal {
6928                        ordinal: header.ordinal,
6929                        protocol_name:
6930                            <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6931                    }),
6932                }))
6933            },
6934        )
6935    }
6936}
6937
6938/// `Registry` instances notify clients as devices arrive and depart, and they
6939/// create observers (see `Observer`) that notify of more detailed state changes.
6940#[derive(Debug)]
6941pub enum RegistryRequest {
6942    /// Register for notification when one or more devices are added.
6943    /// The `devices` vector will always contain at least one `Info` entry.
6944    WatchDevicesAdded { responder: RegistryWatchDevicesAddedResponder },
6945    /// Register for notification when an (active, added) device is removed.
6946    /// Because the method only notifies of one removal, upon completion it
6947    /// should immediately be re-called, in case other removals have occurred.
6948    /// Calls to this method will pend until the removal of a device that was
6949    /// included in a previous `WatchDevicesAdded` response.
6950    WatchDeviceRemoved { responder: RegistryWatchDeviceRemovedResponder },
6951    /// Request an `Observer` for the specified device.
6952    CreateObserver {
6953        payload: RegistryCreateObserverRequest,
6954        responder: RegistryCreateObserverResponder,
6955    },
6956    /// An interaction was received which does not match any known method.
6957    #[non_exhaustive]
6958    _UnknownMethod {
6959        /// Ordinal of the method that was called.
6960        ordinal: u64,
6961        control_handle: RegistryControlHandle,
6962        method_type: fidl::MethodType,
6963    },
6964}
6965
6966impl RegistryRequest {
6967    #[allow(irrefutable_let_patterns)]
6968    pub fn into_watch_devices_added(self) -> Option<(RegistryWatchDevicesAddedResponder)> {
6969        if let RegistryRequest::WatchDevicesAdded { responder } = self {
6970            Some((responder))
6971        } else {
6972            None
6973        }
6974    }
6975
6976    #[allow(irrefutable_let_patterns)]
6977    pub fn into_watch_device_removed(self) -> Option<(RegistryWatchDeviceRemovedResponder)> {
6978        if let RegistryRequest::WatchDeviceRemoved { responder } = self {
6979            Some((responder))
6980        } else {
6981            None
6982        }
6983    }
6984
6985    #[allow(irrefutable_let_patterns)]
6986    pub fn into_create_observer(
6987        self,
6988    ) -> Option<(RegistryCreateObserverRequest, RegistryCreateObserverResponder)> {
6989        if let RegistryRequest::CreateObserver { payload, responder } = self {
6990            Some((payload, responder))
6991        } else {
6992            None
6993        }
6994    }
6995
6996    /// Name of the method defined in FIDL
6997    pub fn method_name(&self) -> &'static str {
6998        match *self {
6999            RegistryRequest::WatchDevicesAdded { .. } => "watch_devices_added",
7000            RegistryRequest::WatchDeviceRemoved { .. } => "watch_device_removed",
7001            RegistryRequest::CreateObserver { .. } => "create_observer",
7002            RegistryRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
7003                "unknown one-way method"
7004            }
7005            RegistryRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
7006                "unknown two-way method"
7007            }
7008        }
7009    }
7010}
7011
7012#[derive(Debug, Clone)]
7013pub struct RegistryControlHandle {
7014    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7015}
7016
7017impl fidl::endpoints::ControlHandle for RegistryControlHandle {
7018    fn shutdown(&self) {
7019        self.inner.shutdown()
7020    }
7021
7022    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7023        self.inner.shutdown_with_epitaph(status)
7024    }
7025
7026    fn is_closed(&self) -> bool {
7027        self.inner.channel().is_closed()
7028    }
7029    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7030        self.inner.channel().on_closed()
7031    }
7032
7033    #[cfg(target_os = "fuchsia")]
7034    fn signal_peer(
7035        &self,
7036        clear_mask: zx::Signals,
7037        set_mask: zx::Signals,
7038    ) -> Result<(), zx_status::Status> {
7039        use fidl::Peered;
7040        self.inner.channel().signal_peer(clear_mask, set_mask)
7041    }
7042}
7043
7044impl RegistryControlHandle {}
7045
7046#[must_use = "FIDL methods require a response to be sent"]
7047#[derive(Debug)]
7048pub struct RegistryWatchDevicesAddedResponder {
7049    control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
7050    tx_id: u32,
7051}
7052
7053/// Set the the channel to be shutdown (see [`RegistryControlHandle::shutdown`])
7054/// if the responder is dropped without sending a response, so that the client
7055/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7056impl std::ops::Drop for RegistryWatchDevicesAddedResponder {
7057    fn drop(&mut self) {
7058        self.control_handle.shutdown();
7059        // Safety: drops once, never accessed again
7060        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7061    }
7062}
7063
7064impl fidl::endpoints::Responder for RegistryWatchDevicesAddedResponder {
7065    type ControlHandle = RegistryControlHandle;
7066
7067    fn control_handle(&self) -> &RegistryControlHandle {
7068        &self.control_handle
7069    }
7070
7071    fn drop_without_shutdown(mut self) {
7072        // Safety: drops once, never accessed again due to mem::forget
7073        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7074        // Prevent Drop from running (which would shut down the channel)
7075        std::mem::forget(self);
7076    }
7077}
7078
7079impl RegistryWatchDevicesAddedResponder {
7080    /// Sends a response to the FIDL transaction.
7081    ///
7082    /// Sets the channel to shutdown if an error occurs.
7083    pub fn send(
7084        self,
7085        mut result: Result<&RegistryWatchDevicesAddedResponse, RegistryWatchDevicesAddedError>,
7086    ) -> Result<(), fidl::Error> {
7087        let _result = self.send_raw(result);
7088        if _result.is_err() {
7089            self.control_handle.shutdown();
7090        }
7091        self.drop_without_shutdown();
7092        _result
7093    }
7094
7095    /// Similar to "send" but does not shutdown the channel if an error occurs.
7096    pub fn send_no_shutdown_on_err(
7097        self,
7098        mut result: Result<&RegistryWatchDevicesAddedResponse, RegistryWatchDevicesAddedError>,
7099    ) -> Result<(), fidl::Error> {
7100        let _result = self.send_raw(result);
7101        self.drop_without_shutdown();
7102        _result
7103    }
7104
7105    fn send_raw(
7106        &self,
7107        mut result: Result<&RegistryWatchDevicesAddedResponse, RegistryWatchDevicesAddedError>,
7108    ) -> Result<(), fidl::Error> {
7109        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7110            RegistryWatchDevicesAddedResponse,
7111            RegistryWatchDevicesAddedError,
7112        >>(
7113            fidl::encoding::FlexibleResult::new(result),
7114            self.tx_id,
7115            0x562ca31f7c149def,
7116            fidl::encoding::DynamicFlags::FLEXIBLE,
7117        )
7118    }
7119}
7120
7121#[must_use = "FIDL methods require a response to be sent"]
7122#[derive(Debug)]
7123pub struct RegistryWatchDeviceRemovedResponder {
7124    control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
7125    tx_id: u32,
7126}
7127
7128/// Set the the channel to be shutdown (see [`RegistryControlHandle::shutdown`])
7129/// if the responder is dropped without sending a response, so that the client
7130/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7131impl std::ops::Drop for RegistryWatchDeviceRemovedResponder {
7132    fn drop(&mut self) {
7133        self.control_handle.shutdown();
7134        // Safety: drops once, never accessed again
7135        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7136    }
7137}
7138
7139impl fidl::endpoints::Responder for RegistryWatchDeviceRemovedResponder {
7140    type ControlHandle = RegistryControlHandle;
7141
7142    fn control_handle(&self) -> &RegistryControlHandle {
7143        &self.control_handle
7144    }
7145
7146    fn drop_without_shutdown(mut self) {
7147        // Safety: drops once, never accessed again due to mem::forget
7148        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7149        // Prevent Drop from running (which would shut down the channel)
7150        std::mem::forget(self);
7151    }
7152}
7153
7154impl RegistryWatchDeviceRemovedResponder {
7155    /// Sends a response to the FIDL transaction.
7156    ///
7157    /// Sets the channel to shutdown if an error occurs.
7158    pub fn send(
7159        self,
7160        mut result: Result<&RegistryWatchDeviceRemovedResponse, RegistryWatchDeviceRemovedError>,
7161    ) -> Result<(), fidl::Error> {
7162        let _result = self.send_raw(result);
7163        if _result.is_err() {
7164            self.control_handle.shutdown();
7165        }
7166        self.drop_without_shutdown();
7167        _result
7168    }
7169
7170    /// Similar to "send" but does not shutdown the channel if an error occurs.
7171    pub fn send_no_shutdown_on_err(
7172        self,
7173        mut result: Result<&RegistryWatchDeviceRemovedResponse, RegistryWatchDeviceRemovedError>,
7174    ) -> Result<(), fidl::Error> {
7175        let _result = self.send_raw(result);
7176        self.drop_without_shutdown();
7177        _result
7178    }
7179
7180    fn send_raw(
7181        &self,
7182        mut result: Result<&RegistryWatchDeviceRemovedResponse, RegistryWatchDeviceRemovedError>,
7183    ) -> Result<(), fidl::Error> {
7184        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7185            RegistryWatchDeviceRemovedResponse,
7186            RegistryWatchDeviceRemovedError,
7187        >>(
7188            fidl::encoding::FlexibleResult::new(result),
7189            self.tx_id,
7190            0x6e67aabc99a502af,
7191            fidl::encoding::DynamicFlags::FLEXIBLE,
7192        )
7193    }
7194}
7195
7196#[must_use = "FIDL methods require a response to be sent"]
7197#[derive(Debug)]
7198pub struct RegistryCreateObserverResponder {
7199    control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
7200    tx_id: u32,
7201}
7202
7203/// Set the the channel to be shutdown (see [`RegistryControlHandle::shutdown`])
7204/// if the responder is dropped without sending a response, so that the client
7205/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7206impl std::ops::Drop for RegistryCreateObserverResponder {
7207    fn drop(&mut self) {
7208        self.control_handle.shutdown();
7209        // Safety: drops once, never accessed again
7210        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7211    }
7212}
7213
7214impl fidl::endpoints::Responder for RegistryCreateObserverResponder {
7215    type ControlHandle = RegistryControlHandle;
7216
7217    fn control_handle(&self) -> &RegistryControlHandle {
7218        &self.control_handle
7219    }
7220
7221    fn drop_without_shutdown(mut self) {
7222        // Safety: drops once, never accessed again due to mem::forget
7223        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7224        // Prevent Drop from running (which would shut down the channel)
7225        std::mem::forget(self);
7226    }
7227}
7228
7229impl RegistryCreateObserverResponder {
7230    /// Sends a response to the FIDL transaction.
7231    ///
7232    /// Sets the channel to shutdown if an error occurs.
7233    pub fn send(
7234        self,
7235        mut result: Result<&RegistryCreateObserverResponse, RegistryCreateObserverError>,
7236    ) -> Result<(), fidl::Error> {
7237        let _result = self.send_raw(result);
7238        if _result.is_err() {
7239            self.control_handle.shutdown();
7240        }
7241        self.drop_without_shutdown();
7242        _result
7243    }
7244
7245    /// Similar to "send" but does not shutdown the channel if an error occurs.
7246    pub fn send_no_shutdown_on_err(
7247        self,
7248        mut result: Result<&RegistryCreateObserverResponse, RegistryCreateObserverError>,
7249    ) -> Result<(), fidl::Error> {
7250        let _result = self.send_raw(result);
7251        self.drop_without_shutdown();
7252        _result
7253    }
7254
7255    fn send_raw(
7256        &self,
7257        mut result: Result<&RegistryCreateObserverResponse, RegistryCreateObserverError>,
7258    ) -> Result<(), fidl::Error> {
7259        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7260            RegistryCreateObserverResponse,
7261            RegistryCreateObserverError,
7262        >>(
7263            fidl::encoding::FlexibleResult::new(result),
7264            self.tx_id,
7265            0x577bc322eb8d2bd1,
7266            fidl::encoding::DynamicFlags::FLEXIBLE,
7267        )
7268    }
7269}
7270
7271#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7272pub struct RingBufferMarker;
7273
7274impl fidl::endpoints::ProtocolMarker for RingBufferMarker {
7275    type Proxy = RingBufferProxy;
7276    type RequestStream = RingBufferRequestStream;
7277    #[cfg(target_os = "fuchsia")]
7278    type SynchronousProxy = RingBufferSynchronousProxy;
7279
7280    const DEBUG_NAME: &'static str = "(anonymous) RingBuffer";
7281}
7282pub type RingBufferSetActiveChannelsResult =
7283    Result<RingBufferSetActiveChannelsResponse, RingBufferSetActiveChannelsError>;
7284pub type RingBufferStartResult = Result<RingBufferStartResponse, RingBufferStartError>;
7285pub type RingBufferStopResult = Result<RingBufferStopResponse, RingBufferStopError>;
7286pub type RingBufferWatchDelayInfoResult =
7287    Result<RingBufferWatchDelayInfoResponse, RingBufferWatchDelayInfoError>;
7288
7289pub trait RingBufferProxyInterface: Send + Sync {
7290    type SetActiveChannelsResponseFut: std::future::Future<Output = Result<RingBufferSetActiveChannelsResult, fidl::Error>>
7291        + Send;
7292    fn r#set_active_channels(
7293        &self,
7294        payload: &RingBufferSetActiveChannelsRequest,
7295    ) -> Self::SetActiveChannelsResponseFut;
7296    type StartResponseFut: std::future::Future<Output = Result<RingBufferStartResult, fidl::Error>>
7297        + Send;
7298    fn r#start(&self, payload: &RingBufferStartRequest) -> Self::StartResponseFut;
7299    type StopResponseFut: std::future::Future<Output = Result<RingBufferStopResult, fidl::Error>>
7300        + Send;
7301    fn r#stop(&self, payload: &RingBufferStopRequest) -> Self::StopResponseFut;
7302    type WatchDelayInfoResponseFut: std::future::Future<Output = Result<RingBufferWatchDelayInfoResult, fidl::Error>>
7303        + Send;
7304    fn r#watch_delay_info(&self) -> Self::WatchDelayInfoResponseFut;
7305}
7306#[derive(Debug)]
7307#[cfg(target_os = "fuchsia")]
7308pub struct RingBufferSynchronousProxy {
7309    client: fidl::client::sync::Client,
7310}
7311
7312#[cfg(target_os = "fuchsia")]
7313impl fidl::endpoints::SynchronousProxy for RingBufferSynchronousProxy {
7314    type Proxy = RingBufferProxy;
7315    type Protocol = RingBufferMarker;
7316
7317    fn from_channel(inner: fidl::Channel) -> Self {
7318        Self::new(inner)
7319    }
7320
7321    fn into_channel(self) -> fidl::Channel {
7322        self.client.into_channel()
7323    }
7324
7325    fn as_channel(&self) -> &fidl::Channel {
7326        self.client.as_channel()
7327    }
7328}
7329
7330#[cfg(target_os = "fuchsia")]
7331impl RingBufferSynchronousProxy {
7332    pub fn new(channel: fidl::Channel) -> Self {
7333        Self { client: fidl::client::sync::Client::new(channel) }
7334    }
7335
7336    pub fn into_channel(self) -> fidl::Channel {
7337        self.client.into_channel()
7338    }
7339
7340    /// Waits until an event arrives and returns it. It is safe for other
7341    /// threads to make concurrent requests while waiting for an event.
7342    pub fn wait_for_event(
7343        &self,
7344        deadline: zx::MonotonicInstant,
7345    ) -> Result<RingBufferEvent, fidl::Error> {
7346        RingBufferEvent::decode(self.client.wait_for_event::<RingBufferMarker>(deadline)?)
7347    }
7348
7349    /// Request that specific individual channels be powered down/up, if the
7350    /// device supports this. This is intended for idle power conservation.
7351    ///
7352    /// Channels are specified by bitmask; the least significant bit corresponds
7353    /// to channel 0. Each bit not set indicates that the channel can be
7354    /// deactivated. `SetActiveChannels` does not change how a ring buffer
7355    /// responds to `Start`/`Stop`, specifically with regards to position.
7356    ///
7357    /// Devices are not required to obey `SetActiveChannels`. For example, they
7358    /// are not required to zero-out an input stream's inactive channels, and
7359    /// data written to inactive channels of an output stream's ring buffer may
7360    /// still be played.
7361    ///
7362    /// If not called, then by default all channels will be active.
7363    pub fn r#set_active_channels(
7364        &self,
7365        mut payload: &RingBufferSetActiveChannelsRequest,
7366        ___deadline: zx::MonotonicInstant,
7367    ) -> Result<RingBufferSetActiveChannelsResult, fidl::Error> {
7368        let _response = self
7369            .client
7370            .send_query::<RingBufferSetActiveChannelsRequest, fidl::encoding::FlexibleResultType<
7371                RingBufferSetActiveChannelsResponse,
7372                RingBufferSetActiveChannelsError,
7373            >, RingBufferMarker>(
7374                payload,
7375                0x4276c43e4a3b59ee,
7376                fidl::encoding::DynamicFlags::FLEXIBLE,
7377                ___deadline,
7378            )?
7379            .into_result::<RingBufferMarker>("set_active_channels")?;
7380        Ok(_response.map(|x| x))
7381    }
7382
7383    /// Start the ring buffer, beginning at the first frame of the ring buffer.
7384    pub fn r#start(
7385        &self,
7386        mut payload: &RingBufferStartRequest,
7387        ___deadline: zx::MonotonicInstant,
7388    ) -> Result<RingBufferStartResult, fidl::Error> {
7389        let _response = self.client.send_query::<
7390            RingBufferStartRequest,
7391            fidl::encoding::FlexibleResultType<RingBufferStartResponse, RingBufferStartError>,
7392            RingBufferMarker,
7393        >(
7394            payload,
7395            0x5365a8609dc2dc5,
7396            fidl::encoding::DynamicFlags::FLEXIBLE,
7397            ___deadline,
7398        )?
7399        .into_result::<RingBufferMarker>("start")?;
7400        Ok(_response.map(|x| x))
7401    }
7402
7403    /// Stop the ring buffer.
7404    pub fn r#stop(
7405        &self,
7406        mut payload: &RingBufferStopRequest,
7407        ___deadline: zx::MonotonicInstant,
7408    ) -> Result<RingBufferStopResult, fidl::Error> {
7409        let _response = self.client.send_query::<
7410            RingBufferStopRequest,
7411            fidl::encoding::FlexibleResultType<RingBufferStopResponse, RingBufferStopError>,
7412            RingBufferMarker,
7413        >(
7414            payload,
7415            0x5a238810af11e6e1,
7416            fidl::encoding::DynamicFlags::FLEXIBLE,
7417            ___deadline,
7418        )?
7419        .into_result::<RingBufferMarker>("stop")?;
7420        Ok(_response.map(|x| x))
7421    }
7422
7423    /// Request delay information via a hanging get. The RingBuffer will respond
7424    /// immediately to the first `WatchDelayInfo` call. Subsequent calls will
7425    /// only be completed when the delay info has changed from previously
7426    /// communicated values.
7427    pub fn r#watch_delay_info(
7428        &self,
7429        ___deadline: zx::MonotonicInstant,
7430    ) -> Result<RingBufferWatchDelayInfoResult, fidl::Error> {
7431        let _response = self
7432            .client
7433            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
7434                RingBufferWatchDelayInfoResponse,
7435                RingBufferWatchDelayInfoError,
7436            >, RingBufferMarker>(
7437                (),
7438                0x6d1dc5a928f38ad6,
7439                fidl::encoding::DynamicFlags::FLEXIBLE,
7440                ___deadline,
7441            )?
7442            .into_result::<RingBufferMarker>("watch_delay_info")?;
7443        Ok(_response.map(|x| x))
7444    }
7445}
7446
7447#[cfg(target_os = "fuchsia")]
7448impl From<RingBufferSynchronousProxy> for zx::NullableHandle {
7449    fn from(value: RingBufferSynchronousProxy) -> Self {
7450        value.into_channel().into()
7451    }
7452}
7453
7454#[cfg(target_os = "fuchsia")]
7455impl From<fidl::Channel> for RingBufferSynchronousProxy {
7456    fn from(value: fidl::Channel) -> Self {
7457        Self::new(value)
7458    }
7459}
7460
7461#[cfg(target_os = "fuchsia")]
7462impl fidl::endpoints::FromClient for RingBufferSynchronousProxy {
7463    type Protocol = RingBufferMarker;
7464
7465    fn from_client(value: fidl::endpoints::ClientEnd<RingBufferMarker>) -> Self {
7466        Self::new(value.into_channel())
7467    }
7468}
7469
7470#[derive(Debug, Clone)]
7471pub struct RingBufferProxy {
7472    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7473}
7474
7475impl fidl::endpoints::Proxy for RingBufferProxy {
7476    type Protocol = RingBufferMarker;
7477
7478    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7479        Self::new(inner)
7480    }
7481
7482    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7483        self.client.into_channel().map_err(|client| Self { client })
7484    }
7485
7486    fn as_channel(&self) -> &::fidl::AsyncChannel {
7487        self.client.as_channel()
7488    }
7489}
7490
7491impl RingBufferProxy {
7492    /// Create a new Proxy for fuchsia.audio.device/RingBuffer.
7493    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7494        let protocol_name = <RingBufferMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7495        Self { client: fidl::client::Client::new(channel, protocol_name) }
7496    }
7497
7498    /// Get a Stream of events from the remote end of the protocol.
7499    ///
7500    /// # Panics
7501    ///
7502    /// Panics if the event stream was already taken.
7503    pub fn take_event_stream(&self) -> RingBufferEventStream {
7504        RingBufferEventStream { event_receiver: self.client.take_event_receiver() }
7505    }
7506
7507    /// Request that specific individual channels be powered down/up, if the
7508    /// device supports this. This is intended for idle power conservation.
7509    ///
7510    /// Channels are specified by bitmask; the least significant bit corresponds
7511    /// to channel 0. Each bit not set indicates that the channel can be
7512    /// deactivated. `SetActiveChannels` does not change how a ring buffer
7513    /// responds to `Start`/`Stop`, specifically with regards to position.
7514    ///
7515    /// Devices are not required to obey `SetActiveChannels`. For example, they
7516    /// are not required to zero-out an input stream's inactive channels, and
7517    /// data written to inactive channels of an output stream's ring buffer may
7518    /// still be played.
7519    ///
7520    /// If not called, then by default all channels will be active.
7521    pub fn r#set_active_channels(
7522        &self,
7523        mut payload: &RingBufferSetActiveChannelsRequest,
7524    ) -> fidl::client::QueryResponseFut<
7525        RingBufferSetActiveChannelsResult,
7526        fidl::encoding::DefaultFuchsiaResourceDialect,
7527    > {
7528        RingBufferProxyInterface::r#set_active_channels(self, payload)
7529    }
7530
7531    /// Start the ring buffer, beginning at the first frame of the ring buffer.
7532    pub fn r#start(
7533        &self,
7534        mut payload: &RingBufferStartRequest,
7535    ) -> fidl::client::QueryResponseFut<
7536        RingBufferStartResult,
7537        fidl::encoding::DefaultFuchsiaResourceDialect,
7538    > {
7539        RingBufferProxyInterface::r#start(self, payload)
7540    }
7541
7542    /// Stop the ring buffer.
7543    pub fn r#stop(
7544        &self,
7545        mut payload: &RingBufferStopRequest,
7546    ) -> fidl::client::QueryResponseFut<
7547        RingBufferStopResult,
7548        fidl::encoding::DefaultFuchsiaResourceDialect,
7549    > {
7550        RingBufferProxyInterface::r#stop(self, payload)
7551    }
7552
7553    /// Request delay information via a hanging get. The RingBuffer will respond
7554    /// immediately to the first `WatchDelayInfo` call. Subsequent calls will
7555    /// only be completed when the delay info has changed from previously
7556    /// communicated values.
7557    pub fn r#watch_delay_info(
7558        &self,
7559    ) -> fidl::client::QueryResponseFut<
7560        RingBufferWatchDelayInfoResult,
7561        fidl::encoding::DefaultFuchsiaResourceDialect,
7562    > {
7563        RingBufferProxyInterface::r#watch_delay_info(self)
7564    }
7565}
7566
7567impl RingBufferProxyInterface for RingBufferProxy {
7568    type SetActiveChannelsResponseFut = fidl::client::QueryResponseFut<
7569        RingBufferSetActiveChannelsResult,
7570        fidl::encoding::DefaultFuchsiaResourceDialect,
7571    >;
7572    fn r#set_active_channels(
7573        &self,
7574        mut payload: &RingBufferSetActiveChannelsRequest,
7575    ) -> Self::SetActiveChannelsResponseFut {
7576        fn _decode(
7577            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7578        ) -> Result<RingBufferSetActiveChannelsResult, fidl::Error> {
7579            let _response = fidl::client::decode_transaction_body::<
7580                fidl::encoding::FlexibleResultType<
7581                    RingBufferSetActiveChannelsResponse,
7582                    RingBufferSetActiveChannelsError,
7583                >,
7584                fidl::encoding::DefaultFuchsiaResourceDialect,
7585                0x4276c43e4a3b59ee,
7586            >(_buf?)?
7587            .into_result::<RingBufferMarker>("set_active_channels")?;
7588            Ok(_response.map(|x| x))
7589        }
7590        self.client.send_query_and_decode::<
7591            RingBufferSetActiveChannelsRequest,
7592            RingBufferSetActiveChannelsResult,
7593        >(
7594            payload,
7595            0x4276c43e4a3b59ee,
7596            fidl::encoding::DynamicFlags::FLEXIBLE,
7597            _decode,
7598        )
7599    }
7600
7601    type StartResponseFut = fidl::client::QueryResponseFut<
7602        RingBufferStartResult,
7603        fidl::encoding::DefaultFuchsiaResourceDialect,
7604    >;
7605    fn r#start(&self, mut payload: &RingBufferStartRequest) -> Self::StartResponseFut {
7606        fn _decode(
7607            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7608        ) -> Result<RingBufferStartResult, fidl::Error> {
7609            let _response = fidl::client::decode_transaction_body::<
7610                fidl::encoding::FlexibleResultType<RingBufferStartResponse, RingBufferStartError>,
7611                fidl::encoding::DefaultFuchsiaResourceDialect,
7612                0x5365a8609dc2dc5,
7613            >(_buf?)?
7614            .into_result::<RingBufferMarker>("start")?;
7615            Ok(_response.map(|x| x))
7616        }
7617        self.client.send_query_and_decode::<RingBufferStartRequest, RingBufferStartResult>(
7618            payload,
7619            0x5365a8609dc2dc5,
7620            fidl::encoding::DynamicFlags::FLEXIBLE,
7621            _decode,
7622        )
7623    }
7624
7625    type StopResponseFut = fidl::client::QueryResponseFut<
7626        RingBufferStopResult,
7627        fidl::encoding::DefaultFuchsiaResourceDialect,
7628    >;
7629    fn r#stop(&self, mut payload: &RingBufferStopRequest) -> Self::StopResponseFut {
7630        fn _decode(
7631            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7632        ) -> Result<RingBufferStopResult, fidl::Error> {
7633            let _response = fidl::client::decode_transaction_body::<
7634                fidl::encoding::FlexibleResultType<RingBufferStopResponse, RingBufferStopError>,
7635                fidl::encoding::DefaultFuchsiaResourceDialect,
7636                0x5a238810af11e6e1,
7637            >(_buf?)?
7638            .into_result::<RingBufferMarker>("stop")?;
7639            Ok(_response.map(|x| x))
7640        }
7641        self.client.send_query_and_decode::<RingBufferStopRequest, RingBufferStopResult>(
7642            payload,
7643            0x5a238810af11e6e1,
7644            fidl::encoding::DynamicFlags::FLEXIBLE,
7645            _decode,
7646        )
7647    }
7648
7649    type WatchDelayInfoResponseFut = fidl::client::QueryResponseFut<
7650        RingBufferWatchDelayInfoResult,
7651        fidl::encoding::DefaultFuchsiaResourceDialect,
7652    >;
7653    fn r#watch_delay_info(&self) -> Self::WatchDelayInfoResponseFut {
7654        fn _decode(
7655            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7656        ) -> Result<RingBufferWatchDelayInfoResult, fidl::Error> {
7657            let _response = fidl::client::decode_transaction_body::<
7658                fidl::encoding::FlexibleResultType<
7659                    RingBufferWatchDelayInfoResponse,
7660                    RingBufferWatchDelayInfoError,
7661                >,
7662                fidl::encoding::DefaultFuchsiaResourceDialect,
7663                0x6d1dc5a928f38ad6,
7664            >(_buf?)?
7665            .into_result::<RingBufferMarker>("watch_delay_info")?;
7666            Ok(_response.map(|x| x))
7667        }
7668        self.client
7669            .send_query_and_decode::<fidl::encoding::EmptyPayload, RingBufferWatchDelayInfoResult>(
7670                (),
7671                0x6d1dc5a928f38ad6,
7672                fidl::encoding::DynamicFlags::FLEXIBLE,
7673                _decode,
7674            )
7675    }
7676}
7677
7678pub struct RingBufferEventStream {
7679    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7680}
7681
7682impl std::marker::Unpin for RingBufferEventStream {}
7683
7684impl futures::stream::FusedStream for RingBufferEventStream {
7685    fn is_terminated(&self) -> bool {
7686        self.event_receiver.is_terminated()
7687    }
7688}
7689
7690impl futures::Stream for RingBufferEventStream {
7691    type Item = Result<RingBufferEvent, fidl::Error>;
7692
7693    fn poll_next(
7694        mut self: std::pin::Pin<&mut Self>,
7695        cx: &mut std::task::Context<'_>,
7696    ) -> std::task::Poll<Option<Self::Item>> {
7697        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7698            &mut self.event_receiver,
7699            cx
7700        )?) {
7701            Some(buf) => std::task::Poll::Ready(Some(RingBufferEvent::decode(buf))),
7702            None => std::task::Poll::Ready(None),
7703        }
7704    }
7705}
7706
7707#[derive(Debug)]
7708pub enum RingBufferEvent {
7709    #[non_exhaustive]
7710    _UnknownEvent {
7711        /// Ordinal of the event that was sent.
7712        ordinal: u64,
7713    },
7714}
7715
7716impl RingBufferEvent {
7717    /// Decodes a message buffer as a [`RingBufferEvent`].
7718    fn decode(
7719        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7720    ) -> Result<RingBufferEvent, fidl::Error> {
7721        let (bytes, _handles) = buf.split_mut();
7722        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7723        debug_assert_eq!(tx_header.tx_id, 0);
7724        match tx_header.ordinal {
7725            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7726                Ok(RingBufferEvent::_UnknownEvent { ordinal: tx_header.ordinal })
7727            }
7728            _ => Err(fidl::Error::UnknownOrdinal {
7729                ordinal: tx_header.ordinal,
7730                protocol_name: <RingBufferMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7731            }),
7732        }
7733    }
7734}
7735
7736/// A Stream of incoming requests for fuchsia.audio.device/RingBuffer.
7737pub struct RingBufferRequestStream {
7738    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7739    is_terminated: bool,
7740}
7741
7742impl std::marker::Unpin for RingBufferRequestStream {}
7743
7744impl futures::stream::FusedStream for RingBufferRequestStream {
7745    fn is_terminated(&self) -> bool {
7746        self.is_terminated
7747    }
7748}
7749
7750impl fidl::endpoints::RequestStream for RingBufferRequestStream {
7751    type Protocol = RingBufferMarker;
7752    type ControlHandle = RingBufferControlHandle;
7753
7754    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7755        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7756    }
7757
7758    fn control_handle(&self) -> Self::ControlHandle {
7759        RingBufferControlHandle { inner: self.inner.clone() }
7760    }
7761
7762    fn into_inner(
7763        self,
7764    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7765    {
7766        (self.inner, self.is_terminated)
7767    }
7768
7769    fn from_inner(
7770        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7771        is_terminated: bool,
7772    ) -> Self {
7773        Self { inner, is_terminated }
7774    }
7775}
7776
7777impl futures::Stream for RingBufferRequestStream {
7778    type Item = Result<RingBufferRequest, fidl::Error>;
7779
7780    fn poll_next(
7781        mut self: std::pin::Pin<&mut Self>,
7782        cx: &mut std::task::Context<'_>,
7783    ) -> std::task::Poll<Option<Self::Item>> {
7784        let this = &mut *self;
7785        if this.inner.check_shutdown(cx) {
7786            this.is_terminated = true;
7787            return std::task::Poll::Ready(None);
7788        }
7789        if this.is_terminated {
7790            panic!("polled RingBufferRequestStream after completion");
7791        }
7792        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7793            |bytes, handles| {
7794                match this.inner.channel().read_etc(cx, bytes, handles) {
7795                    std::task::Poll::Ready(Ok(())) => {}
7796                    std::task::Poll::Pending => return std::task::Poll::Pending,
7797                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7798                        this.is_terminated = true;
7799                        return std::task::Poll::Ready(None);
7800                    }
7801                    std::task::Poll::Ready(Err(e)) => {
7802                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7803                            e.into(),
7804                        ))));
7805                    }
7806                }
7807
7808                // A message has been received from the channel
7809                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7810
7811                std::task::Poll::Ready(Some(match header.ordinal {
7812                    0x4276c43e4a3b59ee => {
7813                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7814                        let mut req = fidl::new_empty!(
7815                            RingBufferSetActiveChannelsRequest,
7816                            fidl::encoding::DefaultFuchsiaResourceDialect
7817                        );
7818                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RingBufferSetActiveChannelsRequest>(&header, _body_bytes, handles, &mut req)?;
7819                        let control_handle = RingBufferControlHandle { inner: this.inner.clone() };
7820                        Ok(RingBufferRequest::SetActiveChannels {
7821                            payload: req,
7822                            responder: RingBufferSetActiveChannelsResponder {
7823                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7824                                tx_id: header.tx_id,
7825                            },
7826                        })
7827                    }
7828                    0x5365a8609dc2dc5 => {
7829                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7830                        let mut req = fidl::new_empty!(
7831                            RingBufferStartRequest,
7832                            fidl::encoding::DefaultFuchsiaResourceDialect
7833                        );
7834                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RingBufferStartRequest>(&header, _body_bytes, handles, &mut req)?;
7835                        let control_handle = RingBufferControlHandle { inner: this.inner.clone() };
7836                        Ok(RingBufferRequest::Start {
7837                            payload: req,
7838                            responder: RingBufferStartResponder {
7839                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7840                                tx_id: header.tx_id,
7841                            },
7842                        })
7843                    }
7844                    0x5a238810af11e6e1 => {
7845                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7846                        let mut req = fidl::new_empty!(
7847                            RingBufferStopRequest,
7848                            fidl::encoding::DefaultFuchsiaResourceDialect
7849                        );
7850                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RingBufferStopRequest>(&header, _body_bytes, handles, &mut req)?;
7851                        let control_handle = RingBufferControlHandle { inner: this.inner.clone() };
7852                        Ok(RingBufferRequest::Stop {
7853                            payload: req,
7854                            responder: RingBufferStopResponder {
7855                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7856                                tx_id: header.tx_id,
7857                            },
7858                        })
7859                    }
7860                    0x6d1dc5a928f38ad6 => {
7861                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7862                        let mut req = fidl::new_empty!(
7863                            fidl::encoding::EmptyPayload,
7864                            fidl::encoding::DefaultFuchsiaResourceDialect
7865                        );
7866                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7867                        let control_handle = RingBufferControlHandle { inner: this.inner.clone() };
7868                        Ok(RingBufferRequest::WatchDelayInfo {
7869                            responder: RingBufferWatchDelayInfoResponder {
7870                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7871                                tx_id: header.tx_id,
7872                            },
7873                        })
7874                    }
7875                    _ if header.tx_id == 0
7876                        && header
7877                            .dynamic_flags()
7878                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
7879                    {
7880                        Ok(RingBufferRequest::_UnknownMethod {
7881                            ordinal: header.ordinal,
7882                            control_handle: RingBufferControlHandle { inner: this.inner.clone() },
7883                            method_type: fidl::MethodType::OneWay,
7884                        })
7885                    }
7886                    _ if header
7887                        .dynamic_flags()
7888                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
7889                    {
7890                        this.inner.send_framework_err(
7891                            fidl::encoding::FrameworkErr::UnknownMethod,
7892                            header.tx_id,
7893                            header.ordinal,
7894                            header.dynamic_flags(),
7895                            (bytes, handles),
7896                        )?;
7897                        Ok(RingBufferRequest::_UnknownMethod {
7898                            ordinal: header.ordinal,
7899                            control_handle: RingBufferControlHandle { inner: this.inner.clone() },
7900                            method_type: fidl::MethodType::TwoWay,
7901                        })
7902                    }
7903                    _ => Err(fidl::Error::UnknownOrdinal {
7904                        ordinal: header.ordinal,
7905                        protocol_name:
7906                            <RingBufferMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7907                    }),
7908                }))
7909            },
7910        )
7911    }
7912}
7913
7914/// A `RingBuffer` instance controls data flow for the associated audio stream.
7915#[derive(Debug)]
7916pub enum RingBufferRequest {
7917    /// Request that specific individual channels be powered down/up, if the
7918    /// device supports this. This is intended for idle power conservation.
7919    ///
7920    /// Channels are specified by bitmask; the least significant bit corresponds
7921    /// to channel 0. Each bit not set indicates that the channel can be
7922    /// deactivated. `SetActiveChannels` does not change how a ring buffer
7923    /// responds to `Start`/`Stop`, specifically with regards to position.
7924    ///
7925    /// Devices are not required to obey `SetActiveChannels`. For example, they
7926    /// are not required to zero-out an input stream's inactive channels, and
7927    /// data written to inactive channels of an output stream's ring buffer may
7928    /// still be played.
7929    ///
7930    /// If not called, then by default all channels will be active.
7931    SetActiveChannels {
7932        payload: RingBufferSetActiveChannelsRequest,
7933        responder: RingBufferSetActiveChannelsResponder,
7934    },
7935    /// Start the ring buffer, beginning at the first frame of the ring buffer.
7936    Start { payload: RingBufferStartRequest, responder: RingBufferStartResponder },
7937    /// Stop the ring buffer.
7938    Stop { payload: RingBufferStopRequest, responder: RingBufferStopResponder },
7939    /// Request delay information via a hanging get. The RingBuffer will respond
7940    /// immediately to the first `WatchDelayInfo` call. Subsequent calls will
7941    /// only be completed when the delay info has changed from previously
7942    /// communicated values.
7943    WatchDelayInfo { responder: RingBufferWatchDelayInfoResponder },
7944    /// An interaction was received which does not match any known method.
7945    #[non_exhaustive]
7946    _UnknownMethod {
7947        /// Ordinal of the method that was called.
7948        ordinal: u64,
7949        control_handle: RingBufferControlHandle,
7950        method_type: fidl::MethodType,
7951    },
7952}
7953
7954impl RingBufferRequest {
7955    #[allow(irrefutable_let_patterns)]
7956    pub fn into_set_active_channels(
7957        self,
7958    ) -> Option<(RingBufferSetActiveChannelsRequest, RingBufferSetActiveChannelsResponder)> {
7959        if let RingBufferRequest::SetActiveChannels { payload, responder } = self {
7960            Some((payload, responder))
7961        } else {
7962            None
7963        }
7964    }
7965
7966    #[allow(irrefutable_let_patterns)]
7967    pub fn into_start(self) -> Option<(RingBufferStartRequest, RingBufferStartResponder)> {
7968        if let RingBufferRequest::Start { payload, responder } = self {
7969            Some((payload, responder))
7970        } else {
7971            None
7972        }
7973    }
7974
7975    #[allow(irrefutable_let_patterns)]
7976    pub fn into_stop(self) -> Option<(RingBufferStopRequest, RingBufferStopResponder)> {
7977        if let RingBufferRequest::Stop { payload, responder } = self {
7978            Some((payload, responder))
7979        } else {
7980            None
7981        }
7982    }
7983
7984    #[allow(irrefutable_let_patterns)]
7985    pub fn into_watch_delay_info(self) -> Option<(RingBufferWatchDelayInfoResponder)> {
7986        if let RingBufferRequest::WatchDelayInfo { responder } = self {
7987            Some((responder))
7988        } else {
7989            None
7990        }
7991    }
7992
7993    /// Name of the method defined in FIDL
7994    pub fn method_name(&self) -> &'static str {
7995        match *self {
7996            RingBufferRequest::SetActiveChannels { .. } => "set_active_channels",
7997            RingBufferRequest::Start { .. } => "start",
7998            RingBufferRequest::Stop { .. } => "stop",
7999            RingBufferRequest::WatchDelayInfo { .. } => "watch_delay_info",
8000            RingBufferRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
8001                "unknown one-way method"
8002            }
8003            RingBufferRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
8004                "unknown two-way method"
8005            }
8006        }
8007    }
8008}
8009
8010#[derive(Debug, Clone)]
8011pub struct RingBufferControlHandle {
8012    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8013}
8014
8015impl fidl::endpoints::ControlHandle for RingBufferControlHandle {
8016    fn shutdown(&self) {
8017        self.inner.shutdown()
8018    }
8019
8020    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8021        self.inner.shutdown_with_epitaph(status)
8022    }
8023
8024    fn is_closed(&self) -> bool {
8025        self.inner.channel().is_closed()
8026    }
8027    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8028        self.inner.channel().on_closed()
8029    }
8030
8031    #[cfg(target_os = "fuchsia")]
8032    fn signal_peer(
8033        &self,
8034        clear_mask: zx::Signals,
8035        set_mask: zx::Signals,
8036    ) -> Result<(), zx_status::Status> {
8037        use fidl::Peered;
8038        self.inner.channel().signal_peer(clear_mask, set_mask)
8039    }
8040}
8041
8042impl RingBufferControlHandle {}
8043
8044#[must_use = "FIDL methods require a response to be sent"]
8045#[derive(Debug)]
8046pub struct RingBufferSetActiveChannelsResponder {
8047    control_handle: std::mem::ManuallyDrop<RingBufferControlHandle>,
8048    tx_id: u32,
8049}
8050
8051/// Set the the channel to be shutdown (see [`RingBufferControlHandle::shutdown`])
8052/// if the responder is dropped without sending a response, so that the client
8053/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8054impl std::ops::Drop for RingBufferSetActiveChannelsResponder {
8055    fn drop(&mut self) {
8056        self.control_handle.shutdown();
8057        // Safety: drops once, never accessed again
8058        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8059    }
8060}
8061
8062impl fidl::endpoints::Responder for RingBufferSetActiveChannelsResponder {
8063    type ControlHandle = RingBufferControlHandle;
8064
8065    fn control_handle(&self) -> &RingBufferControlHandle {
8066        &self.control_handle
8067    }
8068
8069    fn drop_without_shutdown(mut self) {
8070        // Safety: drops once, never accessed again due to mem::forget
8071        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8072        // Prevent Drop from running (which would shut down the channel)
8073        std::mem::forget(self);
8074    }
8075}
8076
8077impl RingBufferSetActiveChannelsResponder {
8078    /// Sends a response to the FIDL transaction.
8079    ///
8080    /// Sets the channel to shutdown if an error occurs.
8081    pub fn send(
8082        self,
8083        mut result: Result<&RingBufferSetActiveChannelsResponse, RingBufferSetActiveChannelsError>,
8084    ) -> Result<(), fidl::Error> {
8085        let _result = self.send_raw(result);
8086        if _result.is_err() {
8087            self.control_handle.shutdown();
8088        }
8089        self.drop_without_shutdown();
8090        _result
8091    }
8092
8093    /// Similar to "send" but does not shutdown the channel if an error occurs.
8094    pub fn send_no_shutdown_on_err(
8095        self,
8096        mut result: Result<&RingBufferSetActiveChannelsResponse, RingBufferSetActiveChannelsError>,
8097    ) -> Result<(), fidl::Error> {
8098        let _result = self.send_raw(result);
8099        self.drop_without_shutdown();
8100        _result
8101    }
8102
8103    fn send_raw(
8104        &self,
8105        mut result: Result<&RingBufferSetActiveChannelsResponse, RingBufferSetActiveChannelsError>,
8106    ) -> Result<(), fidl::Error> {
8107        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
8108            RingBufferSetActiveChannelsResponse,
8109            RingBufferSetActiveChannelsError,
8110        >>(
8111            fidl::encoding::FlexibleResult::new(result),
8112            self.tx_id,
8113            0x4276c43e4a3b59ee,
8114            fidl::encoding::DynamicFlags::FLEXIBLE,
8115        )
8116    }
8117}
8118
8119#[must_use = "FIDL methods require a response to be sent"]
8120#[derive(Debug)]
8121pub struct RingBufferStartResponder {
8122    control_handle: std::mem::ManuallyDrop<RingBufferControlHandle>,
8123    tx_id: u32,
8124}
8125
8126/// Set the the channel to be shutdown (see [`RingBufferControlHandle::shutdown`])
8127/// if the responder is dropped without sending a response, so that the client
8128/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8129impl std::ops::Drop for RingBufferStartResponder {
8130    fn drop(&mut self) {
8131        self.control_handle.shutdown();
8132        // Safety: drops once, never accessed again
8133        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8134    }
8135}
8136
8137impl fidl::endpoints::Responder for RingBufferStartResponder {
8138    type ControlHandle = RingBufferControlHandle;
8139
8140    fn control_handle(&self) -> &RingBufferControlHandle {
8141        &self.control_handle
8142    }
8143
8144    fn drop_without_shutdown(mut self) {
8145        // Safety: drops once, never accessed again due to mem::forget
8146        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8147        // Prevent Drop from running (which would shut down the channel)
8148        std::mem::forget(self);
8149    }
8150}
8151
8152impl RingBufferStartResponder {
8153    /// Sends a response to the FIDL transaction.
8154    ///
8155    /// Sets the channel to shutdown if an error occurs.
8156    pub fn send(
8157        self,
8158        mut result: Result<&RingBufferStartResponse, RingBufferStartError>,
8159    ) -> Result<(), fidl::Error> {
8160        let _result = self.send_raw(result);
8161        if _result.is_err() {
8162            self.control_handle.shutdown();
8163        }
8164        self.drop_without_shutdown();
8165        _result
8166    }
8167
8168    /// Similar to "send" but does not shutdown the channel if an error occurs.
8169    pub fn send_no_shutdown_on_err(
8170        self,
8171        mut result: Result<&RingBufferStartResponse, RingBufferStartError>,
8172    ) -> Result<(), fidl::Error> {
8173        let _result = self.send_raw(result);
8174        self.drop_without_shutdown();
8175        _result
8176    }
8177
8178    fn send_raw(
8179        &self,
8180        mut result: Result<&RingBufferStartResponse, RingBufferStartError>,
8181    ) -> Result<(), fidl::Error> {
8182        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
8183            RingBufferStartResponse,
8184            RingBufferStartError,
8185        >>(
8186            fidl::encoding::FlexibleResult::new(result),
8187            self.tx_id,
8188            0x5365a8609dc2dc5,
8189            fidl::encoding::DynamicFlags::FLEXIBLE,
8190        )
8191    }
8192}
8193
8194#[must_use = "FIDL methods require a response to be sent"]
8195#[derive(Debug)]
8196pub struct RingBufferStopResponder {
8197    control_handle: std::mem::ManuallyDrop<RingBufferControlHandle>,
8198    tx_id: u32,
8199}
8200
8201/// Set the the channel to be shutdown (see [`RingBufferControlHandle::shutdown`])
8202/// if the responder is dropped without sending a response, so that the client
8203/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8204impl std::ops::Drop for RingBufferStopResponder {
8205    fn drop(&mut self) {
8206        self.control_handle.shutdown();
8207        // Safety: drops once, never accessed again
8208        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8209    }
8210}
8211
8212impl fidl::endpoints::Responder for RingBufferStopResponder {
8213    type ControlHandle = RingBufferControlHandle;
8214
8215    fn control_handle(&self) -> &RingBufferControlHandle {
8216        &self.control_handle
8217    }
8218
8219    fn drop_without_shutdown(mut self) {
8220        // Safety: drops once, never accessed again due to mem::forget
8221        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8222        // Prevent Drop from running (which would shut down the channel)
8223        std::mem::forget(self);
8224    }
8225}
8226
8227impl RingBufferStopResponder {
8228    /// Sends a response to the FIDL transaction.
8229    ///
8230    /// Sets the channel to shutdown if an error occurs.
8231    pub fn send(
8232        self,
8233        mut result: Result<&RingBufferStopResponse, RingBufferStopError>,
8234    ) -> Result<(), fidl::Error> {
8235        let _result = self.send_raw(result);
8236        if _result.is_err() {
8237            self.control_handle.shutdown();
8238        }
8239        self.drop_without_shutdown();
8240        _result
8241    }
8242
8243    /// Similar to "send" but does not shutdown the channel if an error occurs.
8244    pub fn send_no_shutdown_on_err(
8245        self,
8246        mut result: Result<&RingBufferStopResponse, RingBufferStopError>,
8247    ) -> Result<(), fidl::Error> {
8248        let _result = self.send_raw(result);
8249        self.drop_without_shutdown();
8250        _result
8251    }
8252
8253    fn send_raw(
8254        &self,
8255        mut result: Result<&RingBufferStopResponse, RingBufferStopError>,
8256    ) -> Result<(), fidl::Error> {
8257        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
8258            RingBufferStopResponse,
8259            RingBufferStopError,
8260        >>(
8261            fidl::encoding::FlexibleResult::new(result),
8262            self.tx_id,
8263            0x5a238810af11e6e1,
8264            fidl::encoding::DynamicFlags::FLEXIBLE,
8265        )
8266    }
8267}
8268
8269#[must_use = "FIDL methods require a response to be sent"]
8270#[derive(Debug)]
8271pub struct RingBufferWatchDelayInfoResponder {
8272    control_handle: std::mem::ManuallyDrop<RingBufferControlHandle>,
8273    tx_id: u32,
8274}
8275
8276/// Set the the channel to be shutdown (see [`RingBufferControlHandle::shutdown`])
8277/// if the responder is dropped without sending a response, so that the client
8278/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8279impl std::ops::Drop for RingBufferWatchDelayInfoResponder {
8280    fn drop(&mut self) {
8281        self.control_handle.shutdown();
8282        // Safety: drops once, never accessed again
8283        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8284    }
8285}
8286
8287impl fidl::endpoints::Responder for RingBufferWatchDelayInfoResponder {
8288    type ControlHandle = RingBufferControlHandle;
8289
8290    fn control_handle(&self) -> &RingBufferControlHandle {
8291        &self.control_handle
8292    }
8293
8294    fn drop_without_shutdown(mut self) {
8295        // Safety: drops once, never accessed again due to mem::forget
8296        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8297        // Prevent Drop from running (which would shut down the channel)
8298        std::mem::forget(self);
8299    }
8300}
8301
8302impl RingBufferWatchDelayInfoResponder {
8303    /// Sends a response to the FIDL transaction.
8304    ///
8305    /// Sets the channel to shutdown if an error occurs.
8306    pub fn send(
8307        self,
8308        mut result: Result<&RingBufferWatchDelayInfoResponse, RingBufferWatchDelayInfoError>,
8309    ) -> Result<(), fidl::Error> {
8310        let _result = self.send_raw(result);
8311        if _result.is_err() {
8312            self.control_handle.shutdown();
8313        }
8314        self.drop_without_shutdown();
8315        _result
8316    }
8317
8318    /// Similar to "send" but does not shutdown the channel if an error occurs.
8319    pub fn send_no_shutdown_on_err(
8320        self,
8321        mut result: Result<&RingBufferWatchDelayInfoResponse, RingBufferWatchDelayInfoError>,
8322    ) -> Result<(), fidl::Error> {
8323        let _result = self.send_raw(result);
8324        self.drop_without_shutdown();
8325        _result
8326    }
8327
8328    fn send_raw(
8329        &self,
8330        mut result: Result<&RingBufferWatchDelayInfoResponse, RingBufferWatchDelayInfoError>,
8331    ) -> Result<(), fidl::Error> {
8332        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
8333            RingBufferWatchDelayInfoResponse,
8334            RingBufferWatchDelayInfoError,
8335        >>(
8336            fidl::encoding::FlexibleResult::new(result),
8337            self.tx_id,
8338            0x6d1dc5a928f38ad6,
8339            fidl::encoding::DynamicFlags::FLEXIBLE,
8340        )
8341    }
8342}
8343
8344mod internal {
8345    use super::*;
8346
8347    impl ControlCreatePacketStreamRequest {
8348        #[inline(always)]
8349        fn max_ordinal_present(&self) -> u64 {
8350            if let Some(_) = self.packet_stream_server {
8351                return 3;
8352            }
8353            if let Some(_) = self.options {
8354                return 2;
8355            }
8356            if let Some(_) = self.element_id {
8357                return 1;
8358            }
8359            0
8360        }
8361    }
8362
8363    impl fidl::encoding::ResourceTypeMarker for ControlCreatePacketStreamRequest {
8364        type Borrowed<'a> = &'a mut Self;
8365        fn take_or_borrow<'a>(
8366            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8367        ) -> Self::Borrowed<'a> {
8368            value
8369        }
8370    }
8371
8372    unsafe impl fidl::encoding::TypeMarker for ControlCreatePacketStreamRequest {
8373        type Owned = Self;
8374
8375        #[inline(always)]
8376        fn inline_align(_context: fidl::encoding::Context) -> usize {
8377            8
8378        }
8379
8380        #[inline(always)]
8381        fn inline_size(_context: fidl::encoding::Context) -> usize {
8382            16
8383        }
8384    }
8385
8386    unsafe impl
8387        fidl::encoding::Encode<
8388            ControlCreatePacketStreamRequest,
8389            fidl::encoding::DefaultFuchsiaResourceDialect,
8390        > for &mut ControlCreatePacketStreamRequest
8391    {
8392        unsafe fn encode(
8393            self,
8394            encoder: &mut fidl::encoding::Encoder<
8395                '_,
8396                fidl::encoding::DefaultFuchsiaResourceDialect,
8397            >,
8398            offset: usize,
8399            mut depth: fidl::encoding::Depth,
8400        ) -> fidl::Result<()> {
8401            encoder.debug_check_bounds::<ControlCreatePacketStreamRequest>(offset);
8402            // Vector header
8403            let max_ordinal: u64 = self.max_ordinal_present();
8404            encoder.write_num(max_ordinal, offset);
8405            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8406            // Calling encoder.out_of_line_offset(0) is not allowed.
8407            if max_ordinal == 0 {
8408                return Ok(());
8409            }
8410            depth.increment()?;
8411            let envelope_size = 8;
8412            let bytes_len = max_ordinal as usize * envelope_size;
8413            #[allow(unused_variables)]
8414            let offset = encoder.out_of_line_offset(bytes_len);
8415            let mut _prev_end_offset: usize = 0;
8416            if 1 > max_ordinal {
8417                return Ok(());
8418            }
8419
8420            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8421            // are envelope_size bytes.
8422            let cur_offset: usize = (1 - 1) * envelope_size;
8423
8424            // Zero reserved fields.
8425            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8426
8427            // Safety:
8428            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8429            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8430            //   envelope_size bytes, there is always sufficient room.
8431            fidl::encoding::encode_in_envelope_optional::<
8432                u64,
8433                fidl::encoding::DefaultFuchsiaResourceDialect,
8434            >(
8435                self.element_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
8436                encoder,
8437                offset + cur_offset,
8438                depth,
8439            )?;
8440
8441            _prev_end_offset = cur_offset + envelope_size;
8442            if 2 > max_ordinal {
8443                return Ok(());
8444            }
8445
8446            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8447            // are envelope_size bytes.
8448            let cur_offset: usize = (2 - 1) * envelope_size;
8449
8450            // Zero reserved fields.
8451            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8452
8453            // Safety:
8454            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8455            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8456            //   envelope_size bytes, there is always sufficient room.
8457            fidl::encoding::encode_in_envelope_optional::<
8458                PacketStreamOptions,
8459                fidl::encoding::DefaultFuchsiaResourceDialect,
8460            >(
8461                self.options.as_mut().map(
8462                    <PacketStreamOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
8463                ),
8464                encoder,
8465                offset + cur_offset,
8466                depth,
8467            )?;
8468
8469            _prev_end_offset = cur_offset + envelope_size;
8470            if 3 > max_ordinal {
8471                return Ok(());
8472            }
8473
8474            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8475            // are envelope_size bytes.
8476            let cur_offset: usize = (3 - 1) * envelope_size;
8477
8478            // Zero reserved fields.
8479            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8480
8481            // Safety:
8482            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8483            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8484            //   envelope_size bytes, there is always sufficient room.
8485            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PacketStreamMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
8486            self.packet_stream_server.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PacketStreamMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
8487            encoder, offset + cur_offset, depth
8488        )?;
8489
8490            _prev_end_offset = cur_offset + envelope_size;
8491
8492            Ok(())
8493        }
8494    }
8495
8496    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8497        for ControlCreatePacketStreamRequest
8498    {
8499        #[inline(always)]
8500        fn new_empty() -> Self {
8501            Self::default()
8502        }
8503
8504        unsafe fn decode(
8505            &mut self,
8506            decoder: &mut fidl::encoding::Decoder<
8507                '_,
8508                fidl::encoding::DefaultFuchsiaResourceDialect,
8509            >,
8510            offset: usize,
8511            mut depth: fidl::encoding::Depth,
8512        ) -> fidl::Result<()> {
8513            decoder.debug_check_bounds::<Self>(offset);
8514            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8515                None => return Err(fidl::Error::NotNullable),
8516                Some(len) => len,
8517            };
8518            // Calling decoder.out_of_line_offset(0) is not allowed.
8519            if len == 0 {
8520                return Ok(());
8521            };
8522            depth.increment()?;
8523            let envelope_size = 8;
8524            let bytes_len = len * envelope_size;
8525            let offset = decoder.out_of_line_offset(bytes_len)?;
8526            // Decode the envelope for each type.
8527            let mut _next_ordinal_to_read = 0;
8528            let mut next_offset = offset;
8529            let end_offset = offset + bytes_len;
8530            _next_ordinal_to_read += 1;
8531            if next_offset >= end_offset {
8532                return Ok(());
8533            }
8534
8535            // Decode unknown envelopes for gaps in ordinals.
8536            while _next_ordinal_to_read < 1 {
8537                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8538                _next_ordinal_to_read += 1;
8539                next_offset += envelope_size;
8540            }
8541
8542            let next_out_of_line = decoder.next_out_of_line();
8543            let handles_before = decoder.remaining_handles();
8544            if let Some((inlined, num_bytes, num_handles)) =
8545                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8546            {
8547                let member_inline_size =
8548                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8549                if inlined != (member_inline_size <= 4) {
8550                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8551                }
8552                let inner_offset;
8553                let mut inner_depth = depth.clone();
8554                if inlined {
8555                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8556                    inner_offset = next_offset;
8557                } else {
8558                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8559                    inner_depth.increment()?;
8560                }
8561                let val_ref = self.element_id.get_or_insert_with(|| {
8562                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
8563                });
8564                fidl::decode!(
8565                    u64,
8566                    fidl::encoding::DefaultFuchsiaResourceDialect,
8567                    val_ref,
8568                    decoder,
8569                    inner_offset,
8570                    inner_depth
8571                )?;
8572                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8573                {
8574                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8575                }
8576                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8577                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8578                }
8579            }
8580
8581            next_offset += envelope_size;
8582            _next_ordinal_to_read += 1;
8583            if next_offset >= end_offset {
8584                return Ok(());
8585            }
8586
8587            // Decode unknown envelopes for gaps in ordinals.
8588            while _next_ordinal_to_read < 2 {
8589                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8590                _next_ordinal_to_read += 1;
8591                next_offset += envelope_size;
8592            }
8593
8594            let next_out_of_line = decoder.next_out_of_line();
8595            let handles_before = decoder.remaining_handles();
8596            if let Some((inlined, num_bytes, num_handles)) =
8597                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8598            {
8599                let member_inline_size =
8600                    <PacketStreamOptions as fidl::encoding::TypeMarker>::inline_size(
8601                        decoder.context,
8602                    );
8603                if inlined != (member_inline_size <= 4) {
8604                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8605                }
8606                let inner_offset;
8607                let mut inner_depth = depth.clone();
8608                if inlined {
8609                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8610                    inner_offset = next_offset;
8611                } else {
8612                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8613                    inner_depth.increment()?;
8614                }
8615                let val_ref = self.options.get_or_insert_with(|| {
8616                    fidl::new_empty!(
8617                        PacketStreamOptions,
8618                        fidl::encoding::DefaultFuchsiaResourceDialect
8619                    )
8620                });
8621                fidl::decode!(
8622                    PacketStreamOptions,
8623                    fidl::encoding::DefaultFuchsiaResourceDialect,
8624                    val_ref,
8625                    decoder,
8626                    inner_offset,
8627                    inner_depth
8628                )?;
8629                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8630                {
8631                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8632                }
8633                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8634                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8635                }
8636            }
8637
8638            next_offset += envelope_size;
8639            _next_ordinal_to_read += 1;
8640            if next_offset >= end_offset {
8641                return Ok(());
8642            }
8643
8644            // Decode unknown envelopes for gaps in ordinals.
8645            while _next_ordinal_to_read < 3 {
8646                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8647                _next_ordinal_to_read += 1;
8648                next_offset += envelope_size;
8649            }
8650
8651            let next_out_of_line = decoder.next_out_of_line();
8652            let handles_before = decoder.remaining_handles();
8653            if let Some((inlined, num_bytes, num_handles)) =
8654                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8655            {
8656                let member_inline_size = <fidl::encoding::Endpoint<
8657                    fidl::endpoints::ServerEnd<PacketStreamMarker>,
8658                > as fidl::encoding::TypeMarker>::inline_size(
8659                    decoder.context
8660                );
8661                if inlined != (member_inline_size <= 4) {
8662                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8663                }
8664                let inner_offset;
8665                let mut inner_depth = depth.clone();
8666                if inlined {
8667                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8668                    inner_offset = next_offset;
8669                } else {
8670                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8671                    inner_depth.increment()?;
8672                }
8673                let val_ref = self.packet_stream_server.get_or_insert_with(|| {
8674                    fidl::new_empty!(
8675                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PacketStreamMarker>>,
8676                        fidl::encoding::DefaultFuchsiaResourceDialect
8677                    )
8678                });
8679                fidl::decode!(
8680                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PacketStreamMarker>>,
8681                    fidl::encoding::DefaultFuchsiaResourceDialect,
8682                    val_ref,
8683                    decoder,
8684                    inner_offset,
8685                    inner_depth
8686                )?;
8687                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8688                {
8689                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8690                }
8691                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8692                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8693                }
8694            }
8695
8696            next_offset += envelope_size;
8697
8698            // Decode the remaining unknown envelopes.
8699            while next_offset < end_offset {
8700                _next_ordinal_to_read += 1;
8701                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8702                next_offset += envelope_size;
8703            }
8704
8705            Ok(())
8706        }
8707    }
8708
8709    impl ControlCreateRingBufferRequest {
8710        #[inline(always)]
8711        fn max_ordinal_present(&self) -> u64 {
8712            if let Some(_) = self.ring_buffer_server {
8713                return 3;
8714            }
8715            if let Some(_) = self.options {
8716                return 2;
8717            }
8718            if let Some(_) = self.element_id {
8719                return 1;
8720            }
8721            0
8722        }
8723    }
8724
8725    impl fidl::encoding::ResourceTypeMarker for ControlCreateRingBufferRequest {
8726        type Borrowed<'a> = &'a mut Self;
8727        fn take_or_borrow<'a>(
8728            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8729        ) -> Self::Borrowed<'a> {
8730            value
8731        }
8732    }
8733
8734    unsafe impl fidl::encoding::TypeMarker for ControlCreateRingBufferRequest {
8735        type Owned = Self;
8736
8737        #[inline(always)]
8738        fn inline_align(_context: fidl::encoding::Context) -> usize {
8739            8
8740        }
8741
8742        #[inline(always)]
8743        fn inline_size(_context: fidl::encoding::Context) -> usize {
8744            16
8745        }
8746    }
8747
8748    unsafe impl
8749        fidl::encoding::Encode<
8750            ControlCreateRingBufferRequest,
8751            fidl::encoding::DefaultFuchsiaResourceDialect,
8752        > for &mut ControlCreateRingBufferRequest
8753    {
8754        unsafe fn encode(
8755            self,
8756            encoder: &mut fidl::encoding::Encoder<
8757                '_,
8758                fidl::encoding::DefaultFuchsiaResourceDialect,
8759            >,
8760            offset: usize,
8761            mut depth: fidl::encoding::Depth,
8762        ) -> fidl::Result<()> {
8763            encoder.debug_check_bounds::<ControlCreateRingBufferRequest>(offset);
8764            // Vector header
8765            let max_ordinal: u64 = self.max_ordinal_present();
8766            encoder.write_num(max_ordinal, offset);
8767            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8768            // Calling encoder.out_of_line_offset(0) is not allowed.
8769            if max_ordinal == 0 {
8770                return Ok(());
8771            }
8772            depth.increment()?;
8773            let envelope_size = 8;
8774            let bytes_len = max_ordinal as usize * envelope_size;
8775            #[allow(unused_variables)]
8776            let offset = encoder.out_of_line_offset(bytes_len);
8777            let mut _prev_end_offset: usize = 0;
8778            if 1 > max_ordinal {
8779                return Ok(());
8780            }
8781
8782            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8783            // are envelope_size bytes.
8784            let cur_offset: usize = (1 - 1) * envelope_size;
8785
8786            // Zero reserved fields.
8787            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8788
8789            // Safety:
8790            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8791            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8792            //   envelope_size bytes, there is always sufficient room.
8793            fidl::encoding::encode_in_envelope_optional::<
8794                u64,
8795                fidl::encoding::DefaultFuchsiaResourceDialect,
8796            >(
8797                self.element_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
8798                encoder,
8799                offset + cur_offset,
8800                depth,
8801            )?;
8802
8803            _prev_end_offset = cur_offset + envelope_size;
8804            if 2 > max_ordinal {
8805                return Ok(());
8806            }
8807
8808            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8809            // are envelope_size bytes.
8810            let cur_offset: usize = (2 - 1) * envelope_size;
8811
8812            // Zero reserved fields.
8813            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8814
8815            // Safety:
8816            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8817            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8818            //   envelope_size bytes, there is always sufficient room.
8819            fidl::encoding::encode_in_envelope_optional::<
8820                RingBufferOptions,
8821                fidl::encoding::DefaultFuchsiaResourceDialect,
8822            >(
8823                self.options
8824                    .as_ref()
8825                    .map(<RingBufferOptions as fidl::encoding::ValueTypeMarker>::borrow),
8826                encoder,
8827                offset + cur_offset,
8828                depth,
8829            )?;
8830
8831            _prev_end_offset = cur_offset + envelope_size;
8832            if 3 > max_ordinal {
8833                return Ok(());
8834            }
8835
8836            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8837            // are envelope_size bytes.
8838            let cur_offset: usize = (3 - 1) * envelope_size;
8839
8840            // Zero reserved fields.
8841            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8842
8843            // Safety:
8844            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8845            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8846            //   envelope_size bytes, there is always sufficient room.
8847            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RingBufferMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
8848            self.ring_buffer_server.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RingBufferMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
8849            encoder, offset + cur_offset, depth
8850        )?;
8851
8852            _prev_end_offset = cur_offset + envelope_size;
8853
8854            Ok(())
8855        }
8856    }
8857
8858    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8859        for ControlCreateRingBufferRequest
8860    {
8861        #[inline(always)]
8862        fn new_empty() -> Self {
8863            Self::default()
8864        }
8865
8866        unsafe fn decode(
8867            &mut self,
8868            decoder: &mut fidl::encoding::Decoder<
8869                '_,
8870                fidl::encoding::DefaultFuchsiaResourceDialect,
8871            >,
8872            offset: usize,
8873            mut depth: fidl::encoding::Depth,
8874        ) -> fidl::Result<()> {
8875            decoder.debug_check_bounds::<Self>(offset);
8876            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8877                None => return Err(fidl::Error::NotNullable),
8878                Some(len) => len,
8879            };
8880            // Calling decoder.out_of_line_offset(0) is not allowed.
8881            if len == 0 {
8882                return Ok(());
8883            };
8884            depth.increment()?;
8885            let envelope_size = 8;
8886            let bytes_len = len * envelope_size;
8887            let offset = decoder.out_of_line_offset(bytes_len)?;
8888            // Decode the envelope for each type.
8889            let mut _next_ordinal_to_read = 0;
8890            let mut next_offset = offset;
8891            let end_offset = offset + bytes_len;
8892            _next_ordinal_to_read += 1;
8893            if next_offset >= end_offset {
8894                return Ok(());
8895            }
8896
8897            // Decode unknown envelopes for gaps in ordinals.
8898            while _next_ordinal_to_read < 1 {
8899                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8900                _next_ordinal_to_read += 1;
8901                next_offset += envelope_size;
8902            }
8903
8904            let next_out_of_line = decoder.next_out_of_line();
8905            let handles_before = decoder.remaining_handles();
8906            if let Some((inlined, num_bytes, num_handles)) =
8907                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8908            {
8909                let member_inline_size =
8910                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8911                if inlined != (member_inline_size <= 4) {
8912                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8913                }
8914                let inner_offset;
8915                let mut inner_depth = depth.clone();
8916                if inlined {
8917                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8918                    inner_offset = next_offset;
8919                } else {
8920                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8921                    inner_depth.increment()?;
8922                }
8923                let val_ref = self.element_id.get_or_insert_with(|| {
8924                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
8925                });
8926                fidl::decode!(
8927                    u64,
8928                    fidl::encoding::DefaultFuchsiaResourceDialect,
8929                    val_ref,
8930                    decoder,
8931                    inner_offset,
8932                    inner_depth
8933                )?;
8934                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8935                {
8936                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8937                }
8938                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8939                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8940                }
8941            }
8942
8943            next_offset += envelope_size;
8944            _next_ordinal_to_read += 1;
8945            if next_offset >= end_offset {
8946                return Ok(());
8947            }
8948
8949            // Decode unknown envelopes for gaps in ordinals.
8950            while _next_ordinal_to_read < 2 {
8951                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8952                _next_ordinal_to_read += 1;
8953                next_offset += envelope_size;
8954            }
8955
8956            let next_out_of_line = decoder.next_out_of_line();
8957            let handles_before = decoder.remaining_handles();
8958            if let Some((inlined, num_bytes, num_handles)) =
8959                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8960            {
8961                let member_inline_size =
8962                    <RingBufferOptions as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8963                if inlined != (member_inline_size <= 4) {
8964                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8965                }
8966                let inner_offset;
8967                let mut inner_depth = depth.clone();
8968                if inlined {
8969                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8970                    inner_offset = next_offset;
8971                } else {
8972                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8973                    inner_depth.increment()?;
8974                }
8975                let val_ref = self.options.get_or_insert_with(|| {
8976                    fidl::new_empty!(
8977                        RingBufferOptions,
8978                        fidl::encoding::DefaultFuchsiaResourceDialect
8979                    )
8980                });
8981                fidl::decode!(
8982                    RingBufferOptions,
8983                    fidl::encoding::DefaultFuchsiaResourceDialect,
8984                    val_ref,
8985                    decoder,
8986                    inner_offset,
8987                    inner_depth
8988                )?;
8989                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8990                {
8991                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8992                }
8993                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8994                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8995                }
8996            }
8997
8998            next_offset += envelope_size;
8999            _next_ordinal_to_read += 1;
9000            if next_offset >= end_offset {
9001                return Ok(());
9002            }
9003
9004            // Decode unknown envelopes for gaps in ordinals.
9005            while _next_ordinal_to_read < 3 {
9006                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9007                _next_ordinal_to_read += 1;
9008                next_offset += envelope_size;
9009            }
9010
9011            let next_out_of_line = decoder.next_out_of_line();
9012            let handles_before = decoder.remaining_handles();
9013            if let Some((inlined, num_bytes, num_handles)) =
9014                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9015            {
9016                let member_inline_size = <fidl::encoding::Endpoint<
9017                    fidl::endpoints::ServerEnd<RingBufferMarker>,
9018                > as fidl::encoding::TypeMarker>::inline_size(
9019                    decoder.context
9020                );
9021                if inlined != (member_inline_size <= 4) {
9022                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9023                }
9024                let inner_offset;
9025                let mut inner_depth = depth.clone();
9026                if inlined {
9027                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9028                    inner_offset = next_offset;
9029                } else {
9030                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9031                    inner_depth.increment()?;
9032                }
9033                let val_ref = self.ring_buffer_server.get_or_insert_with(|| {
9034                    fidl::new_empty!(
9035                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RingBufferMarker>>,
9036                        fidl::encoding::DefaultFuchsiaResourceDialect
9037                    )
9038                });
9039                fidl::decode!(
9040                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RingBufferMarker>>,
9041                    fidl::encoding::DefaultFuchsiaResourceDialect,
9042                    val_ref,
9043                    decoder,
9044                    inner_offset,
9045                    inner_depth
9046                )?;
9047                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9048                {
9049                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9050                }
9051                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9052                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9053                }
9054            }
9055
9056            next_offset += envelope_size;
9057
9058            // Decode the remaining unknown envelopes.
9059            while next_offset < end_offset {
9060                _next_ordinal_to_read += 1;
9061                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9062                next_offset += envelope_size;
9063            }
9064
9065            Ok(())
9066        }
9067    }
9068
9069    impl ControlCreatorCreateRequest {
9070        #[inline(always)]
9071        fn max_ordinal_present(&self) -> u64 {
9072            if let Some(_) = self.control_server {
9073                return 2;
9074            }
9075            if let Some(_) = self.token_id {
9076                return 1;
9077            }
9078            0
9079        }
9080    }
9081
9082    impl fidl::encoding::ResourceTypeMarker for ControlCreatorCreateRequest {
9083        type Borrowed<'a> = &'a mut Self;
9084        fn take_or_borrow<'a>(
9085            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9086        ) -> Self::Borrowed<'a> {
9087            value
9088        }
9089    }
9090
9091    unsafe impl fidl::encoding::TypeMarker for ControlCreatorCreateRequest {
9092        type Owned = Self;
9093
9094        #[inline(always)]
9095        fn inline_align(_context: fidl::encoding::Context) -> usize {
9096            8
9097        }
9098
9099        #[inline(always)]
9100        fn inline_size(_context: fidl::encoding::Context) -> usize {
9101            16
9102        }
9103    }
9104
9105    unsafe impl
9106        fidl::encoding::Encode<
9107            ControlCreatorCreateRequest,
9108            fidl::encoding::DefaultFuchsiaResourceDialect,
9109        > for &mut ControlCreatorCreateRequest
9110    {
9111        unsafe fn encode(
9112            self,
9113            encoder: &mut fidl::encoding::Encoder<
9114                '_,
9115                fidl::encoding::DefaultFuchsiaResourceDialect,
9116            >,
9117            offset: usize,
9118            mut depth: fidl::encoding::Depth,
9119        ) -> fidl::Result<()> {
9120            encoder.debug_check_bounds::<ControlCreatorCreateRequest>(offset);
9121            // Vector header
9122            let max_ordinal: u64 = self.max_ordinal_present();
9123            encoder.write_num(max_ordinal, offset);
9124            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9125            // Calling encoder.out_of_line_offset(0) is not allowed.
9126            if max_ordinal == 0 {
9127                return Ok(());
9128            }
9129            depth.increment()?;
9130            let envelope_size = 8;
9131            let bytes_len = max_ordinal as usize * envelope_size;
9132            #[allow(unused_variables)]
9133            let offset = encoder.out_of_line_offset(bytes_len);
9134            let mut _prev_end_offset: usize = 0;
9135            if 1 > max_ordinal {
9136                return Ok(());
9137            }
9138
9139            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9140            // are envelope_size bytes.
9141            let cur_offset: usize = (1 - 1) * envelope_size;
9142
9143            // Zero reserved fields.
9144            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9145
9146            // Safety:
9147            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9148            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9149            //   envelope_size bytes, there is always sufficient room.
9150            fidl::encoding::encode_in_envelope_optional::<
9151                u64,
9152                fidl::encoding::DefaultFuchsiaResourceDialect,
9153            >(
9154                self.token_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
9155                encoder,
9156                offset + cur_offset,
9157                depth,
9158            )?;
9159
9160            _prev_end_offset = cur_offset + envelope_size;
9161            if 2 > max_ordinal {
9162                return Ok(());
9163            }
9164
9165            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9166            // are envelope_size bytes.
9167            let cur_offset: usize = (2 - 1) * envelope_size;
9168
9169            // Zero reserved fields.
9170            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9171
9172            // Safety:
9173            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9174            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9175            //   envelope_size bytes, there is always sufficient room.
9176            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
9177            self.control_server.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
9178            encoder, offset + cur_offset, depth
9179        )?;
9180
9181            _prev_end_offset = cur_offset + envelope_size;
9182
9183            Ok(())
9184        }
9185    }
9186
9187    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9188        for ControlCreatorCreateRequest
9189    {
9190        #[inline(always)]
9191        fn new_empty() -> Self {
9192            Self::default()
9193        }
9194
9195        unsafe fn decode(
9196            &mut self,
9197            decoder: &mut fidl::encoding::Decoder<
9198                '_,
9199                fidl::encoding::DefaultFuchsiaResourceDialect,
9200            >,
9201            offset: usize,
9202            mut depth: fidl::encoding::Depth,
9203        ) -> fidl::Result<()> {
9204            decoder.debug_check_bounds::<Self>(offset);
9205            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9206                None => return Err(fidl::Error::NotNullable),
9207                Some(len) => len,
9208            };
9209            // Calling decoder.out_of_line_offset(0) is not allowed.
9210            if len == 0 {
9211                return Ok(());
9212            };
9213            depth.increment()?;
9214            let envelope_size = 8;
9215            let bytes_len = len * envelope_size;
9216            let offset = decoder.out_of_line_offset(bytes_len)?;
9217            // Decode the envelope for each type.
9218            let mut _next_ordinal_to_read = 0;
9219            let mut next_offset = offset;
9220            let end_offset = offset + bytes_len;
9221            _next_ordinal_to_read += 1;
9222            if next_offset >= end_offset {
9223                return Ok(());
9224            }
9225
9226            // Decode unknown envelopes for gaps in ordinals.
9227            while _next_ordinal_to_read < 1 {
9228                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9229                _next_ordinal_to_read += 1;
9230                next_offset += envelope_size;
9231            }
9232
9233            let next_out_of_line = decoder.next_out_of_line();
9234            let handles_before = decoder.remaining_handles();
9235            if let Some((inlined, num_bytes, num_handles)) =
9236                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9237            {
9238                let member_inline_size =
9239                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9240                if inlined != (member_inline_size <= 4) {
9241                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9242                }
9243                let inner_offset;
9244                let mut inner_depth = depth.clone();
9245                if inlined {
9246                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9247                    inner_offset = next_offset;
9248                } else {
9249                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9250                    inner_depth.increment()?;
9251                }
9252                let val_ref = self.token_id.get_or_insert_with(|| {
9253                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
9254                });
9255                fidl::decode!(
9256                    u64,
9257                    fidl::encoding::DefaultFuchsiaResourceDialect,
9258                    val_ref,
9259                    decoder,
9260                    inner_offset,
9261                    inner_depth
9262                )?;
9263                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9264                {
9265                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9266                }
9267                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9268                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9269                }
9270            }
9271
9272            next_offset += envelope_size;
9273            _next_ordinal_to_read += 1;
9274            if next_offset >= end_offset {
9275                return Ok(());
9276            }
9277
9278            // Decode unknown envelopes for gaps in ordinals.
9279            while _next_ordinal_to_read < 2 {
9280                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9281                _next_ordinal_to_read += 1;
9282                next_offset += envelope_size;
9283            }
9284
9285            let next_out_of_line = decoder.next_out_of_line();
9286            let handles_before = decoder.remaining_handles();
9287            if let Some((inlined, num_bytes, num_handles)) =
9288                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9289            {
9290                let member_inline_size = <fidl::encoding::Endpoint<
9291                    fidl::endpoints::ServerEnd<ControlMarker>,
9292                > as fidl::encoding::TypeMarker>::inline_size(
9293                    decoder.context
9294                );
9295                if inlined != (member_inline_size <= 4) {
9296                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9297                }
9298                let inner_offset;
9299                let mut inner_depth = depth.clone();
9300                if inlined {
9301                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9302                    inner_offset = next_offset;
9303                } else {
9304                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9305                    inner_depth.increment()?;
9306                }
9307                let val_ref = self.control_server.get_or_insert_with(|| {
9308                    fidl::new_empty!(
9309                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
9310                        fidl::encoding::DefaultFuchsiaResourceDialect
9311                    )
9312                });
9313                fidl::decode!(
9314                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
9315                    fidl::encoding::DefaultFuchsiaResourceDialect,
9316                    val_ref,
9317                    decoder,
9318                    inner_offset,
9319                    inner_depth
9320                )?;
9321                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9322                {
9323                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9324                }
9325                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9326                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9327                }
9328            }
9329
9330            next_offset += envelope_size;
9331
9332            // Decode the remaining unknown envelopes.
9333            while next_offset < end_offset {
9334                _next_ordinal_to_read += 1;
9335                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9336                next_offset += envelope_size;
9337            }
9338
9339            Ok(())
9340        }
9341    }
9342
9343    impl ControlCreatePacketStreamResponse {
9344        #[inline(always)]
9345        fn max_ordinal_present(&self) -> u64 {
9346            if let Some(_) = self.properties {
9347                return 1;
9348            }
9349            0
9350        }
9351    }
9352
9353    impl fidl::encoding::ResourceTypeMarker for ControlCreatePacketStreamResponse {
9354        type Borrowed<'a> = &'a mut Self;
9355        fn take_or_borrow<'a>(
9356            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9357        ) -> Self::Borrowed<'a> {
9358            value
9359        }
9360    }
9361
9362    unsafe impl fidl::encoding::TypeMarker for ControlCreatePacketStreamResponse {
9363        type Owned = Self;
9364
9365        #[inline(always)]
9366        fn inline_align(_context: fidl::encoding::Context) -> usize {
9367            8
9368        }
9369
9370        #[inline(always)]
9371        fn inline_size(_context: fidl::encoding::Context) -> usize {
9372            16
9373        }
9374    }
9375
9376    unsafe impl
9377        fidl::encoding::Encode<
9378            ControlCreatePacketStreamResponse,
9379            fidl::encoding::DefaultFuchsiaResourceDialect,
9380        > for &mut ControlCreatePacketStreamResponse
9381    {
9382        unsafe fn encode(
9383            self,
9384            encoder: &mut fidl::encoding::Encoder<
9385                '_,
9386                fidl::encoding::DefaultFuchsiaResourceDialect,
9387            >,
9388            offset: usize,
9389            mut depth: fidl::encoding::Depth,
9390        ) -> fidl::Result<()> {
9391            encoder.debug_check_bounds::<ControlCreatePacketStreamResponse>(offset);
9392            // Vector header
9393            let max_ordinal: u64 = self.max_ordinal_present();
9394            encoder.write_num(max_ordinal, offset);
9395            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9396            // Calling encoder.out_of_line_offset(0) is not allowed.
9397            if max_ordinal == 0 {
9398                return Ok(());
9399            }
9400            depth.increment()?;
9401            let envelope_size = 8;
9402            let bytes_len = max_ordinal as usize * envelope_size;
9403            #[allow(unused_variables)]
9404            let offset = encoder.out_of_line_offset(bytes_len);
9405            let mut _prev_end_offset: usize = 0;
9406            if 1 > max_ordinal {
9407                return Ok(());
9408            }
9409
9410            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9411            // are envelope_size bytes.
9412            let cur_offset: usize = (1 - 1) * envelope_size;
9413
9414            // Zero reserved fields.
9415            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9416
9417            // Safety:
9418            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9419            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9420            //   envelope_size bytes, there is always sufficient room.
9421            fidl::encoding::encode_in_envelope_optional::<
9422                PacketStreamProperties,
9423                fidl::encoding::DefaultFuchsiaResourceDialect,
9424            >(
9425                self.properties.as_mut().map(
9426                    <PacketStreamProperties as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
9427                ),
9428                encoder,
9429                offset + cur_offset,
9430                depth,
9431            )?;
9432
9433            _prev_end_offset = cur_offset + envelope_size;
9434
9435            Ok(())
9436        }
9437    }
9438
9439    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9440        for ControlCreatePacketStreamResponse
9441    {
9442        #[inline(always)]
9443        fn new_empty() -> Self {
9444            Self::default()
9445        }
9446
9447        unsafe fn decode(
9448            &mut self,
9449            decoder: &mut fidl::encoding::Decoder<
9450                '_,
9451                fidl::encoding::DefaultFuchsiaResourceDialect,
9452            >,
9453            offset: usize,
9454            mut depth: fidl::encoding::Depth,
9455        ) -> fidl::Result<()> {
9456            decoder.debug_check_bounds::<Self>(offset);
9457            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9458                None => return Err(fidl::Error::NotNullable),
9459                Some(len) => len,
9460            };
9461            // Calling decoder.out_of_line_offset(0) is not allowed.
9462            if len == 0 {
9463                return Ok(());
9464            };
9465            depth.increment()?;
9466            let envelope_size = 8;
9467            let bytes_len = len * envelope_size;
9468            let offset = decoder.out_of_line_offset(bytes_len)?;
9469            // Decode the envelope for each type.
9470            let mut _next_ordinal_to_read = 0;
9471            let mut next_offset = offset;
9472            let end_offset = offset + bytes_len;
9473            _next_ordinal_to_read += 1;
9474            if next_offset >= end_offset {
9475                return Ok(());
9476            }
9477
9478            // Decode unknown envelopes for gaps in ordinals.
9479            while _next_ordinal_to_read < 1 {
9480                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9481                _next_ordinal_to_read += 1;
9482                next_offset += envelope_size;
9483            }
9484
9485            let next_out_of_line = decoder.next_out_of_line();
9486            let handles_before = decoder.remaining_handles();
9487            if let Some((inlined, num_bytes, num_handles)) =
9488                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9489            {
9490                let member_inline_size =
9491                    <PacketStreamProperties as fidl::encoding::TypeMarker>::inline_size(
9492                        decoder.context,
9493                    );
9494                if inlined != (member_inline_size <= 4) {
9495                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9496                }
9497                let inner_offset;
9498                let mut inner_depth = depth.clone();
9499                if inlined {
9500                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9501                    inner_offset = next_offset;
9502                } else {
9503                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9504                    inner_depth.increment()?;
9505                }
9506                let val_ref = self.properties.get_or_insert_with(|| {
9507                    fidl::new_empty!(
9508                        PacketStreamProperties,
9509                        fidl::encoding::DefaultFuchsiaResourceDialect
9510                    )
9511                });
9512                fidl::decode!(
9513                    PacketStreamProperties,
9514                    fidl::encoding::DefaultFuchsiaResourceDialect,
9515                    val_ref,
9516                    decoder,
9517                    inner_offset,
9518                    inner_depth
9519                )?;
9520                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9521                {
9522                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9523                }
9524                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9525                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9526                }
9527            }
9528
9529            next_offset += envelope_size;
9530
9531            // Decode the remaining unknown envelopes.
9532            while next_offset < end_offset {
9533                _next_ordinal_to_read += 1;
9534                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9535                next_offset += envelope_size;
9536            }
9537
9538            Ok(())
9539        }
9540    }
9541
9542    impl ControlCreateRingBufferResponse {
9543        #[inline(always)]
9544        fn max_ordinal_present(&self) -> u64 {
9545            if let Some(_) = self.ring_buffer {
9546                return 2;
9547            }
9548            if let Some(_) = self.properties {
9549                return 1;
9550            }
9551            0
9552        }
9553    }
9554
9555    impl fidl::encoding::ResourceTypeMarker for ControlCreateRingBufferResponse {
9556        type Borrowed<'a> = &'a mut Self;
9557        fn take_or_borrow<'a>(
9558            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9559        ) -> Self::Borrowed<'a> {
9560            value
9561        }
9562    }
9563
9564    unsafe impl fidl::encoding::TypeMarker for ControlCreateRingBufferResponse {
9565        type Owned = Self;
9566
9567        #[inline(always)]
9568        fn inline_align(_context: fidl::encoding::Context) -> usize {
9569            8
9570        }
9571
9572        #[inline(always)]
9573        fn inline_size(_context: fidl::encoding::Context) -> usize {
9574            16
9575        }
9576    }
9577
9578    unsafe impl
9579        fidl::encoding::Encode<
9580            ControlCreateRingBufferResponse,
9581            fidl::encoding::DefaultFuchsiaResourceDialect,
9582        > for &mut ControlCreateRingBufferResponse
9583    {
9584        unsafe fn encode(
9585            self,
9586            encoder: &mut fidl::encoding::Encoder<
9587                '_,
9588                fidl::encoding::DefaultFuchsiaResourceDialect,
9589            >,
9590            offset: usize,
9591            mut depth: fidl::encoding::Depth,
9592        ) -> fidl::Result<()> {
9593            encoder.debug_check_bounds::<ControlCreateRingBufferResponse>(offset);
9594            // Vector header
9595            let max_ordinal: u64 = self.max_ordinal_present();
9596            encoder.write_num(max_ordinal, offset);
9597            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9598            // Calling encoder.out_of_line_offset(0) is not allowed.
9599            if max_ordinal == 0 {
9600                return Ok(());
9601            }
9602            depth.increment()?;
9603            let envelope_size = 8;
9604            let bytes_len = max_ordinal as usize * envelope_size;
9605            #[allow(unused_variables)]
9606            let offset = encoder.out_of_line_offset(bytes_len);
9607            let mut _prev_end_offset: usize = 0;
9608            if 1 > max_ordinal {
9609                return Ok(());
9610            }
9611
9612            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9613            // are envelope_size bytes.
9614            let cur_offset: usize = (1 - 1) * envelope_size;
9615
9616            // Zero reserved fields.
9617            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9618
9619            // Safety:
9620            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9621            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9622            //   envelope_size bytes, there is always sufficient room.
9623            fidl::encoding::encode_in_envelope_optional::<
9624                RingBufferProperties,
9625                fidl::encoding::DefaultFuchsiaResourceDialect,
9626            >(
9627                self.properties
9628                    .as_ref()
9629                    .map(<RingBufferProperties as fidl::encoding::ValueTypeMarker>::borrow),
9630                encoder,
9631                offset + cur_offset,
9632                depth,
9633            )?;
9634
9635            _prev_end_offset = cur_offset + envelope_size;
9636            if 2 > max_ordinal {
9637                return Ok(());
9638            }
9639
9640            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9641            // are envelope_size bytes.
9642            let cur_offset: usize = (2 - 1) * envelope_size;
9643
9644            // Zero reserved fields.
9645            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9646
9647            // Safety:
9648            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9649            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9650            //   envelope_size bytes, there is always sufficient room.
9651            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_audio::RingBuffer, fidl::encoding::DefaultFuchsiaResourceDialect>(
9652            self.ring_buffer.as_mut().map(<fidl_fuchsia_audio::RingBuffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
9653            encoder, offset + cur_offset, depth
9654        )?;
9655
9656            _prev_end_offset = cur_offset + envelope_size;
9657
9658            Ok(())
9659        }
9660    }
9661
9662    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9663        for ControlCreateRingBufferResponse
9664    {
9665        #[inline(always)]
9666        fn new_empty() -> Self {
9667            Self::default()
9668        }
9669
9670        unsafe fn decode(
9671            &mut self,
9672            decoder: &mut fidl::encoding::Decoder<
9673                '_,
9674                fidl::encoding::DefaultFuchsiaResourceDialect,
9675            >,
9676            offset: usize,
9677            mut depth: fidl::encoding::Depth,
9678        ) -> fidl::Result<()> {
9679            decoder.debug_check_bounds::<Self>(offset);
9680            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9681                None => return Err(fidl::Error::NotNullable),
9682                Some(len) => len,
9683            };
9684            // Calling decoder.out_of_line_offset(0) is not allowed.
9685            if len == 0 {
9686                return Ok(());
9687            };
9688            depth.increment()?;
9689            let envelope_size = 8;
9690            let bytes_len = len * envelope_size;
9691            let offset = decoder.out_of_line_offset(bytes_len)?;
9692            // Decode the envelope for each type.
9693            let mut _next_ordinal_to_read = 0;
9694            let mut next_offset = offset;
9695            let end_offset = offset + bytes_len;
9696            _next_ordinal_to_read += 1;
9697            if next_offset >= end_offset {
9698                return Ok(());
9699            }
9700
9701            // Decode unknown envelopes for gaps in ordinals.
9702            while _next_ordinal_to_read < 1 {
9703                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9704                _next_ordinal_to_read += 1;
9705                next_offset += envelope_size;
9706            }
9707
9708            let next_out_of_line = decoder.next_out_of_line();
9709            let handles_before = decoder.remaining_handles();
9710            if let Some((inlined, num_bytes, num_handles)) =
9711                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9712            {
9713                let member_inline_size =
9714                    <RingBufferProperties as fidl::encoding::TypeMarker>::inline_size(
9715                        decoder.context,
9716                    );
9717                if inlined != (member_inline_size <= 4) {
9718                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9719                }
9720                let inner_offset;
9721                let mut inner_depth = depth.clone();
9722                if inlined {
9723                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9724                    inner_offset = next_offset;
9725                } else {
9726                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9727                    inner_depth.increment()?;
9728                }
9729                let val_ref = self.properties.get_or_insert_with(|| {
9730                    fidl::new_empty!(
9731                        RingBufferProperties,
9732                        fidl::encoding::DefaultFuchsiaResourceDialect
9733                    )
9734                });
9735                fidl::decode!(
9736                    RingBufferProperties,
9737                    fidl::encoding::DefaultFuchsiaResourceDialect,
9738                    val_ref,
9739                    decoder,
9740                    inner_offset,
9741                    inner_depth
9742                )?;
9743                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9744                {
9745                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9746                }
9747                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9748                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9749                }
9750            }
9751
9752            next_offset += envelope_size;
9753            _next_ordinal_to_read += 1;
9754            if next_offset >= end_offset {
9755                return Ok(());
9756            }
9757
9758            // Decode unknown envelopes for gaps in ordinals.
9759            while _next_ordinal_to_read < 2 {
9760                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9761                _next_ordinal_to_read += 1;
9762                next_offset += envelope_size;
9763            }
9764
9765            let next_out_of_line = decoder.next_out_of_line();
9766            let handles_before = decoder.remaining_handles();
9767            if let Some((inlined, num_bytes, num_handles)) =
9768                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9769            {
9770                let member_inline_size =
9771                    <fidl_fuchsia_audio::RingBuffer as fidl::encoding::TypeMarker>::inline_size(
9772                        decoder.context,
9773                    );
9774                if inlined != (member_inline_size <= 4) {
9775                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9776                }
9777                let inner_offset;
9778                let mut inner_depth = depth.clone();
9779                if inlined {
9780                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9781                    inner_offset = next_offset;
9782                } else {
9783                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9784                    inner_depth.increment()?;
9785                }
9786                let val_ref = self.ring_buffer.get_or_insert_with(|| {
9787                    fidl::new_empty!(
9788                        fidl_fuchsia_audio::RingBuffer,
9789                        fidl::encoding::DefaultFuchsiaResourceDialect
9790                    )
9791                });
9792                fidl::decode!(
9793                    fidl_fuchsia_audio::RingBuffer,
9794                    fidl::encoding::DefaultFuchsiaResourceDialect,
9795                    val_ref,
9796                    decoder,
9797                    inner_offset,
9798                    inner_depth
9799                )?;
9800                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9801                {
9802                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9803                }
9804                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9805                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9806                }
9807            }
9808
9809            next_offset += envelope_size;
9810
9811            // Decode the remaining unknown envelopes.
9812            while next_offset < end_offset {
9813                _next_ordinal_to_read += 1;
9814                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9815                next_offset += envelope_size;
9816            }
9817
9818            Ok(())
9819        }
9820    }
9821
9822    impl ObserverGetReferenceClockResponse {
9823        #[inline(always)]
9824        fn max_ordinal_present(&self) -> u64 {
9825            if let Some(_) = self.reference_clock {
9826                return 1;
9827            }
9828            0
9829        }
9830    }
9831
9832    impl fidl::encoding::ResourceTypeMarker for ObserverGetReferenceClockResponse {
9833        type Borrowed<'a> = &'a mut Self;
9834        fn take_or_borrow<'a>(
9835            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9836        ) -> Self::Borrowed<'a> {
9837            value
9838        }
9839    }
9840
9841    unsafe impl fidl::encoding::TypeMarker for ObserverGetReferenceClockResponse {
9842        type Owned = Self;
9843
9844        #[inline(always)]
9845        fn inline_align(_context: fidl::encoding::Context) -> usize {
9846            8
9847        }
9848
9849        #[inline(always)]
9850        fn inline_size(_context: fidl::encoding::Context) -> usize {
9851            16
9852        }
9853    }
9854
9855    unsafe impl
9856        fidl::encoding::Encode<
9857            ObserverGetReferenceClockResponse,
9858            fidl::encoding::DefaultFuchsiaResourceDialect,
9859        > for &mut ObserverGetReferenceClockResponse
9860    {
9861        unsafe fn encode(
9862            self,
9863            encoder: &mut fidl::encoding::Encoder<
9864                '_,
9865                fidl::encoding::DefaultFuchsiaResourceDialect,
9866            >,
9867            offset: usize,
9868            mut depth: fidl::encoding::Depth,
9869        ) -> fidl::Result<()> {
9870            encoder.debug_check_bounds::<ObserverGetReferenceClockResponse>(offset);
9871            // Vector header
9872            let max_ordinal: u64 = self.max_ordinal_present();
9873            encoder.write_num(max_ordinal, offset);
9874            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9875            // Calling encoder.out_of_line_offset(0) is not allowed.
9876            if max_ordinal == 0 {
9877                return Ok(());
9878            }
9879            depth.increment()?;
9880            let envelope_size = 8;
9881            let bytes_len = max_ordinal as usize * envelope_size;
9882            #[allow(unused_variables)]
9883            let offset = encoder.out_of_line_offset(bytes_len);
9884            let mut _prev_end_offset: usize = 0;
9885            if 1 > max_ordinal {
9886                return Ok(());
9887            }
9888
9889            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9890            // are envelope_size bytes.
9891            let cur_offset: usize = (1 - 1) * envelope_size;
9892
9893            // Zero reserved fields.
9894            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9895
9896            // Safety:
9897            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9898            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9899            //   envelope_size bytes, there is always sufficient room.
9900            fidl::encoding::encode_in_envelope_optional::<
9901                fidl::encoding::HandleType<
9902                    fidl::Clock,
9903                    { fidl::ObjectType::CLOCK.into_raw() },
9904                    2147483648,
9905                >,
9906                fidl::encoding::DefaultFuchsiaResourceDialect,
9907            >(
9908                self.reference_clock.as_mut().map(
9909                    <fidl::encoding::HandleType<
9910                        fidl::Clock,
9911                        { fidl::ObjectType::CLOCK.into_raw() },
9912                        2147483648,
9913                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
9914                ),
9915                encoder,
9916                offset + cur_offset,
9917                depth,
9918            )?;
9919
9920            _prev_end_offset = cur_offset + envelope_size;
9921
9922            Ok(())
9923        }
9924    }
9925
9926    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9927        for ObserverGetReferenceClockResponse
9928    {
9929        #[inline(always)]
9930        fn new_empty() -> Self {
9931            Self::default()
9932        }
9933
9934        unsafe fn decode(
9935            &mut self,
9936            decoder: &mut fidl::encoding::Decoder<
9937                '_,
9938                fidl::encoding::DefaultFuchsiaResourceDialect,
9939            >,
9940            offset: usize,
9941            mut depth: fidl::encoding::Depth,
9942        ) -> fidl::Result<()> {
9943            decoder.debug_check_bounds::<Self>(offset);
9944            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9945                None => return Err(fidl::Error::NotNullable),
9946                Some(len) => len,
9947            };
9948            // Calling decoder.out_of_line_offset(0) is not allowed.
9949            if len == 0 {
9950                return Ok(());
9951            };
9952            depth.increment()?;
9953            let envelope_size = 8;
9954            let bytes_len = len * envelope_size;
9955            let offset = decoder.out_of_line_offset(bytes_len)?;
9956            // Decode the envelope for each type.
9957            let mut _next_ordinal_to_read = 0;
9958            let mut next_offset = offset;
9959            let end_offset = offset + bytes_len;
9960            _next_ordinal_to_read += 1;
9961            if next_offset >= end_offset {
9962                return Ok(());
9963            }
9964
9965            // Decode unknown envelopes for gaps in ordinals.
9966            while _next_ordinal_to_read < 1 {
9967                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9968                _next_ordinal_to_read += 1;
9969                next_offset += envelope_size;
9970            }
9971
9972            let next_out_of_line = decoder.next_out_of_line();
9973            let handles_before = decoder.remaining_handles();
9974            if let Some((inlined, num_bytes, num_handles)) =
9975                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9976            {
9977                let member_inline_size = <fidl::encoding::HandleType<
9978                    fidl::Clock,
9979                    { fidl::ObjectType::CLOCK.into_raw() },
9980                    2147483648,
9981                > as fidl::encoding::TypeMarker>::inline_size(
9982                    decoder.context
9983                );
9984                if inlined != (member_inline_size <= 4) {
9985                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9986                }
9987                let inner_offset;
9988                let mut inner_depth = depth.clone();
9989                if inlined {
9990                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9991                    inner_offset = next_offset;
9992                } else {
9993                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9994                    inner_depth.increment()?;
9995                }
9996                let val_ref =
9997                self.reference_clock.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
9998                fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
9999                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10000                {
10001                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10002                }
10003                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10004                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10005                }
10006            }
10007
10008            next_offset += envelope_size;
10009
10010            // Decode the remaining unknown envelopes.
10011            while next_offset < end_offset {
10012                _next_ordinal_to_read += 1;
10013                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10014                next_offset += envelope_size;
10015            }
10016
10017            Ok(())
10018        }
10019    }
10020
10021    impl PacketStreamBuffers {
10022        #[inline(always)]
10023        fn max_ordinal_present(&self) -> u64 {
10024            if let Some(_) = self.vmo_infos {
10025                return 1;
10026            }
10027            0
10028        }
10029    }
10030
10031    impl fidl::encoding::ResourceTypeMarker for PacketStreamBuffers {
10032        type Borrowed<'a> = &'a mut Self;
10033        fn take_or_borrow<'a>(
10034            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10035        ) -> Self::Borrowed<'a> {
10036            value
10037        }
10038    }
10039
10040    unsafe impl fidl::encoding::TypeMarker for PacketStreamBuffers {
10041        type Owned = Self;
10042
10043        #[inline(always)]
10044        fn inline_align(_context: fidl::encoding::Context) -> usize {
10045            8
10046        }
10047
10048        #[inline(always)]
10049        fn inline_size(_context: fidl::encoding::Context) -> usize {
10050            16
10051        }
10052    }
10053
10054    unsafe impl
10055        fidl::encoding::Encode<PacketStreamBuffers, fidl::encoding::DefaultFuchsiaResourceDialect>
10056        for &mut PacketStreamBuffers
10057    {
10058        unsafe fn encode(
10059            self,
10060            encoder: &mut fidl::encoding::Encoder<
10061                '_,
10062                fidl::encoding::DefaultFuchsiaResourceDialect,
10063            >,
10064            offset: usize,
10065            mut depth: fidl::encoding::Depth,
10066        ) -> fidl::Result<()> {
10067            encoder.debug_check_bounds::<PacketStreamBuffers>(offset);
10068            // Vector header
10069            let max_ordinal: u64 = self.max_ordinal_present();
10070            encoder.write_num(max_ordinal, offset);
10071            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10072            // Calling encoder.out_of_line_offset(0) is not allowed.
10073            if max_ordinal == 0 {
10074                return Ok(());
10075            }
10076            depth.increment()?;
10077            let envelope_size = 8;
10078            let bytes_len = max_ordinal as usize * envelope_size;
10079            #[allow(unused_variables)]
10080            let offset = encoder.out_of_line_offset(bytes_len);
10081            let mut _prev_end_offset: usize = 0;
10082            if 1 > max_ordinal {
10083                return Ok(());
10084            }
10085
10086            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10087            // are envelope_size bytes.
10088            let cur_offset: usize = (1 - 1) * envelope_size;
10089
10090            // Zero reserved fields.
10091            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10092
10093            // Safety:
10094            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10095            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10096            //   envelope_size bytes, there is always sufficient room.
10097            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl_fuchsia_hardware_audio::VmoInfo, 256>, fidl::encoding::DefaultFuchsiaResourceDialect>(
10098            self.vmo_infos.as_mut().map(<fidl::encoding::Vector<fidl_fuchsia_hardware_audio::VmoInfo, 256> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
10099            encoder, offset + cur_offset, depth
10100        )?;
10101
10102            _prev_end_offset = cur_offset + envelope_size;
10103
10104            Ok(())
10105        }
10106    }
10107
10108    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10109        for PacketStreamBuffers
10110    {
10111        #[inline(always)]
10112        fn new_empty() -> Self {
10113            Self::default()
10114        }
10115
10116        unsafe fn decode(
10117            &mut self,
10118            decoder: &mut fidl::encoding::Decoder<
10119                '_,
10120                fidl::encoding::DefaultFuchsiaResourceDialect,
10121            >,
10122            offset: usize,
10123            mut depth: fidl::encoding::Depth,
10124        ) -> fidl::Result<()> {
10125            decoder.debug_check_bounds::<Self>(offset);
10126            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10127                None => return Err(fidl::Error::NotNullable),
10128                Some(len) => len,
10129            };
10130            // Calling decoder.out_of_line_offset(0) is not allowed.
10131            if len == 0 {
10132                return Ok(());
10133            };
10134            depth.increment()?;
10135            let envelope_size = 8;
10136            let bytes_len = len * envelope_size;
10137            let offset = decoder.out_of_line_offset(bytes_len)?;
10138            // Decode the envelope for each type.
10139            let mut _next_ordinal_to_read = 0;
10140            let mut next_offset = offset;
10141            let end_offset = offset + bytes_len;
10142            _next_ordinal_to_read += 1;
10143            if next_offset >= end_offset {
10144                return Ok(());
10145            }
10146
10147            // Decode unknown envelopes for gaps in ordinals.
10148            while _next_ordinal_to_read < 1 {
10149                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10150                _next_ordinal_to_read += 1;
10151                next_offset += envelope_size;
10152            }
10153
10154            let next_out_of_line = decoder.next_out_of_line();
10155            let handles_before = decoder.remaining_handles();
10156            if let Some((inlined, num_bytes, num_handles)) =
10157                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10158            {
10159                let member_inline_size = <fidl::encoding::Vector<
10160                    fidl_fuchsia_hardware_audio::VmoInfo,
10161                    256,
10162                > as fidl::encoding::TypeMarker>::inline_size(
10163                    decoder.context
10164                );
10165                if inlined != (member_inline_size <= 4) {
10166                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10167                }
10168                let inner_offset;
10169                let mut inner_depth = depth.clone();
10170                if inlined {
10171                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10172                    inner_offset = next_offset;
10173                } else {
10174                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10175                    inner_depth.increment()?;
10176                }
10177                let val_ref =
10178                self.vmo_infos.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_hardware_audio::VmoInfo, 256>, fidl::encoding::DefaultFuchsiaResourceDialect));
10179                fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_hardware_audio::VmoInfo, 256>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
10180                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10181                {
10182                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10183                }
10184                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10185                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10186                }
10187            }
10188
10189            next_offset += envelope_size;
10190
10191            // Decode the remaining unknown envelopes.
10192            while next_offset < end_offset {
10193                _next_ordinal_to_read += 1;
10194                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10195                next_offset += envelope_size;
10196            }
10197
10198            Ok(())
10199        }
10200    }
10201
10202    impl PacketStreamOptions {
10203        #[inline(always)]
10204        fn max_ordinal_present(&self) -> u64 {
10205            if let Some(_) = self.format {
10206                return 1;
10207            }
10208            0
10209        }
10210    }
10211
10212    impl fidl::encoding::ResourceTypeMarker for PacketStreamOptions {
10213        type Borrowed<'a> = &'a mut Self;
10214        fn take_or_borrow<'a>(
10215            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10216        ) -> Self::Borrowed<'a> {
10217            value
10218        }
10219    }
10220
10221    unsafe impl fidl::encoding::TypeMarker for PacketStreamOptions {
10222        type Owned = Self;
10223
10224        #[inline(always)]
10225        fn inline_align(_context: fidl::encoding::Context) -> usize {
10226            8
10227        }
10228
10229        #[inline(always)]
10230        fn inline_size(_context: fidl::encoding::Context) -> usize {
10231            16
10232        }
10233    }
10234
10235    unsafe impl
10236        fidl::encoding::Encode<PacketStreamOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
10237        for &mut PacketStreamOptions
10238    {
10239        unsafe fn encode(
10240            self,
10241            encoder: &mut fidl::encoding::Encoder<
10242                '_,
10243                fidl::encoding::DefaultFuchsiaResourceDialect,
10244            >,
10245            offset: usize,
10246            mut depth: fidl::encoding::Depth,
10247        ) -> fidl::Result<()> {
10248            encoder.debug_check_bounds::<PacketStreamOptions>(offset);
10249            // Vector header
10250            let max_ordinal: u64 = self.max_ordinal_present();
10251            encoder.write_num(max_ordinal, offset);
10252            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10253            // Calling encoder.out_of_line_offset(0) is not allowed.
10254            if max_ordinal == 0 {
10255                return Ok(());
10256            }
10257            depth.increment()?;
10258            let envelope_size = 8;
10259            let bytes_len = max_ordinal as usize * envelope_size;
10260            #[allow(unused_variables)]
10261            let offset = encoder.out_of_line_offset(bytes_len);
10262            let mut _prev_end_offset: usize = 0;
10263            if 1 > max_ordinal {
10264                return Ok(());
10265            }
10266
10267            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10268            // are envelope_size bytes.
10269            let cur_offset: usize = (1 - 1) * envelope_size;
10270
10271            // Zero reserved fields.
10272            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10273
10274            // Safety:
10275            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10276            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10277            //   envelope_size bytes, there is always sufficient room.
10278            fidl::encoding::encode_in_envelope_optional::<
10279                PacketStreamFormat,
10280                fidl::encoding::DefaultFuchsiaResourceDialect,
10281            >(
10282                self.format
10283                    .as_ref()
10284                    .map(<PacketStreamFormat as fidl::encoding::ValueTypeMarker>::borrow),
10285                encoder,
10286                offset + cur_offset,
10287                depth,
10288            )?;
10289
10290            _prev_end_offset = cur_offset + envelope_size;
10291
10292            Ok(())
10293        }
10294    }
10295
10296    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10297        for PacketStreamOptions
10298    {
10299        #[inline(always)]
10300        fn new_empty() -> Self {
10301            Self::default()
10302        }
10303
10304        unsafe fn decode(
10305            &mut self,
10306            decoder: &mut fidl::encoding::Decoder<
10307                '_,
10308                fidl::encoding::DefaultFuchsiaResourceDialect,
10309            >,
10310            offset: usize,
10311            mut depth: fidl::encoding::Depth,
10312        ) -> fidl::Result<()> {
10313            decoder.debug_check_bounds::<Self>(offset);
10314            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10315                None => return Err(fidl::Error::NotNullable),
10316                Some(len) => len,
10317            };
10318            // Calling decoder.out_of_line_offset(0) is not allowed.
10319            if len == 0 {
10320                return Ok(());
10321            };
10322            depth.increment()?;
10323            let envelope_size = 8;
10324            let bytes_len = len * envelope_size;
10325            let offset = decoder.out_of_line_offset(bytes_len)?;
10326            // Decode the envelope for each type.
10327            let mut _next_ordinal_to_read = 0;
10328            let mut next_offset = offset;
10329            let end_offset = offset + bytes_len;
10330            _next_ordinal_to_read += 1;
10331            if next_offset >= end_offset {
10332                return Ok(());
10333            }
10334
10335            // Decode unknown envelopes for gaps in ordinals.
10336            while _next_ordinal_to_read < 1 {
10337                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10338                _next_ordinal_to_read += 1;
10339                next_offset += envelope_size;
10340            }
10341
10342            let next_out_of_line = decoder.next_out_of_line();
10343            let handles_before = decoder.remaining_handles();
10344            if let Some((inlined, num_bytes, num_handles)) =
10345                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10346            {
10347                let member_inline_size =
10348                    <PacketStreamFormat as fidl::encoding::TypeMarker>::inline_size(
10349                        decoder.context,
10350                    );
10351                if inlined != (member_inline_size <= 4) {
10352                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10353                }
10354                let inner_offset;
10355                let mut inner_depth = depth.clone();
10356                if inlined {
10357                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10358                    inner_offset = next_offset;
10359                } else {
10360                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10361                    inner_depth.increment()?;
10362                }
10363                let val_ref = self.format.get_or_insert_with(|| {
10364                    fidl::new_empty!(
10365                        PacketStreamFormat,
10366                        fidl::encoding::DefaultFuchsiaResourceDialect
10367                    )
10368                });
10369                fidl::decode!(
10370                    PacketStreamFormat,
10371                    fidl::encoding::DefaultFuchsiaResourceDialect,
10372                    val_ref,
10373                    decoder,
10374                    inner_offset,
10375                    inner_depth
10376                )?;
10377                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10378                {
10379                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10380                }
10381                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10382                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10383                }
10384            }
10385
10386            next_offset += envelope_size;
10387
10388            // Decode the remaining unknown envelopes.
10389            while next_offset < end_offset {
10390                _next_ordinal_to_read += 1;
10391                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10392                next_offset += envelope_size;
10393            }
10394
10395            Ok(())
10396        }
10397    }
10398
10399    impl PacketStreamProperties {
10400        #[inline(always)]
10401        fn max_ordinal_present(&self) -> u64 {
10402            if let Some(_) = self.supported_buffer_types {
10403                return 4;
10404            }
10405            if let Some(_) = self.valid_bits_per_sample {
10406                return 3;
10407            }
10408            if let Some(_) = self.format {
10409                return 2;
10410            }
10411            if let Some(_) = self.data_sink {
10412                return 1;
10413            }
10414            0
10415        }
10416    }
10417
10418    impl fidl::encoding::ResourceTypeMarker for PacketStreamProperties {
10419        type Borrowed<'a> = &'a mut Self;
10420        fn take_or_borrow<'a>(
10421            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10422        ) -> Self::Borrowed<'a> {
10423            value
10424        }
10425    }
10426
10427    unsafe impl fidl::encoding::TypeMarker for PacketStreamProperties {
10428        type Owned = Self;
10429
10430        #[inline(always)]
10431        fn inline_align(_context: fidl::encoding::Context) -> usize {
10432            8
10433        }
10434
10435        #[inline(always)]
10436        fn inline_size(_context: fidl::encoding::Context) -> usize {
10437            16
10438        }
10439    }
10440
10441    unsafe impl
10442        fidl::encoding::Encode<
10443            PacketStreamProperties,
10444            fidl::encoding::DefaultFuchsiaResourceDialect,
10445        > for &mut PacketStreamProperties
10446    {
10447        unsafe fn encode(
10448            self,
10449            encoder: &mut fidl::encoding::Encoder<
10450                '_,
10451                fidl::encoding::DefaultFuchsiaResourceDialect,
10452            >,
10453            offset: usize,
10454            mut depth: fidl::encoding::Depth,
10455        ) -> fidl::Result<()> {
10456            encoder.debug_check_bounds::<PacketStreamProperties>(offset);
10457            // Vector header
10458            let max_ordinal: u64 = self.max_ordinal_present();
10459            encoder.write_num(max_ordinal, offset);
10460            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10461            // Calling encoder.out_of_line_offset(0) is not allowed.
10462            if max_ordinal == 0 {
10463                return Ok(());
10464            }
10465            depth.increment()?;
10466            let envelope_size = 8;
10467            let bytes_len = max_ordinal as usize * envelope_size;
10468            #[allow(unused_variables)]
10469            let offset = encoder.out_of_line_offset(bytes_len);
10470            let mut _prev_end_offset: usize = 0;
10471            if 1 > max_ordinal {
10472                return Ok(());
10473            }
10474
10475            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10476            // are envelope_size bytes.
10477            let cur_offset: usize = (1 - 1) * envelope_size;
10478
10479            // Zero reserved fields.
10480            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10481
10482            // Safety:
10483            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10484            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10485            //   envelope_size bytes, there is always sufficient room.
10486            fidl::encoding::encode_in_envelope_optional::<
10487                fidl::encoding::Endpoint<
10488                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::PacketStreamSinkMarker>,
10489                >,
10490                fidl::encoding::DefaultFuchsiaResourceDialect,
10491            >(
10492                self.data_sink.as_mut().map(
10493                    <fidl::encoding::Endpoint<
10494                        fidl::endpoints::ClientEnd<
10495                            fidl_fuchsia_hardware_audio::PacketStreamSinkMarker,
10496                        >,
10497                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
10498                ),
10499                encoder,
10500                offset + cur_offset,
10501                depth,
10502            )?;
10503
10504            _prev_end_offset = cur_offset + envelope_size;
10505            if 2 > max_ordinal {
10506                return Ok(());
10507            }
10508
10509            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10510            // are envelope_size bytes.
10511            let cur_offset: usize = (2 - 1) * envelope_size;
10512
10513            // Zero reserved fields.
10514            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10515
10516            // Safety:
10517            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10518            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10519            //   envelope_size bytes, there is always sufficient room.
10520            fidl::encoding::encode_in_envelope_optional::<
10521                PacketStreamFormat,
10522                fidl::encoding::DefaultFuchsiaResourceDialect,
10523            >(
10524                self.format
10525                    .as_ref()
10526                    .map(<PacketStreamFormat as fidl::encoding::ValueTypeMarker>::borrow),
10527                encoder,
10528                offset + cur_offset,
10529                depth,
10530            )?;
10531
10532            _prev_end_offset = cur_offset + envelope_size;
10533            if 3 > max_ordinal {
10534                return Ok(());
10535            }
10536
10537            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10538            // are envelope_size bytes.
10539            let cur_offset: usize = (3 - 1) * envelope_size;
10540
10541            // Zero reserved fields.
10542            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10543
10544            // Safety:
10545            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10546            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10547            //   envelope_size bytes, there is always sufficient room.
10548            fidl::encoding::encode_in_envelope_optional::<
10549                u8,
10550                fidl::encoding::DefaultFuchsiaResourceDialect,
10551            >(
10552                self.valid_bits_per_sample
10553                    .as_ref()
10554                    .map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
10555                encoder,
10556                offset + cur_offset,
10557                depth,
10558            )?;
10559
10560            _prev_end_offset = cur_offset + envelope_size;
10561            if 4 > max_ordinal {
10562                return Ok(());
10563            }
10564
10565            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10566            // are envelope_size bytes.
10567            let cur_offset: usize = (4 - 1) * envelope_size;
10568
10569            // Zero reserved fields.
10570            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10571
10572            // Safety:
10573            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10574            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10575            //   envelope_size bytes, there is always sufficient room.
10576            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_hardware_audio::BufferType, fidl::encoding::DefaultFuchsiaResourceDialect>(
10577            self.supported_buffer_types.as_ref().map(<fidl_fuchsia_hardware_audio::BufferType as fidl::encoding::ValueTypeMarker>::borrow),
10578            encoder, offset + cur_offset, depth
10579        )?;
10580
10581            _prev_end_offset = cur_offset + envelope_size;
10582
10583            Ok(())
10584        }
10585    }
10586
10587    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10588        for PacketStreamProperties
10589    {
10590        #[inline(always)]
10591        fn new_empty() -> Self {
10592            Self::default()
10593        }
10594
10595        unsafe fn decode(
10596            &mut self,
10597            decoder: &mut fidl::encoding::Decoder<
10598                '_,
10599                fidl::encoding::DefaultFuchsiaResourceDialect,
10600            >,
10601            offset: usize,
10602            mut depth: fidl::encoding::Depth,
10603        ) -> fidl::Result<()> {
10604            decoder.debug_check_bounds::<Self>(offset);
10605            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10606                None => return Err(fidl::Error::NotNullable),
10607                Some(len) => len,
10608            };
10609            // Calling decoder.out_of_line_offset(0) is not allowed.
10610            if len == 0 {
10611                return Ok(());
10612            };
10613            depth.increment()?;
10614            let envelope_size = 8;
10615            let bytes_len = len * envelope_size;
10616            let offset = decoder.out_of_line_offset(bytes_len)?;
10617            // Decode the envelope for each type.
10618            let mut _next_ordinal_to_read = 0;
10619            let mut next_offset = offset;
10620            let end_offset = offset + bytes_len;
10621            _next_ordinal_to_read += 1;
10622            if next_offset >= end_offset {
10623                return Ok(());
10624            }
10625
10626            // Decode unknown envelopes for gaps in ordinals.
10627            while _next_ordinal_to_read < 1 {
10628                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10629                _next_ordinal_to_read += 1;
10630                next_offset += envelope_size;
10631            }
10632
10633            let next_out_of_line = decoder.next_out_of_line();
10634            let handles_before = decoder.remaining_handles();
10635            if let Some((inlined, num_bytes, num_handles)) =
10636                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10637            {
10638                let member_inline_size = <fidl::encoding::Endpoint<
10639                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::PacketStreamSinkMarker>,
10640                > as fidl::encoding::TypeMarker>::inline_size(
10641                    decoder.context
10642                );
10643                if inlined != (member_inline_size <= 4) {
10644                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10645                }
10646                let inner_offset;
10647                let mut inner_depth = depth.clone();
10648                if inlined {
10649                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10650                    inner_offset = next_offset;
10651                } else {
10652                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10653                    inner_depth.increment()?;
10654                }
10655                let val_ref = self.data_sink.get_or_insert_with(|| {
10656                    fidl::new_empty!(
10657                        fidl::encoding::Endpoint<
10658                            fidl::endpoints::ClientEnd<
10659                                fidl_fuchsia_hardware_audio::PacketStreamSinkMarker,
10660                            >,
10661                        >,
10662                        fidl::encoding::DefaultFuchsiaResourceDialect
10663                    )
10664                });
10665                fidl::decode!(
10666                    fidl::encoding::Endpoint<
10667                        fidl::endpoints::ClientEnd<
10668                            fidl_fuchsia_hardware_audio::PacketStreamSinkMarker,
10669                        >,
10670                    >,
10671                    fidl::encoding::DefaultFuchsiaResourceDialect,
10672                    val_ref,
10673                    decoder,
10674                    inner_offset,
10675                    inner_depth
10676                )?;
10677                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10678                {
10679                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10680                }
10681                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10682                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10683                }
10684            }
10685
10686            next_offset += envelope_size;
10687            _next_ordinal_to_read += 1;
10688            if next_offset >= end_offset {
10689                return Ok(());
10690            }
10691
10692            // Decode unknown envelopes for gaps in ordinals.
10693            while _next_ordinal_to_read < 2 {
10694                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10695                _next_ordinal_to_read += 1;
10696                next_offset += envelope_size;
10697            }
10698
10699            let next_out_of_line = decoder.next_out_of_line();
10700            let handles_before = decoder.remaining_handles();
10701            if let Some((inlined, num_bytes, num_handles)) =
10702                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10703            {
10704                let member_inline_size =
10705                    <PacketStreamFormat as fidl::encoding::TypeMarker>::inline_size(
10706                        decoder.context,
10707                    );
10708                if inlined != (member_inline_size <= 4) {
10709                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10710                }
10711                let inner_offset;
10712                let mut inner_depth = depth.clone();
10713                if inlined {
10714                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10715                    inner_offset = next_offset;
10716                } else {
10717                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10718                    inner_depth.increment()?;
10719                }
10720                let val_ref = self.format.get_or_insert_with(|| {
10721                    fidl::new_empty!(
10722                        PacketStreamFormat,
10723                        fidl::encoding::DefaultFuchsiaResourceDialect
10724                    )
10725                });
10726                fidl::decode!(
10727                    PacketStreamFormat,
10728                    fidl::encoding::DefaultFuchsiaResourceDialect,
10729                    val_ref,
10730                    decoder,
10731                    inner_offset,
10732                    inner_depth
10733                )?;
10734                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10735                {
10736                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10737                }
10738                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10739                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10740                }
10741            }
10742
10743            next_offset += envelope_size;
10744            _next_ordinal_to_read += 1;
10745            if next_offset >= end_offset {
10746                return Ok(());
10747            }
10748
10749            // Decode unknown envelopes for gaps in ordinals.
10750            while _next_ordinal_to_read < 3 {
10751                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10752                _next_ordinal_to_read += 1;
10753                next_offset += envelope_size;
10754            }
10755
10756            let next_out_of_line = decoder.next_out_of_line();
10757            let handles_before = decoder.remaining_handles();
10758            if let Some((inlined, num_bytes, num_handles)) =
10759                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10760            {
10761                let member_inline_size =
10762                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10763                if inlined != (member_inline_size <= 4) {
10764                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10765                }
10766                let inner_offset;
10767                let mut inner_depth = depth.clone();
10768                if inlined {
10769                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10770                    inner_offset = next_offset;
10771                } else {
10772                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10773                    inner_depth.increment()?;
10774                }
10775                let val_ref = self.valid_bits_per_sample.get_or_insert_with(|| {
10776                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
10777                });
10778                fidl::decode!(
10779                    u8,
10780                    fidl::encoding::DefaultFuchsiaResourceDialect,
10781                    val_ref,
10782                    decoder,
10783                    inner_offset,
10784                    inner_depth
10785                )?;
10786                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10787                {
10788                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10789                }
10790                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10791                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10792                }
10793            }
10794
10795            next_offset += envelope_size;
10796            _next_ordinal_to_read += 1;
10797            if next_offset >= end_offset {
10798                return Ok(());
10799            }
10800
10801            // Decode unknown envelopes for gaps in ordinals.
10802            while _next_ordinal_to_read < 4 {
10803                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10804                _next_ordinal_to_read += 1;
10805                next_offset += envelope_size;
10806            }
10807
10808            let next_out_of_line = decoder.next_out_of_line();
10809            let handles_before = decoder.remaining_handles();
10810            if let Some((inlined, num_bytes, num_handles)) =
10811                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10812            {
10813                let member_inline_size = <fidl_fuchsia_hardware_audio::BufferType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10814                if inlined != (member_inline_size <= 4) {
10815                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10816                }
10817                let inner_offset;
10818                let mut inner_depth = depth.clone();
10819                if inlined {
10820                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10821                    inner_offset = next_offset;
10822                } else {
10823                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10824                    inner_depth.increment()?;
10825                }
10826                let val_ref = self.supported_buffer_types.get_or_insert_with(|| {
10827                    fidl::new_empty!(
10828                        fidl_fuchsia_hardware_audio::BufferType,
10829                        fidl::encoding::DefaultFuchsiaResourceDialect
10830                    )
10831                });
10832                fidl::decode!(
10833                    fidl_fuchsia_hardware_audio::BufferType,
10834                    fidl::encoding::DefaultFuchsiaResourceDialect,
10835                    val_ref,
10836                    decoder,
10837                    inner_offset,
10838                    inner_depth
10839                )?;
10840                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10841                {
10842                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10843                }
10844                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10845                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10846                }
10847            }
10848
10849            next_offset += envelope_size;
10850
10851            // Decode the remaining unknown envelopes.
10852            while next_offset < end_offset {
10853                _next_ordinal_to_read += 1;
10854                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10855                next_offset += envelope_size;
10856            }
10857
10858            Ok(())
10859        }
10860    }
10861
10862    impl PacketStreamSetBuffersRequest {
10863        #[inline(always)]
10864        fn max_ordinal_present(&self) -> u64 {
10865            if let Some(_) = self.vmo_info {
10866                return 1;
10867            }
10868            0
10869        }
10870    }
10871
10872    impl fidl::encoding::ResourceTypeMarker for PacketStreamSetBuffersRequest {
10873        type Borrowed<'a> = &'a mut Self;
10874        fn take_or_borrow<'a>(
10875            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10876        ) -> Self::Borrowed<'a> {
10877            value
10878        }
10879    }
10880
10881    unsafe impl fidl::encoding::TypeMarker for PacketStreamSetBuffersRequest {
10882        type Owned = Self;
10883
10884        #[inline(always)]
10885        fn inline_align(_context: fidl::encoding::Context) -> usize {
10886            8
10887        }
10888
10889        #[inline(always)]
10890        fn inline_size(_context: fidl::encoding::Context) -> usize {
10891            16
10892        }
10893    }
10894
10895    unsafe impl
10896        fidl::encoding::Encode<
10897            PacketStreamSetBuffersRequest,
10898            fidl::encoding::DefaultFuchsiaResourceDialect,
10899        > for &mut PacketStreamSetBuffersRequest
10900    {
10901        unsafe fn encode(
10902            self,
10903            encoder: &mut fidl::encoding::Encoder<
10904                '_,
10905                fidl::encoding::DefaultFuchsiaResourceDialect,
10906            >,
10907            offset: usize,
10908            mut depth: fidl::encoding::Depth,
10909        ) -> fidl::Result<()> {
10910            encoder.debug_check_bounds::<PacketStreamSetBuffersRequest>(offset);
10911            // Vector header
10912            let max_ordinal: u64 = self.max_ordinal_present();
10913            encoder.write_num(max_ordinal, offset);
10914            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10915            // Calling encoder.out_of_line_offset(0) is not allowed.
10916            if max_ordinal == 0 {
10917                return Ok(());
10918            }
10919            depth.increment()?;
10920            let envelope_size = 8;
10921            let bytes_len = max_ordinal as usize * envelope_size;
10922            #[allow(unused_variables)]
10923            let offset = encoder.out_of_line_offset(bytes_len);
10924            let mut _prev_end_offset: usize = 0;
10925            if 1 > max_ordinal {
10926                return Ok(());
10927            }
10928
10929            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10930            // are envelope_size bytes.
10931            let cur_offset: usize = (1 - 1) * envelope_size;
10932
10933            // Zero reserved fields.
10934            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10935
10936            // Safety:
10937            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10938            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10939            //   envelope_size bytes, there is always sufficient room.
10940            fidl::encoding::encode_in_envelope_optional::<PacketStreamSetupVmoInfo, fidl::encoding::DefaultFuchsiaResourceDialect>(
10941            self.vmo_info.as_mut().map(<PacketStreamSetupVmoInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
10942            encoder, offset + cur_offset, depth
10943        )?;
10944
10945            _prev_end_offset = cur_offset + envelope_size;
10946
10947            Ok(())
10948        }
10949    }
10950
10951    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10952        for PacketStreamSetBuffersRequest
10953    {
10954        #[inline(always)]
10955        fn new_empty() -> Self {
10956            Self::default()
10957        }
10958
10959        unsafe fn decode(
10960            &mut self,
10961            decoder: &mut fidl::encoding::Decoder<
10962                '_,
10963                fidl::encoding::DefaultFuchsiaResourceDialect,
10964            >,
10965            offset: usize,
10966            mut depth: fidl::encoding::Depth,
10967        ) -> fidl::Result<()> {
10968            decoder.debug_check_bounds::<Self>(offset);
10969            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10970                None => return Err(fidl::Error::NotNullable),
10971                Some(len) => len,
10972            };
10973            // Calling decoder.out_of_line_offset(0) is not allowed.
10974            if len == 0 {
10975                return Ok(());
10976            };
10977            depth.increment()?;
10978            let envelope_size = 8;
10979            let bytes_len = len * envelope_size;
10980            let offset = decoder.out_of_line_offset(bytes_len)?;
10981            // Decode the envelope for each type.
10982            let mut _next_ordinal_to_read = 0;
10983            let mut next_offset = offset;
10984            let end_offset = offset + bytes_len;
10985            _next_ordinal_to_read += 1;
10986            if next_offset >= end_offset {
10987                return Ok(());
10988            }
10989
10990            // Decode unknown envelopes for gaps in ordinals.
10991            while _next_ordinal_to_read < 1 {
10992                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10993                _next_ordinal_to_read += 1;
10994                next_offset += envelope_size;
10995            }
10996
10997            let next_out_of_line = decoder.next_out_of_line();
10998            let handles_before = decoder.remaining_handles();
10999            if let Some((inlined, num_bytes, num_handles)) =
11000                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11001            {
11002                let member_inline_size =
11003                    <PacketStreamSetupVmoInfo as fidl::encoding::TypeMarker>::inline_size(
11004                        decoder.context,
11005                    );
11006                if inlined != (member_inline_size <= 4) {
11007                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11008                }
11009                let inner_offset;
11010                let mut inner_depth = depth.clone();
11011                if inlined {
11012                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11013                    inner_offset = next_offset;
11014                } else {
11015                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11016                    inner_depth.increment()?;
11017                }
11018                let val_ref = self.vmo_info.get_or_insert_with(|| {
11019                    fidl::new_empty!(
11020                        PacketStreamSetupVmoInfo,
11021                        fidl::encoding::DefaultFuchsiaResourceDialect
11022                    )
11023                });
11024                fidl::decode!(
11025                    PacketStreamSetupVmoInfo,
11026                    fidl::encoding::DefaultFuchsiaResourceDialect,
11027                    val_ref,
11028                    decoder,
11029                    inner_offset,
11030                    inner_depth
11031                )?;
11032                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11033                {
11034                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11035                }
11036                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11037                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11038                }
11039            }
11040
11041            next_offset += envelope_size;
11042
11043            // Decode the remaining unknown envelopes.
11044            while next_offset < end_offset {
11045                _next_ordinal_to_read += 1;
11046                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11047                next_offset += envelope_size;
11048            }
11049
11050            Ok(())
11051        }
11052    }
11053
11054    impl PacketStreamSetBuffersResponse {
11055        #[inline(always)]
11056        fn max_ordinal_present(&self) -> u64 {
11057            if let Some(_) = self.packet_stream {
11058                return 1;
11059            }
11060            0
11061        }
11062    }
11063
11064    impl fidl::encoding::ResourceTypeMarker for PacketStreamSetBuffersResponse {
11065        type Borrowed<'a> = &'a mut Self;
11066        fn take_or_borrow<'a>(
11067            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11068        ) -> Self::Borrowed<'a> {
11069            value
11070        }
11071    }
11072
11073    unsafe impl fidl::encoding::TypeMarker for PacketStreamSetBuffersResponse {
11074        type Owned = Self;
11075
11076        #[inline(always)]
11077        fn inline_align(_context: fidl::encoding::Context) -> usize {
11078            8
11079        }
11080
11081        #[inline(always)]
11082        fn inline_size(_context: fidl::encoding::Context) -> usize {
11083            16
11084        }
11085    }
11086
11087    unsafe impl
11088        fidl::encoding::Encode<
11089            PacketStreamSetBuffersResponse,
11090            fidl::encoding::DefaultFuchsiaResourceDialect,
11091        > for &mut PacketStreamSetBuffersResponse
11092    {
11093        unsafe fn encode(
11094            self,
11095            encoder: &mut fidl::encoding::Encoder<
11096                '_,
11097                fidl::encoding::DefaultFuchsiaResourceDialect,
11098            >,
11099            offset: usize,
11100            mut depth: fidl::encoding::Depth,
11101        ) -> fidl::Result<()> {
11102            encoder.debug_check_bounds::<PacketStreamSetBuffersResponse>(offset);
11103            // Vector header
11104            let max_ordinal: u64 = self.max_ordinal_present();
11105            encoder.write_num(max_ordinal, offset);
11106            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11107            // Calling encoder.out_of_line_offset(0) is not allowed.
11108            if max_ordinal == 0 {
11109                return Ok(());
11110            }
11111            depth.increment()?;
11112            let envelope_size = 8;
11113            let bytes_len = max_ordinal as usize * envelope_size;
11114            #[allow(unused_variables)]
11115            let offset = encoder.out_of_line_offset(bytes_len);
11116            let mut _prev_end_offset: usize = 0;
11117            if 1 > max_ordinal {
11118                return Ok(());
11119            }
11120
11121            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11122            // are envelope_size bytes.
11123            let cur_offset: usize = (1 - 1) * envelope_size;
11124
11125            // Zero reserved fields.
11126            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11127
11128            // Safety:
11129            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11130            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11131            //   envelope_size bytes, there is always sufficient room.
11132            fidl::encoding::encode_in_envelope_optional::<
11133                PacketStreamBuffers,
11134                fidl::encoding::DefaultFuchsiaResourceDialect,
11135            >(
11136                self.packet_stream.as_mut().map(
11137                    <PacketStreamBuffers as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11138                ),
11139                encoder,
11140                offset + cur_offset,
11141                depth,
11142            )?;
11143
11144            _prev_end_offset = cur_offset + envelope_size;
11145
11146            Ok(())
11147        }
11148    }
11149
11150    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11151        for PacketStreamSetBuffersResponse
11152    {
11153        #[inline(always)]
11154        fn new_empty() -> Self {
11155            Self::default()
11156        }
11157
11158        unsafe fn decode(
11159            &mut self,
11160            decoder: &mut fidl::encoding::Decoder<
11161                '_,
11162                fidl::encoding::DefaultFuchsiaResourceDialect,
11163            >,
11164            offset: usize,
11165            mut depth: fidl::encoding::Depth,
11166        ) -> fidl::Result<()> {
11167            decoder.debug_check_bounds::<Self>(offset);
11168            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11169                None => return Err(fidl::Error::NotNullable),
11170                Some(len) => len,
11171            };
11172            // Calling decoder.out_of_line_offset(0) is not allowed.
11173            if len == 0 {
11174                return Ok(());
11175            };
11176            depth.increment()?;
11177            let envelope_size = 8;
11178            let bytes_len = len * envelope_size;
11179            let offset = decoder.out_of_line_offset(bytes_len)?;
11180            // Decode the envelope for each type.
11181            let mut _next_ordinal_to_read = 0;
11182            let mut next_offset = offset;
11183            let end_offset = offset + bytes_len;
11184            _next_ordinal_to_read += 1;
11185            if next_offset >= end_offset {
11186                return Ok(());
11187            }
11188
11189            // Decode unknown envelopes for gaps in ordinals.
11190            while _next_ordinal_to_read < 1 {
11191                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11192                _next_ordinal_to_read += 1;
11193                next_offset += envelope_size;
11194            }
11195
11196            let next_out_of_line = decoder.next_out_of_line();
11197            let handles_before = decoder.remaining_handles();
11198            if let Some((inlined, num_bytes, num_handles)) =
11199                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11200            {
11201                let member_inline_size =
11202                    <PacketStreamBuffers as fidl::encoding::TypeMarker>::inline_size(
11203                        decoder.context,
11204                    );
11205                if inlined != (member_inline_size <= 4) {
11206                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11207                }
11208                let inner_offset;
11209                let mut inner_depth = depth.clone();
11210                if inlined {
11211                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11212                    inner_offset = next_offset;
11213                } else {
11214                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11215                    inner_depth.increment()?;
11216                }
11217                let val_ref = self.packet_stream.get_or_insert_with(|| {
11218                    fidl::new_empty!(
11219                        PacketStreamBuffers,
11220                        fidl::encoding::DefaultFuchsiaResourceDialect
11221                    )
11222                });
11223                fidl::decode!(
11224                    PacketStreamBuffers,
11225                    fidl::encoding::DefaultFuchsiaResourceDialect,
11226                    val_ref,
11227                    decoder,
11228                    inner_offset,
11229                    inner_depth
11230                )?;
11231                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11232                {
11233                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11234                }
11235                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11236                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11237                }
11238            }
11239
11240            next_offset += envelope_size;
11241
11242            // Decode the remaining unknown envelopes.
11243            while next_offset < end_offset {
11244                _next_ordinal_to_read += 1;
11245                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11246                next_offset += envelope_size;
11247            }
11248
11249            Ok(())
11250        }
11251    }
11252
11253    impl ProviderAddDeviceRequest {
11254        #[inline(always)]
11255        fn max_ordinal_present(&self) -> u64 {
11256            if let Some(_) = self.driver_client {
11257                return 3;
11258            }
11259            if let Some(_) = self.device_type {
11260                return 2;
11261            }
11262            if let Some(_) = self.device_name {
11263                return 1;
11264            }
11265            0
11266        }
11267    }
11268
11269    impl fidl::encoding::ResourceTypeMarker for ProviderAddDeviceRequest {
11270        type Borrowed<'a> = &'a mut Self;
11271        fn take_or_borrow<'a>(
11272            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11273        ) -> Self::Borrowed<'a> {
11274            value
11275        }
11276    }
11277
11278    unsafe impl fidl::encoding::TypeMarker for ProviderAddDeviceRequest {
11279        type Owned = Self;
11280
11281        #[inline(always)]
11282        fn inline_align(_context: fidl::encoding::Context) -> usize {
11283            8
11284        }
11285
11286        #[inline(always)]
11287        fn inline_size(_context: fidl::encoding::Context) -> usize {
11288            16
11289        }
11290    }
11291
11292    unsafe impl
11293        fidl::encoding::Encode<
11294            ProviderAddDeviceRequest,
11295            fidl::encoding::DefaultFuchsiaResourceDialect,
11296        > for &mut ProviderAddDeviceRequest
11297    {
11298        unsafe fn encode(
11299            self,
11300            encoder: &mut fidl::encoding::Encoder<
11301                '_,
11302                fidl::encoding::DefaultFuchsiaResourceDialect,
11303            >,
11304            offset: usize,
11305            mut depth: fidl::encoding::Depth,
11306        ) -> fidl::Result<()> {
11307            encoder.debug_check_bounds::<ProviderAddDeviceRequest>(offset);
11308            // Vector header
11309            let max_ordinal: u64 = self.max_ordinal_present();
11310            encoder.write_num(max_ordinal, offset);
11311            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11312            // Calling encoder.out_of_line_offset(0) is not allowed.
11313            if max_ordinal == 0 {
11314                return Ok(());
11315            }
11316            depth.increment()?;
11317            let envelope_size = 8;
11318            let bytes_len = max_ordinal as usize * envelope_size;
11319            #[allow(unused_variables)]
11320            let offset = encoder.out_of_line_offset(bytes_len);
11321            let mut _prev_end_offset: usize = 0;
11322            if 1 > max_ordinal {
11323                return Ok(());
11324            }
11325
11326            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11327            // are envelope_size bytes.
11328            let cur_offset: usize = (1 - 1) * envelope_size;
11329
11330            // Zero reserved fields.
11331            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11332
11333            // Safety:
11334            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11335            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11336            //   envelope_size bytes, there is always sufficient room.
11337            fidl::encoding::encode_in_envelope_optional::<
11338                fidl::encoding::BoundedString<256>,
11339                fidl::encoding::DefaultFuchsiaResourceDialect,
11340            >(
11341                self.device_name.as_ref().map(
11342                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow,
11343                ),
11344                encoder,
11345                offset + cur_offset,
11346                depth,
11347            )?;
11348
11349            _prev_end_offset = cur_offset + envelope_size;
11350            if 2 > max_ordinal {
11351                return Ok(());
11352            }
11353
11354            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11355            // are envelope_size bytes.
11356            let cur_offset: usize = (2 - 1) * envelope_size;
11357
11358            // Zero reserved fields.
11359            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11360
11361            // Safety:
11362            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11363            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11364            //   envelope_size bytes, there is always sufficient room.
11365            fidl::encoding::encode_in_envelope_optional::<
11366                DeviceType,
11367                fidl::encoding::DefaultFuchsiaResourceDialect,
11368            >(
11369                self.device_type
11370                    .as_ref()
11371                    .map(<DeviceType as fidl::encoding::ValueTypeMarker>::borrow),
11372                encoder,
11373                offset + cur_offset,
11374                depth,
11375            )?;
11376
11377            _prev_end_offset = cur_offset + envelope_size;
11378            if 3 > max_ordinal {
11379                return Ok(());
11380            }
11381
11382            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11383            // are envelope_size bytes.
11384            let cur_offset: usize = (3 - 1) * envelope_size;
11385
11386            // Zero reserved fields.
11387            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11388
11389            // Safety:
11390            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11391            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11392            //   envelope_size bytes, there is always sufficient room.
11393            fidl::encoding::encode_in_envelope_optional::<
11394                DriverClient,
11395                fidl::encoding::DefaultFuchsiaResourceDialect,
11396            >(
11397                self.driver_client
11398                    .as_mut()
11399                    .map(<DriverClient as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11400                encoder,
11401                offset + cur_offset,
11402                depth,
11403            )?;
11404
11405            _prev_end_offset = cur_offset + envelope_size;
11406
11407            Ok(())
11408        }
11409    }
11410
11411    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11412        for ProviderAddDeviceRequest
11413    {
11414        #[inline(always)]
11415        fn new_empty() -> Self {
11416            Self::default()
11417        }
11418
11419        unsafe fn decode(
11420            &mut self,
11421            decoder: &mut fidl::encoding::Decoder<
11422                '_,
11423                fidl::encoding::DefaultFuchsiaResourceDialect,
11424            >,
11425            offset: usize,
11426            mut depth: fidl::encoding::Depth,
11427        ) -> fidl::Result<()> {
11428            decoder.debug_check_bounds::<Self>(offset);
11429            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11430                None => return Err(fidl::Error::NotNullable),
11431                Some(len) => len,
11432            };
11433            // Calling decoder.out_of_line_offset(0) is not allowed.
11434            if len == 0 {
11435                return Ok(());
11436            };
11437            depth.increment()?;
11438            let envelope_size = 8;
11439            let bytes_len = len * envelope_size;
11440            let offset = decoder.out_of_line_offset(bytes_len)?;
11441            // Decode the envelope for each type.
11442            let mut _next_ordinal_to_read = 0;
11443            let mut next_offset = offset;
11444            let end_offset = offset + bytes_len;
11445            _next_ordinal_to_read += 1;
11446            if next_offset >= end_offset {
11447                return Ok(());
11448            }
11449
11450            // Decode unknown envelopes for gaps in ordinals.
11451            while _next_ordinal_to_read < 1 {
11452                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11453                _next_ordinal_to_read += 1;
11454                next_offset += envelope_size;
11455            }
11456
11457            let next_out_of_line = decoder.next_out_of_line();
11458            let handles_before = decoder.remaining_handles();
11459            if let Some((inlined, num_bytes, num_handles)) =
11460                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11461            {
11462                let member_inline_size =
11463                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
11464                        decoder.context,
11465                    );
11466                if inlined != (member_inline_size <= 4) {
11467                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11468                }
11469                let inner_offset;
11470                let mut inner_depth = depth.clone();
11471                if inlined {
11472                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11473                    inner_offset = next_offset;
11474                } else {
11475                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11476                    inner_depth.increment()?;
11477                }
11478                let val_ref = self.device_name.get_or_insert_with(|| {
11479                    fidl::new_empty!(
11480                        fidl::encoding::BoundedString<256>,
11481                        fidl::encoding::DefaultFuchsiaResourceDialect
11482                    )
11483                });
11484                fidl::decode!(
11485                    fidl::encoding::BoundedString<256>,
11486                    fidl::encoding::DefaultFuchsiaResourceDialect,
11487                    val_ref,
11488                    decoder,
11489                    inner_offset,
11490                    inner_depth
11491                )?;
11492                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11493                {
11494                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11495                }
11496                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11497                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11498                }
11499            }
11500
11501            next_offset += envelope_size;
11502            _next_ordinal_to_read += 1;
11503            if next_offset >= end_offset {
11504                return Ok(());
11505            }
11506
11507            // Decode unknown envelopes for gaps in ordinals.
11508            while _next_ordinal_to_read < 2 {
11509                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11510                _next_ordinal_to_read += 1;
11511                next_offset += envelope_size;
11512            }
11513
11514            let next_out_of_line = decoder.next_out_of_line();
11515            let handles_before = decoder.remaining_handles();
11516            if let Some((inlined, num_bytes, num_handles)) =
11517                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11518            {
11519                let member_inline_size =
11520                    <DeviceType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11521                if inlined != (member_inline_size <= 4) {
11522                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11523                }
11524                let inner_offset;
11525                let mut inner_depth = depth.clone();
11526                if inlined {
11527                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11528                    inner_offset = next_offset;
11529                } else {
11530                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11531                    inner_depth.increment()?;
11532                }
11533                let val_ref = self.device_type.get_or_insert_with(|| {
11534                    fidl::new_empty!(DeviceType, fidl::encoding::DefaultFuchsiaResourceDialect)
11535                });
11536                fidl::decode!(
11537                    DeviceType,
11538                    fidl::encoding::DefaultFuchsiaResourceDialect,
11539                    val_ref,
11540                    decoder,
11541                    inner_offset,
11542                    inner_depth
11543                )?;
11544                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11545                {
11546                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11547                }
11548                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11549                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11550                }
11551            }
11552
11553            next_offset += envelope_size;
11554            _next_ordinal_to_read += 1;
11555            if next_offset >= end_offset {
11556                return Ok(());
11557            }
11558
11559            // Decode unknown envelopes for gaps in ordinals.
11560            while _next_ordinal_to_read < 3 {
11561                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11562                _next_ordinal_to_read += 1;
11563                next_offset += envelope_size;
11564            }
11565
11566            let next_out_of_line = decoder.next_out_of_line();
11567            let handles_before = decoder.remaining_handles();
11568            if let Some((inlined, num_bytes, num_handles)) =
11569                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11570            {
11571                let member_inline_size =
11572                    <DriverClient as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11573                if inlined != (member_inline_size <= 4) {
11574                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11575                }
11576                let inner_offset;
11577                let mut inner_depth = depth.clone();
11578                if inlined {
11579                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11580                    inner_offset = next_offset;
11581                } else {
11582                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11583                    inner_depth.increment()?;
11584                }
11585                let val_ref = self.driver_client.get_or_insert_with(|| {
11586                    fidl::new_empty!(DriverClient, fidl::encoding::DefaultFuchsiaResourceDialect)
11587                });
11588                fidl::decode!(
11589                    DriverClient,
11590                    fidl::encoding::DefaultFuchsiaResourceDialect,
11591                    val_ref,
11592                    decoder,
11593                    inner_offset,
11594                    inner_depth
11595                )?;
11596                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11597                {
11598                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11599                }
11600                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11601                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11602                }
11603            }
11604
11605            next_offset += envelope_size;
11606
11607            // Decode the remaining unknown envelopes.
11608            while next_offset < end_offset {
11609                _next_ordinal_to_read += 1;
11610                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11611                next_offset += envelope_size;
11612            }
11613
11614            Ok(())
11615        }
11616    }
11617
11618    impl RegistryCreateObserverRequest {
11619        #[inline(always)]
11620        fn max_ordinal_present(&self) -> u64 {
11621            if let Some(_) = self.observer_server {
11622                return 2;
11623            }
11624            if let Some(_) = self.token_id {
11625                return 1;
11626            }
11627            0
11628        }
11629    }
11630
11631    impl fidl::encoding::ResourceTypeMarker for RegistryCreateObserverRequest {
11632        type Borrowed<'a> = &'a mut Self;
11633        fn take_or_borrow<'a>(
11634            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11635        ) -> Self::Borrowed<'a> {
11636            value
11637        }
11638    }
11639
11640    unsafe impl fidl::encoding::TypeMarker for RegistryCreateObserverRequest {
11641        type Owned = Self;
11642
11643        #[inline(always)]
11644        fn inline_align(_context: fidl::encoding::Context) -> usize {
11645            8
11646        }
11647
11648        #[inline(always)]
11649        fn inline_size(_context: fidl::encoding::Context) -> usize {
11650            16
11651        }
11652    }
11653
11654    unsafe impl
11655        fidl::encoding::Encode<
11656            RegistryCreateObserverRequest,
11657            fidl::encoding::DefaultFuchsiaResourceDialect,
11658        > for &mut RegistryCreateObserverRequest
11659    {
11660        unsafe fn encode(
11661            self,
11662            encoder: &mut fidl::encoding::Encoder<
11663                '_,
11664                fidl::encoding::DefaultFuchsiaResourceDialect,
11665            >,
11666            offset: usize,
11667            mut depth: fidl::encoding::Depth,
11668        ) -> fidl::Result<()> {
11669            encoder.debug_check_bounds::<RegistryCreateObserverRequest>(offset);
11670            // Vector header
11671            let max_ordinal: u64 = self.max_ordinal_present();
11672            encoder.write_num(max_ordinal, offset);
11673            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11674            // Calling encoder.out_of_line_offset(0) is not allowed.
11675            if max_ordinal == 0 {
11676                return Ok(());
11677            }
11678            depth.increment()?;
11679            let envelope_size = 8;
11680            let bytes_len = max_ordinal as usize * envelope_size;
11681            #[allow(unused_variables)]
11682            let offset = encoder.out_of_line_offset(bytes_len);
11683            let mut _prev_end_offset: usize = 0;
11684            if 1 > max_ordinal {
11685                return Ok(());
11686            }
11687
11688            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11689            // are envelope_size bytes.
11690            let cur_offset: usize = (1 - 1) * envelope_size;
11691
11692            // Zero reserved fields.
11693            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11694
11695            // Safety:
11696            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11697            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11698            //   envelope_size bytes, there is always sufficient room.
11699            fidl::encoding::encode_in_envelope_optional::<
11700                u64,
11701                fidl::encoding::DefaultFuchsiaResourceDialect,
11702            >(
11703                self.token_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11704                encoder,
11705                offset + cur_offset,
11706                depth,
11707            )?;
11708
11709            _prev_end_offset = cur_offset + envelope_size;
11710            if 2 > max_ordinal {
11711                return Ok(());
11712            }
11713
11714            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11715            // are envelope_size bytes.
11716            let cur_offset: usize = (2 - 1) * envelope_size;
11717
11718            // Zero reserved fields.
11719            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11720
11721            // Safety:
11722            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11723            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11724            //   envelope_size bytes, there is always sufficient room.
11725            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ObserverMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11726            self.observer_server.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ObserverMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11727            encoder, offset + cur_offset, depth
11728        )?;
11729
11730            _prev_end_offset = cur_offset + envelope_size;
11731
11732            Ok(())
11733        }
11734    }
11735
11736    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11737        for RegistryCreateObserverRequest
11738    {
11739        #[inline(always)]
11740        fn new_empty() -> Self {
11741            Self::default()
11742        }
11743
11744        unsafe fn decode(
11745            &mut self,
11746            decoder: &mut fidl::encoding::Decoder<
11747                '_,
11748                fidl::encoding::DefaultFuchsiaResourceDialect,
11749            >,
11750            offset: usize,
11751            mut depth: fidl::encoding::Depth,
11752        ) -> fidl::Result<()> {
11753            decoder.debug_check_bounds::<Self>(offset);
11754            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11755                None => return Err(fidl::Error::NotNullable),
11756                Some(len) => len,
11757            };
11758            // Calling decoder.out_of_line_offset(0) is not allowed.
11759            if len == 0 {
11760                return Ok(());
11761            };
11762            depth.increment()?;
11763            let envelope_size = 8;
11764            let bytes_len = len * envelope_size;
11765            let offset = decoder.out_of_line_offset(bytes_len)?;
11766            // Decode the envelope for each type.
11767            let mut _next_ordinal_to_read = 0;
11768            let mut next_offset = offset;
11769            let end_offset = offset + bytes_len;
11770            _next_ordinal_to_read += 1;
11771            if next_offset >= end_offset {
11772                return Ok(());
11773            }
11774
11775            // Decode unknown envelopes for gaps in ordinals.
11776            while _next_ordinal_to_read < 1 {
11777                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11778                _next_ordinal_to_read += 1;
11779                next_offset += envelope_size;
11780            }
11781
11782            let next_out_of_line = decoder.next_out_of_line();
11783            let handles_before = decoder.remaining_handles();
11784            if let Some((inlined, num_bytes, num_handles)) =
11785                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11786            {
11787                let member_inline_size =
11788                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11789                if inlined != (member_inline_size <= 4) {
11790                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11791                }
11792                let inner_offset;
11793                let mut inner_depth = depth.clone();
11794                if inlined {
11795                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11796                    inner_offset = next_offset;
11797                } else {
11798                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11799                    inner_depth.increment()?;
11800                }
11801                let val_ref = self.token_id.get_or_insert_with(|| {
11802                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
11803                });
11804                fidl::decode!(
11805                    u64,
11806                    fidl::encoding::DefaultFuchsiaResourceDialect,
11807                    val_ref,
11808                    decoder,
11809                    inner_offset,
11810                    inner_depth
11811                )?;
11812                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11813                {
11814                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11815                }
11816                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11817                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11818                }
11819            }
11820
11821            next_offset += envelope_size;
11822            _next_ordinal_to_read += 1;
11823            if next_offset >= end_offset {
11824                return Ok(());
11825            }
11826
11827            // Decode unknown envelopes for gaps in ordinals.
11828            while _next_ordinal_to_read < 2 {
11829                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11830                _next_ordinal_to_read += 1;
11831                next_offset += envelope_size;
11832            }
11833
11834            let next_out_of_line = decoder.next_out_of_line();
11835            let handles_before = decoder.remaining_handles();
11836            if let Some((inlined, num_bytes, num_handles)) =
11837                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11838            {
11839                let member_inline_size = <fidl::encoding::Endpoint<
11840                    fidl::endpoints::ServerEnd<ObserverMarker>,
11841                > as fidl::encoding::TypeMarker>::inline_size(
11842                    decoder.context
11843                );
11844                if inlined != (member_inline_size <= 4) {
11845                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11846                }
11847                let inner_offset;
11848                let mut inner_depth = depth.clone();
11849                if inlined {
11850                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11851                    inner_offset = next_offset;
11852                } else {
11853                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11854                    inner_depth.increment()?;
11855                }
11856                let val_ref = self.observer_server.get_or_insert_with(|| {
11857                    fidl::new_empty!(
11858                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ObserverMarker>>,
11859                        fidl::encoding::DefaultFuchsiaResourceDialect
11860                    )
11861                });
11862                fidl::decode!(
11863                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ObserverMarker>>,
11864                    fidl::encoding::DefaultFuchsiaResourceDialect,
11865                    val_ref,
11866                    decoder,
11867                    inner_offset,
11868                    inner_depth
11869                )?;
11870                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11871                {
11872                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11873                }
11874                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11875                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11876                }
11877            }
11878
11879            next_offset += envelope_size;
11880
11881            // Decode the remaining unknown envelopes.
11882            while next_offset < end_offset {
11883                _next_ordinal_to_read += 1;
11884                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11885                next_offset += envelope_size;
11886            }
11887
11888            Ok(())
11889        }
11890    }
11891
11892    impl fidl::encoding::ResourceTypeMarker for DriverClient {
11893        type Borrowed<'a> = &'a mut Self;
11894        fn take_or_borrow<'a>(
11895            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11896        ) -> Self::Borrowed<'a> {
11897            value
11898        }
11899    }
11900
11901    unsafe impl fidl::encoding::TypeMarker for DriverClient {
11902        type Owned = Self;
11903
11904        #[inline(always)]
11905        fn inline_align(_context: fidl::encoding::Context) -> usize {
11906            8
11907        }
11908
11909        #[inline(always)]
11910        fn inline_size(_context: fidl::encoding::Context) -> usize {
11911            16
11912        }
11913    }
11914
11915    unsafe impl fidl::encoding::Encode<DriverClient, fidl::encoding::DefaultFuchsiaResourceDialect>
11916        for &mut DriverClient
11917    {
11918        #[inline]
11919        unsafe fn encode(
11920            self,
11921            encoder: &mut fidl::encoding::Encoder<
11922                '_,
11923                fidl::encoding::DefaultFuchsiaResourceDialect,
11924            >,
11925            offset: usize,
11926            _depth: fidl::encoding::Depth,
11927        ) -> fidl::Result<()> {
11928            encoder.debug_check_bounds::<DriverClient>(offset);
11929            encoder.write_num::<u64>(self.ordinal(), offset);
11930            match self {
11931                DriverClient::Codec(ref mut val) => fidl::encoding::encode_in_envelope::<
11932                    fidl::encoding::Endpoint<
11933                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CodecMarker>,
11934                    >,
11935                    fidl::encoding::DefaultFuchsiaResourceDialect,
11936                >(
11937                    <fidl::encoding::Endpoint<
11938                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CodecMarker>,
11939                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11940                        val
11941                    ),
11942                    encoder,
11943                    offset + 8,
11944                    _depth,
11945                ),
11946                DriverClient::Composite(ref mut val) => fidl::encoding::encode_in_envelope::<
11947                    fidl::encoding::Endpoint<
11948                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CompositeMarker>,
11949                    >,
11950                    fidl::encoding::DefaultFuchsiaResourceDialect,
11951                >(
11952                    <fidl::encoding::Endpoint<
11953                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CompositeMarker>,
11954                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11955                        val
11956                    ),
11957                    encoder,
11958                    offset + 8,
11959                    _depth,
11960                ),
11961                DriverClient::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
11962            }
11963        }
11964    }
11965
11966    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for DriverClient {
11967        #[inline(always)]
11968        fn new_empty() -> Self {
11969            Self::__SourceBreaking { unknown_ordinal: 0 }
11970        }
11971
11972        #[inline]
11973        unsafe fn decode(
11974            &mut self,
11975            decoder: &mut fidl::encoding::Decoder<
11976                '_,
11977                fidl::encoding::DefaultFuchsiaResourceDialect,
11978            >,
11979            offset: usize,
11980            mut depth: fidl::encoding::Depth,
11981        ) -> fidl::Result<()> {
11982            decoder.debug_check_bounds::<Self>(offset);
11983            #[allow(unused_variables)]
11984            let next_out_of_line = decoder.next_out_of_line();
11985            let handles_before = decoder.remaining_handles();
11986            let (ordinal, inlined, num_bytes, num_handles) =
11987                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
11988
11989            let member_inline_size = match ordinal {
11990                1 => <fidl::encoding::Endpoint<
11991                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CodecMarker>,
11992                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
11993                2 => <fidl::encoding::Endpoint<
11994                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CompositeMarker>,
11995                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
11996                0 => return Err(fidl::Error::UnknownUnionTag),
11997                _ => num_bytes as usize,
11998            };
11999
12000            if inlined != (member_inline_size <= 4) {
12001                return Err(fidl::Error::InvalidInlineBitInEnvelope);
12002            }
12003            let _inner_offset;
12004            if inlined {
12005                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
12006                _inner_offset = offset + 8;
12007            } else {
12008                depth.increment()?;
12009                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12010            }
12011            match ordinal {
12012                1 => {
12013                    #[allow(irrefutable_let_patterns)]
12014                    if let DriverClient::Codec(_) = self {
12015                        // Do nothing, read the value into the object
12016                    } else {
12017                        // Initialize `self` to the right variant
12018                        *self = DriverClient::Codec(fidl::new_empty!(
12019                            fidl::encoding::Endpoint<
12020                                fidl::endpoints::ClientEnd<
12021                                    fidl_fuchsia_hardware_audio::CodecMarker,
12022                                >,
12023                            >,
12024                            fidl::encoding::DefaultFuchsiaResourceDialect
12025                        ));
12026                    }
12027                    #[allow(irrefutable_let_patterns)]
12028                    if let DriverClient::Codec(ref mut val) = self {
12029                        fidl::decode!(
12030                            fidl::encoding::Endpoint<
12031                                fidl::endpoints::ClientEnd<
12032                                    fidl_fuchsia_hardware_audio::CodecMarker,
12033                                >,
12034                            >,
12035                            fidl::encoding::DefaultFuchsiaResourceDialect,
12036                            val,
12037                            decoder,
12038                            _inner_offset,
12039                            depth
12040                        )?;
12041                    } else {
12042                        unreachable!()
12043                    }
12044                }
12045                2 => {
12046                    #[allow(irrefutable_let_patterns)]
12047                    if let DriverClient::Composite(_) = self {
12048                        // Do nothing, read the value into the object
12049                    } else {
12050                        // Initialize `self` to the right variant
12051                        *self = DriverClient::Composite(fidl::new_empty!(
12052                            fidl::encoding::Endpoint<
12053                                fidl::endpoints::ClientEnd<
12054                                    fidl_fuchsia_hardware_audio::CompositeMarker,
12055                                >,
12056                            >,
12057                            fidl::encoding::DefaultFuchsiaResourceDialect
12058                        ));
12059                    }
12060                    #[allow(irrefutable_let_patterns)]
12061                    if let DriverClient::Composite(ref mut val) = self {
12062                        fidl::decode!(
12063                            fidl::encoding::Endpoint<
12064                                fidl::endpoints::ClientEnd<
12065                                    fidl_fuchsia_hardware_audio::CompositeMarker,
12066                                >,
12067                            >,
12068                            fidl::encoding::DefaultFuchsiaResourceDialect,
12069                            val,
12070                            decoder,
12071                            _inner_offset,
12072                            depth
12073                        )?;
12074                    } else {
12075                        unreachable!()
12076                    }
12077                }
12078                #[allow(deprecated)]
12079                ordinal => {
12080                    for _ in 0..num_handles {
12081                        decoder.drop_next_handle()?;
12082                    }
12083                    *self = DriverClient::__SourceBreaking { unknown_ordinal: ordinal };
12084                }
12085            }
12086            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
12087                return Err(fidl::Error::InvalidNumBytesInEnvelope);
12088            }
12089            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12090                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12091            }
12092            Ok(())
12093        }
12094    }
12095
12096    impl fidl::encoding::ResourceTypeMarker for PacketStreamSetupVmoInfo {
12097        type Borrowed<'a> = &'a mut Self;
12098        fn take_or_borrow<'a>(
12099            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12100        ) -> Self::Borrowed<'a> {
12101            value
12102        }
12103    }
12104
12105    unsafe impl fidl::encoding::TypeMarker for PacketStreamSetupVmoInfo {
12106        type Owned = Self;
12107
12108        #[inline(always)]
12109        fn inline_align(_context: fidl::encoding::Context) -> usize {
12110            8
12111        }
12112
12113        #[inline(always)]
12114        fn inline_size(_context: fidl::encoding::Context) -> usize {
12115            16
12116        }
12117    }
12118
12119    unsafe impl
12120        fidl::encoding::Encode<
12121            PacketStreamSetupVmoInfo,
12122            fidl::encoding::DefaultFuchsiaResourceDialect,
12123        > for &mut PacketStreamSetupVmoInfo
12124    {
12125        #[inline]
12126        unsafe fn encode(
12127            self,
12128            encoder: &mut fidl::encoding::Encoder<
12129                '_,
12130                fidl::encoding::DefaultFuchsiaResourceDialect,
12131            >,
12132            offset: usize,
12133            _depth: fidl::encoding::Depth,
12134        ) -> fidl::Result<()> {
12135            encoder.debug_check_bounds::<PacketStreamSetupVmoInfo>(offset);
12136            encoder.write_num::<u64>(self.ordinal(), offset);
12137            match self {
12138            PacketStreamSetupVmoInfo::AllocateInfo(ref val) => {
12139                fidl::encoding::encode_in_envelope::<fidl_fuchsia_hardware_audio::AllocateVmosConfig, fidl::encoding::DefaultFuchsiaResourceDialect>(
12140                    <fidl_fuchsia_hardware_audio::AllocateVmosConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
12141                    encoder, offset + 8, _depth
12142                )
12143            }
12144            PacketStreamSetupVmoInfo::RegisterInfo(ref mut val) => {
12145                fidl::encoding::encode_in_envelope::<fidl_fuchsia_hardware_audio::RegisterVmosConfig, fidl::encoding::DefaultFuchsiaResourceDialect>(
12146                    <fidl_fuchsia_hardware_audio::RegisterVmosConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
12147                    encoder, offset + 8, _depth
12148                )
12149            }
12150            PacketStreamSetupVmoInfo::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
12151        }
12152        }
12153    }
12154
12155    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12156        for PacketStreamSetupVmoInfo
12157    {
12158        #[inline(always)]
12159        fn new_empty() -> Self {
12160            Self::__SourceBreaking { unknown_ordinal: 0 }
12161        }
12162
12163        #[inline]
12164        unsafe fn decode(
12165            &mut self,
12166            decoder: &mut fidl::encoding::Decoder<
12167                '_,
12168                fidl::encoding::DefaultFuchsiaResourceDialect,
12169            >,
12170            offset: usize,
12171            mut depth: fidl::encoding::Depth,
12172        ) -> fidl::Result<()> {
12173            decoder.debug_check_bounds::<Self>(offset);
12174            #[allow(unused_variables)]
12175            let next_out_of_line = decoder.next_out_of_line();
12176            let handles_before = decoder.remaining_handles();
12177            let (ordinal, inlined, num_bytes, num_handles) =
12178                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
12179
12180            let member_inline_size = match ordinal {
12181            1 => <fidl_fuchsia_hardware_audio::AllocateVmosConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context),
12182            2 => <fidl_fuchsia_hardware_audio::RegisterVmosConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context),
12183            0 => return Err(fidl::Error::UnknownUnionTag),
12184            _ => num_bytes as usize,
12185        };
12186
12187            if inlined != (member_inline_size <= 4) {
12188                return Err(fidl::Error::InvalidInlineBitInEnvelope);
12189            }
12190            let _inner_offset;
12191            if inlined {
12192                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
12193                _inner_offset = offset + 8;
12194            } else {
12195                depth.increment()?;
12196                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12197            }
12198            match ordinal {
12199                1 => {
12200                    #[allow(irrefutable_let_patterns)]
12201                    if let PacketStreamSetupVmoInfo::AllocateInfo(_) = self {
12202                        // Do nothing, read the value into the object
12203                    } else {
12204                        // Initialize `self` to the right variant
12205                        *self = PacketStreamSetupVmoInfo::AllocateInfo(fidl::new_empty!(
12206                            fidl_fuchsia_hardware_audio::AllocateVmosConfig,
12207                            fidl::encoding::DefaultFuchsiaResourceDialect
12208                        ));
12209                    }
12210                    #[allow(irrefutable_let_patterns)]
12211                    if let PacketStreamSetupVmoInfo::AllocateInfo(ref mut val) = self {
12212                        fidl::decode!(
12213                            fidl_fuchsia_hardware_audio::AllocateVmosConfig,
12214                            fidl::encoding::DefaultFuchsiaResourceDialect,
12215                            val,
12216                            decoder,
12217                            _inner_offset,
12218                            depth
12219                        )?;
12220                    } else {
12221                        unreachable!()
12222                    }
12223                }
12224                2 => {
12225                    #[allow(irrefutable_let_patterns)]
12226                    if let PacketStreamSetupVmoInfo::RegisterInfo(_) = self {
12227                        // Do nothing, read the value into the object
12228                    } else {
12229                        // Initialize `self` to the right variant
12230                        *self = PacketStreamSetupVmoInfo::RegisterInfo(fidl::new_empty!(
12231                            fidl_fuchsia_hardware_audio::RegisterVmosConfig,
12232                            fidl::encoding::DefaultFuchsiaResourceDialect
12233                        ));
12234                    }
12235                    #[allow(irrefutable_let_patterns)]
12236                    if let PacketStreamSetupVmoInfo::RegisterInfo(ref mut val) = self {
12237                        fidl::decode!(
12238                            fidl_fuchsia_hardware_audio::RegisterVmosConfig,
12239                            fidl::encoding::DefaultFuchsiaResourceDialect,
12240                            val,
12241                            decoder,
12242                            _inner_offset,
12243                            depth
12244                        )?;
12245                    } else {
12246                        unreachable!()
12247                    }
12248                }
12249                #[allow(deprecated)]
12250                ordinal => {
12251                    for _ in 0..num_handles {
12252                        decoder.drop_next_handle()?;
12253                    }
12254                    *self = PacketStreamSetupVmoInfo::__SourceBreaking { unknown_ordinal: ordinal };
12255                }
12256            }
12257            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
12258                return Err(fidl::Error::InvalidNumBytesInEnvelope);
12259            }
12260            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12261                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12262            }
12263            Ok(())
12264        }
12265    }
12266}