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 ControlCreateRingBufferRequest {
16    /// The element ID for an `ENDPOINT` of type `RING_BUFFER`.
17    ///
18    /// Required.
19    pub element_id: Option<u64>,
20    /// Additional requirements about the actual ring buffer being created.
21    ///
22    /// Required.
23    pub options: Option<RingBufferOptions>,
24    /// The server_end of the `RingBuffer` to be created.
25    ///
26    /// Required.
27    pub ring_buffer_server: Option<fidl::endpoints::ServerEnd<RingBufferMarker>>,
28    #[doc(hidden)]
29    pub __source_breaking: fidl::marker::SourceBreaking,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
33    for ControlCreateRingBufferRequest
34{
35}
36
37#[derive(Debug, Default, PartialEq)]
38pub struct ControlCreatorCreateRequest {
39    /// The token id for the device to be controlled.
40    ///
41    /// Required.
42    pub token_id: Option<u64>,
43    /// The server_end of the `Control` to be created.
44    ///
45    /// Required.
46    pub control_server: Option<fidl::endpoints::ServerEnd<ControlMarker>>,
47    #[doc(hidden)]
48    pub __source_breaking: fidl::marker::SourceBreaking,
49}
50
51impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
52    for ControlCreatorCreateRequest
53{
54}
55
56#[derive(Debug, Default, PartialEq)]
57pub struct ControlCreateRingBufferResponse {
58    /// Properties about the ring buffer and active audio stream as created.
59    pub properties: Option<RingBufferProperties>,
60    /// An object that represents the audio stream and ring memory itself.
61    /// Note: ring-buffer VMO memory ranges must be cache-invalidated before
62    /// each read, and cache-flushed after each write.
63    pub ring_buffer: Option<fidl_fuchsia_audio::RingBuffer>,
64    #[doc(hidden)]
65    pub __source_breaking: fidl::marker::SourceBreaking,
66}
67
68impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
69    for ControlCreateRingBufferResponse
70{
71}
72
73#[derive(Debug, Default, PartialEq)]
74pub struct ObserverGetReferenceClockResponse {
75    /// The device's reference clock.
76    pub reference_clock: Option<fidl::Clock>,
77    #[doc(hidden)]
78    pub __source_breaking: fidl::marker::SourceBreaking,
79}
80
81impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
82    for ObserverGetReferenceClockResponse
83{
84}
85
86#[derive(Debug, Default, PartialEq)]
87pub struct ProviderAddDeviceRequest {
88    /// The device's high-level name. Must not be an empty string.
89    ///
90    /// Required.
91    pub device_name: Option<String>,
92    /// Indicates the protocol used by the device.
93    ///
94    /// Required.
95    pub device_type: Option<DeviceType>,
96    /// The client_end of the protocol channel (Codec or Composite)
97    /// that this service will use to configure/observe the device.
98    ///
99    /// Required.
100    /// # Deprecation
101    ///
102    /// Codec is not supported anymore, instead use an
103    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
104    /// , see
105    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
106    pub driver_client: Option<DriverClient>,
107    #[doc(hidden)]
108    pub __source_breaking: fidl::marker::SourceBreaking,
109}
110
111impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ProviderAddDeviceRequest {}
112
113#[derive(Debug, Default, PartialEq)]
114pub struct RegistryCreateObserverRequest {
115    /// The token of the device to be observed.
116    ///
117    /// Required.
118    pub token_id: Option<u64>,
119    /// The server end of the `Observer` that will be created.
120    ///
121    /// Required.
122    pub observer_server: Option<fidl::endpoints::ServerEnd<ObserverMarker>>,
123    #[doc(hidden)]
124    pub __source_breaking: fidl::marker::SourceBreaking,
125}
126
127impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
128    for RegistryCreateObserverRequest
129{
130}
131
132/// The protocol channel used to configure and observe a device.
133/// # Deprecation
134///
135/// Codec drivers are not supported anymore, instead use an
136/// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite), see
137/// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
138#[derive(Debug)]
139pub enum DriverClient {
140    /// Populated for drivers that use the `fuchsia_hardware_audio.Codec` interface.
141    Codec(fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CodecMarker>),
142    /// Populated for drivers that use the `fuchsia_hardware_audio.Composite` interface.
143    Composite(fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CompositeMarker>),
144    #[doc(hidden)]
145    __SourceBreaking { unknown_ordinal: u64 },
146}
147
148/// Pattern that matches an unknown `DriverClient` member.
149#[macro_export]
150macro_rules! DriverClientUnknown {
151    () => {
152        _
153    };
154}
155
156// Custom PartialEq so that unknown variants are not equal to themselves.
157impl PartialEq for DriverClient {
158    fn eq(&self, other: &Self) -> bool {
159        match (self, other) {
160            (Self::Codec(x), Self::Codec(y)) => *x == *y,
161            (Self::Composite(x), Self::Composite(y)) => *x == *y,
162            _ => false,
163        }
164    }
165}
166
167impl DriverClient {
168    #[inline]
169    pub fn ordinal(&self) -> u64 {
170        match *self {
171            Self::Codec(_) => 1,
172            Self::Composite(_) => 2,
173            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
174        }
175    }
176
177    #[inline]
178    pub fn unknown_variant_for_testing() -> Self {
179        Self::__SourceBreaking { unknown_ordinal: 0 }
180    }
181
182    #[inline]
183    pub fn is_unknown(&self) -> bool {
184        match self {
185            Self::__SourceBreaking { .. } => true,
186            _ => false,
187        }
188    }
189}
190
191impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DriverClient {}
192
193#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
194pub struct ControlMarker;
195
196impl fidl::endpoints::ProtocolMarker for ControlMarker {
197    type Proxy = ControlProxy;
198    type RequestStream = ControlRequestStream;
199    #[cfg(target_os = "fuchsia")]
200    type SynchronousProxy = ControlSynchronousProxy;
201
202    const DEBUG_NAME: &'static str = "(anonymous) Control";
203}
204pub type ControlCreateRingBufferResult =
205    Result<ControlCreateRingBufferResponse, ControlCreateRingBufferError>;
206pub type ControlSetDaiFormatResult = Result<ControlSetDaiFormatResponse, ControlSetDaiFormatError>;
207pub type ControlCodecStartResult = Result<ControlCodecStartResponse, ControlCodecStartError>;
208pub type ControlCodecStopResult = Result<ControlCodecStopResponse, ControlCodecStopError>;
209pub type ControlResetResult = Result<ControlResetResponse, ControlResetError>;
210
211pub trait ControlProxyInterface: Send + Sync {
212    type GetElementsResponseFut: std::future::Future<
213            Output = Result<
214                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
215                fidl::Error,
216            >,
217        > + Send;
218    fn r#get_elements(&self) -> Self::GetElementsResponseFut;
219    type WatchElementStateResponseFut: std::future::Future<
220            Output = Result<
221                fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
222                fidl::Error,
223            >,
224        > + Send;
225    fn r#watch_element_state(
226        &self,
227        processing_element_id: u64,
228    ) -> Self::WatchElementStateResponseFut;
229    type GetTopologiesResponseFut: std::future::Future<
230            Output = Result<
231                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
232                fidl::Error,
233            >,
234        > + Send;
235    fn r#get_topologies(&self) -> Self::GetTopologiesResponseFut;
236    type WatchTopologyResponseFut: std::future::Future<Output = Result<u64, fidl::Error>> + Send;
237    fn r#watch_topology(&self) -> Self::WatchTopologyResponseFut;
238    type SetElementStateResponseFut: std::future::Future<
239            Output = Result<
240                fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateResult,
241                fidl::Error,
242            >,
243        > + Send;
244    fn r#set_element_state(
245        &self,
246        processing_element_id: u64,
247        state: &fidl_fuchsia_hardware_audio_signalprocessing::SettableElementState,
248    ) -> Self::SetElementStateResponseFut;
249    type SetTopologyResponseFut: std::future::Future<
250            Output = Result<
251                fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyResult,
252                fidl::Error,
253            >,
254        > + Send;
255    fn r#set_topology(&self, topology_id: u64) -> Self::SetTopologyResponseFut;
256    type CreateRingBufferResponseFut: std::future::Future<Output = Result<ControlCreateRingBufferResult, fidl::Error>>
257        + Send;
258    fn r#create_ring_buffer(
259        &self,
260        payload: ControlCreateRingBufferRequest,
261    ) -> Self::CreateRingBufferResponseFut;
262    type SetDaiFormatResponseFut: std::future::Future<Output = Result<ControlSetDaiFormatResult, fidl::Error>>
263        + Send;
264    fn r#set_dai_format(
265        &self,
266        payload: &ControlSetDaiFormatRequest,
267    ) -> Self::SetDaiFormatResponseFut;
268    type CodecStartResponseFut: std::future::Future<Output = Result<ControlCodecStartResult, fidl::Error>>
269        + Send;
270    fn r#codec_start(&self) -> Self::CodecStartResponseFut;
271    type CodecStopResponseFut: std::future::Future<Output = Result<ControlCodecStopResult, fidl::Error>>
272        + Send;
273    fn r#codec_stop(&self) -> Self::CodecStopResponseFut;
274    type ResetResponseFut: std::future::Future<Output = Result<ControlResetResult, fidl::Error>>
275        + Send;
276    fn r#reset(&self) -> Self::ResetResponseFut;
277}
278#[derive(Debug)]
279#[cfg(target_os = "fuchsia")]
280pub struct ControlSynchronousProxy {
281    client: fidl::client::sync::Client,
282}
283
284#[cfg(target_os = "fuchsia")]
285impl fidl::endpoints::SynchronousProxy for ControlSynchronousProxy {
286    type Proxy = ControlProxy;
287    type Protocol = ControlMarker;
288
289    fn from_channel(inner: fidl::Channel) -> Self {
290        Self::new(inner)
291    }
292
293    fn into_channel(self) -> fidl::Channel {
294        self.client.into_channel()
295    }
296
297    fn as_channel(&self) -> &fidl::Channel {
298        self.client.as_channel()
299    }
300}
301
302#[cfg(target_os = "fuchsia")]
303impl ControlSynchronousProxy {
304    pub fn new(channel: fidl::Channel) -> Self {
305        let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
306        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
307    }
308
309    pub fn into_channel(self) -> fidl::Channel {
310        self.client.into_channel()
311    }
312
313    /// Waits until an event arrives and returns it. It is safe for other
314    /// threads to make concurrent requests while waiting for an event.
315    pub fn wait_for_event(
316        &self,
317        deadline: zx::MonotonicInstant,
318    ) -> Result<ControlEvent, fidl::Error> {
319        ControlEvent::decode(self.client.wait_for_event(deadline)?)
320    }
321
322    /// Returns a vector of supported processing elements.
323    /// Must return one or more processing elements, or `ZX_ERR_NOT_SUPPORTED`.
324    /// If `GetTopologies` returns one or more topologies, then `GetElements` must return one or
325    /// more elements.
326    pub fn r#get_elements(
327        &self,
328        ___deadline: zx::MonotonicInstant,
329    ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult, fidl::Error>
330    {
331        let _response = self
332            .client
333            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
334                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResponse,
335                i32,
336            >>(
337                (), 0x1b14ff4adf5dc6f8, fidl::encoding::DynamicFlags::empty(), ___deadline
338            )?;
339        Ok(_response.map(|x| x.processing_elements))
340    }
341
342    /// Get the processing element state via a hanging get.
343    /// For a given `processing_element_id`, the driver will reply to the first `WatchElementState`
344    /// sent by the client. The driver will not respond to subsequent client `WatchElementState`
345    /// calls for a given `processing_element_id` until any field of the `Element` table changes
346    /// from what was most recently reported for that `processing_element_id`.
347    ///
348    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
349    /// method is called again while there is already a pending `WatchElementState` for this client
350    /// and processing_element_id.
351    pub fn r#watch_element_state(
352        &self,
353        mut processing_element_id: u64,
354        ___deadline: zx::MonotonicInstant,
355    ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ElementState, fidl::Error> {
356        let _response = self.client.send_query::<
357            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest,
358            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateResponse,
359        >(
360            (processing_element_id,),
361            0x524da8772a69056f,
362            fidl::encoding::DynamicFlags::empty(),
363            ___deadline,
364        )?;
365        Ok(_response.state)
366    }
367
368    /// Returns a vector of supported topologies.
369    /// Must return one or more topologies, or `ZX_ERR_NOT_SUPPORTED`.
370    /// If more than one topology is returned, then the client may choose any of the topologies from
371    /// the list with `SetTopology`.
372    /// If only one topology is returned, then the topology definition is informational only since
373    /// the one and only topology used can't be changed with `SetTopology`.
374    /// If `GetElements` returns one or more elements, then `GetTopologies` must return one or
375    /// more topologies.
376    pub fn r#get_topologies(
377        &self,
378        ___deadline: zx::MonotonicInstant,
379    ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult, fidl::Error>
380    {
381        let _response = self
382            .client
383            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
384                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResponse,
385                i32,
386            >>(
387                (), 0x73ffb73af24d30b6, fidl::encoding::DynamicFlags::empty(), ___deadline
388            )?;
389        Ok(_response.map(|x| x.topologies))
390    }
391
392    /// Get the current topology via a hanging get.
393    /// The driver will immediately reply to the first `WatchTopology` sent by each client. The
394    /// driver will not respond to subsequent `WatchTopology` calls from that client until the
395    /// signal-processing topology changes, which occurs as a result of a `SetTopology` call.
396    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
397    /// method is called again while there is already a pending `WatchTopology` for this client.
398    pub fn r#watch_topology(&self, ___deadline: zx::MonotonicInstant) -> Result<u64, fidl::Error> {
399        let _response = self
400            .client
401            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleType<
402                fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchTopologyResponse,
403            >>(
404                (), 0x66d172acdb36a729, fidl::encoding::DynamicFlags::FLEXIBLE, ___deadline
405            )?
406            .into_result::<ControlMarker>("watch_topology")?;
407        Ok(_response.topology_id)
408    }
409
410    /// Controls a processing element using a unique ElementId returned by `GetElements`.
411    /// Note that `SettableElementState` is a subset of `ElementState`, because some fields returned
412    /// from `WatchElementState` (e.g. `latency`) can only be observed (not set) by the client.
413    ///
414    /// Returns `ZX_ERR_INVALID_ARGS` if the `processing_element_id` does not match an id returned
415    /// by `GetElements` or the type of `SettableTypeSpecificElementState` does not
416    /// match the `ElementType` of the processing element returned by
417    /// `GetElements` for this id.
418    /// The driver may return `ZX_ERR_INVALID_ARGS` if the `state` values are invalid, i.e. any
419    /// of the values violates rules specified in this protocol, e.g. trying to change an
420    /// `EQUALIZER` processing element's `EqualizerBandState` `frequency` when this processing
421    /// element did not advertise `CAN_CONTROL_FREQUENCY` in its `supported_controls`.
422    ///
423    /// `SetElementState` may be called before or after non-`SignalProcessing` protocol
424    /// calls. If called after non-`SignalProcessing` protocol calls then
425    /// `SetElementState` may or may not require renegotiation of the driver state as
426    /// reached with calls of the protocol composing `SignalProcessing`, e.g. `Dai`.
427    /// For instance, `SetElementState` changing an `AGL` processing element's parameters
428    /// may not require renegotiation of the `Dai` state because changing a gain parameter usually
429    /// does not change the set of supported audio formats.
430    /// By contrast, if `SetElementState` changes the parameters of a `CONNECTION_POINT`
431    /// element, the change may require renegotiation because it may invalidate the set of
432    /// supported formats returned in a previous `GetDaiFormats` `Dai` protocol call.
433    ///
434    /// It is the driver's job to determine when renegotiation is required. If renegotiation is
435    /// required, then `SetElementState` must return `ZX_ERR_BAD_STATE` and the client must
436    /// close the protocol channel such that the protocol negotiations are started over.
437    /// The client then must make the `SetElementState` call that returned
438    /// `ZX_ERR_BAD_STATE` before any non-`SignalProcessing` protocol calls.
439    pub fn r#set_element_state(
440        &self,
441        mut processing_element_id: u64,
442        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::SettableElementState,
443        ___deadline: zx::MonotonicInstant,
444    ) -> Result<
445        fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateResult,
446        fidl::Error,
447    > {
448        let _response = self.client.send_query::<
449            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateRequest,
450            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
451        >(
452            (processing_element_id, state,),
453            0x38c3b2d4bae698f4,
454            fidl::encoding::DynamicFlags::empty(),
455            ___deadline,
456        )?;
457        Ok(_response.map(|x| x))
458    }
459
460    /// Sets the topology to be used using an id to the vector returned by `GetTopologies`.
461    /// The current topology is communicated by `WatchTopology` responses. To change which topology
462    /// is active, a client uses `SetTopology`.
463    /// If the specified `topology_id` is not within the`topologies` returned by `GetTopologies`,
464    /// this call will return `ZX_ERR_INVALID_ARGS`.
465    /// If `GetTopologies` returns only one `Topology`, `SetTopology` is optional and has no effect.
466    ///
467    /// `SetTopology` may be called before or after non-`SignalProcessing` protocol calls.
468    /// If called after non-`SignalProcessing` protocol calls, then `SetTopology` may return
469    /// `ZX_ERR_BAD_STATE` to indicate that the operation can not proceed without renegotiation of
470    /// the driver state. See `SetElementState` for further discussion.
471    pub fn r#set_topology(
472        &self,
473        mut topology_id: u64,
474        ___deadline: zx::MonotonicInstant,
475    ) -> Result<
476        fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyResult,
477        fidl::Error,
478    > {
479        let _response = self.client.send_query::<
480            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyRequest,
481            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
482        >(
483            (topology_id,),
484            0x1d9a7f9b8fee790c,
485            fidl::encoding::DynamicFlags::empty(),
486            ___deadline,
487        )?;
488        Ok(_response.map(|x| x))
489    }
490
491    /// Create the ring buffer used to pass audio to/from this device. If the device is
492    /// Composite, then the targeted RING_BUFFER ENDPOINT must be identified by `element_id`.
493    ///
494    /// Should only be called for Composite devices.
495    pub fn r#create_ring_buffer(
496        &self,
497        mut payload: ControlCreateRingBufferRequest,
498        ___deadline: zx::MonotonicInstant,
499    ) -> Result<ControlCreateRingBufferResult, fidl::Error> {
500        let _response = self
501            .client
502            .send_query::<ControlCreateRingBufferRequest, fidl::encoding::FlexibleResultType<
503                ControlCreateRingBufferResponse,
504                ControlCreateRingBufferError,
505            >>(
506                &mut payload,
507                0x7462941cedb333db,
508                fidl::encoding::DynamicFlags::FLEXIBLE,
509                ___deadline,
510            )?
511            .into_result::<ControlMarker>("create_ring_buffer")?;
512        Ok(_response.map(|x| x))
513    }
514
515    /// Set the wire format for the digital interconnect connected to this Codec endpoint.
516    /// This method returns information related to the format that was set, including delay values.
517    /// If the device is Composite, then the targeted DAI_INTERCONNECT ENDPOINT must be identified
518    /// by `element_id`.
519    ///
520    /// Should only be called for Codec and Composite devices.
521    pub fn r#set_dai_format(
522        &self,
523        mut payload: &ControlSetDaiFormatRequest,
524        ___deadline: zx::MonotonicInstant,
525    ) -> Result<ControlSetDaiFormatResult, fidl::Error> {
526        let _response = self
527            .client
528            .send_query::<ControlSetDaiFormatRequest, fidl::encoding::FlexibleResultType<
529                ControlSetDaiFormatResponse,
530                ControlSetDaiFormatError,
531            >>(
532                payload, 0x1d84f5a456a92216, fidl::encoding::DynamicFlags::FLEXIBLE, ___deadline
533            )?
534            .into_result::<ControlMarker>("set_dai_format")?;
535        Ok(_response.map(|x| x))
536    }
537
538    /// Start the Codec hardware. If successful, this returns after the Codec was started and
539    /// `start_time` indicates the time when the hardware started. Note that the Codec's DaiFormat
540    /// must be set (by a successful `SetDaiFormat` call) before calling this method.
541    ///
542    /// Should only be called for Codec devices.
543    pub fn r#codec_start(
544        &self,
545        ___deadline: zx::MonotonicInstant,
546    ) -> Result<ControlCodecStartResult, fidl::Error> {
547        let _response =
548            self.client
549                .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
550                    ControlCodecStartResponse,
551                    ControlCodecStartError,
552                >>(
553                    (), 0x2a90a9d2958b997b, fidl::encoding::DynamicFlags::FLEXIBLE, ___deadline
554                )?
555                .into_result::<ControlMarker>("codec_start")?;
556        Ok(_response.map(|x| x))
557    }
558
559    /// Stop the Codec hardware. If successful, this returns after the Codec was stopped and
560    /// `stop_time` indicates the time when the hardware stopped. Note that the Codec's DaiFormat
561    /// must be set (by a successful `SetDaiFormat` call) before calling this method.
562    ///
563    /// Should only be called for Codec devices.
564    pub fn r#codec_stop(
565        &self,
566        ___deadline: zx::MonotonicInstant,
567    ) -> Result<ControlCodecStopResult, fidl::Error> {
568        let _response = self.client.send_query::<
569            fidl::encoding::EmptyPayload,
570            fidl::encoding::FlexibleResultType<ControlCodecStopResponse, ControlCodecStopError>,
571        >(
572            (),
573            0x387297bb6bcad25f,
574            fidl::encoding::DynamicFlags::FLEXIBLE,
575            ___deadline,
576        )?
577        .into_result::<ControlMarker>("codec_stop")?;
578        Ok(_response.map(|x| x))
579    }
580
581    /// Reset the hardware -- stopping the hardware, releasing any ring buffers, and clearing any
582    /// DaiFormats or RingBufferFormats that were set.
583    ///
584    /// This method returns when the hardware reset is complete.
585    /// After calling this method, the device is still controlled, but any ring buffers must be
586    /// re-created and re-started.
587    /// For devices with DAI_INTERCONNECTs (such as Codecs and some Composites), `SetDaiFormat` and
588    /// `CodecStart` must be called again (in that order) to return the interconnect to the active
589    /// operational mode.
590    /// As applicable, `SetTopology` and `SetElementState` must also be called.
591    ///
592    /// Should only be called for Codec and Composite devices.
593    pub fn r#reset(
594        &self,
595        ___deadline: zx::MonotonicInstant,
596    ) -> Result<ControlResetResult, fidl::Error> {
597        let _response = self.client.send_query::<
598            fidl::encoding::EmptyPayload,
599            fidl::encoding::FlexibleResultType<ControlResetResponse, ControlResetError>,
600        >(
601            (),
602            0x49840db00a698996,
603            fidl::encoding::DynamicFlags::FLEXIBLE,
604            ___deadline,
605        )?
606        .into_result::<ControlMarker>("reset")?;
607        Ok(_response.map(|x| x))
608    }
609}
610
611#[derive(Debug, Clone)]
612pub struct ControlProxy {
613    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
614}
615
616impl fidl::endpoints::Proxy for ControlProxy {
617    type Protocol = ControlMarker;
618
619    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
620        Self::new(inner)
621    }
622
623    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
624        self.client.into_channel().map_err(|client| Self { client })
625    }
626
627    fn as_channel(&self) -> &::fidl::AsyncChannel {
628        self.client.as_channel()
629    }
630}
631
632impl ControlProxy {
633    /// Create a new Proxy for fuchsia.audio.device/Control.
634    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
635        let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
636        Self { client: fidl::client::Client::new(channel, protocol_name) }
637    }
638
639    /// Get a Stream of events from the remote end of the protocol.
640    ///
641    /// # Panics
642    ///
643    /// Panics if the event stream was already taken.
644    pub fn take_event_stream(&self) -> ControlEventStream {
645        ControlEventStream { event_receiver: self.client.take_event_receiver() }
646    }
647
648    /// Returns a vector of supported processing elements.
649    /// Must return one or more processing elements, or `ZX_ERR_NOT_SUPPORTED`.
650    /// If `GetTopologies` returns one or more topologies, then `GetElements` must return one or
651    /// more elements.
652    pub fn r#get_elements(
653        &self,
654    ) -> fidl::client::QueryResponseFut<
655        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
656        fidl::encoding::DefaultFuchsiaResourceDialect,
657    > {
658        ControlProxyInterface::r#get_elements(self)
659    }
660
661    /// Get the processing element state via a hanging get.
662    /// For a given `processing_element_id`, the driver will reply to the first `WatchElementState`
663    /// sent by the client. The driver will not respond to subsequent client `WatchElementState`
664    /// calls for a given `processing_element_id` until any field of the `Element` table changes
665    /// from what was most recently reported for that `processing_element_id`.
666    ///
667    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
668    /// method is called again while there is already a pending `WatchElementState` for this client
669    /// and processing_element_id.
670    pub fn r#watch_element_state(
671        &self,
672        mut processing_element_id: u64,
673    ) -> fidl::client::QueryResponseFut<
674        fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
675        fidl::encoding::DefaultFuchsiaResourceDialect,
676    > {
677        ControlProxyInterface::r#watch_element_state(self, processing_element_id)
678    }
679
680    /// Returns a vector of supported topologies.
681    /// Must return one or more topologies, or `ZX_ERR_NOT_SUPPORTED`.
682    /// If more than one topology is returned, then the client may choose any of the topologies from
683    /// the list with `SetTopology`.
684    /// If only one topology is returned, then the topology definition is informational only since
685    /// the one and only topology used can't be changed with `SetTopology`.
686    /// If `GetElements` returns one or more elements, then `GetTopologies` must return one or
687    /// more topologies.
688    pub fn r#get_topologies(
689        &self,
690    ) -> fidl::client::QueryResponseFut<
691        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
692        fidl::encoding::DefaultFuchsiaResourceDialect,
693    > {
694        ControlProxyInterface::r#get_topologies(self)
695    }
696
697    /// Get the current topology via a hanging get.
698    /// The driver will immediately reply to the first `WatchTopology` sent by each client. The
699    /// driver will not respond to subsequent `WatchTopology` calls from that client until the
700    /// signal-processing topology changes, which occurs as a result of a `SetTopology` call.
701    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
702    /// method is called again while there is already a pending `WatchTopology` for this client.
703    pub fn r#watch_topology(
704        &self,
705    ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
706        ControlProxyInterface::r#watch_topology(self)
707    }
708
709    /// Controls a processing element using a unique ElementId returned by `GetElements`.
710    /// Note that `SettableElementState` is a subset of `ElementState`, because some fields returned
711    /// from `WatchElementState` (e.g. `latency`) can only be observed (not set) by the client.
712    ///
713    /// Returns `ZX_ERR_INVALID_ARGS` if the `processing_element_id` does not match an id returned
714    /// by `GetElements` or the type of `SettableTypeSpecificElementState` does not
715    /// match the `ElementType` of the processing element returned by
716    /// `GetElements` for this id.
717    /// The driver may return `ZX_ERR_INVALID_ARGS` if the `state` values are invalid, i.e. any
718    /// of the values violates rules specified in this protocol, e.g. trying to change an
719    /// `EQUALIZER` processing element's `EqualizerBandState` `frequency` when this processing
720    /// element did not advertise `CAN_CONTROL_FREQUENCY` in its `supported_controls`.
721    ///
722    /// `SetElementState` may be called before or after non-`SignalProcessing` protocol
723    /// calls. If called after non-`SignalProcessing` protocol calls then
724    /// `SetElementState` may or may not require renegotiation of the driver state as
725    /// reached with calls of the protocol composing `SignalProcessing`, e.g. `Dai`.
726    /// For instance, `SetElementState` changing an `AGL` processing element's parameters
727    /// may not require renegotiation of the `Dai` state because changing a gain parameter usually
728    /// does not change the set of supported audio formats.
729    /// By contrast, if `SetElementState` changes the parameters of a `CONNECTION_POINT`
730    /// element, the change may require renegotiation because it may invalidate the set of
731    /// supported formats returned in a previous `GetDaiFormats` `Dai` protocol call.
732    ///
733    /// It is the driver's job to determine when renegotiation is required. If renegotiation is
734    /// required, then `SetElementState` must return `ZX_ERR_BAD_STATE` and the client must
735    /// close the protocol channel such that the protocol negotiations are started over.
736    /// The client then must make the `SetElementState` call that returned
737    /// `ZX_ERR_BAD_STATE` before any non-`SignalProcessing` protocol calls.
738    pub fn r#set_element_state(
739        &self,
740        mut processing_element_id: u64,
741        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::SettableElementState,
742    ) -> fidl::client::QueryResponseFut<
743        fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateResult,
744        fidl::encoding::DefaultFuchsiaResourceDialect,
745    > {
746        ControlProxyInterface::r#set_element_state(self, processing_element_id, state)
747    }
748
749    /// Sets the topology to be used using an id to the vector returned by `GetTopologies`.
750    /// The current topology is communicated by `WatchTopology` responses. To change which topology
751    /// is active, a client uses `SetTopology`.
752    /// If the specified `topology_id` is not within the`topologies` returned by `GetTopologies`,
753    /// this call will return `ZX_ERR_INVALID_ARGS`.
754    /// If `GetTopologies` returns only one `Topology`, `SetTopology` is optional and has no effect.
755    ///
756    /// `SetTopology` may be called before or after non-`SignalProcessing` protocol calls.
757    /// If called after non-`SignalProcessing` protocol calls, then `SetTopology` may return
758    /// `ZX_ERR_BAD_STATE` to indicate that the operation can not proceed without renegotiation of
759    /// the driver state. See `SetElementState` for further discussion.
760    pub fn r#set_topology(
761        &self,
762        mut topology_id: u64,
763    ) -> fidl::client::QueryResponseFut<
764        fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyResult,
765        fidl::encoding::DefaultFuchsiaResourceDialect,
766    > {
767        ControlProxyInterface::r#set_topology(self, topology_id)
768    }
769
770    /// Create the ring buffer used to pass audio to/from this device. If the device is
771    /// Composite, then the targeted RING_BUFFER ENDPOINT must be identified by `element_id`.
772    ///
773    /// Should only be called for Composite devices.
774    pub fn r#create_ring_buffer(
775        &self,
776        mut payload: ControlCreateRingBufferRequest,
777    ) -> fidl::client::QueryResponseFut<
778        ControlCreateRingBufferResult,
779        fidl::encoding::DefaultFuchsiaResourceDialect,
780    > {
781        ControlProxyInterface::r#create_ring_buffer(self, payload)
782    }
783
784    /// Set the wire format for the digital interconnect connected to this Codec endpoint.
785    /// This method returns information related to the format that was set, including delay values.
786    /// If the device is Composite, then the targeted DAI_INTERCONNECT ENDPOINT must be identified
787    /// by `element_id`.
788    ///
789    /// Should only be called for Codec and Composite devices.
790    pub fn r#set_dai_format(
791        &self,
792        mut payload: &ControlSetDaiFormatRequest,
793    ) -> fidl::client::QueryResponseFut<
794        ControlSetDaiFormatResult,
795        fidl::encoding::DefaultFuchsiaResourceDialect,
796    > {
797        ControlProxyInterface::r#set_dai_format(self, payload)
798    }
799
800    /// Start the Codec hardware. If successful, this returns after the Codec was started and
801    /// `start_time` indicates the time when the hardware started. Note that the Codec's DaiFormat
802    /// must be set (by a successful `SetDaiFormat` call) before calling this method.
803    ///
804    /// Should only be called for Codec devices.
805    pub fn r#codec_start(
806        &self,
807    ) -> fidl::client::QueryResponseFut<
808        ControlCodecStartResult,
809        fidl::encoding::DefaultFuchsiaResourceDialect,
810    > {
811        ControlProxyInterface::r#codec_start(self)
812    }
813
814    /// Stop the Codec hardware. If successful, this returns after the Codec was stopped and
815    /// `stop_time` indicates the time when the hardware stopped. Note that the Codec's DaiFormat
816    /// must be set (by a successful `SetDaiFormat` call) before calling this method.
817    ///
818    /// Should only be called for Codec devices.
819    pub fn r#codec_stop(
820        &self,
821    ) -> fidl::client::QueryResponseFut<
822        ControlCodecStopResult,
823        fidl::encoding::DefaultFuchsiaResourceDialect,
824    > {
825        ControlProxyInterface::r#codec_stop(self)
826    }
827
828    /// Reset the hardware -- stopping the hardware, releasing any ring buffers, and clearing any
829    /// DaiFormats or RingBufferFormats that were set.
830    ///
831    /// This method returns when the hardware reset is complete.
832    /// After calling this method, the device is still controlled, but any ring buffers must be
833    /// re-created and re-started.
834    /// For devices with DAI_INTERCONNECTs (such as Codecs and some Composites), `SetDaiFormat` and
835    /// `CodecStart` must be called again (in that order) to return the interconnect to the active
836    /// operational mode.
837    /// As applicable, `SetTopology` and `SetElementState` must also be called.
838    ///
839    /// Should only be called for Codec and Composite devices.
840    pub fn r#reset(
841        &self,
842    ) -> fidl::client::QueryResponseFut<
843        ControlResetResult,
844        fidl::encoding::DefaultFuchsiaResourceDialect,
845    > {
846        ControlProxyInterface::r#reset(self)
847    }
848}
849
850impl ControlProxyInterface for ControlProxy {
851    type GetElementsResponseFut = fidl::client::QueryResponseFut<
852        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
853        fidl::encoding::DefaultFuchsiaResourceDialect,
854    >;
855    fn r#get_elements(&self) -> Self::GetElementsResponseFut {
856        fn _decode(
857            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
858        ) -> Result<
859            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
860            fidl::Error,
861        > {
862            let _response = fidl::client::decode_transaction_body::<
863                fidl::encoding::ResultType<
864                    fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResponse,
865                    i32,
866                >,
867                fidl::encoding::DefaultFuchsiaResourceDialect,
868                0x1b14ff4adf5dc6f8,
869            >(_buf?)?;
870            Ok(_response.map(|x| x.processing_elements))
871        }
872        self.client.send_query_and_decode::<
873            fidl::encoding::EmptyPayload,
874            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
875        >(
876            (),
877            0x1b14ff4adf5dc6f8,
878            fidl::encoding::DynamicFlags::empty(),
879            _decode,
880        )
881    }
882
883    type WatchElementStateResponseFut = fidl::client::QueryResponseFut<
884        fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
885        fidl::encoding::DefaultFuchsiaResourceDialect,
886    >;
887    fn r#watch_element_state(
888        &self,
889        mut processing_element_id: u64,
890    ) -> Self::WatchElementStateResponseFut {
891        fn _decode(
892            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
893        ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ElementState, fidl::Error>
894        {
895            let _response = fidl::client::decode_transaction_body::<
896                fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateResponse,
897                fidl::encoding::DefaultFuchsiaResourceDialect,
898                0x524da8772a69056f,
899            >(_buf?)?;
900            Ok(_response.state)
901        }
902        self.client.send_query_and_decode::<
903            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest,
904            fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
905        >(
906            (processing_element_id,),
907            0x524da8772a69056f,
908            fidl::encoding::DynamicFlags::empty(),
909            _decode,
910        )
911    }
912
913    type GetTopologiesResponseFut = fidl::client::QueryResponseFut<
914        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
915        fidl::encoding::DefaultFuchsiaResourceDialect,
916    >;
917    fn r#get_topologies(&self) -> Self::GetTopologiesResponseFut {
918        fn _decode(
919            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
920        ) -> Result<
921            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
922            fidl::Error,
923        > {
924            let _response = fidl::client::decode_transaction_body::<
925                fidl::encoding::ResultType<
926                    fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResponse,
927                    i32,
928                >,
929                fidl::encoding::DefaultFuchsiaResourceDialect,
930                0x73ffb73af24d30b6,
931            >(_buf?)?;
932            Ok(_response.map(|x| x.topologies))
933        }
934        self.client.send_query_and_decode::<
935            fidl::encoding::EmptyPayload,
936            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
937        >(
938            (),
939            0x73ffb73af24d30b6,
940            fidl::encoding::DynamicFlags::empty(),
941            _decode,
942        )
943    }
944
945    type WatchTopologyResponseFut =
946        fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
947    fn r#watch_topology(&self) -> Self::WatchTopologyResponseFut {
948        fn _decode(
949            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
950        ) -> Result<u64, fidl::Error> {
951            let _response = fidl::client::decode_transaction_body::<
952                fidl::encoding::FlexibleType<
953                    fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchTopologyResponse,
954                >,
955                fidl::encoding::DefaultFuchsiaResourceDialect,
956                0x66d172acdb36a729,
957            >(_buf?)?
958            .into_result::<ControlMarker>("watch_topology")?;
959            Ok(_response.topology_id)
960        }
961        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u64>(
962            (),
963            0x66d172acdb36a729,
964            fidl::encoding::DynamicFlags::FLEXIBLE,
965            _decode,
966        )
967    }
968
969    type SetElementStateResponseFut = fidl::client::QueryResponseFut<
970        fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateResult,
971        fidl::encoding::DefaultFuchsiaResourceDialect,
972    >;
973    fn r#set_element_state(
974        &self,
975        mut processing_element_id: u64,
976        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::SettableElementState,
977    ) -> Self::SetElementStateResponseFut {
978        fn _decode(
979            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
980        ) -> Result<
981            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateResult,
982            fidl::Error,
983        > {
984            let _response = fidl::client::decode_transaction_body::<
985                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
986                fidl::encoding::DefaultFuchsiaResourceDialect,
987                0x38c3b2d4bae698f4,
988            >(_buf?)?;
989            Ok(_response.map(|x| x))
990        }
991        self.client.send_query_and_decode::<
992            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateRequest,
993            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateResult,
994        >(
995            (processing_element_id, state,),
996            0x38c3b2d4bae698f4,
997            fidl::encoding::DynamicFlags::empty(),
998            _decode,
999        )
1000    }
1001
1002    type SetTopologyResponseFut = fidl::client::QueryResponseFut<
1003        fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyResult,
1004        fidl::encoding::DefaultFuchsiaResourceDialect,
1005    >;
1006    fn r#set_topology(&self, mut topology_id: u64) -> Self::SetTopologyResponseFut {
1007        fn _decode(
1008            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1009        ) -> Result<
1010            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyResult,
1011            fidl::Error,
1012        > {
1013            let _response = fidl::client::decode_transaction_body::<
1014                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1015                fidl::encoding::DefaultFuchsiaResourceDialect,
1016                0x1d9a7f9b8fee790c,
1017            >(_buf?)?;
1018            Ok(_response.map(|x| x))
1019        }
1020        self.client.send_query_and_decode::<
1021            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyRequest,
1022            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyResult,
1023        >(
1024            (topology_id,),
1025            0x1d9a7f9b8fee790c,
1026            fidl::encoding::DynamicFlags::empty(),
1027            _decode,
1028        )
1029    }
1030
1031    type CreateRingBufferResponseFut = fidl::client::QueryResponseFut<
1032        ControlCreateRingBufferResult,
1033        fidl::encoding::DefaultFuchsiaResourceDialect,
1034    >;
1035    fn r#create_ring_buffer(
1036        &self,
1037        mut payload: ControlCreateRingBufferRequest,
1038    ) -> Self::CreateRingBufferResponseFut {
1039        fn _decode(
1040            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1041        ) -> Result<ControlCreateRingBufferResult, fidl::Error> {
1042            let _response = fidl::client::decode_transaction_body::<
1043                fidl::encoding::FlexibleResultType<
1044                    ControlCreateRingBufferResponse,
1045                    ControlCreateRingBufferError,
1046                >,
1047                fidl::encoding::DefaultFuchsiaResourceDialect,
1048                0x7462941cedb333db,
1049            >(_buf?)?
1050            .into_result::<ControlMarker>("create_ring_buffer")?;
1051            Ok(_response.map(|x| x))
1052        }
1053        self.client
1054            .send_query_and_decode::<ControlCreateRingBufferRequest, ControlCreateRingBufferResult>(
1055                &mut payload,
1056                0x7462941cedb333db,
1057                fidl::encoding::DynamicFlags::FLEXIBLE,
1058                _decode,
1059            )
1060    }
1061
1062    type SetDaiFormatResponseFut = fidl::client::QueryResponseFut<
1063        ControlSetDaiFormatResult,
1064        fidl::encoding::DefaultFuchsiaResourceDialect,
1065    >;
1066    fn r#set_dai_format(
1067        &self,
1068        mut payload: &ControlSetDaiFormatRequest,
1069    ) -> Self::SetDaiFormatResponseFut {
1070        fn _decode(
1071            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1072        ) -> Result<ControlSetDaiFormatResult, fidl::Error> {
1073            let _response = fidl::client::decode_transaction_body::<
1074                fidl::encoding::FlexibleResultType<
1075                    ControlSetDaiFormatResponse,
1076                    ControlSetDaiFormatError,
1077                >,
1078                fidl::encoding::DefaultFuchsiaResourceDialect,
1079                0x1d84f5a456a92216,
1080            >(_buf?)?
1081            .into_result::<ControlMarker>("set_dai_format")?;
1082            Ok(_response.map(|x| x))
1083        }
1084        self.client.send_query_and_decode::<ControlSetDaiFormatRequest, ControlSetDaiFormatResult>(
1085            payload,
1086            0x1d84f5a456a92216,
1087            fidl::encoding::DynamicFlags::FLEXIBLE,
1088            _decode,
1089        )
1090    }
1091
1092    type CodecStartResponseFut = fidl::client::QueryResponseFut<
1093        ControlCodecStartResult,
1094        fidl::encoding::DefaultFuchsiaResourceDialect,
1095    >;
1096    fn r#codec_start(&self) -> Self::CodecStartResponseFut {
1097        fn _decode(
1098            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1099        ) -> Result<ControlCodecStartResult, fidl::Error> {
1100            let _response = fidl::client::decode_transaction_body::<
1101                fidl::encoding::FlexibleResultType<
1102                    ControlCodecStartResponse,
1103                    ControlCodecStartError,
1104                >,
1105                fidl::encoding::DefaultFuchsiaResourceDialect,
1106                0x2a90a9d2958b997b,
1107            >(_buf?)?
1108            .into_result::<ControlMarker>("codec_start")?;
1109            Ok(_response.map(|x| x))
1110        }
1111        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ControlCodecStartResult>(
1112            (),
1113            0x2a90a9d2958b997b,
1114            fidl::encoding::DynamicFlags::FLEXIBLE,
1115            _decode,
1116        )
1117    }
1118
1119    type CodecStopResponseFut = fidl::client::QueryResponseFut<
1120        ControlCodecStopResult,
1121        fidl::encoding::DefaultFuchsiaResourceDialect,
1122    >;
1123    fn r#codec_stop(&self) -> Self::CodecStopResponseFut {
1124        fn _decode(
1125            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1126        ) -> Result<ControlCodecStopResult, fidl::Error> {
1127            let _response = fidl::client::decode_transaction_body::<
1128                fidl::encoding::FlexibleResultType<ControlCodecStopResponse, ControlCodecStopError>,
1129                fidl::encoding::DefaultFuchsiaResourceDialect,
1130                0x387297bb6bcad25f,
1131            >(_buf?)?
1132            .into_result::<ControlMarker>("codec_stop")?;
1133            Ok(_response.map(|x| x))
1134        }
1135        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ControlCodecStopResult>(
1136            (),
1137            0x387297bb6bcad25f,
1138            fidl::encoding::DynamicFlags::FLEXIBLE,
1139            _decode,
1140        )
1141    }
1142
1143    type ResetResponseFut = fidl::client::QueryResponseFut<
1144        ControlResetResult,
1145        fidl::encoding::DefaultFuchsiaResourceDialect,
1146    >;
1147    fn r#reset(&self) -> Self::ResetResponseFut {
1148        fn _decode(
1149            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1150        ) -> Result<ControlResetResult, fidl::Error> {
1151            let _response = fidl::client::decode_transaction_body::<
1152                fidl::encoding::FlexibleResultType<ControlResetResponse, ControlResetError>,
1153                fidl::encoding::DefaultFuchsiaResourceDialect,
1154                0x49840db00a698996,
1155            >(_buf?)?
1156            .into_result::<ControlMarker>("reset")?;
1157            Ok(_response.map(|x| x))
1158        }
1159        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ControlResetResult>(
1160            (),
1161            0x49840db00a698996,
1162            fidl::encoding::DynamicFlags::FLEXIBLE,
1163            _decode,
1164        )
1165    }
1166}
1167
1168pub struct ControlEventStream {
1169    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1170}
1171
1172impl std::marker::Unpin for ControlEventStream {}
1173
1174impl futures::stream::FusedStream for ControlEventStream {
1175    fn is_terminated(&self) -> bool {
1176        self.event_receiver.is_terminated()
1177    }
1178}
1179
1180impl futures::Stream for ControlEventStream {
1181    type Item = Result<ControlEvent, fidl::Error>;
1182
1183    fn poll_next(
1184        mut self: std::pin::Pin<&mut Self>,
1185        cx: &mut std::task::Context<'_>,
1186    ) -> std::task::Poll<Option<Self::Item>> {
1187        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1188            &mut self.event_receiver,
1189            cx
1190        )?) {
1191            Some(buf) => std::task::Poll::Ready(Some(ControlEvent::decode(buf))),
1192            None => std::task::Poll::Ready(None),
1193        }
1194    }
1195}
1196
1197#[derive(Debug)]
1198pub enum ControlEvent {
1199    #[non_exhaustive]
1200    _UnknownEvent {
1201        /// Ordinal of the event that was sent.
1202        ordinal: u64,
1203    },
1204}
1205
1206impl ControlEvent {
1207    /// Decodes a message buffer as a [`ControlEvent`].
1208    fn decode(
1209        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1210    ) -> Result<ControlEvent, fidl::Error> {
1211        let (bytes, _handles) = buf.split_mut();
1212        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1213        debug_assert_eq!(tx_header.tx_id, 0);
1214        match tx_header.ordinal {
1215            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1216                Ok(ControlEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1217            }
1218            _ => Err(fidl::Error::UnknownOrdinal {
1219                ordinal: tx_header.ordinal,
1220                protocol_name: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1221            }),
1222        }
1223    }
1224}
1225
1226/// A Stream of incoming requests for fuchsia.audio.device/Control.
1227pub struct ControlRequestStream {
1228    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1229    is_terminated: bool,
1230}
1231
1232impl std::marker::Unpin for ControlRequestStream {}
1233
1234impl futures::stream::FusedStream for ControlRequestStream {
1235    fn is_terminated(&self) -> bool {
1236        self.is_terminated
1237    }
1238}
1239
1240impl fidl::endpoints::RequestStream for ControlRequestStream {
1241    type Protocol = ControlMarker;
1242    type ControlHandle = ControlControlHandle;
1243
1244    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1245        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1246    }
1247
1248    fn control_handle(&self) -> Self::ControlHandle {
1249        ControlControlHandle { inner: self.inner.clone() }
1250    }
1251
1252    fn into_inner(
1253        self,
1254    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1255    {
1256        (self.inner, self.is_terminated)
1257    }
1258
1259    fn from_inner(
1260        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1261        is_terminated: bool,
1262    ) -> Self {
1263        Self { inner, is_terminated }
1264    }
1265}
1266
1267impl futures::Stream for ControlRequestStream {
1268    type Item = Result<ControlRequest, fidl::Error>;
1269
1270    fn poll_next(
1271        mut self: std::pin::Pin<&mut Self>,
1272        cx: &mut std::task::Context<'_>,
1273    ) -> std::task::Poll<Option<Self::Item>> {
1274        let this = &mut *self;
1275        if this.inner.check_shutdown(cx) {
1276            this.is_terminated = true;
1277            return std::task::Poll::Ready(None);
1278        }
1279        if this.is_terminated {
1280            panic!("polled ControlRequestStream after completion");
1281        }
1282        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1283            |bytes, handles| {
1284                match this.inner.channel().read_etc(cx, bytes, handles) {
1285                    std::task::Poll::Ready(Ok(())) => {}
1286                    std::task::Poll::Pending => return std::task::Poll::Pending,
1287                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1288                        this.is_terminated = true;
1289                        return std::task::Poll::Ready(None);
1290                    }
1291                    std::task::Poll::Ready(Err(e)) => {
1292                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1293                            e.into(),
1294                        ))))
1295                    }
1296                }
1297
1298                // A message has been received from the channel
1299                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1300
1301                std::task::Poll::Ready(Some(match header.ordinal {
1302                    0x1b14ff4adf5dc6f8 => {
1303                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1304                        let mut req = fidl::new_empty!(
1305                            fidl::encoding::EmptyPayload,
1306                            fidl::encoding::DefaultFuchsiaResourceDialect
1307                        );
1308                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1309                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1310                        Ok(ControlRequest::GetElements {
1311                            responder: ControlGetElementsResponder {
1312                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1313                                tx_id: header.tx_id,
1314                            },
1315                        })
1316                    }
1317                    0x524da8772a69056f => {
1318                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1319                        let mut req = fidl::new_empty!(fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1320                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest>(&header, _body_bytes, handles, &mut req)?;
1321                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1322                        Ok(ControlRequest::WatchElementState {
1323                            processing_element_id: req.processing_element_id,
1324
1325                            responder: ControlWatchElementStateResponder {
1326                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1327                                tx_id: header.tx_id,
1328                            },
1329                        })
1330                    }
1331                    0x73ffb73af24d30b6 => {
1332                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1333                        let mut req = fidl::new_empty!(
1334                            fidl::encoding::EmptyPayload,
1335                            fidl::encoding::DefaultFuchsiaResourceDialect
1336                        );
1337                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1338                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1339                        Ok(ControlRequest::GetTopologies {
1340                            responder: ControlGetTopologiesResponder {
1341                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1342                                tx_id: header.tx_id,
1343                            },
1344                        })
1345                    }
1346                    0x66d172acdb36a729 => {
1347                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1348                        let mut req = fidl::new_empty!(
1349                            fidl::encoding::EmptyPayload,
1350                            fidl::encoding::DefaultFuchsiaResourceDialect
1351                        );
1352                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1353                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1354                        Ok(ControlRequest::WatchTopology {
1355                            responder: ControlWatchTopologyResponder {
1356                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1357                                tx_id: header.tx_id,
1358                            },
1359                        })
1360                    }
1361                    0x38c3b2d4bae698f4 => {
1362                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1363                        let mut req = fidl::new_empty!(fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1364                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateRequest>(&header, _body_bytes, handles, &mut req)?;
1365                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1366                        Ok(ControlRequest::SetElementState {
1367                            processing_element_id: req.processing_element_id,
1368                            state: req.state,
1369
1370                            responder: ControlSetElementStateResponder {
1371                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1372                                tx_id: header.tx_id,
1373                            },
1374                        })
1375                    }
1376                    0x1d9a7f9b8fee790c => {
1377                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1378                        let mut req = fidl::new_empty!(fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1379                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyRequest>(&header, _body_bytes, handles, &mut req)?;
1380                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1381                        Ok(ControlRequest::SetTopology {
1382                            topology_id: req.topology_id,
1383
1384                            responder: ControlSetTopologyResponder {
1385                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1386                                tx_id: header.tx_id,
1387                            },
1388                        })
1389                    }
1390                    0x7462941cedb333db => {
1391                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1392                        let mut req = fidl::new_empty!(
1393                            ControlCreateRingBufferRequest,
1394                            fidl::encoding::DefaultFuchsiaResourceDialect
1395                        );
1396                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlCreateRingBufferRequest>(&header, _body_bytes, handles, &mut req)?;
1397                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1398                        Ok(ControlRequest::CreateRingBuffer {
1399                            payload: req,
1400                            responder: ControlCreateRingBufferResponder {
1401                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1402                                tx_id: header.tx_id,
1403                            },
1404                        })
1405                    }
1406                    0x1d84f5a456a92216 => {
1407                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1408                        let mut req = fidl::new_empty!(
1409                            ControlSetDaiFormatRequest,
1410                            fidl::encoding::DefaultFuchsiaResourceDialect
1411                        );
1412                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetDaiFormatRequest>(&header, _body_bytes, handles, &mut req)?;
1413                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1414                        Ok(ControlRequest::SetDaiFormat {
1415                            payload: req,
1416                            responder: ControlSetDaiFormatResponder {
1417                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1418                                tx_id: header.tx_id,
1419                            },
1420                        })
1421                    }
1422                    0x2a90a9d2958b997b => {
1423                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1424                        let mut req = fidl::new_empty!(
1425                            fidl::encoding::EmptyPayload,
1426                            fidl::encoding::DefaultFuchsiaResourceDialect
1427                        );
1428                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1429                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1430                        Ok(ControlRequest::CodecStart {
1431                            responder: ControlCodecStartResponder {
1432                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1433                                tx_id: header.tx_id,
1434                            },
1435                        })
1436                    }
1437                    0x387297bb6bcad25f => {
1438                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1439                        let mut req = fidl::new_empty!(
1440                            fidl::encoding::EmptyPayload,
1441                            fidl::encoding::DefaultFuchsiaResourceDialect
1442                        );
1443                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1444                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1445                        Ok(ControlRequest::CodecStop {
1446                            responder: ControlCodecStopResponder {
1447                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1448                                tx_id: header.tx_id,
1449                            },
1450                        })
1451                    }
1452                    0x49840db00a698996 => {
1453                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1454                        let mut req = fidl::new_empty!(
1455                            fidl::encoding::EmptyPayload,
1456                            fidl::encoding::DefaultFuchsiaResourceDialect
1457                        );
1458                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1459                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1460                        Ok(ControlRequest::Reset {
1461                            responder: ControlResetResponder {
1462                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1463                                tx_id: header.tx_id,
1464                            },
1465                        })
1466                    }
1467                    _ if header.tx_id == 0
1468                        && header
1469                            .dynamic_flags()
1470                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1471                    {
1472                        Ok(ControlRequest::_UnknownMethod {
1473                            ordinal: header.ordinal,
1474                            control_handle: ControlControlHandle { inner: this.inner.clone() },
1475                            method_type: fidl::MethodType::OneWay,
1476                        })
1477                    }
1478                    _ if header
1479                        .dynamic_flags()
1480                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1481                    {
1482                        this.inner.send_framework_err(
1483                            fidl::encoding::FrameworkErr::UnknownMethod,
1484                            header.tx_id,
1485                            header.ordinal,
1486                            header.dynamic_flags(),
1487                            (bytes, handles),
1488                        )?;
1489                        Ok(ControlRequest::_UnknownMethod {
1490                            ordinal: header.ordinal,
1491                            control_handle: ControlControlHandle { inner: this.inner.clone() },
1492                            method_type: fidl::MethodType::TwoWay,
1493                        })
1494                    }
1495                    _ => Err(fidl::Error::UnknownOrdinal {
1496                        ordinal: header.ordinal,
1497                        protocol_name:
1498                            <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1499                    }),
1500                }))
1501            },
1502        )
1503    }
1504}
1505
1506/// A `Control` instance is used to change the settings or state of an audio
1507/// device. It also creates the ring buffer used to pass audio data between
1508/// client and device. Each `Control` is associated with an initialized audio
1509/// device; conversely each device is associated with either zero or one
1510/// `Control` at any time.
1511#[derive(Debug)]
1512pub enum ControlRequest {
1513    /// Returns a vector of supported processing elements.
1514    /// Must return one or more processing elements, or `ZX_ERR_NOT_SUPPORTED`.
1515    /// If `GetTopologies` returns one or more topologies, then `GetElements` must return one or
1516    /// more elements.
1517    GetElements { responder: ControlGetElementsResponder },
1518    /// Get the processing element state via a hanging get.
1519    /// For a given `processing_element_id`, the driver will reply to the first `WatchElementState`
1520    /// sent by the client. The driver will not respond to subsequent client `WatchElementState`
1521    /// calls for a given `processing_element_id` until any field of the `Element` table changes
1522    /// from what was most recently reported for that `processing_element_id`.
1523    ///
1524    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
1525    /// method is called again while there is already a pending `WatchElementState` for this client
1526    /// and processing_element_id.
1527    WatchElementState { processing_element_id: u64, responder: ControlWatchElementStateResponder },
1528    /// Returns a vector of supported topologies.
1529    /// Must return one or more topologies, or `ZX_ERR_NOT_SUPPORTED`.
1530    /// If more than one topology is returned, then the client may choose any of the topologies from
1531    /// the list with `SetTopology`.
1532    /// If only one topology is returned, then the topology definition is informational only since
1533    /// the one and only topology used can't be changed with `SetTopology`.
1534    /// If `GetElements` returns one or more elements, then `GetTopologies` must return one or
1535    /// more topologies.
1536    GetTopologies { responder: ControlGetTopologiesResponder },
1537    /// Get the current topology via a hanging get.
1538    /// The driver will immediately reply to the first `WatchTopology` sent by each client. The
1539    /// driver will not respond to subsequent `WatchTopology` calls from that client until the
1540    /// signal-processing topology changes, which occurs as a result of a `SetTopology` call.
1541    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
1542    /// method is called again while there is already a pending `WatchTopology` for this client.
1543    WatchTopology { responder: ControlWatchTopologyResponder },
1544    /// Controls a processing element using a unique ElementId returned by `GetElements`.
1545    /// Note that `SettableElementState` is a subset of `ElementState`, because some fields returned
1546    /// from `WatchElementState` (e.g. `latency`) can only be observed (not set) by the client.
1547    ///
1548    /// Returns `ZX_ERR_INVALID_ARGS` if the `processing_element_id` does not match an id returned
1549    /// by `GetElements` or the type of `SettableTypeSpecificElementState` does not
1550    /// match the `ElementType` of the processing element returned by
1551    /// `GetElements` for this id.
1552    /// The driver may return `ZX_ERR_INVALID_ARGS` if the `state` values are invalid, i.e. any
1553    /// of the values violates rules specified in this protocol, e.g. trying to change an
1554    /// `EQUALIZER` processing element's `EqualizerBandState` `frequency` when this processing
1555    /// element did not advertise `CAN_CONTROL_FREQUENCY` in its `supported_controls`.
1556    ///
1557    /// `SetElementState` may be called before or after non-`SignalProcessing` protocol
1558    /// calls. If called after non-`SignalProcessing` protocol calls then
1559    /// `SetElementState` may or may not require renegotiation of the driver state as
1560    /// reached with calls of the protocol composing `SignalProcessing`, e.g. `Dai`.
1561    /// For instance, `SetElementState` changing an `AGL` processing element's parameters
1562    /// may not require renegotiation of the `Dai` state because changing a gain parameter usually
1563    /// does not change the set of supported audio formats.
1564    /// By contrast, if `SetElementState` changes the parameters of a `CONNECTION_POINT`
1565    /// element, the change may require renegotiation because it may invalidate the set of
1566    /// supported formats returned in a previous `GetDaiFormats` `Dai` protocol call.
1567    ///
1568    /// It is the driver's job to determine when renegotiation is required. If renegotiation is
1569    /// required, then `SetElementState` must return `ZX_ERR_BAD_STATE` and the client must
1570    /// close the protocol channel such that the protocol negotiations are started over.
1571    /// The client then must make the `SetElementState` call that returned
1572    /// `ZX_ERR_BAD_STATE` before any non-`SignalProcessing` protocol calls.
1573    SetElementState {
1574        processing_element_id: u64,
1575        state: fidl_fuchsia_hardware_audio_signalprocessing::SettableElementState,
1576        responder: ControlSetElementStateResponder,
1577    },
1578    /// Sets the topology to be used using an id to the vector returned by `GetTopologies`.
1579    /// The current topology is communicated by `WatchTopology` responses. To change which topology
1580    /// is active, a client uses `SetTopology`.
1581    /// If the specified `topology_id` is not within the`topologies` returned by `GetTopologies`,
1582    /// this call will return `ZX_ERR_INVALID_ARGS`.
1583    /// If `GetTopologies` returns only one `Topology`, `SetTopology` is optional and has no effect.
1584    ///
1585    /// `SetTopology` may be called before or after non-`SignalProcessing` protocol calls.
1586    /// If called after non-`SignalProcessing` protocol calls, then `SetTopology` may return
1587    /// `ZX_ERR_BAD_STATE` to indicate that the operation can not proceed without renegotiation of
1588    /// the driver state. See `SetElementState` for further discussion.
1589    SetTopology { topology_id: u64, responder: ControlSetTopologyResponder },
1590    /// Create the ring buffer used to pass audio to/from this device. If the device is
1591    /// Composite, then the targeted RING_BUFFER ENDPOINT must be identified by `element_id`.
1592    ///
1593    /// Should only be called for Composite devices.
1594    CreateRingBuffer {
1595        payload: ControlCreateRingBufferRequest,
1596        responder: ControlCreateRingBufferResponder,
1597    },
1598    /// Set the wire format for the digital interconnect connected to this Codec endpoint.
1599    /// This method returns information related to the format that was set, including delay values.
1600    /// If the device is Composite, then the targeted DAI_INTERCONNECT ENDPOINT must be identified
1601    /// by `element_id`.
1602    ///
1603    /// Should only be called for Codec and Composite devices.
1604    SetDaiFormat { payload: ControlSetDaiFormatRequest, responder: ControlSetDaiFormatResponder },
1605    /// Start the Codec hardware. If successful, this returns after the Codec was started and
1606    /// `start_time` indicates the time when the hardware started. Note that the Codec's DaiFormat
1607    /// must be set (by a successful `SetDaiFormat` call) before calling this method.
1608    ///
1609    /// Should only be called for Codec devices.
1610    CodecStart { responder: ControlCodecStartResponder },
1611    /// Stop the Codec hardware. If successful, this returns after the Codec was stopped and
1612    /// `stop_time` indicates the time when the hardware stopped. Note that the Codec's DaiFormat
1613    /// must be set (by a successful `SetDaiFormat` call) before calling this method.
1614    ///
1615    /// Should only be called for Codec devices.
1616    CodecStop { responder: ControlCodecStopResponder },
1617    /// Reset the hardware -- stopping the hardware, releasing any ring buffers, and clearing any
1618    /// DaiFormats or RingBufferFormats that were set.
1619    ///
1620    /// This method returns when the hardware reset is complete.
1621    /// After calling this method, the device is still controlled, but any ring buffers must be
1622    /// re-created and re-started.
1623    /// For devices with DAI_INTERCONNECTs (such as Codecs and some Composites), `SetDaiFormat` and
1624    /// `CodecStart` must be called again (in that order) to return the interconnect to the active
1625    /// operational mode.
1626    /// As applicable, `SetTopology` and `SetElementState` must also be called.
1627    ///
1628    /// Should only be called for Codec and Composite devices.
1629    Reset { responder: ControlResetResponder },
1630    /// An interaction was received which does not match any known method.
1631    #[non_exhaustive]
1632    _UnknownMethod {
1633        /// Ordinal of the method that was called.
1634        ordinal: u64,
1635        control_handle: ControlControlHandle,
1636        method_type: fidl::MethodType,
1637    },
1638}
1639
1640impl ControlRequest {
1641    #[allow(irrefutable_let_patterns)]
1642    pub fn into_get_elements(self) -> Option<(ControlGetElementsResponder)> {
1643        if let ControlRequest::GetElements { responder } = self {
1644            Some((responder))
1645        } else {
1646            None
1647        }
1648    }
1649
1650    #[allow(irrefutable_let_patterns)]
1651    pub fn into_watch_element_state(self) -> Option<(u64, ControlWatchElementStateResponder)> {
1652        if let ControlRequest::WatchElementState { processing_element_id, responder } = self {
1653            Some((processing_element_id, responder))
1654        } else {
1655            None
1656        }
1657    }
1658
1659    #[allow(irrefutable_let_patterns)]
1660    pub fn into_get_topologies(self) -> Option<(ControlGetTopologiesResponder)> {
1661        if let ControlRequest::GetTopologies { responder } = self {
1662            Some((responder))
1663        } else {
1664            None
1665        }
1666    }
1667
1668    #[allow(irrefutable_let_patterns)]
1669    pub fn into_watch_topology(self) -> Option<(ControlWatchTopologyResponder)> {
1670        if let ControlRequest::WatchTopology { responder } = self {
1671            Some((responder))
1672        } else {
1673            None
1674        }
1675    }
1676
1677    #[allow(irrefutable_let_patterns)]
1678    pub fn into_set_element_state(
1679        self,
1680    ) -> Option<(
1681        u64,
1682        fidl_fuchsia_hardware_audio_signalprocessing::SettableElementState,
1683        ControlSetElementStateResponder,
1684    )> {
1685        if let ControlRequest::SetElementState { processing_element_id, state, responder } = self {
1686            Some((processing_element_id, state, responder))
1687        } else {
1688            None
1689        }
1690    }
1691
1692    #[allow(irrefutable_let_patterns)]
1693    pub fn into_set_topology(self) -> Option<(u64, ControlSetTopologyResponder)> {
1694        if let ControlRequest::SetTopology { topology_id, responder } = self {
1695            Some((topology_id, responder))
1696        } else {
1697            None
1698        }
1699    }
1700
1701    #[allow(irrefutable_let_patterns)]
1702    pub fn into_create_ring_buffer(
1703        self,
1704    ) -> Option<(ControlCreateRingBufferRequest, ControlCreateRingBufferResponder)> {
1705        if let ControlRequest::CreateRingBuffer { payload, responder } = self {
1706            Some((payload, responder))
1707        } else {
1708            None
1709        }
1710    }
1711
1712    #[allow(irrefutable_let_patterns)]
1713    pub fn into_set_dai_format(
1714        self,
1715    ) -> Option<(ControlSetDaiFormatRequest, ControlSetDaiFormatResponder)> {
1716        if let ControlRequest::SetDaiFormat { payload, responder } = self {
1717            Some((payload, responder))
1718        } else {
1719            None
1720        }
1721    }
1722
1723    #[allow(irrefutable_let_patterns)]
1724    pub fn into_codec_start(self) -> Option<(ControlCodecStartResponder)> {
1725        if let ControlRequest::CodecStart { responder } = self {
1726            Some((responder))
1727        } else {
1728            None
1729        }
1730    }
1731
1732    #[allow(irrefutable_let_patterns)]
1733    pub fn into_codec_stop(self) -> Option<(ControlCodecStopResponder)> {
1734        if let ControlRequest::CodecStop { responder } = self {
1735            Some((responder))
1736        } else {
1737            None
1738        }
1739    }
1740
1741    #[allow(irrefutable_let_patterns)]
1742    pub fn into_reset(self) -> Option<(ControlResetResponder)> {
1743        if let ControlRequest::Reset { responder } = self {
1744            Some((responder))
1745        } else {
1746            None
1747        }
1748    }
1749
1750    /// Name of the method defined in FIDL
1751    pub fn method_name(&self) -> &'static str {
1752        match *self {
1753            ControlRequest::GetElements { .. } => "get_elements",
1754            ControlRequest::WatchElementState { .. } => "watch_element_state",
1755            ControlRequest::GetTopologies { .. } => "get_topologies",
1756            ControlRequest::WatchTopology { .. } => "watch_topology",
1757            ControlRequest::SetElementState { .. } => "set_element_state",
1758            ControlRequest::SetTopology { .. } => "set_topology",
1759            ControlRequest::CreateRingBuffer { .. } => "create_ring_buffer",
1760            ControlRequest::SetDaiFormat { .. } => "set_dai_format",
1761            ControlRequest::CodecStart { .. } => "codec_start",
1762            ControlRequest::CodecStop { .. } => "codec_stop",
1763            ControlRequest::Reset { .. } => "reset",
1764            ControlRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1765                "unknown one-way method"
1766            }
1767            ControlRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1768                "unknown two-way method"
1769            }
1770        }
1771    }
1772}
1773
1774#[derive(Debug, Clone)]
1775pub struct ControlControlHandle {
1776    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1777}
1778
1779impl fidl::endpoints::ControlHandle for ControlControlHandle {
1780    fn shutdown(&self) {
1781        self.inner.shutdown()
1782    }
1783    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1784        self.inner.shutdown_with_epitaph(status)
1785    }
1786
1787    fn is_closed(&self) -> bool {
1788        self.inner.channel().is_closed()
1789    }
1790    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1791        self.inner.channel().on_closed()
1792    }
1793
1794    #[cfg(target_os = "fuchsia")]
1795    fn signal_peer(
1796        &self,
1797        clear_mask: zx::Signals,
1798        set_mask: zx::Signals,
1799    ) -> Result<(), zx_status::Status> {
1800        use fidl::Peered;
1801        self.inner.channel().signal_peer(clear_mask, set_mask)
1802    }
1803}
1804
1805impl ControlControlHandle {}
1806
1807#[must_use = "FIDL methods require a response to be sent"]
1808#[derive(Debug)]
1809pub struct ControlGetElementsResponder {
1810    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
1811    tx_id: u32,
1812}
1813
1814/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
1815/// if the responder is dropped without sending a response, so that the client
1816/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1817impl std::ops::Drop for ControlGetElementsResponder {
1818    fn drop(&mut self) {
1819        self.control_handle.shutdown();
1820        // Safety: drops once, never accessed again
1821        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1822    }
1823}
1824
1825impl fidl::endpoints::Responder for ControlGetElementsResponder {
1826    type ControlHandle = ControlControlHandle;
1827
1828    fn control_handle(&self) -> &ControlControlHandle {
1829        &self.control_handle
1830    }
1831
1832    fn drop_without_shutdown(mut self) {
1833        // Safety: drops once, never accessed again due to mem::forget
1834        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1835        // Prevent Drop from running (which would shut down the channel)
1836        std::mem::forget(self);
1837    }
1838}
1839
1840impl ControlGetElementsResponder {
1841    /// Sends a response to the FIDL transaction.
1842    ///
1843    /// Sets the channel to shutdown if an error occurs.
1844    pub fn send(
1845        self,
1846        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Element], i32>,
1847    ) -> Result<(), fidl::Error> {
1848        let _result = self.send_raw(result);
1849        if _result.is_err() {
1850            self.control_handle.shutdown();
1851        }
1852        self.drop_without_shutdown();
1853        _result
1854    }
1855
1856    /// Similar to "send" but does not shutdown the channel if an error occurs.
1857    pub fn send_no_shutdown_on_err(
1858        self,
1859        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Element], i32>,
1860    ) -> Result<(), fidl::Error> {
1861        let _result = self.send_raw(result);
1862        self.drop_without_shutdown();
1863        _result
1864    }
1865
1866    fn send_raw(
1867        &self,
1868        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Element], i32>,
1869    ) -> Result<(), fidl::Error> {
1870        self.control_handle.inner.send::<fidl::encoding::ResultType<
1871            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResponse,
1872            i32,
1873        >>(
1874            result.map(|processing_elements| (processing_elements,)),
1875            self.tx_id,
1876            0x1b14ff4adf5dc6f8,
1877            fidl::encoding::DynamicFlags::empty(),
1878        )
1879    }
1880}
1881
1882#[must_use = "FIDL methods require a response to be sent"]
1883#[derive(Debug)]
1884pub struct ControlWatchElementStateResponder {
1885    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
1886    tx_id: u32,
1887}
1888
1889/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
1890/// if the responder is dropped without sending a response, so that the client
1891/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1892impl std::ops::Drop for ControlWatchElementStateResponder {
1893    fn drop(&mut self) {
1894        self.control_handle.shutdown();
1895        // Safety: drops once, never accessed again
1896        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1897    }
1898}
1899
1900impl fidl::endpoints::Responder for ControlWatchElementStateResponder {
1901    type ControlHandle = ControlControlHandle;
1902
1903    fn control_handle(&self) -> &ControlControlHandle {
1904        &self.control_handle
1905    }
1906
1907    fn drop_without_shutdown(mut self) {
1908        // Safety: drops once, never accessed again due to mem::forget
1909        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1910        // Prevent Drop from running (which would shut down the channel)
1911        std::mem::forget(self);
1912    }
1913}
1914
1915impl ControlWatchElementStateResponder {
1916    /// Sends a response to the FIDL transaction.
1917    ///
1918    /// Sets the channel to shutdown if an error occurs.
1919    pub fn send(
1920        self,
1921        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
1922    ) -> Result<(), fidl::Error> {
1923        let _result = self.send_raw(state);
1924        if _result.is_err() {
1925            self.control_handle.shutdown();
1926        }
1927        self.drop_without_shutdown();
1928        _result
1929    }
1930
1931    /// Similar to "send" but does not shutdown the channel if an error occurs.
1932    pub fn send_no_shutdown_on_err(
1933        self,
1934        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
1935    ) -> Result<(), fidl::Error> {
1936        let _result = self.send_raw(state);
1937        self.drop_without_shutdown();
1938        _result
1939    }
1940
1941    fn send_raw(
1942        &self,
1943        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
1944    ) -> Result<(), fidl::Error> {
1945        self.control_handle
1946            .inner
1947            .send::<fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateResponse>(
1948            (state,),
1949            self.tx_id,
1950            0x524da8772a69056f,
1951            fidl::encoding::DynamicFlags::empty(),
1952        )
1953    }
1954}
1955
1956#[must_use = "FIDL methods require a response to be sent"]
1957#[derive(Debug)]
1958pub struct ControlGetTopologiesResponder {
1959    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
1960    tx_id: u32,
1961}
1962
1963/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
1964/// if the responder is dropped without sending a response, so that the client
1965/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1966impl std::ops::Drop for ControlGetTopologiesResponder {
1967    fn drop(&mut self) {
1968        self.control_handle.shutdown();
1969        // Safety: drops once, never accessed again
1970        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1971    }
1972}
1973
1974impl fidl::endpoints::Responder for ControlGetTopologiesResponder {
1975    type ControlHandle = ControlControlHandle;
1976
1977    fn control_handle(&self) -> &ControlControlHandle {
1978        &self.control_handle
1979    }
1980
1981    fn drop_without_shutdown(mut self) {
1982        // Safety: drops once, never accessed again due to mem::forget
1983        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1984        // Prevent Drop from running (which would shut down the channel)
1985        std::mem::forget(self);
1986    }
1987}
1988
1989impl ControlGetTopologiesResponder {
1990    /// Sends a response to the FIDL transaction.
1991    ///
1992    /// Sets the channel to shutdown if an error occurs.
1993    pub fn send(
1994        self,
1995        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Topology], i32>,
1996    ) -> Result<(), fidl::Error> {
1997        let _result = self.send_raw(result);
1998        if _result.is_err() {
1999            self.control_handle.shutdown();
2000        }
2001        self.drop_without_shutdown();
2002        _result
2003    }
2004
2005    /// Similar to "send" but does not shutdown the channel if an error occurs.
2006    pub fn send_no_shutdown_on_err(
2007        self,
2008        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Topology], i32>,
2009    ) -> Result<(), fidl::Error> {
2010        let _result = self.send_raw(result);
2011        self.drop_without_shutdown();
2012        _result
2013    }
2014
2015    fn send_raw(
2016        &self,
2017        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Topology], i32>,
2018    ) -> Result<(), fidl::Error> {
2019        self.control_handle.inner.send::<fidl::encoding::ResultType<
2020            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResponse,
2021            i32,
2022        >>(
2023            result.map(|topologies| (topologies,)),
2024            self.tx_id,
2025            0x73ffb73af24d30b6,
2026            fidl::encoding::DynamicFlags::empty(),
2027        )
2028    }
2029}
2030
2031#[must_use = "FIDL methods require a response to be sent"]
2032#[derive(Debug)]
2033pub struct ControlWatchTopologyResponder {
2034    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2035    tx_id: u32,
2036}
2037
2038/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2039/// if the responder is dropped without sending a response, so that the client
2040/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2041impl std::ops::Drop for ControlWatchTopologyResponder {
2042    fn drop(&mut self) {
2043        self.control_handle.shutdown();
2044        // Safety: drops once, never accessed again
2045        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2046    }
2047}
2048
2049impl fidl::endpoints::Responder for ControlWatchTopologyResponder {
2050    type ControlHandle = ControlControlHandle;
2051
2052    fn control_handle(&self) -> &ControlControlHandle {
2053        &self.control_handle
2054    }
2055
2056    fn drop_without_shutdown(mut self) {
2057        // Safety: drops once, never accessed again due to mem::forget
2058        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2059        // Prevent Drop from running (which would shut down the channel)
2060        std::mem::forget(self);
2061    }
2062}
2063
2064impl ControlWatchTopologyResponder {
2065    /// Sends a response to the FIDL transaction.
2066    ///
2067    /// Sets the channel to shutdown if an error occurs.
2068    pub fn send(self, mut topology_id: u64) -> Result<(), fidl::Error> {
2069        let _result = self.send_raw(topology_id);
2070        if _result.is_err() {
2071            self.control_handle.shutdown();
2072        }
2073        self.drop_without_shutdown();
2074        _result
2075    }
2076
2077    /// Similar to "send" but does not shutdown the channel if an error occurs.
2078    pub fn send_no_shutdown_on_err(self, mut topology_id: u64) -> Result<(), fidl::Error> {
2079        let _result = self.send_raw(topology_id);
2080        self.drop_without_shutdown();
2081        _result
2082    }
2083
2084    fn send_raw(&self, mut topology_id: u64) -> Result<(), fidl::Error> {
2085        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
2086            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchTopologyResponse,
2087        >>(
2088            fidl::encoding::Flexible::new((topology_id,)),
2089            self.tx_id,
2090            0x66d172acdb36a729,
2091            fidl::encoding::DynamicFlags::FLEXIBLE,
2092        )
2093    }
2094}
2095
2096#[must_use = "FIDL methods require a response to be sent"]
2097#[derive(Debug)]
2098pub struct ControlSetElementStateResponder {
2099    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2100    tx_id: u32,
2101}
2102
2103/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2104/// if the responder is dropped without sending a response, so that the client
2105/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2106impl std::ops::Drop for ControlSetElementStateResponder {
2107    fn drop(&mut self) {
2108        self.control_handle.shutdown();
2109        // Safety: drops once, never accessed again
2110        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2111    }
2112}
2113
2114impl fidl::endpoints::Responder for ControlSetElementStateResponder {
2115    type ControlHandle = ControlControlHandle;
2116
2117    fn control_handle(&self) -> &ControlControlHandle {
2118        &self.control_handle
2119    }
2120
2121    fn drop_without_shutdown(mut self) {
2122        // Safety: drops once, never accessed again due to mem::forget
2123        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2124        // Prevent Drop from running (which would shut down the channel)
2125        std::mem::forget(self);
2126    }
2127}
2128
2129impl ControlSetElementStateResponder {
2130    /// Sends a response to the FIDL transaction.
2131    ///
2132    /// Sets the channel to shutdown if an error occurs.
2133    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2134        let _result = self.send_raw(result);
2135        if _result.is_err() {
2136            self.control_handle.shutdown();
2137        }
2138        self.drop_without_shutdown();
2139        _result
2140    }
2141
2142    /// Similar to "send" but does not shutdown the channel if an error occurs.
2143    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2144        let _result = self.send_raw(result);
2145        self.drop_without_shutdown();
2146        _result
2147    }
2148
2149    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2150        self.control_handle
2151            .inner
2152            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2153                result,
2154                self.tx_id,
2155                0x38c3b2d4bae698f4,
2156                fidl::encoding::DynamicFlags::empty(),
2157            )
2158    }
2159}
2160
2161#[must_use = "FIDL methods require a response to be sent"]
2162#[derive(Debug)]
2163pub struct ControlSetTopologyResponder {
2164    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2165    tx_id: u32,
2166}
2167
2168/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2169/// if the responder is dropped without sending a response, so that the client
2170/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2171impl std::ops::Drop for ControlSetTopologyResponder {
2172    fn drop(&mut self) {
2173        self.control_handle.shutdown();
2174        // Safety: drops once, never accessed again
2175        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2176    }
2177}
2178
2179impl fidl::endpoints::Responder for ControlSetTopologyResponder {
2180    type ControlHandle = ControlControlHandle;
2181
2182    fn control_handle(&self) -> &ControlControlHandle {
2183        &self.control_handle
2184    }
2185
2186    fn drop_without_shutdown(mut self) {
2187        // Safety: drops once, never accessed again due to mem::forget
2188        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2189        // Prevent Drop from running (which would shut down the channel)
2190        std::mem::forget(self);
2191    }
2192}
2193
2194impl ControlSetTopologyResponder {
2195    /// Sends a response to the FIDL transaction.
2196    ///
2197    /// Sets the channel to shutdown if an error occurs.
2198    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2199        let _result = self.send_raw(result);
2200        if _result.is_err() {
2201            self.control_handle.shutdown();
2202        }
2203        self.drop_without_shutdown();
2204        _result
2205    }
2206
2207    /// Similar to "send" but does not shutdown the channel if an error occurs.
2208    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2209        let _result = self.send_raw(result);
2210        self.drop_without_shutdown();
2211        _result
2212    }
2213
2214    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2215        self.control_handle
2216            .inner
2217            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2218                result,
2219                self.tx_id,
2220                0x1d9a7f9b8fee790c,
2221                fidl::encoding::DynamicFlags::empty(),
2222            )
2223    }
2224}
2225
2226#[must_use = "FIDL methods require a response to be sent"]
2227#[derive(Debug)]
2228pub struct ControlCreateRingBufferResponder {
2229    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2230    tx_id: u32,
2231}
2232
2233/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2234/// if the responder is dropped without sending a response, so that the client
2235/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2236impl std::ops::Drop for ControlCreateRingBufferResponder {
2237    fn drop(&mut self) {
2238        self.control_handle.shutdown();
2239        // Safety: drops once, never accessed again
2240        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2241    }
2242}
2243
2244impl fidl::endpoints::Responder for ControlCreateRingBufferResponder {
2245    type ControlHandle = ControlControlHandle;
2246
2247    fn control_handle(&self) -> &ControlControlHandle {
2248        &self.control_handle
2249    }
2250
2251    fn drop_without_shutdown(mut self) {
2252        // Safety: drops once, never accessed again due to mem::forget
2253        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2254        // Prevent Drop from running (which would shut down the channel)
2255        std::mem::forget(self);
2256    }
2257}
2258
2259impl ControlCreateRingBufferResponder {
2260    /// Sends a response to the FIDL transaction.
2261    ///
2262    /// Sets the channel to shutdown if an error occurs.
2263    pub fn send(
2264        self,
2265        mut result: Result<ControlCreateRingBufferResponse, ControlCreateRingBufferError>,
2266    ) -> Result<(), fidl::Error> {
2267        let _result = self.send_raw(result);
2268        if _result.is_err() {
2269            self.control_handle.shutdown();
2270        }
2271        self.drop_without_shutdown();
2272        _result
2273    }
2274
2275    /// Similar to "send" but does not shutdown the channel if an error occurs.
2276    pub fn send_no_shutdown_on_err(
2277        self,
2278        mut result: Result<ControlCreateRingBufferResponse, ControlCreateRingBufferError>,
2279    ) -> Result<(), fidl::Error> {
2280        let _result = self.send_raw(result);
2281        self.drop_without_shutdown();
2282        _result
2283    }
2284
2285    fn send_raw(
2286        &self,
2287        mut result: Result<ControlCreateRingBufferResponse, ControlCreateRingBufferError>,
2288    ) -> Result<(), fidl::Error> {
2289        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2290            ControlCreateRingBufferResponse,
2291            ControlCreateRingBufferError,
2292        >>(
2293            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
2294            self.tx_id,
2295            0x7462941cedb333db,
2296            fidl::encoding::DynamicFlags::FLEXIBLE,
2297        )
2298    }
2299}
2300
2301#[must_use = "FIDL methods require a response to be sent"]
2302#[derive(Debug)]
2303pub struct ControlSetDaiFormatResponder {
2304    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2305    tx_id: u32,
2306}
2307
2308/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2309/// if the responder is dropped without sending a response, so that the client
2310/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2311impl std::ops::Drop for ControlSetDaiFormatResponder {
2312    fn drop(&mut self) {
2313        self.control_handle.shutdown();
2314        // Safety: drops once, never accessed again
2315        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2316    }
2317}
2318
2319impl fidl::endpoints::Responder for ControlSetDaiFormatResponder {
2320    type ControlHandle = ControlControlHandle;
2321
2322    fn control_handle(&self) -> &ControlControlHandle {
2323        &self.control_handle
2324    }
2325
2326    fn drop_without_shutdown(mut self) {
2327        // Safety: drops once, never accessed again due to mem::forget
2328        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2329        // Prevent Drop from running (which would shut down the channel)
2330        std::mem::forget(self);
2331    }
2332}
2333
2334impl ControlSetDaiFormatResponder {
2335    /// Sends a response to the FIDL transaction.
2336    ///
2337    /// Sets the channel to shutdown if an error occurs.
2338    pub fn send(
2339        self,
2340        mut result: Result<&ControlSetDaiFormatResponse, ControlSetDaiFormatError>,
2341    ) -> Result<(), fidl::Error> {
2342        let _result = self.send_raw(result);
2343        if _result.is_err() {
2344            self.control_handle.shutdown();
2345        }
2346        self.drop_without_shutdown();
2347        _result
2348    }
2349
2350    /// Similar to "send" but does not shutdown the channel if an error occurs.
2351    pub fn send_no_shutdown_on_err(
2352        self,
2353        mut result: Result<&ControlSetDaiFormatResponse, ControlSetDaiFormatError>,
2354    ) -> Result<(), fidl::Error> {
2355        let _result = self.send_raw(result);
2356        self.drop_without_shutdown();
2357        _result
2358    }
2359
2360    fn send_raw(
2361        &self,
2362        mut result: Result<&ControlSetDaiFormatResponse, ControlSetDaiFormatError>,
2363    ) -> Result<(), fidl::Error> {
2364        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2365            ControlSetDaiFormatResponse,
2366            ControlSetDaiFormatError,
2367        >>(
2368            fidl::encoding::FlexibleResult::new(result),
2369            self.tx_id,
2370            0x1d84f5a456a92216,
2371            fidl::encoding::DynamicFlags::FLEXIBLE,
2372        )
2373    }
2374}
2375
2376#[must_use = "FIDL methods require a response to be sent"]
2377#[derive(Debug)]
2378pub struct ControlCodecStartResponder {
2379    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2380    tx_id: u32,
2381}
2382
2383/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2384/// if the responder is dropped without sending a response, so that the client
2385/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2386impl std::ops::Drop for ControlCodecStartResponder {
2387    fn drop(&mut self) {
2388        self.control_handle.shutdown();
2389        // Safety: drops once, never accessed again
2390        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2391    }
2392}
2393
2394impl fidl::endpoints::Responder for ControlCodecStartResponder {
2395    type ControlHandle = ControlControlHandle;
2396
2397    fn control_handle(&self) -> &ControlControlHandle {
2398        &self.control_handle
2399    }
2400
2401    fn drop_without_shutdown(mut self) {
2402        // Safety: drops once, never accessed again due to mem::forget
2403        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2404        // Prevent Drop from running (which would shut down the channel)
2405        std::mem::forget(self);
2406    }
2407}
2408
2409impl ControlCodecStartResponder {
2410    /// Sends a response to the FIDL transaction.
2411    ///
2412    /// Sets the channel to shutdown if an error occurs.
2413    pub fn send(
2414        self,
2415        mut result: Result<&ControlCodecStartResponse, ControlCodecStartError>,
2416    ) -> Result<(), fidl::Error> {
2417        let _result = self.send_raw(result);
2418        if _result.is_err() {
2419            self.control_handle.shutdown();
2420        }
2421        self.drop_without_shutdown();
2422        _result
2423    }
2424
2425    /// Similar to "send" but does not shutdown the channel if an error occurs.
2426    pub fn send_no_shutdown_on_err(
2427        self,
2428        mut result: Result<&ControlCodecStartResponse, ControlCodecStartError>,
2429    ) -> Result<(), fidl::Error> {
2430        let _result = self.send_raw(result);
2431        self.drop_without_shutdown();
2432        _result
2433    }
2434
2435    fn send_raw(
2436        &self,
2437        mut result: Result<&ControlCodecStartResponse, ControlCodecStartError>,
2438    ) -> Result<(), fidl::Error> {
2439        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2440            ControlCodecStartResponse,
2441            ControlCodecStartError,
2442        >>(
2443            fidl::encoding::FlexibleResult::new(result),
2444            self.tx_id,
2445            0x2a90a9d2958b997b,
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 ControlCodecStopResponder {
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 ControlCodecStopResponder {
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 ControlCodecStopResponder {
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 ControlCodecStopResponder {
2485    /// Sends a response to the FIDL transaction.
2486    ///
2487    /// Sets the channel to shutdown if an error occurs.
2488    pub fn send(
2489        self,
2490        mut result: Result<&ControlCodecStopResponse, ControlCodecStopError>,
2491    ) -> Result<(), fidl::Error> {
2492        let _result = self.send_raw(result);
2493        if _result.is_err() {
2494            self.control_handle.shutdown();
2495        }
2496        self.drop_without_shutdown();
2497        _result
2498    }
2499
2500    /// Similar to "send" but does not shutdown the channel if an error occurs.
2501    pub fn send_no_shutdown_on_err(
2502        self,
2503        mut result: Result<&ControlCodecStopResponse, ControlCodecStopError>,
2504    ) -> Result<(), fidl::Error> {
2505        let _result = self.send_raw(result);
2506        self.drop_without_shutdown();
2507        _result
2508    }
2509
2510    fn send_raw(
2511        &self,
2512        mut result: Result<&ControlCodecStopResponse, ControlCodecStopError>,
2513    ) -> Result<(), fidl::Error> {
2514        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2515            ControlCodecStopResponse,
2516            ControlCodecStopError,
2517        >>(
2518            fidl::encoding::FlexibleResult::new(result),
2519            self.tx_id,
2520            0x387297bb6bcad25f,
2521            fidl::encoding::DynamicFlags::FLEXIBLE,
2522        )
2523    }
2524}
2525
2526#[must_use = "FIDL methods require a response to be sent"]
2527#[derive(Debug)]
2528pub struct ControlResetResponder {
2529    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2530    tx_id: u32,
2531}
2532
2533/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2534/// if the responder is dropped without sending a response, so that the client
2535/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2536impl std::ops::Drop for ControlResetResponder {
2537    fn drop(&mut self) {
2538        self.control_handle.shutdown();
2539        // Safety: drops once, never accessed again
2540        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2541    }
2542}
2543
2544impl fidl::endpoints::Responder for ControlResetResponder {
2545    type ControlHandle = ControlControlHandle;
2546
2547    fn control_handle(&self) -> &ControlControlHandle {
2548        &self.control_handle
2549    }
2550
2551    fn drop_without_shutdown(mut self) {
2552        // Safety: drops once, never accessed again due to mem::forget
2553        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2554        // Prevent Drop from running (which would shut down the channel)
2555        std::mem::forget(self);
2556    }
2557}
2558
2559impl ControlResetResponder {
2560    /// Sends a response to the FIDL transaction.
2561    ///
2562    /// Sets the channel to shutdown if an error occurs.
2563    pub fn send(
2564        self,
2565        mut result: Result<&ControlResetResponse, ControlResetError>,
2566    ) -> Result<(), fidl::Error> {
2567        let _result = self.send_raw(result);
2568        if _result.is_err() {
2569            self.control_handle.shutdown();
2570        }
2571        self.drop_without_shutdown();
2572        _result
2573    }
2574
2575    /// Similar to "send" but does not shutdown the channel if an error occurs.
2576    pub fn send_no_shutdown_on_err(
2577        self,
2578        mut result: Result<&ControlResetResponse, ControlResetError>,
2579    ) -> Result<(), fidl::Error> {
2580        let _result = self.send_raw(result);
2581        self.drop_without_shutdown();
2582        _result
2583    }
2584
2585    fn send_raw(
2586        &self,
2587        mut result: Result<&ControlResetResponse, ControlResetError>,
2588    ) -> Result<(), fidl::Error> {
2589        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2590            ControlResetResponse,
2591            ControlResetError,
2592        >>(
2593            fidl::encoding::FlexibleResult::new(result),
2594            self.tx_id,
2595            0x49840db00a698996,
2596            fidl::encoding::DynamicFlags::FLEXIBLE,
2597        )
2598    }
2599}
2600
2601#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2602pub struct ControlCreatorMarker;
2603
2604impl fidl::endpoints::ProtocolMarker for ControlCreatorMarker {
2605    type Proxy = ControlCreatorProxy;
2606    type RequestStream = ControlCreatorRequestStream;
2607    #[cfg(target_os = "fuchsia")]
2608    type SynchronousProxy = ControlCreatorSynchronousProxy;
2609
2610    const DEBUG_NAME: &'static str = "fuchsia.audio.device.ControlCreator";
2611}
2612impl fidl::endpoints::DiscoverableProtocolMarker for ControlCreatorMarker {}
2613pub type ControlCreatorCreateResult = Result<ControlCreatorCreateResponse, ControlCreatorError>;
2614
2615pub trait ControlCreatorProxyInterface: Send + Sync {
2616    type CreateResponseFut: std::future::Future<Output = Result<ControlCreatorCreateResult, fidl::Error>>
2617        + Send;
2618    fn r#create(&self, payload: ControlCreatorCreateRequest) -> Self::CreateResponseFut;
2619}
2620#[derive(Debug)]
2621#[cfg(target_os = "fuchsia")]
2622pub struct ControlCreatorSynchronousProxy {
2623    client: fidl::client::sync::Client,
2624}
2625
2626#[cfg(target_os = "fuchsia")]
2627impl fidl::endpoints::SynchronousProxy for ControlCreatorSynchronousProxy {
2628    type Proxy = ControlCreatorProxy;
2629    type Protocol = ControlCreatorMarker;
2630
2631    fn from_channel(inner: fidl::Channel) -> Self {
2632        Self::new(inner)
2633    }
2634
2635    fn into_channel(self) -> fidl::Channel {
2636        self.client.into_channel()
2637    }
2638
2639    fn as_channel(&self) -> &fidl::Channel {
2640        self.client.as_channel()
2641    }
2642}
2643
2644#[cfg(target_os = "fuchsia")]
2645impl ControlCreatorSynchronousProxy {
2646    pub fn new(channel: fidl::Channel) -> Self {
2647        let protocol_name = <ControlCreatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2648        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2649    }
2650
2651    pub fn into_channel(self) -> fidl::Channel {
2652        self.client.into_channel()
2653    }
2654
2655    /// Waits until an event arrives and returns it. It is safe for other
2656    /// threads to make concurrent requests while waiting for an event.
2657    pub fn wait_for_event(
2658        &self,
2659        deadline: zx::MonotonicInstant,
2660    ) -> Result<ControlCreatorEvent, fidl::Error> {
2661        ControlCreatorEvent::decode(self.client.wait_for_event(deadline)?)
2662    }
2663
2664    /// Create a `Control` for the specified device.
2665    pub fn r#create(
2666        &self,
2667        mut payload: ControlCreatorCreateRequest,
2668        ___deadline: zx::MonotonicInstant,
2669    ) -> Result<ControlCreatorCreateResult, fidl::Error> {
2670        let _response =
2671            self.client
2672                .send_query::<ControlCreatorCreateRequest, fidl::encoding::FlexibleResultType<
2673                    ControlCreatorCreateResponse,
2674                    ControlCreatorError,
2675                >>(
2676                    &mut payload,
2677                    0x341bdc9f49103a31,
2678                    fidl::encoding::DynamicFlags::FLEXIBLE,
2679                    ___deadline,
2680                )?
2681                .into_result::<ControlCreatorMarker>("create")?;
2682        Ok(_response.map(|x| x))
2683    }
2684}
2685
2686#[derive(Debug, Clone)]
2687pub struct ControlCreatorProxy {
2688    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2689}
2690
2691impl fidl::endpoints::Proxy for ControlCreatorProxy {
2692    type Protocol = ControlCreatorMarker;
2693
2694    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2695        Self::new(inner)
2696    }
2697
2698    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2699        self.client.into_channel().map_err(|client| Self { client })
2700    }
2701
2702    fn as_channel(&self) -> &::fidl::AsyncChannel {
2703        self.client.as_channel()
2704    }
2705}
2706
2707impl ControlCreatorProxy {
2708    /// Create a new Proxy for fuchsia.audio.device/ControlCreator.
2709    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2710        let protocol_name = <ControlCreatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2711        Self { client: fidl::client::Client::new(channel, protocol_name) }
2712    }
2713
2714    /// Get a Stream of events from the remote end of the protocol.
2715    ///
2716    /// # Panics
2717    ///
2718    /// Panics if the event stream was already taken.
2719    pub fn take_event_stream(&self) -> ControlCreatorEventStream {
2720        ControlCreatorEventStream { event_receiver: self.client.take_event_receiver() }
2721    }
2722
2723    /// Create a `Control` for the specified device.
2724    pub fn r#create(
2725        &self,
2726        mut payload: ControlCreatorCreateRequest,
2727    ) -> fidl::client::QueryResponseFut<
2728        ControlCreatorCreateResult,
2729        fidl::encoding::DefaultFuchsiaResourceDialect,
2730    > {
2731        ControlCreatorProxyInterface::r#create(self, payload)
2732    }
2733}
2734
2735impl ControlCreatorProxyInterface for ControlCreatorProxy {
2736    type CreateResponseFut = fidl::client::QueryResponseFut<
2737        ControlCreatorCreateResult,
2738        fidl::encoding::DefaultFuchsiaResourceDialect,
2739    >;
2740    fn r#create(&self, mut payload: ControlCreatorCreateRequest) -> Self::CreateResponseFut {
2741        fn _decode(
2742            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2743        ) -> Result<ControlCreatorCreateResult, fidl::Error> {
2744            let _response = fidl::client::decode_transaction_body::<
2745                fidl::encoding::FlexibleResultType<
2746                    ControlCreatorCreateResponse,
2747                    ControlCreatorError,
2748                >,
2749                fidl::encoding::DefaultFuchsiaResourceDialect,
2750                0x341bdc9f49103a31,
2751            >(_buf?)?
2752            .into_result::<ControlCreatorMarker>("create")?;
2753            Ok(_response.map(|x| x))
2754        }
2755        self.client
2756            .send_query_and_decode::<ControlCreatorCreateRequest, ControlCreatorCreateResult>(
2757                &mut payload,
2758                0x341bdc9f49103a31,
2759                fidl::encoding::DynamicFlags::FLEXIBLE,
2760                _decode,
2761            )
2762    }
2763}
2764
2765pub struct ControlCreatorEventStream {
2766    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2767}
2768
2769impl std::marker::Unpin for ControlCreatorEventStream {}
2770
2771impl futures::stream::FusedStream for ControlCreatorEventStream {
2772    fn is_terminated(&self) -> bool {
2773        self.event_receiver.is_terminated()
2774    }
2775}
2776
2777impl futures::Stream for ControlCreatorEventStream {
2778    type Item = Result<ControlCreatorEvent, fidl::Error>;
2779
2780    fn poll_next(
2781        mut self: std::pin::Pin<&mut Self>,
2782        cx: &mut std::task::Context<'_>,
2783    ) -> std::task::Poll<Option<Self::Item>> {
2784        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2785            &mut self.event_receiver,
2786            cx
2787        )?) {
2788            Some(buf) => std::task::Poll::Ready(Some(ControlCreatorEvent::decode(buf))),
2789            None => std::task::Poll::Ready(None),
2790        }
2791    }
2792}
2793
2794#[derive(Debug)]
2795pub enum ControlCreatorEvent {
2796    #[non_exhaustive]
2797    _UnknownEvent {
2798        /// Ordinal of the event that was sent.
2799        ordinal: u64,
2800    },
2801}
2802
2803impl ControlCreatorEvent {
2804    /// Decodes a message buffer as a [`ControlCreatorEvent`].
2805    fn decode(
2806        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2807    ) -> Result<ControlCreatorEvent, fidl::Error> {
2808        let (bytes, _handles) = buf.split_mut();
2809        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2810        debug_assert_eq!(tx_header.tx_id, 0);
2811        match tx_header.ordinal {
2812            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2813                Ok(ControlCreatorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2814            }
2815            _ => Err(fidl::Error::UnknownOrdinal {
2816                ordinal: tx_header.ordinal,
2817                protocol_name:
2818                    <ControlCreatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2819            }),
2820        }
2821    }
2822}
2823
2824/// A Stream of incoming requests for fuchsia.audio.device/ControlCreator.
2825pub struct ControlCreatorRequestStream {
2826    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2827    is_terminated: bool,
2828}
2829
2830impl std::marker::Unpin for ControlCreatorRequestStream {}
2831
2832impl futures::stream::FusedStream for ControlCreatorRequestStream {
2833    fn is_terminated(&self) -> bool {
2834        self.is_terminated
2835    }
2836}
2837
2838impl fidl::endpoints::RequestStream for ControlCreatorRequestStream {
2839    type Protocol = ControlCreatorMarker;
2840    type ControlHandle = ControlCreatorControlHandle;
2841
2842    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2843        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2844    }
2845
2846    fn control_handle(&self) -> Self::ControlHandle {
2847        ControlCreatorControlHandle { inner: self.inner.clone() }
2848    }
2849
2850    fn into_inner(
2851        self,
2852    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2853    {
2854        (self.inner, self.is_terminated)
2855    }
2856
2857    fn from_inner(
2858        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2859        is_terminated: bool,
2860    ) -> Self {
2861        Self { inner, is_terminated }
2862    }
2863}
2864
2865impl futures::Stream for ControlCreatorRequestStream {
2866    type Item = Result<ControlCreatorRequest, fidl::Error>;
2867
2868    fn poll_next(
2869        mut self: std::pin::Pin<&mut Self>,
2870        cx: &mut std::task::Context<'_>,
2871    ) -> std::task::Poll<Option<Self::Item>> {
2872        let this = &mut *self;
2873        if this.inner.check_shutdown(cx) {
2874            this.is_terminated = true;
2875            return std::task::Poll::Ready(None);
2876        }
2877        if this.is_terminated {
2878            panic!("polled ControlCreatorRequestStream after completion");
2879        }
2880        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2881            |bytes, handles| {
2882                match this.inner.channel().read_etc(cx, bytes, handles) {
2883                    std::task::Poll::Ready(Ok(())) => {}
2884                    std::task::Poll::Pending => return std::task::Poll::Pending,
2885                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2886                        this.is_terminated = true;
2887                        return std::task::Poll::Ready(None);
2888                    }
2889                    std::task::Poll::Ready(Err(e)) => {
2890                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2891                            e.into(),
2892                        ))))
2893                    }
2894                }
2895
2896                // A message has been received from the channel
2897                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2898
2899                std::task::Poll::Ready(Some(match header.ordinal {
2900                    0x341bdc9f49103a31 => {
2901                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2902                        let mut req = fidl::new_empty!(
2903                            ControlCreatorCreateRequest,
2904                            fidl::encoding::DefaultFuchsiaResourceDialect
2905                        );
2906                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlCreatorCreateRequest>(&header, _body_bytes, handles, &mut req)?;
2907                        let control_handle =
2908                            ControlCreatorControlHandle { inner: this.inner.clone() };
2909                        Ok(ControlCreatorRequest::Create {
2910                            payload: req,
2911                            responder: ControlCreatorCreateResponder {
2912                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2913                                tx_id: header.tx_id,
2914                            },
2915                        })
2916                    }
2917                    _ if header.tx_id == 0
2918                        && header
2919                            .dynamic_flags()
2920                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2921                    {
2922                        Ok(ControlCreatorRequest::_UnknownMethod {
2923                            ordinal: header.ordinal,
2924                            control_handle: ControlCreatorControlHandle {
2925                                inner: this.inner.clone(),
2926                            },
2927                            method_type: fidl::MethodType::OneWay,
2928                        })
2929                    }
2930                    _ if header
2931                        .dynamic_flags()
2932                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2933                    {
2934                        this.inner.send_framework_err(
2935                            fidl::encoding::FrameworkErr::UnknownMethod,
2936                            header.tx_id,
2937                            header.ordinal,
2938                            header.dynamic_flags(),
2939                            (bytes, handles),
2940                        )?;
2941                        Ok(ControlCreatorRequest::_UnknownMethod {
2942                            ordinal: header.ordinal,
2943                            control_handle: ControlCreatorControlHandle {
2944                                inner: this.inner.clone(),
2945                            },
2946                            method_type: fidl::MethodType::TwoWay,
2947                        })
2948                    }
2949                    _ => Err(fidl::Error::UnknownOrdinal {
2950                        ordinal: header.ordinal,
2951                        protocol_name:
2952                            <ControlCreatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2953                    }),
2954                }))
2955            },
2956        )
2957    }
2958}
2959
2960/// A `ControlCreator` interface creates `Control` instances. Each `Control` binds
2961/// to a single device. A device can only be bound to one `Control` at any time.
2962#[derive(Debug)]
2963pub enum ControlCreatorRequest {
2964    /// Create a `Control` for the specified device.
2965    Create { payload: ControlCreatorCreateRequest, responder: ControlCreatorCreateResponder },
2966    /// An interaction was received which does not match any known method.
2967    #[non_exhaustive]
2968    _UnknownMethod {
2969        /// Ordinal of the method that was called.
2970        ordinal: u64,
2971        control_handle: ControlCreatorControlHandle,
2972        method_type: fidl::MethodType,
2973    },
2974}
2975
2976impl ControlCreatorRequest {
2977    #[allow(irrefutable_let_patterns)]
2978    pub fn into_create(
2979        self,
2980    ) -> Option<(ControlCreatorCreateRequest, ControlCreatorCreateResponder)> {
2981        if let ControlCreatorRequest::Create { payload, responder } = self {
2982            Some((payload, responder))
2983        } else {
2984            None
2985        }
2986    }
2987
2988    /// Name of the method defined in FIDL
2989    pub fn method_name(&self) -> &'static str {
2990        match *self {
2991            ControlCreatorRequest::Create { .. } => "create",
2992            ControlCreatorRequest::_UnknownMethod {
2993                method_type: fidl::MethodType::OneWay, ..
2994            } => "unknown one-way method",
2995            ControlCreatorRequest::_UnknownMethod {
2996                method_type: fidl::MethodType::TwoWay, ..
2997            } => "unknown two-way method",
2998        }
2999    }
3000}
3001
3002#[derive(Debug, Clone)]
3003pub struct ControlCreatorControlHandle {
3004    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3005}
3006
3007impl fidl::endpoints::ControlHandle for ControlCreatorControlHandle {
3008    fn shutdown(&self) {
3009        self.inner.shutdown()
3010    }
3011    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3012        self.inner.shutdown_with_epitaph(status)
3013    }
3014
3015    fn is_closed(&self) -> bool {
3016        self.inner.channel().is_closed()
3017    }
3018    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3019        self.inner.channel().on_closed()
3020    }
3021
3022    #[cfg(target_os = "fuchsia")]
3023    fn signal_peer(
3024        &self,
3025        clear_mask: zx::Signals,
3026        set_mask: zx::Signals,
3027    ) -> Result<(), zx_status::Status> {
3028        use fidl::Peered;
3029        self.inner.channel().signal_peer(clear_mask, set_mask)
3030    }
3031}
3032
3033impl ControlCreatorControlHandle {}
3034
3035#[must_use = "FIDL methods require a response to be sent"]
3036#[derive(Debug)]
3037pub struct ControlCreatorCreateResponder {
3038    control_handle: std::mem::ManuallyDrop<ControlCreatorControlHandle>,
3039    tx_id: u32,
3040}
3041
3042/// Set the the channel to be shutdown (see [`ControlCreatorControlHandle::shutdown`])
3043/// if the responder is dropped without sending a response, so that the client
3044/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3045impl std::ops::Drop for ControlCreatorCreateResponder {
3046    fn drop(&mut self) {
3047        self.control_handle.shutdown();
3048        // Safety: drops once, never accessed again
3049        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3050    }
3051}
3052
3053impl fidl::endpoints::Responder for ControlCreatorCreateResponder {
3054    type ControlHandle = ControlCreatorControlHandle;
3055
3056    fn control_handle(&self) -> &ControlCreatorControlHandle {
3057        &self.control_handle
3058    }
3059
3060    fn drop_without_shutdown(mut self) {
3061        // Safety: drops once, never accessed again due to mem::forget
3062        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3063        // Prevent Drop from running (which would shut down the channel)
3064        std::mem::forget(self);
3065    }
3066}
3067
3068impl ControlCreatorCreateResponder {
3069    /// Sends a response to the FIDL transaction.
3070    ///
3071    /// Sets the channel to shutdown if an error occurs.
3072    pub fn send(
3073        self,
3074        mut result: Result<&ControlCreatorCreateResponse, ControlCreatorError>,
3075    ) -> Result<(), fidl::Error> {
3076        let _result = self.send_raw(result);
3077        if _result.is_err() {
3078            self.control_handle.shutdown();
3079        }
3080        self.drop_without_shutdown();
3081        _result
3082    }
3083
3084    /// Similar to "send" but does not shutdown the channel if an error occurs.
3085    pub fn send_no_shutdown_on_err(
3086        self,
3087        mut result: Result<&ControlCreatorCreateResponse, ControlCreatorError>,
3088    ) -> Result<(), fidl::Error> {
3089        let _result = self.send_raw(result);
3090        self.drop_without_shutdown();
3091        _result
3092    }
3093
3094    fn send_raw(
3095        &self,
3096        mut result: Result<&ControlCreatorCreateResponse, ControlCreatorError>,
3097    ) -> Result<(), fidl::Error> {
3098        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3099            ControlCreatorCreateResponse,
3100            ControlCreatorError,
3101        >>(
3102            fidl::encoding::FlexibleResult::new(result),
3103            self.tx_id,
3104            0x341bdc9f49103a31,
3105            fidl::encoding::DynamicFlags::FLEXIBLE,
3106        )
3107    }
3108}
3109
3110#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3111pub struct ObserverMarker;
3112
3113impl fidl::endpoints::ProtocolMarker for ObserverMarker {
3114    type Proxy = ObserverProxy;
3115    type RequestStream = ObserverRequestStream;
3116    #[cfg(target_os = "fuchsia")]
3117    type SynchronousProxy = ObserverSynchronousProxy;
3118
3119    const DEBUG_NAME: &'static str = "(anonymous) Observer";
3120}
3121pub type ObserverWatchPlugStateResult =
3122    Result<ObserverWatchPlugStateResponse, ObserverWatchPlugStateError>;
3123pub type ObserverGetReferenceClockResult =
3124    Result<ObserverGetReferenceClockResponse, ObserverGetReferenceClockError>;
3125
3126pub trait ObserverProxyInterface: Send + Sync {
3127    type GetElementsResponseFut: std::future::Future<
3128            Output = Result<
3129                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
3130                fidl::Error,
3131            >,
3132        > + Send;
3133    fn r#get_elements(&self) -> Self::GetElementsResponseFut;
3134    type WatchElementStateResponseFut: std::future::Future<
3135            Output = Result<
3136                fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
3137                fidl::Error,
3138            >,
3139        > + Send;
3140    fn r#watch_element_state(
3141        &self,
3142        processing_element_id: u64,
3143    ) -> Self::WatchElementStateResponseFut;
3144    type GetTopologiesResponseFut: std::future::Future<
3145            Output = Result<
3146                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
3147                fidl::Error,
3148            >,
3149        > + Send;
3150    fn r#get_topologies(&self) -> Self::GetTopologiesResponseFut;
3151    type WatchTopologyResponseFut: std::future::Future<Output = Result<u64, fidl::Error>> + Send;
3152    fn r#watch_topology(&self) -> Self::WatchTopologyResponseFut;
3153    type WatchPlugStateResponseFut: std::future::Future<Output = Result<ObserverWatchPlugStateResult, fidl::Error>>
3154        + Send;
3155    fn r#watch_plug_state(&self) -> Self::WatchPlugStateResponseFut;
3156    type GetReferenceClockResponseFut: std::future::Future<Output = Result<ObserverGetReferenceClockResult, fidl::Error>>
3157        + Send;
3158    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
3159}
3160#[derive(Debug)]
3161#[cfg(target_os = "fuchsia")]
3162pub struct ObserverSynchronousProxy {
3163    client: fidl::client::sync::Client,
3164}
3165
3166#[cfg(target_os = "fuchsia")]
3167impl fidl::endpoints::SynchronousProxy for ObserverSynchronousProxy {
3168    type Proxy = ObserverProxy;
3169    type Protocol = ObserverMarker;
3170
3171    fn from_channel(inner: fidl::Channel) -> Self {
3172        Self::new(inner)
3173    }
3174
3175    fn into_channel(self) -> fidl::Channel {
3176        self.client.into_channel()
3177    }
3178
3179    fn as_channel(&self) -> &fidl::Channel {
3180        self.client.as_channel()
3181    }
3182}
3183
3184#[cfg(target_os = "fuchsia")]
3185impl ObserverSynchronousProxy {
3186    pub fn new(channel: fidl::Channel) -> Self {
3187        let protocol_name = <ObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3188        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3189    }
3190
3191    pub fn into_channel(self) -> fidl::Channel {
3192        self.client.into_channel()
3193    }
3194
3195    /// Waits until an event arrives and returns it. It is safe for other
3196    /// threads to make concurrent requests while waiting for an event.
3197    pub fn wait_for_event(
3198        &self,
3199        deadline: zx::MonotonicInstant,
3200    ) -> Result<ObserverEvent, fidl::Error> {
3201        ObserverEvent::decode(self.client.wait_for_event(deadline)?)
3202    }
3203
3204    /// Returns a vector of supported processing elements.
3205    /// Must return one or more processing elements, or `ZX_ERR_NOT_SUPPORTED`.
3206    /// If `GetTopologies` returns one or more topologies, then `GetElements` must return one or
3207    /// more elements.
3208    pub fn r#get_elements(
3209        &self,
3210        ___deadline: zx::MonotonicInstant,
3211    ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult, fidl::Error>
3212    {
3213        let _response = self
3214            .client
3215            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
3216                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResponse,
3217                i32,
3218            >>(
3219                (), 0x1b14ff4adf5dc6f8, fidl::encoding::DynamicFlags::empty(), ___deadline
3220            )?;
3221        Ok(_response.map(|x| x.processing_elements))
3222    }
3223
3224    /// Get the processing element state via a hanging get.
3225    /// For a given `processing_element_id`, the driver will reply to the first `WatchElementState`
3226    /// sent by the client. The driver will not respond to subsequent client `WatchElementState`
3227    /// calls for a given `processing_element_id` until any field of the `Element` table changes
3228    /// from what was most recently reported for that `processing_element_id`.
3229    ///
3230    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
3231    /// method is called again while there is already a pending `WatchElementState` for this client
3232    /// and processing_element_id.
3233    pub fn r#watch_element_state(
3234        &self,
3235        mut processing_element_id: u64,
3236        ___deadline: zx::MonotonicInstant,
3237    ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ElementState, fidl::Error> {
3238        let _response = self.client.send_query::<
3239            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest,
3240            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateResponse,
3241        >(
3242            (processing_element_id,),
3243            0x524da8772a69056f,
3244            fidl::encoding::DynamicFlags::empty(),
3245            ___deadline,
3246        )?;
3247        Ok(_response.state)
3248    }
3249
3250    /// Returns a vector of supported topologies.
3251    /// Must return one or more topologies, or `ZX_ERR_NOT_SUPPORTED`.
3252    /// If more than one topology is returned, then the client may choose any of the topologies from
3253    /// the list with `SetTopology`.
3254    /// If only one topology is returned, then the topology definition is informational only since
3255    /// the one and only topology used can't be changed with `SetTopology`.
3256    /// If `GetElements` returns one or more elements, then `GetTopologies` must return one or
3257    /// more topologies.
3258    pub fn r#get_topologies(
3259        &self,
3260        ___deadline: zx::MonotonicInstant,
3261    ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult, fidl::Error>
3262    {
3263        let _response = self
3264            .client
3265            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
3266                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResponse,
3267                i32,
3268            >>(
3269                (), 0x73ffb73af24d30b6, fidl::encoding::DynamicFlags::empty(), ___deadline
3270            )?;
3271        Ok(_response.map(|x| x.topologies))
3272    }
3273
3274    /// Get the current topology via a hanging get.
3275    /// The driver will immediately reply to the first `WatchTopology` sent by each client. The
3276    /// driver will not respond to subsequent `WatchTopology` calls from that client until the
3277    /// signal-processing topology changes, which occurs as a result of a `SetTopology` call.
3278    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
3279    /// method is called again while there is already a pending `WatchTopology` for this client.
3280    pub fn r#watch_topology(&self, ___deadline: zx::MonotonicInstant) -> Result<u64, fidl::Error> {
3281        let _response = self
3282            .client
3283            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleType<
3284                fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchTopologyResponse,
3285            >>(
3286                (), 0x66d172acdb36a729, fidl::encoding::DynamicFlags::FLEXIBLE, ___deadline
3287            )?
3288            .into_result::<ObserverMarker>("watch_topology")?;
3289        Ok(_response.topology_id)
3290    }
3291
3292    /// Request notification of any change to the device's plug state. When
3293    /// called for the first time, it will return immediately.
3294    ///
3295    /// Should only be called for Codec devices.
3296    pub fn r#watch_plug_state(
3297        &self,
3298        ___deadline: zx::MonotonicInstant,
3299    ) -> Result<ObserverWatchPlugStateResult, fidl::Error> {
3300        let _response = self
3301            .client
3302            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
3303                ObserverWatchPlugStateResponse,
3304                ObserverWatchPlugStateError,
3305            >>(
3306                (), 0x6312bce495d2907a, fidl::encoding::DynamicFlags::FLEXIBLE, ___deadline
3307            )?
3308            .into_result::<ObserverMarker>("watch_plug_state")?;
3309        Ok(_response.map(|x| x))
3310    }
3311
3312    /// Retrieve the device's reference clock.
3313    ///
3314    /// This clock will be in the domain specified in the device's `Info` table.
3315    ///
3316    /// Should only be called for Composite devices.
3317    pub fn r#get_reference_clock(
3318        &self,
3319        ___deadline: zx::MonotonicInstant,
3320    ) -> Result<ObserverGetReferenceClockResult, fidl::Error> {
3321        let _response = self
3322            .client
3323            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
3324                ObserverGetReferenceClockResponse,
3325                ObserverGetReferenceClockError,
3326            >>(
3327                (), 0x3819c5e0f9574c39, fidl::encoding::DynamicFlags::FLEXIBLE, ___deadline
3328            )?
3329            .into_result::<ObserverMarker>("get_reference_clock")?;
3330        Ok(_response.map(|x| x))
3331    }
3332}
3333
3334#[derive(Debug, Clone)]
3335pub struct ObserverProxy {
3336    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3337}
3338
3339impl fidl::endpoints::Proxy for ObserverProxy {
3340    type Protocol = ObserverMarker;
3341
3342    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3343        Self::new(inner)
3344    }
3345
3346    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3347        self.client.into_channel().map_err(|client| Self { client })
3348    }
3349
3350    fn as_channel(&self) -> &::fidl::AsyncChannel {
3351        self.client.as_channel()
3352    }
3353}
3354
3355impl ObserverProxy {
3356    /// Create a new Proxy for fuchsia.audio.device/Observer.
3357    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3358        let protocol_name = <ObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3359        Self { client: fidl::client::Client::new(channel, protocol_name) }
3360    }
3361
3362    /// Get a Stream of events from the remote end of the protocol.
3363    ///
3364    /// # Panics
3365    ///
3366    /// Panics if the event stream was already taken.
3367    pub fn take_event_stream(&self) -> ObserverEventStream {
3368        ObserverEventStream { event_receiver: self.client.take_event_receiver() }
3369    }
3370
3371    /// Returns a vector of supported processing elements.
3372    /// Must return one or more processing elements, or `ZX_ERR_NOT_SUPPORTED`.
3373    /// If `GetTopologies` returns one or more topologies, then `GetElements` must return one or
3374    /// more elements.
3375    pub fn r#get_elements(
3376        &self,
3377    ) -> fidl::client::QueryResponseFut<
3378        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
3379        fidl::encoding::DefaultFuchsiaResourceDialect,
3380    > {
3381        ObserverProxyInterface::r#get_elements(self)
3382    }
3383
3384    /// Get the processing element state via a hanging get.
3385    /// For a given `processing_element_id`, the driver will reply to the first `WatchElementState`
3386    /// sent by the client. The driver will not respond to subsequent client `WatchElementState`
3387    /// calls for a given `processing_element_id` until any field of the `Element` table changes
3388    /// from what was most recently reported for that `processing_element_id`.
3389    ///
3390    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
3391    /// method is called again while there is already a pending `WatchElementState` for this client
3392    /// and processing_element_id.
3393    pub fn r#watch_element_state(
3394        &self,
3395        mut processing_element_id: u64,
3396    ) -> fidl::client::QueryResponseFut<
3397        fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
3398        fidl::encoding::DefaultFuchsiaResourceDialect,
3399    > {
3400        ObserverProxyInterface::r#watch_element_state(self, processing_element_id)
3401    }
3402
3403    /// Returns a vector of supported topologies.
3404    /// Must return one or more topologies, or `ZX_ERR_NOT_SUPPORTED`.
3405    /// If more than one topology is returned, then the client may choose any of the topologies from
3406    /// the list with `SetTopology`.
3407    /// If only one topology is returned, then the topology definition is informational only since
3408    /// the one and only topology used can't be changed with `SetTopology`.
3409    /// If `GetElements` returns one or more elements, then `GetTopologies` must return one or
3410    /// more topologies.
3411    pub fn r#get_topologies(
3412        &self,
3413    ) -> fidl::client::QueryResponseFut<
3414        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
3415        fidl::encoding::DefaultFuchsiaResourceDialect,
3416    > {
3417        ObserverProxyInterface::r#get_topologies(self)
3418    }
3419
3420    /// Get the current topology via a hanging get.
3421    /// The driver will immediately reply to the first `WatchTopology` sent by each client. The
3422    /// driver will not respond to subsequent `WatchTopology` calls from that client until the
3423    /// signal-processing topology changes, which occurs as a result of a `SetTopology` call.
3424    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
3425    /// method is called again while there is already a pending `WatchTopology` for this client.
3426    pub fn r#watch_topology(
3427        &self,
3428    ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
3429        ObserverProxyInterface::r#watch_topology(self)
3430    }
3431
3432    /// Request notification of any change to the device's plug state. When
3433    /// called for the first time, it will return immediately.
3434    ///
3435    /// Should only be called for Codec devices.
3436    pub fn r#watch_plug_state(
3437        &self,
3438    ) -> fidl::client::QueryResponseFut<
3439        ObserverWatchPlugStateResult,
3440        fidl::encoding::DefaultFuchsiaResourceDialect,
3441    > {
3442        ObserverProxyInterface::r#watch_plug_state(self)
3443    }
3444
3445    /// Retrieve the device's reference clock.
3446    ///
3447    /// This clock will be in the domain specified in the device's `Info` table.
3448    ///
3449    /// Should only be called for Composite devices.
3450    pub fn r#get_reference_clock(
3451        &self,
3452    ) -> fidl::client::QueryResponseFut<
3453        ObserverGetReferenceClockResult,
3454        fidl::encoding::DefaultFuchsiaResourceDialect,
3455    > {
3456        ObserverProxyInterface::r#get_reference_clock(self)
3457    }
3458}
3459
3460impl ObserverProxyInterface for ObserverProxy {
3461    type GetElementsResponseFut = fidl::client::QueryResponseFut<
3462        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
3463        fidl::encoding::DefaultFuchsiaResourceDialect,
3464    >;
3465    fn r#get_elements(&self) -> Self::GetElementsResponseFut {
3466        fn _decode(
3467            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3468        ) -> Result<
3469            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
3470            fidl::Error,
3471        > {
3472            let _response = fidl::client::decode_transaction_body::<
3473                fidl::encoding::ResultType<
3474                    fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResponse,
3475                    i32,
3476                >,
3477                fidl::encoding::DefaultFuchsiaResourceDialect,
3478                0x1b14ff4adf5dc6f8,
3479            >(_buf?)?;
3480            Ok(_response.map(|x| x.processing_elements))
3481        }
3482        self.client.send_query_and_decode::<
3483            fidl::encoding::EmptyPayload,
3484            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
3485        >(
3486            (),
3487            0x1b14ff4adf5dc6f8,
3488            fidl::encoding::DynamicFlags::empty(),
3489            _decode,
3490        )
3491    }
3492
3493    type WatchElementStateResponseFut = fidl::client::QueryResponseFut<
3494        fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
3495        fidl::encoding::DefaultFuchsiaResourceDialect,
3496    >;
3497    fn r#watch_element_state(
3498        &self,
3499        mut processing_element_id: u64,
3500    ) -> Self::WatchElementStateResponseFut {
3501        fn _decode(
3502            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3503        ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ElementState, fidl::Error>
3504        {
3505            let _response = fidl::client::decode_transaction_body::<
3506                fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateResponse,
3507                fidl::encoding::DefaultFuchsiaResourceDialect,
3508                0x524da8772a69056f,
3509            >(_buf?)?;
3510            Ok(_response.state)
3511        }
3512        self.client.send_query_and_decode::<
3513            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest,
3514            fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
3515        >(
3516            (processing_element_id,),
3517            0x524da8772a69056f,
3518            fidl::encoding::DynamicFlags::empty(),
3519            _decode,
3520        )
3521    }
3522
3523    type GetTopologiesResponseFut = fidl::client::QueryResponseFut<
3524        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
3525        fidl::encoding::DefaultFuchsiaResourceDialect,
3526    >;
3527    fn r#get_topologies(&self) -> Self::GetTopologiesResponseFut {
3528        fn _decode(
3529            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3530        ) -> Result<
3531            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
3532            fidl::Error,
3533        > {
3534            let _response = fidl::client::decode_transaction_body::<
3535                fidl::encoding::ResultType<
3536                    fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResponse,
3537                    i32,
3538                >,
3539                fidl::encoding::DefaultFuchsiaResourceDialect,
3540                0x73ffb73af24d30b6,
3541            >(_buf?)?;
3542            Ok(_response.map(|x| x.topologies))
3543        }
3544        self.client.send_query_and_decode::<
3545            fidl::encoding::EmptyPayload,
3546            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
3547        >(
3548            (),
3549            0x73ffb73af24d30b6,
3550            fidl::encoding::DynamicFlags::empty(),
3551            _decode,
3552        )
3553    }
3554
3555    type WatchTopologyResponseFut =
3556        fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
3557    fn r#watch_topology(&self) -> Self::WatchTopologyResponseFut {
3558        fn _decode(
3559            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3560        ) -> Result<u64, fidl::Error> {
3561            let _response = fidl::client::decode_transaction_body::<
3562                fidl::encoding::FlexibleType<
3563                    fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchTopologyResponse,
3564                >,
3565                fidl::encoding::DefaultFuchsiaResourceDialect,
3566                0x66d172acdb36a729,
3567            >(_buf?)?
3568            .into_result::<ObserverMarker>("watch_topology")?;
3569            Ok(_response.topology_id)
3570        }
3571        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u64>(
3572            (),
3573            0x66d172acdb36a729,
3574            fidl::encoding::DynamicFlags::FLEXIBLE,
3575            _decode,
3576        )
3577    }
3578
3579    type WatchPlugStateResponseFut = fidl::client::QueryResponseFut<
3580        ObserverWatchPlugStateResult,
3581        fidl::encoding::DefaultFuchsiaResourceDialect,
3582    >;
3583    fn r#watch_plug_state(&self) -> Self::WatchPlugStateResponseFut {
3584        fn _decode(
3585            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3586        ) -> Result<ObserverWatchPlugStateResult, fidl::Error> {
3587            let _response = fidl::client::decode_transaction_body::<
3588                fidl::encoding::FlexibleResultType<
3589                    ObserverWatchPlugStateResponse,
3590                    ObserverWatchPlugStateError,
3591                >,
3592                fidl::encoding::DefaultFuchsiaResourceDialect,
3593                0x6312bce495d2907a,
3594            >(_buf?)?
3595            .into_result::<ObserverMarker>("watch_plug_state")?;
3596            Ok(_response.map(|x| x))
3597        }
3598        self.client
3599            .send_query_and_decode::<fidl::encoding::EmptyPayload, ObserverWatchPlugStateResult>(
3600                (),
3601                0x6312bce495d2907a,
3602                fidl::encoding::DynamicFlags::FLEXIBLE,
3603                _decode,
3604            )
3605    }
3606
3607    type GetReferenceClockResponseFut = fidl::client::QueryResponseFut<
3608        ObserverGetReferenceClockResult,
3609        fidl::encoding::DefaultFuchsiaResourceDialect,
3610    >;
3611    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
3612        fn _decode(
3613            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3614        ) -> Result<ObserverGetReferenceClockResult, fidl::Error> {
3615            let _response = fidl::client::decode_transaction_body::<
3616                fidl::encoding::FlexibleResultType<
3617                    ObserverGetReferenceClockResponse,
3618                    ObserverGetReferenceClockError,
3619                >,
3620                fidl::encoding::DefaultFuchsiaResourceDialect,
3621                0x3819c5e0f9574c39,
3622            >(_buf?)?
3623            .into_result::<ObserverMarker>("get_reference_clock")?;
3624            Ok(_response.map(|x| x))
3625        }
3626        self.client
3627            .send_query_and_decode::<fidl::encoding::EmptyPayload, ObserverGetReferenceClockResult>(
3628                (),
3629                0x3819c5e0f9574c39,
3630                fidl::encoding::DynamicFlags::FLEXIBLE,
3631                _decode,
3632            )
3633    }
3634}
3635
3636pub struct ObserverEventStream {
3637    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3638}
3639
3640impl std::marker::Unpin for ObserverEventStream {}
3641
3642impl futures::stream::FusedStream for ObserverEventStream {
3643    fn is_terminated(&self) -> bool {
3644        self.event_receiver.is_terminated()
3645    }
3646}
3647
3648impl futures::Stream for ObserverEventStream {
3649    type Item = Result<ObserverEvent, fidl::Error>;
3650
3651    fn poll_next(
3652        mut self: std::pin::Pin<&mut Self>,
3653        cx: &mut std::task::Context<'_>,
3654    ) -> std::task::Poll<Option<Self::Item>> {
3655        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3656            &mut self.event_receiver,
3657            cx
3658        )?) {
3659            Some(buf) => std::task::Poll::Ready(Some(ObserverEvent::decode(buf))),
3660            None => std::task::Poll::Ready(None),
3661        }
3662    }
3663}
3664
3665#[derive(Debug)]
3666pub enum ObserverEvent {
3667    #[non_exhaustive]
3668    _UnknownEvent {
3669        /// Ordinal of the event that was sent.
3670        ordinal: u64,
3671    },
3672}
3673
3674impl ObserverEvent {
3675    /// Decodes a message buffer as a [`ObserverEvent`].
3676    fn decode(
3677        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3678    ) -> Result<ObserverEvent, fidl::Error> {
3679        let (bytes, _handles) = buf.split_mut();
3680        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3681        debug_assert_eq!(tx_header.tx_id, 0);
3682        match tx_header.ordinal {
3683            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3684                Ok(ObserverEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3685            }
3686            _ => Err(fidl::Error::UnknownOrdinal {
3687                ordinal: tx_header.ordinal,
3688                protocol_name: <ObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3689            }),
3690        }
3691    }
3692}
3693
3694/// A Stream of incoming requests for fuchsia.audio.device/Observer.
3695pub struct ObserverRequestStream {
3696    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3697    is_terminated: bool,
3698}
3699
3700impl std::marker::Unpin for ObserverRequestStream {}
3701
3702impl futures::stream::FusedStream for ObserverRequestStream {
3703    fn is_terminated(&self) -> bool {
3704        self.is_terminated
3705    }
3706}
3707
3708impl fidl::endpoints::RequestStream for ObserverRequestStream {
3709    type Protocol = ObserverMarker;
3710    type ControlHandle = ObserverControlHandle;
3711
3712    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3713        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3714    }
3715
3716    fn control_handle(&self) -> Self::ControlHandle {
3717        ObserverControlHandle { inner: self.inner.clone() }
3718    }
3719
3720    fn into_inner(
3721        self,
3722    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3723    {
3724        (self.inner, self.is_terminated)
3725    }
3726
3727    fn from_inner(
3728        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3729        is_terminated: bool,
3730    ) -> Self {
3731        Self { inner, is_terminated }
3732    }
3733}
3734
3735impl futures::Stream for ObserverRequestStream {
3736    type Item = Result<ObserverRequest, fidl::Error>;
3737
3738    fn poll_next(
3739        mut self: std::pin::Pin<&mut Self>,
3740        cx: &mut std::task::Context<'_>,
3741    ) -> std::task::Poll<Option<Self::Item>> {
3742        let this = &mut *self;
3743        if this.inner.check_shutdown(cx) {
3744            this.is_terminated = true;
3745            return std::task::Poll::Ready(None);
3746        }
3747        if this.is_terminated {
3748            panic!("polled ObserverRequestStream after completion");
3749        }
3750        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3751            |bytes, handles| {
3752                match this.inner.channel().read_etc(cx, bytes, handles) {
3753                    std::task::Poll::Ready(Ok(())) => {}
3754                    std::task::Poll::Pending => return std::task::Poll::Pending,
3755                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3756                        this.is_terminated = true;
3757                        return std::task::Poll::Ready(None);
3758                    }
3759                    std::task::Poll::Ready(Err(e)) => {
3760                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3761                            e.into(),
3762                        ))))
3763                    }
3764                }
3765
3766                // A message has been received from the channel
3767                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3768
3769                std::task::Poll::Ready(Some(match header.ordinal {
3770                    0x1b14ff4adf5dc6f8 => {
3771                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3772                        let mut req = fidl::new_empty!(
3773                            fidl::encoding::EmptyPayload,
3774                            fidl::encoding::DefaultFuchsiaResourceDialect
3775                        );
3776                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3777                        let control_handle = ObserverControlHandle { inner: this.inner.clone() };
3778                        Ok(ObserverRequest::GetElements {
3779                            responder: ObserverGetElementsResponder {
3780                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3781                                tx_id: header.tx_id,
3782                            },
3783                        })
3784                    }
3785                    0x524da8772a69056f => {
3786                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3787                        let mut req = fidl::new_empty!(fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
3788                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest>(&header, _body_bytes, handles, &mut req)?;
3789                        let control_handle = ObserverControlHandle { inner: this.inner.clone() };
3790                        Ok(ObserverRequest::WatchElementState {
3791                            processing_element_id: req.processing_element_id,
3792
3793                            responder: ObserverWatchElementStateResponder {
3794                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3795                                tx_id: header.tx_id,
3796                            },
3797                        })
3798                    }
3799                    0x73ffb73af24d30b6 => {
3800                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3801                        let mut req = fidl::new_empty!(
3802                            fidl::encoding::EmptyPayload,
3803                            fidl::encoding::DefaultFuchsiaResourceDialect
3804                        );
3805                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3806                        let control_handle = ObserverControlHandle { inner: this.inner.clone() };
3807                        Ok(ObserverRequest::GetTopologies {
3808                            responder: ObserverGetTopologiesResponder {
3809                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3810                                tx_id: header.tx_id,
3811                            },
3812                        })
3813                    }
3814                    0x66d172acdb36a729 => {
3815                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3816                        let mut req = fidl::new_empty!(
3817                            fidl::encoding::EmptyPayload,
3818                            fidl::encoding::DefaultFuchsiaResourceDialect
3819                        );
3820                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3821                        let control_handle = ObserverControlHandle { inner: this.inner.clone() };
3822                        Ok(ObserverRequest::WatchTopology {
3823                            responder: ObserverWatchTopologyResponder {
3824                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3825                                tx_id: header.tx_id,
3826                            },
3827                        })
3828                    }
3829                    0x6312bce495d2907a => {
3830                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3831                        let mut req = fidl::new_empty!(
3832                            fidl::encoding::EmptyPayload,
3833                            fidl::encoding::DefaultFuchsiaResourceDialect
3834                        );
3835                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3836                        let control_handle = ObserverControlHandle { inner: this.inner.clone() };
3837                        Ok(ObserverRequest::WatchPlugState {
3838                            responder: ObserverWatchPlugStateResponder {
3839                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3840                                tx_id: header.tx_id,
3841                            },
3842                        })
3843                    }
3844                    0x3819c5e0f9574c39 => {
3845                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3846                        let mut req = fidl::new_empty!(
3847                            fidl::encoding::EmptyPayload,
3848                            fidl::encoding::DefaultFuchsiaResourceDialect
3849                        );
3850                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3851                        let control_handle = ObserverControlHandle { inner: this.inner.clone() };
3852                        Ok(ObserverRequest::GetReferenceClock {
3853                            responder: ObserverGetReferenceClockResponder {
3854                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3855                                tx_id: header.tx_id,
3856                            },
3857                        })
3858                    }
3859                    _ if header.tx_id == 0
3860                        && header
3861                            .dynamic_flags()
3862                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3863                    {
3864                        Ok(ObserverRequest::_UnknownMethod {
3865                            ordinal: header.ordinal,
3866                            control_handle: ObserverControlHandle { inner: this.inner.clone() },
3867                            method_type: fidl::MethodType::OneWay,
3868                        })
3869                    }
3870                    _ if header
3871                        .dynamic_flags()
3872                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3873                    {
3874                        this.inner.send_framework_err(
3875                            fidl::encoding::FrameworkErr::UnknownMethod,
3876                            header.tx_id,
3877                            header.ordinal,
3878                            header.dynamic_flags(),
3879                            (bytes, handles),
3880                        )?;
3881                        Ok(ObserverRequest::_UnknownMethod {
3882                            ordinal: header.ordinal,
3883                            control_handle: ObserverControlHandle { inner: this.inner.clone() },
3884                            method_type: fidl::MethodType::TwoWay,
3885                        })
3886                    }
3887                    _ => Err(fidl::Error::UnknownOrdinal {
3888                        ordinal: header.ordinal,
3889                        protocol_name:
3890                            <ObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3891                    }),
3892                }))
3893            },
3894        )
3895    }
3896}
3897
3898/// `Observer` instances are used to learn the capabilities and state of an
3899/// audio device, and to stay informed as its state changes over time. Each
3900/// `Observer` is associated with an initialized audio device. An audio device
3901/// may be observed by multiple `Observer` instances.
3902#[derive(Debug)]
3903pub enum ObserverRequest {
3904    /// Returns a vector of supported processing elements.
3905    /// Must return one or more processing elements, or `ZX_ERR_NOT_SUPPORTED`.
3906    /// If `GetTopologies` returns one or more topologies, then `GetElements` must return one or
3907    /// more elements.
3908    GetElements { responder: ObserverGetElementsResponder },
3909    /// Get the processing element state via a hanging get.
3910    /// For a given `processing_element_id`, the driver will reply to the first `WatchElementState`
3911    /// sent by the client. The driver will not respond to subsequent client `WatchElementState`
3912    /// calls for a given `processing_element_id` until any field of the `Element` table changes
3913    /// from what was most recently reported for that `processing_element_id`.
3914    ///
3915    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
3916    /// method is called again while there is already a pending `WatchElementState` for this client
3917    /// and processing_element_id.
3918    WatchElementState { processing_element_id: u64, responder: ObserverWatchElementStateResponder },
3919    /// Returns a vector of supported topologies.
3920    /// Must return one or more topologies, or `ZX_ERR_NOT_SUPPORTED`.
3921    /// If more than one topology is returned, then the client may choose any of the topologies from
3922    /// the list with `SetTopology`.
3923    /// If only one topology is returned, then the topology definition is informational only since
3924    /// the one and only topology used can't be changed with `SetTopology`.
3925    /// If `GetElements` returns one or more elements, then `GetTopologies` must return one or
3926    /// more topologies.
3927    GetTopologies { responder: ObserverGetTopologiesResponder },
3928    /// Get the current topology via a hanging get.
3929    /// The driver will immediately reply to the first `WatchTopology` sent by each client. The
3930    /// driver will not respond to subsequent `WatchTopology` calls from that client until the
3931    /// signal-processing topology changes, which occurs as a result of a `SetTopology` call.
3932    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
3933    /// method is called again while there is already a pending `WatchTopology` for this client.
3934    WatchTopology { responder: ObserverWatchTopologyResponder },
3935    /// Request notification of any change to the device's plug state. When
3936    /// called for the first time, it will return immediately.
3937    ///
3938    /// Should only be called for Codec devices.
3939    WatchPlugState { responder: ObserverWatchPlugStateResponder },
3940    /// Retrieve the device's reference clock.
3941    ///
3942    /// This clock will be in the domain specified in the device's `Info` table.
3943    ///
3944    /// Should only be called for Composite devices.
3945    GetReferenceClock { responder: ObserverGetReferenceClockResponder },
3946    /// An interaction was received which does not match any known method.
3947    #[non_exhaustive]
3948    _UnknownMethod {
3949        /// Ordinal of the method that was called.
3950        ordinal: u64,
3951        control_handle: ObserverControlHandle,
3952        method_type: fidl::MethodType,
3953    },
3954}
3955
3956impl ObserverRequest {
3957    #[allow(irrefutable_let_patterns)]
3958    pub fn into_get_elements(self) -> Option<(ObserverGetElementsResponder)> {
3959        if let ObserverRequest::GetElements { responder } = self {
3960            Some((responder))
3961        } else {
3962            None
3963        }
3964    }
3965
3966    #[allow(irrefutable_let_patterns)]
3967    pub fn into_watch_element_state(self) -> Option<(u64, ObserverWatchElementStateResponder)> {
3968        if let ObserverRequest::WatchElementState { processing_element_id, responder } = self {
3969            Some((processing_element_id, responder))
3970        } else {
3971            None
3972        }
3973    }
3974
3975    #[allow(irrefutable_let_patterns)]
3976    pub fn into_get_topologies(self) -> Option<(ObserverGetTopologiesResponder)> {
3977        if let ObserverRequest::GetTopologies { responder } = self {
3978            Some((responder))
3979        } else {
3980            None
3981        }
3982    }
3983
3984    #[allow(irrefutable_let_patterns)]
3985    pub fn into_watch_topology(self) -> Option<(ObserverWatchTopologyResponder)> {
3986        if let ObserverRequest::WatchTopology { responder } = self {
3987            Some((responder))
3988        } else {
3989            None
3990        }
3991    }
3992
3993    #[allow(irrefutable_let_patterns)]
3994    pub fn into_watch_plug_state(self) -> Option<(ObserverWatchPlugStateResponder)> {
3995        if let ObserverRequest::WatchPlugState { responder } = self {
3996            Some((responder))
3997        } else {
3998            None
3999        }
4000    }
4001
4002    #[allow(irrefutable_let_patterns)]
4003    pub fn into_get_reference_clock(self) -> Option<(ObserverGetReferenceClockResponder)> {
4004        if let ObserverRequest::GetReferenceClock { responder } = self {
4005            Some((responder))
4006        } else {
4007            None
4008        }
4009    }
4010
4011    /// Name of the method defined in FIDL
4012    pub fn method_name(&self) -> &'static str {
4013        match *self {
4014            ObserverRequest::GetElements { .. } => "get_elements",
4015            ObserverRequest::WatchElementState { .. } => "watch_element_state",
4016            ObserverRequest::GetTopologies { .. } => "get_topologies",
4017            ObserverRequest::WatchTopology { .. } => "watch_topology",
4018            ObserverRequest::WatchPlugState { .. } => "watch_plug_state",
4019            ObserverRequest::GetReferenceClock { .. } => "get_reference_clock",
4020            ObserverRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
4021                "unknown one-way method"
4022            }
4023            ObserverRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
4024                "unknown two-way method"
4025            }
4026        }
4027    }
4028}
4029
4030#[derive(Debug, Clone)]
4031pub struct ObserverControlHandle {
4032    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4033}
4034
4035impl fidl::endpoints::ControlHandle for ObserverControlHandle {
4036    fn shutdown(&self) {
4037        self.inner.shutdown()
4038    }
4039    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4040        self.inner.shutdown_with_epitaph(status)
4041    }
4042
4043    fn is_closed(&self) -> bool {
4044        self.inner.channel().is_closed()
4045    }
4046    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4047        self.inner.channel().on_closed()
4048    }
4049
4050    #[cfg(target_os = "fuchsia")]
4051    fn signal_peer(
4052        &self,
4053        clear_mask: zx::Signals,
4054        set_mask: zx::Signals,
4055    ) -> Result<(), zx_status::Status> {
4056        use fidl::Peered;
4057        self.inner.channel().signal_peer(clear_mask, set_mask)
4058    }
4059}
4060
4061impl ObserverControlHandle {}
4062
4063#[must_use = "FIDL methods require a response to be sent"]
4064#[derive(Debug)]
4065pub struct ObserverGetElementsResponder {
4066    control_handle: std::mem::ManuallyDrop<ObserverControlHandle>,
4067    tx_id: u32,
4068}
4069
4070/// Set the the channel to be shutdown (see [`ObserverControlHandle::shutdown`])
4071/// if the responder is dropped without sending a response, so that the client
4072/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4073impl std::ops::Drop for ObserverGetElementsResponder {
4074    fn drop(&mut self) {
4075        self.control_handle.shutdown();
4076        // Safety: drops once, never accessed again
4077        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4078    }
4079}
4080
4081impl fidl::endpoints::Responder for ObserverGetElementsResponder {
4082    type ControlHandle = ObserverControlHandle;
4083
4084    fn control_handle(&self) -> &ObserverControlHandle {
4085        &self.control_handle
4086    }
4087
4088    fn drop_without_shutdown(mut self) {
4089        // Safety: drops once, never accessed again due to mem::forget
4090        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4091        // Prevent Drop from running (which would shut down the channel)
4092        std::mem::forget(self);
4093    }
4094}
4095
4096impl ObserverGetElementsResponder {
4097    /// Sends a response to the FIDL transaction.
4098    ///
4099    /// Sets the channel to shutdown if an error occurs.
4100    pub fn send(
4101        self,
4102        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Element], i32>,
4103    ) -> Result<(), fidl::Error> {
4104        let _result = self.send_raw(result);
4105        if _result.is_err() {
4106            self.control_handle.shutdown();
4107        }
4108        self.drop_without_shutdown();
4109        _result
4110    }
4111
4112    /// Similar to "send" but does not shutdown the channel if an error occurs.
4113    pub fn send_no_shutdown_on_err(
4114        self,
4115        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Element], i32>,
4116    ) -> Result<(), fidl::Error> {
4117        let _result = self.send_raw(result);
4118        self.drop_without_shutdown();
4119        _result
4120    }
4121
4122    fn send_raw(
4123        &self,
4124        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Element], i32>,
4125    ) -> Result<(), fidl::Error> {
4126        self.control_handle.inner.send::<fidl::encoding::ResultType<
4127            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResponse,
4128            i32,
4129        >>(
4130            result.map(|processing_elements| (processing_elements,)),
4131            self.tx_id,
4132            0x1b14ff4adf5dc6f8,
4133            fidl::encoding::DynamicFlags::empty(),
4134        )
4135    }
4136}
4137
4138#[must_use = "FIDL methods require a response to be sent"]
4139#[derive(Debug)]
4140pub struct ObserverWatchElementStateResponder {
4141    control_handle: std::mem::ManuallyDrop<ObserverControlHandle>,
4142    tx_id: u32,
4143}
4144
4145/// Set the the channel to be shutdown (see [`ObserverControlHandle::shutdown`])
4146/// if the responder is dropped without sending a response, so that the client
4147/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4148impl std::ops::Drop for ObserverWatchElementStateResponder {
4149    fn drop(&mut self) {
4150        self.control_handle.shutdown();
4151        // Safety: drops once, never accessed again
4152        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4153    }
4154}
4155
4156impl fidl::endpoints::Responder for ObserverWatchElementStateResponder {
4157    type ControlHandle = ObserverControlHandle;
4158
4159    fn control_handle(&self) -> &ObserverControlHandle {
4160        &self.control_handle
4161    }
4162
4163    fn drop_without_shutdown(mut self) {
4164        // Safety: drops once, never accessed again due to mem::forget
4165        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4166        // Prevent Drop from running (which would shut down the channel)
4167        std::mem::forget(self);
4168    }
4169}
4170
4171impl ObserverWatchElementStateResponder {
4172    /// Sends a response to the FIDL transaction.
4173    ///
4174    /// Sets the channel to shutdown if an error occurs.
4175    pub fn send(
4176        self,
4177        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
4178    ) -> Result<(), fidl::Error> {
4179        let _result = self.send_raw(state);
4180        if _result.is_err() {
4181            self.control_handle.shutdown();
4182        }
4183        self.drop_without_shutdown();
4184        _result
4185    }
4186
4187    /// Similar to "send" but does not shutdown the channel if an error occurs.
4188    pub fn send_no_shutdown_on_err(
4189        self,
4190        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
4191    ) -> Result<(), fidl::Error> {
4192        let _result = self.send_raw(state);
4193        self.drop_without_shutdown();
4194        _result
4195    }
4196
4197    fn send_raw(
4198        &self,
4199        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
4200    ) -> Result<(), fidl::Error> {
4201        self.control_handle
4202            .inner
4203            .send::<fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateResponse>(
4204            (state,),
4205            self.tx_id,
4206            0x524da8772a69056f,
4207            fidl::encoding::DynamicFlags::empty(),
4208        )
4209    }
4210}
4211
4212#[must_use = "FIDL methods require a response to be sent"]
4213#[derive(Debug)]
4214pub struct ObserverGetTopologiesResponder {
4215    control_handle: std::mem::ManuallyDrop<ObserverControlHandle>,
4216    tx_id: u32,
4217}
4218
4219/// Set the the channel to be shutdown (see [`ObserverControlHandle::shutdown`])
4220/// if the responder is dropped without sending a response, so that the client
4221/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4222impl std::ops::Drop for ObserverGetTopologiesResponder {
4223    fn drop(&mut self) {
4224        self.control_handle.shutdown();
4225        // Safety: drops once, never accessed again
4226        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4227    }
4228}
4229
4230impl fidl::endpoints::Responder for ObserverGetTopologiesResponder {
4231    type ControlHandle = ObserverControlHandle;
4232
4233    fn control_handle(&self) -> &ObserverControlHandle {
4234        &self.control_handle
4235    }
4236
4237    fn drop_without_shutdown(mut self) {
4238        // Safety: drops once, never accessed again due to mem::forget
4239        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4240        // Prevent Drop from running (which would shut down the channel)
4241        std::mem::forget(self);
4242    }
4243}
4244
4245impl ObserverGetTopologiesResponder {
4246    /// Sends a response to the FIDL transaction.
4247    ///
4248    /// Sets the channel to shutdown if an error occurs.
4249    pub fn send(
4250        self,
4251        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Topology], i32>,
4252    ) -> Result<(), fidl::Error> {
4253        let _result = self.send_raw(result);
4254        if _result.is_err() {
4255            self.control_handle.shutdown();
4256        }
4257        self.drop_without_shutdown();
4258        _result
4259    }
4260
4261    /// Similar to "send" but does not shutdown the channel if an error occurs.
4262    pub fn send_no_shutdown_on_err(
4263        self,
4264        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Topology], i32>,
4265    ) -> Result<(), fidl::Error> {
4266        let _result = self.send_raw(result);
4267        self.drop_without_shutdown();
4268        _result
4269    }
4270
4271    fn send_raw(
4272        &self,
4273        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Topology], i32>,
4274    ) -> Result<(), fidl::Error> {
4275        self.control_handle.inner.send::<fidl::encoding::ResultType<
4276            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResponse,
4277            i32,
4278        >>(
4279            result.map(|topologies| (topologies,)),
4280            self.tx_id,
4281            0x73ffb73af24d30b6,
4282            fidl::encoding::DynamicFlags::empty(),
4283        )
4284    }
4285}
4286
4287#[must_use = "FIDL methods require a response to be sent"]
4288#[derive(Debug)]
4289pub struct ObserverWatchTopologyResponder {
4290    control_handle: std::mem::ManuallyDrop<ObserverControlHandle>,
4291    tx_id: u32,
4292}
4293
4294/// Set the the channel to be shutdown (see [`ObserverControlHandle::shutdown`])
4295/// if the responder is dropped without sending a response, so that the client
4296/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4297impl std::ops::Drop for ObserverWatchTopologyResponder {
4298    fn drop(&mut self) {
4299        self.control_handle.shutdown();
4300        // Safety: drops once, never accessed again
4301        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4302    }
4303}
4304
4305impl fidl::endpoints::Responder for ObserverWatchTopologyResponder {
4306    type ControlHandle = ObserverControlHandle;
4307
4308    fn control_handle(&self) -> &ObserverControlHandle {
4309        &self.control_handle
4310    }
4311
4312    fn drop_without_shutdown(mut self) {
4313        // Safety: drops once, never accessed again due to mem::forget
4314        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4315        // Prevent Drop from running (which would shut down the channel)
4316        std::mem::forget(self);
4317    }
4318}
4319
4320impl ObserverWatchTopologyResponder {
4321    /// Sends a response to the FIDL transaction.
4322    ///
4323    /// Sets the channel to shutdown if an error occurs.
4324    pub fn send(self, mut topology_id: u64) -> Result<(), fidl::Error> {
4325        let _result = self.send_raw(topology_id);
4326        if _result.is_err() {
4327            self.control_handle.shutdown();
4328        }
4329        self.drop_without_shutdown();
4330        _result
4331    }
4332
4333    /// Similar to "send" but does not shutdown the channel if an error occurs.
4334    pub fn send_no_shutdown_on_err(self, mut topology_id: u64) -> Result<(), fidl::Error> {
4335        let _result = self.send_raw(topology_id);
4336        self.drop_without_shutdown();
4337        _result
4338    }
4339
4340    fn send_raw(&self, mut topology_id: u64) -> Result<(), fidl::Error> {
4341        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
4342            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchTopologyResponse,
4343        >>(
4344            fidl::encoding::Flexible::new((topology_id,)),
4345            self.tx_id,
4346            0x66d172acdb36a729,
4347            fidl::encoding::DynamicFlags::FLEXIBLE,
4348        )
4349    }
4350}
4351
4352#[must_use = "FIDL methods require a response to be sent"]
4353#[derive(Debug)]
4354pub struct ObserverWatchPlugStateResponder {
4355    control_handle: std::mem::ManuallyDrop<ObserverControlHandle>,
4356    tx_id: u32,
4357}
4358
4359/// Set the the channel to be shutdown (see [`ObserverControlHandle::shutdown`])
4360/// if the responder is dropped without sending a response, so that the client
4361/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4362impl std::ops::Drop for ObserverWatchPlugStateResponder {
4363    fn drop(&mut self) {
4364        self.control_handle.shutdown();
4365        // Safety: drops once, never accessed again
4366        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4367    }
4368}
4369
4370impl fidl::endpoints::Responder for ObserverWatchPlugStateResponder {
4371    type ControlHandle = ObserverControlHandle;
4372
4373    fn control_handle(&self) -> &ObserverControlHandle {
4374        &self.control_handle
4375    }
4376
4377    fn drop_without_shutdown(mut self) {
4378        // Safety: drops once, never accessed again due to mem::forget
4379        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4380        // Prevent Drop from running (which would shut down the channel)
4381        std::mem::forget(self);
4382    }
4383}
4384
4385impl ObserverWatchPlugStateResponder {
4386    /// Sends a response to the FIDL transaction.
4387    ///
4388    /// Sets the channel to shutdown if an error occurs.
4389    pub fn send(
4390        self,
4391        mut result: Result<&ObserverWatchPlugStateResponse, ObserverWatchPlugStateError>,
4392    ) -> Result<(), fidl::Error> {
4393        let _result = self.send_raw(result);
4394        if _result.is_err() {
4395            self.control_handle.shutdown();
4396        }
4397        self.drop_without_shutdown();
4398        _result
4399    }
4400
4401    /// Similar to "send" but does not shutdown the channel if an error occurs.
4402    pub fn send_no_shutdown_on_err(
4403        self,
4404        mut result: Result<&ObserverWatchPlugStateResponse, ObserverWatchPlugStateError>,
4405    ) -> Result<(), fidl::Error> {
4406        let _result = self.send_raw(result);
4407        self.drop_without_shutdown();
4408        _result
4409    }
4410
4411    fn send_raw(
4412        &self,
4413        mut result: Result<&ObserverWatchPlugStateResponse, ObserverWatchPlugStateError>,
4414    ) -> Result<(), fidl::Error> {
4415        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4416            ObserverWatchPlugStateResponse,
4417            ObserverWatchPlugStateError,
4418        >>(
4419            fidl::encoding::FlexibleResult::new(result),
4420            self.tx_id,
4421            0x6312bce495d2907a,
4422            fidl::encoding::DynamicFlags::FLEXIBLE,
4423        )
4424    }
4425}
4426
4427#[must_use = "FIDL methods require a response to be sent"]
4428#[derive(Debug)]
4429pub struct ObserverGetReferenceClockResponder {
4430    control_handle: std::mem::ManuallyDrop<ObserverControlHandle>,
4431    tx_id: u32,
4432}
4433
4434/// Set the the channel to be shutdown (see [`ObserverControlHandle::shutdown`])
4435/// if the responder is dropped without sending a response, so that the client
4436/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4437impl std::ops::Drop for ObserverGetReferenceClockResponder {
4438    fn drop(&mut self) {
4439        self.control_handle.shutdown();
4440        // Safety: drops once, never accessed again
4441        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4442    }
4443}
4444
4445impl fidl::endpoints::Responder for ObserverGetReferenceClockResponder {
4446    type ControlHandle = ObserverControlHandle;
4447
4448    fn control_handle(&self) -> &ObserverControlHandle {
4449        &self.control_handle
4450    }
4451
4452    fn drop_without_shutdown(mut self) {
4453        // Safety: drops once, never accessed again due to mem::forget
4454        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4455        // Prevent Drop from running (which would shut down the channel)
4456        std::mem::forget(self);
4457    }
4458}
4459
4460impl ObserverGetReferenceClockResponder {
4461    /// Sends a response to the FIDL transaction.
4462    ///
4463    /// Sets the channel to shutdown if an error occurs.
4464    pub fn send(
4465        self,
4466        mut result: Result<ObserverGetReferenceClockResponse, ObserverGetReferenceClockError>,
4467    ) -> Result<(), fidl::Error> {
4468        let _result = self.send_raw(result);
4469        if _result.is_err() {
4470            self.control_handle.shutdown();
4471        }
4472        self.drop_without_shutdown();
4473        _result
4474    }
4475
4476    /// Similar to "send" but does not shutdown the channel if an error occurs.
4477    pub fn send_no_shutdown_on_err(
4478        self,
4479        mut result: Result<ObserverGetReferenceClockResponse, ObserverGetReferenceClockError>,
4480    ) -> Result<(), fidl::Error> {
4481        let _result = self.send_raw(result);
4482        self.drop_without_shutdown();
4483        _result
4484    }
4485
4486    fn send_raw(
4487        &self,
4488        mut result: Result<ObserverGetReferenceClockResponse, ObserverGetReferenceClockError>,
4489    ) -> Result<(), fidl::Error> {
4490        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4491            ObserverGetReferenceClockResponse,
4492            ObserverGetReferenceClockError,
4493        >>(
4494            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
4495            self.tx_id,
4496            0x3819c5e0f9574c39,
4497            fidl::encoding::DynamicFlags::FLEXIBLE,
4498        )
4499    }
4500}
4501
4502#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4503pub struct ProviderMarker;
4504
4505impl fidl::endpoints::ProtocolMarker for ProviderMarker {
4506    type Proxy = ProviderProxy;
4507    type RequestStream = ProviderRequestStream;
4508    #[cfg(target_os = "fuchsia")]
4509    type SynchronousProxy = ProviderSynchronousProxy;
4510
4511    const DEBUG_NAME: &'static str = "fuchsia.audio.device.Provider";
4512}
4513impl fidl::endpoints::DiscoverableProtocolMarker for ProviderMarker {}
4514pub type ProviderAddDeviceResult = Result<ProviderAddDeviceResponse, ProviderAddDeviceError>;
4515
4516pub trait ProviderProxyInterface: Send + Sync {
4517    type AddDeviceResponseFut: std::future::Future<Output = Result<ProviderAddDeviceResult, fidl::Error>>
4518        + Send;
4519    fn r#add_device(&self, payload: ProviderAddDeviceRequest) -> Self::AddDeviceResponseFut;
4520}
4521#[derive(Debug)]
4522#[cfg(target_os = "fuchsia")]
4523pub struct ProviderSynchronousProxy {
4524    client: fidl::client::sync::Client,
4525}
4526
4527#[cfg(target_os = "fuchsia")]
4528impl fidl::endpoints::SynchronousProxy for ProviderSynchronousProxy {
4529    type Proxy = ProviderProxy;
4530    type Protocol = ProviderMarker;
4531
4532    fn from_channel(inner: fidl::Channel) -> Self {
4533        Self::new(inner)
4534    }
4535
4536    fn into_channel(self) -> fidl::Channel {
4537        self.client.into_channel()
4538    }
4539
4540    fn as_channel(&self) -> &fidl::Channel {
4541        self.client.as_channel()
4542    }
4543}
4544
4545#[cfg(target_os = "fuchsia")]
4546impl ProviderSynchronousProxy {
4547    pub fn new(channel: fidl::Channel) -> Self {
4548        let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4549        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4550    }
4551
4552    pub fn into_channel(self) -> fidl::Channel {
4553        self.client.into_channel()
4554    }
4555
4556    /// Waits until an event arrives and returns it. It is safe for other
4557    /// threads to make concurrent requests while waiting for an event.
4558    pub fn wait_for_event(
4559        &self,
4560        deadline: zx::MonotonicInstant,
4561    ) -> Result<ProviderEvent, fidl::Error> {
4562        ProviderEvent::decode(self.client.wait_for_event(deadline)?)
4563    }
4564
4565    pub fn r#add_device(
4566        &self,
4567        mut payload: ProviderAddDeviceRequest,
4568        ___deadline: zx::MonotonicInstant,
4569    ) -> Result<ProviderAddDeviceResult, fidl::Error> {
4570        let _response =
4571            self.client
4572                .send_query::<ProviderAddDeviceRequest, fidl::encoding::FlexibleResultType<
4573                    ProviderAddDeviceResponse,
4574                    ProviderAddDeviceError,
4575                >>(
4576                    &mut payload,
4577                    0x685fdfd91937758b,
4578                    fidl::encoding::DynamicFlags::FLEXIBLE,
4579                    ___deadline,
4580                )?
4581                .into_result::<ProviderMarker>("add_device")?;
4582        Ok(_response.map(|x| x))
4583    }
4584}
4585
4586#[derive(Debug, Clone)]
4587pub struct ProviderProxy {
4588    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4589}
4590
4591impl fidl::endpoints::Proxy for ProviderProxy {
4592    type Protocol = ProviderMarker;
4593
4594    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4595        Self::new(inner)
4596    }
4597
4598    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4599        self.client.into_channel().map_err(|client| Self { client })
4600    }
4601
4602    fn as_channel(&self) -> &::fidl::AsyncChannel {
4603        self.client.as_channel()
4604    }
4605}
4606
4607impl ProviderProxy {
4608    /// Create a new Proxy for fuchsia.audio.device/Provider.
4609    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4610        let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4611        Self { client: fidl::client::Client::new(channel, protocol_name) }
4612    }
4613
4614    /// Get a Stream of events from the remote end of the protocol.
4615    ///
4616    /// # Panics
4617    ///
4618    /// Panics if the event stream was already taken.
4619    pub fn take_event_stream(&self) -> ProviderEventStream {
4620        ProviderEventStream { event_receiver: self.client.take_event_receiver() }
4621    }
4622
4623    pub fn r#add_device(
4624        &self,
4625        mut payload: ProviderAddDeviceRequest,
4626    ) -> fidl::client::QueryResponseFut<
4627        ProviderAddDeviceResult,
4628        fidl::encoding::DefaultFuchsiaResourceDialect,
4629    > {
4630        ProviderProxyInterface::r#add_device(self, payload)
4631    }
4632}
4633
4634impl ProviderProxyInterface for ProviderProxy {
4635    type AddDeviceResponseFut = fidl::client::QueryResponseFut<
4636        ProviderAddDeviceResult,
4637        fidl::encoding::DefaultFuchsiaResourceDialect,
4638    >;
4639    fn r#add_device(&self, mut payload: ProviderAddDeviceRequest) -> Self::AddDeviceResponseFut {
4640        fn _decode(
4641            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4642        ) -> Result<ProviderAddDeviceResult, fidl::Error> {
4643            let _response = fidl::client::decode_transaction_body::<
4644                fidl::encoding::FlexibleResultType<
4645                    ProviderAddDeviceResponse,
4646                    ProviderAddDeviceError,
4647                >,
4648                fidl::encoding::DefaultFuchsiaResourceDialect,
4649                0x685fdfd91937758b,
4650            >(_buf?)?
4651            .into_result::<ProviderMarker>("add_device")?;
4652            Ok(_response.map(|x| x))
4653        }
4654        self.client.send_query_and_decode::<ProviderAddDeviceRequest, ProviderAddDeviceResult>(
4655            &mut payload,
4656            0x685fdfd91937758b,
4657            fidl::encoding::DynamicFlags::FLEXIBLE,
4658            _decode,
4659        )
4660    }
4661}
4662
4663pub struct ProviderEventStream {
4664    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4665}
4666
4667impl std::marker::Unpin for ProviderEventStream {}
4668
4669impl futures::stream::FusedStream for ProviderEventStream {
4670    fn is_terminated(&self) -> bool {
4671        self.event_receiver.is_terminated()
4672    }
4673}
4674
4675impl futures::Stream for ProviderEventStream {
4676    type Item = Result<ProviderEvent, fidl::Error>;
4677
4678    fn poll_next(
4679        mut self: std::pin::Pin<&mut Self>,
4680        cx: &mut std::task::Context<'_>,
4681    ) -> std::task::Poll<Option<Self::Item>> {
4682        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4683            &mut self.event_receiver,
4684            cx
4685        )?) {
4686            Some(buf) => std::task::Poll::Ready(Some(ProviderEvent::decode(buf))),
4687            None => std::task::Poll::Ready(None),
4688        }
4689    }
4690}
4691
4692#[derive(Debug)]
4693pub enum ProviderEvent {
4694    #[non_exhaustive]
4695    _UnknownEvent {
4696        /// Ordinal of the event that was sent.
4697        ordinal: u64,
4698    },
4699}
4700
4701impl ProviderEvent {
4702    /// Decodes a message buffer as a [`ProviderEvent`].
4703    fn decode(
4704        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4705    ) -> Result<ProviderEvent, fidl::Error> {
4706        let (bytes, _handles) = buf.split_mut();
4707        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4708        debug_assert_eq!(tx_header.tx_id, 0);
4709        match tx_header.ordinal {
4710            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4711                Ok(ProviderEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4712            }
4713            _ => Err(fidl::Error::UnknownOrdinal {
4714                ordinal: tx_header.ordinal,
4715                protocol_name: <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4716            }),
4717        }
4718    }
4719}
4720
4721/// A Stream of incoming requests for fuchsia.audio.device/Provider.
4722pub struct ProviderRequestStream {
4723    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4724    is_terminated: bool,
4725}
4726
4727impl std::marker::Unpin for ProviderRequestStream {}
4728
4729impl futures::stream::FusedStream for ProviderRequestStream {
4730    fn is_terminated(&self) -> bool {
4731        self.is_terminated
4732    }
4733}
4734
4735impl fidl::endpoints::RequestStream for ProviderRequestStream {
4736    type Protocol = ProviderMarker;
4737    type ControlHandle = ProviderControlHandle;
4738
4739    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4740        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4741    }
4742
4743    fn control_handle(&self) -> Self::ControlHandle {
4744        ProviderControlHandle { inner: self.inner.clone() }
4745    }
4746
4747    fn into_inner(
4748        self,
4749    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4750    {
4751        (self.inner, self.is_terminated)
4752    }
4753
4754    fn from_inner(
4755        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4756        is_terminated: bool,
4757    ) -> Self {
4758        Self { inner, is_terminated }
4759    }
4760}
4761
4762impl futures::Stream for ProviderRequestStream {
4763    type Item = Result<ProviderRequest, fidl::Error>;
4764
4765    fn poll_next(
4766        mut self: std::pin::Pin<&mut Self>,
4767        cx: &mut std::task::Context<'_>,
4768    ) -> std::task::Poll<Option<Self::Item>> {
4769        let this = &mut *self;
4770        if this.inner.check_shutdown(cx) {
4771            this.is_terminated = true;
4772            return std::task::Poll::Ready(None);
4773        }
4774        if this.is_terminated {
4775            panic!("polled ProviderRequestStream after completion");
4776        }
4777        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4778            |bytes, handles| {
4779                match this.inner.channel().read_etc(cx, bytes, handles) {
4780                    std::task::Poll::Ready(Ok(())) => {}
4781                    std::task::Poll::Pending => return std::task::Poll::Pending,
4782                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4783                        this.is_terminated = true;
4784                        return std::task::Poll::Ready(None);
4785                    }
4786                    std::task::Poll::Ready(Err(e)) => {
4787                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4788                            e.into(),
4789                        ))))
4790                    }
4791                }
4792
4793                // A message has been received from the channel
4794                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4795
4796                std::task::Poll::Ready(Some(match header.ordinal {
4797                    0x685fdfd91937758b => {
4798                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4799                        let mut req = fidl::new_empty!(
4800                            ProviderAddDeviceRequest,
4801                            fidl::encoding::DefaultFuchsiaResourceDialect
4802                        );
4803                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderAddDeviceRequest>(&header, _body_bytes, handles, &mut req)?;
4804                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
4805                        Ok(ProviderRequest::AddDevice {
4806                            payload: req,
4807                            responder: ProviderAddDeviceResponder {
4808                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4809                                tx_id: header.tx_id,
4810                            },
4811                        })
4812                    }
4813                    _ if header.tx_id == 0
4814                        && header
4815                            .dynamic_flags()
4816                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4817                    {
4818                        Ok(ProviderRequest::_UnknownMethod {
4819                            ordinal: header.ordinal,
4820                            control_handle: ProviderControlHandle { inner: this.inner.clone() },
4821                            method_type: fidl::MethodType::OneWay,
4822                        })
4823                    }
4824                    _ if header
4825                        .dynamic_flags()
4826                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4827                    {
4828                        this.inner.send_framework_err(
4829                            fidl::encoding::FrameworkErr::UnknownMethod,
4830                            header.tx_id,
4831                            header.ordinal,
4832                            header.dynamic_flags(),
4833                            (bytes, handles),
4834                        )?;
4835                        Ok(ProviderRequest::_UnknownMethod {
4836                            ordinal: header.ordinal,
4837                            control_handle: ProviderControlHandle { inner: this.inner.clone() },
4838                            method_type: fidl::MethodType::TwoWay,
4839                        })
4840                    }
4841                    _ => Err(fidl::Error::UnknownOrdinal {
4842                        ordinal: header.ordinal,
4843                        protocol_name:
4844                            <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4845                    }),
4846                }))
4847            },
4848        )
4849    }
4850}
4851
4852/// Use the `Provider` interface to manually add devices that do not use the devfs
4853/// mechanism. (Devices that use devfs are automatically added, upon detection.)
4854#[derive(Debug)]
4855pub enum ProviderRequest {
4856    AddDevice {
4857        payload: ProviderAddDeviceRequest,
4858        responder: ProviderAddDeviceResponder,
4859    },
4860    /// An interaction was received which does not match any known method.
4861    #[non_exhaustive]
4862    _UnknownMethod {
4863        /// Ordinal of the method that was called.
4864        ordinal: u64,
4865        control_handle: ProviderControlHandle,
4866        method_type: fidl::MethodType,
4867    },
4868}
4869
4870impl ProviderRequest {
4871    #[allow(irrefutable_let_patterns)]
4872    pub fn into_add_device(self) -> Option<(ProviderAddDeviceRequest, ProviderAddDeviceResponder)> {
4873        if let ProviderRequest::AddDevice { payload, responder } = self {
4874            Some((payload, responder))
4875        } else {
4876            None
4877        }
4878    }
4879
4880    /// Name of the method defined in FIDL
4881    pub fn method_name(&self) -> &'static str {
4882        match *self {
4883            ProviderRequest::AddDevice { .. } => "add_device",
4884            ProviderRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
4885                "unknown one-way method"
4886            }
4887            ProviderRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
4888                "unknown two-way method"
4889            }
4890        }
4891    }
4892}
4893
4894#[derive(Debug, Clone)]
4895pub struct ProviderControlHandle {
4896    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4897}
4898
4899impl fidl::endpoints::ControlHandle for ProviderControlHandle {
4900    fn shutdown(&self) {
4901        self.inner.shutdown()
4902    }
4903    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4904        self.inner.shutdown_with_epitaph(status)
4905    }
4906
4907    fn is_closed(&self) -> bool {
4908        self.inner.channel().is_closed()
4909    }
4910    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4911        self.inner.channel().on_closed()
4912    }
4913
4914    #[cfg(target_os = "fuchsia")]
4915    fn signal_peer(
4916        &self,
4917        clear_mask: zx::Signals,
4918        set_mask: zx::Signals,
4919    ) -> Result<(), zx_status::Status> {
4920        use fidl::Peered;
4921        self.inner.channel().signal_peer(clear_mask, set_mask)
4922    }
4923}
4924
4925impl ProviderControlHandle {}
4926
4927#[must_use = "FIDL methods require a response to be sent"]
4928#[derive(Debug)]
4929pub struct ProviderAddDeviceResponder {
4930    control_handle: std::mem::ManuallyDrop<ProviderControlHandle>,
4931    tx_id: u32,
4932}
4933
4934/// Set the the channel to be shutdown (see [`ProviderControlHandle::shutdown`])
4935/// if the responder is dropped without sending a response, so that the client
4936/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4937impl std::ops::Drop for ProviderAddDeviceResponder {
4938    fn drop(&mut self) {
4939        self.control_handle.shutdown();
4940        // Safety: drops once, never accessed again
4941        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4942    }
4943}
4944
4945impl fidl::endpoints::Responder for ProviderAddDeviceResponder {
4946    type ControlHandle = ProviderControlHandle;
4947
4948    fn control_handle(&self) -> &ProviderControlHandle {
4949        &self.control_handle
4950    }
4951
4952    fn drop_without_shutdown(mut self) {
4953        // Safety: drops once, never accessed again due to mem::forget
4954        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4955        // Prevent Drop from running (which would shut down the channel)
4956        std::mem::forget(self);
4957    }
4958}
4959
4960impl ProviderAddDeviceResponder {
4961    /// Sends a response to the FIDL transaction.
4962    ///
4963    /// Sets the channel to shutdown if an error occurs.
4964    pub fn send(
4965        self,
4966        mut result: Result<&ProviderAddDeviceResponse, ProviderAddDeviceError>,
4967    ) -> Result<(), fidl::Error> {
4968        let _result = self.send_raw(result);
4969        if _result.is_err() {
4970            self.control_handle.shutdown();
4971        }
4972        self.drop_without_shutdown();
4973        _result
4974    }
4975
4976    /// Similar to "send" but does not shutdown the channel if an error occurs.
4977    pub fn send_no_shutdown_on_err(
4978        self,
4979        mut result: Result<&ProviderAddDeviceResponse, ProviderAddDeviceError>,
4980    ) -> Result<(), fidl::Error> {
4981        let _result = self.send_raw(result);
4982        self.drop_without_shutdown();
4983        _result
4984    }
4985
4986    fn send_raw(
4987        &self,
4988        mut result: Result<&ProviderAddDeviceResponse, ProviderAddDeviceError>,
4989    ) -> Result<(), fidl::Error> {
4990        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4991            ProviderAddDeviceResponse,
4992            ProviderAddDeviceError,
4993        >>(
4994            fidl::encoding::FlexibleResult::new(result),
4995            self.tx_id,
4996            0x685fdfd91937758b,
4997            fidl::encoding::DynamicFlags::FLEXIBLE,
4998        )
4999    }
5000}
5001
5002#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5003pub struct RegistryMarker;
5004
5005impl fidl::endpoints::ProtocolMarker for RegistryMarker {
5006    type Proxy = RegistryProxy;
5007    type RequestStream = RegistryRequestStream;
5008    #[cfg(target_os = "fuchsia")]
5009    type SynchronousProxy = RegistrySynchronousProxy;
5010
5011    const DEBUG_NAME: &'static str = "fuchsia.audio.device.Registry";
5012}
5013impl fidl::endpoints::DiscoverableProtocolMarker for RegistryMarker {}
5014pub type RegistryWatchDevicesAddedResult =
5015    Result<RegistryWatchDevicesAddedResponse, RegistryWatchDevicesAddedError>;
5016pub type RegistryWatchDeviceRemovedResult =
5017    Result<RegistryWatchDeviceRemovedResponse, RegistryWatchDeviceRemovedError>;
5018pub type RegistryCreateObserverResult =
5019    Result<RegistryCreateObserverResponse, RegistryCreateObserverError>;
5020
5021pub trait RegistryProxyInterface: Send + Sync {
5022    type WatchDevicesAddedResponseFut: std::future::Future<Output = Result<RegistryWatchDevicesAddedResult, fidl::Error>>
5023        + Send;
5024    fn r#watch_devices_added(&self) -> Self::WatchDevicesAddedResponseFut;
5025    type WatchDeviceRemovedResponseFut: std::future::Future<Output = Result<RegistryWatchDeviceRemovedResult, fidl::Error>>
5026        + Send;
5027    fn r#watch_device_removed(&self) -> Self::WatchDeviceRemovedResponseFut;
5028    type CreateObserverResponseFut: std::future::Future<Output = Result<RegistryCreateObserverResult, fidl::Error>>
5029        + Send;
5030    fn r#create_observer(
5031        &self,
5032        payload: RegistryCreateObserverRequest,
5033    ) -> Self::CreateObserverResponseFut;
5034}
5035#[derive(Debug)]
5036#[cfg(target_os = "fuchsia")]
5037pub struct RegistrySynchronousProxy {
5038    client: fidl::client::sync::Client,
5039}
5040
5041#[cfg(target_os = "fuchsia")]
5042impl fidl::endpoints::SynchronousProxy for RegistrySynchronousProxy {
5043    type Proxy = RegistryProxy;
5044    type Protocol = RegistryMarker;
5045
5046    fn from_channel(inner: fidl::Channel) -> Self {
5047        Self::new(inner)
5048    }
5049
5050    fn into_channel(self) -> fidl::Channel {
5051        self.client.into_channel()
5052    }
5053
5054    fn as_channel(&self) -> &fidl::Channel {
5055        self.client.as_channel()
5056    }
5057}
5058
5059#[cfg(target_os = "fuchsia")]
5060impl RegistrySynchronousProxy {
5061    pub fn new(channel: fidl::Channel) -> Self {
5062        let protocol_name = <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5063        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5064    }
5065
5066    pub fn into_channel(self) -> fidl::Channel {
5067        self.client.into_channel()
5068    }
5069
5070    /// Waits until an event arrives and returns it. It is safe for other
5071    /// threads to make concurrent requests while waiting for an event.
5072    pub fn wait_for_event(
5073        &self,
5074        deadline: zx::MonotonicInstant,
5075    ) -> Result<RegistryEvent, fidl::Error> {
5076        RegistryEvent::decode(self.client.wait_for_event(deadline)?)
5077    }
5078
5079    /// Register for notification when one or more devices are added.
5080    /// The `devices` vector will always contain at least one `Info` entry.
5081    pub fn r#watch_devices_added(
5082        &self,
5083        ___deadline: zx::MonotonicInstant,
5084    ) -> Result<RegistryWatchDevicesAddedResult, fidl::Error> {
5085        let _response = self
5086            .client
5087            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
5088                RegistryWatchDevicesAddedResponse,
5089                RegistryWatchDevicesAddedError,
5090            >>(
5091                (), 0x562ca31f7c149def, fidl::encoding::DynamicFlags::FLEXIBLE, ___deadline
5092            )?
5093            .into_result::<RegistryMarker>("watch_devices_added")?;
5094        Ok(_response.map(|x| x))
5095    }
5096
5097    /// Register for notification when an (active, added) device is removed.
5098    /// Because the method only notifies of one removal, upon completion it
5099    /// should immediately be re-called, in case other removals have occurred.
5100    /// Calls to this method will pend until the removal of a device that was
5101    /// included in a previous `WatchDevicesAdded` response.
5102    pub fn r#watch_device_removed(
5103        &self,
5104        ___deadline: zx::MonotonicInstant,
5105    ) -> Result<RegistryWatchDeviceRemovedResult, fidl::Error> {
5106        let _response = self
5107            .client
5108            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
5109                RegistryWatchDeviceRemovedResponse,
5110                RegistryWatchDeviceRemovedError,
5111            >>(
5112                (), 0x6e67aabc99a502af, fidl::encoding::DynamicFlags::FLEXIBLE, ___deadline
5113            )?
5114            .into_result::<RegistryMarker>("watch_device_removed")?;
5115        Ok(_response.map(|x| x))
5116    }
5117
5118    /// Request an `Observer` for the specified device.
5119    pub fn r#create_observer(
5120        &self,
5121        mut payload: RegistryCreateObserverRequest,
5122        ___deadline: zx::MonotonicInstant,
5123    ) -> Result<RegistryCreateObserverResult, fidl::Error> {
5124        let _response = self
5125            .client
5126            .send_query::<RegistryCreateObserverRequest, fidl::encoding::FlexibleResultType<
5127                RegistryCreateObserverResponse,
5128                RegistryCreateObserverError,
5129            >>(
5130                &mut payload,
5131                0x577bc322eb8d2bd1,
5132                fidl::encoding::DynamicFlags::FLEXIBLE,
5133                ___deadline,
5134            )?
5135            .into_result::<RegistryMarker>("create_observer")?;
5136        Ok(_response.map(|x| x))
5137    }
5138}
5139
5140#[derive(Debug, Clone)]
5141pub struct RegistryProxy {
5142    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5143}
5144
5145impl fidl::endpoints::Proxy for RegistryProxy {
5146    type Protocol = RegistryMarker;
5147
5148    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5149        Self::new(inner)
5150    }
5151
5152    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5153        self.client.into_channel().map_err(|client| Self { client })
5154    }
5155
5156    fn as_channel(&self) -> &::fidl::AsyncChannel {
5157        self.client.as_channel()
5158    }
5159}
5160
5161impl RegistryProxy {
5162    /// Create a new Proxy for fuchsia.audio.device/Registry.
5163    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5164        let protocol_name = <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5165        Self { client: fidl::client::Client::new(channel, protocol_name) }
5166    }
5167
5168    /// Get a Stream of events from the remote end of the protocol.
5169    ///
5170    /// # Panics
5171    ///
5172    /// Panics if the event stream was already taken.
5173    pub fn take_event_stream(&self) -> RegistryEventStream {
5174        RegistryEventStream { event_receiver: self.client.take_event_receiver() }
5175    }
5176
5177    /// Register for notification when one or more devices are added.
5178    /// The `devices` vector will always contain at least one `Info` entry.
5179    pub fn r#watch_devices_added(
5180        &self,
5181    ) -> fidl::client::QueryResponseFut<
5182        RegistryWatchDevicesAddedResult,
5183        fidl::encoding::DefaultFuchsiaResourceDialect,
5184    > {
5185        RegistryProxyInterface::r#watch_devices_added(self)
5186    }
5187
5188    /// Register for notification when an (active, added) device is removed.
5189    /// Because the method only notifies of one removal, upon completion it
5190    /// should immediately be re-called, in case other removals have occurred.
5191    /// Calls to this method will pend until the removal of a device that was
5192    /// included in a previous `WatchDevicesAdded` response.
5193    pub fn r#watch_device_removed(
5194        &self,
5195    ) -> fidl::client::QueryResponseFut<
5196        RegistryWatchDeviceRemovedResult,
5197        fidl::encoding::DefaultFuchsiaResourceDialect,
5198    > {
5199        RegistryProxyInterface::r#watch_device_removed(self)
5200    }
5201
5202    /// Request an `Observer` for the specified device.
5203    pub fn r#create_observer(
5204        &self,
5205        mut payload: RegistryCreateObserverRequest,
5206    ) -> fidl::client::QueryResponseFut<
5207        RegistryCreateObserverResult,
5208        fidl::encoding::DefaultFuchsiaResourceDialect,
5209    > {
5210        RegistryProxyInterface::r#create_observer(self, payload)
5211    }
5212}
5213
5214impl RegistryProxyInterface for RegistryProxy {
5215    type WatchDevicesAddedResponseFut = fidl::client::QueryResponseFut<
5216        RegistryWatchDevicesAddedResult,
5217        fidl::encoding::DefaultFuchsiaResourceDialect,
5218    >;
5219    fn r#watch_devices_added(&self) -> Self::WatchDevicesAddedResponseFut {
5220        fn _decode(
5221            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5222        ) -> Result<RegistryWatchDevicesAddedResult, fidl::Error> {
5223            let _response = fidl::client::decode_transaction_body::<
5224                fidl::encoding::FlexibleResultType<
5225                    RegistryWatchDevicesAddedResponse,
5226                    RegistryWatchDevicesAddedError,
5227                >,
5228                fidl::encoding::DefaultFuchsiaResourceDialect,
5229                0x562ca31f7c149def,
5230            >(_buf?)?
5231            .into_result::<RegistryMarker>("watch_devices_added")?;
5232            Ok(_response.map(|x| x))
5233        }
5234        self.client
5235            .send_query_and_decode::<fidl::encoding::EmptyPayload, RegistryWatchDevicesAddedResult>(
5236                (),
5237                0x562ca31f7c149def,
5238                fidl::encoding::DynamicFlags::FLEXIBLE,
5239                _decode,
5240            )
5241    }
5242
5243    type WatchDeviceRemovedResponseFut = fidl::client::QueryResponseFut<
5244        RegistryWatchDeviceRemovedResult,
5245        fidl::encoding::DefaultFuchsiaResourceDialect,
5246    >;
5247    fn r#watch_device_removed(&self) -> Self::WatchDeviceRemovedResponseFut {
5248        fn _decode(
5249            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5250        ) -> Result<RegistryWatchDeviceRemovedResult, fidl::Error> {
5251            let _response = fidl::client::decode_transaction_body::<
5252                fidl::encoding::FlexibleResultType<
5253                    RegistryWatchDeviceRemovedResponse,
5254                    RegistryWatchDeviceRemovedError,
5255                >,
5256                fidl::encoding::DefaultFuchsiaResourceDialect,
5257                0x6e67aabc99a502af,
5258            >(_buf?)?
5259            .into_result::<RegistryMarker>("watch_device_removed")?;
5260            Ok(_response.map(|x| x))
5261        }
5262        self.client.send_query_and_decode::<
5263            fidl::encoding::EmptyPayload,
5264            RegistryWatchDeviceRemovedResult,
5265        >(
5266            (),
5267            0x6e67aabc99a502af,
5268            fidl::encoding::DynamicFlags::FLEXIBLE,
5269            _decode,
5270        )
5271    }
5272
5273    type CreateObserverResponseFut = fidl::client::QueryResponseFut<
5274        RegistryCreateObserverResult,
5275        fidl::encoding::DefaultFuchsiaResourceDialect,
5276    >;
5277    fn r#create_observer(
5278        &self,
5279        mut payload: RegistryCreateObserverRequest,
5280    ) -> Self::CreateObserverResponseFut {
5281        fn _decode(
5282            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5283        ) -> Result<RegistryCreateObserverResult, fidl::Error> {
5284            let _response = fidl::client::decode_transaction_body::<
5285                fidl::encoding::FlexibleResultType<
5286                    RegistryCreateObserverResponse,
5287                    RegistryCreateObserverError,
5288                >,
5289                fidl::encoding::DefaultFuchsiaResourceDialect,
5290                0x577bc322eb8d2bd1,
5291            >(_buf?)?
5292            .into_result::<RegistryMarker>("create_observer")?;
5293            Ok(_response.map(|x| x))
5294        }
5295        self.client
5296            .send_query_and_decode::<RegistryCreateObserverRequest, RegistryCreateObserverResult>(
5297                &mut payload,
5298                0x577bc322eb8d2bd1,
5299                fidl::encoding::DynamicFlags::FLEXIBLE,
5300                _decode,
5301            )
5302    }
5303}
5304
5305pub struct RegistryEventStream {
5306    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5307}
5308
5309impl std::marker::Unpin for RegistryEventStream {}
5310
5311impl futures::stream::FusedStream for RegistryEventStream {
5312    fn is_terminated(&self) -> bool {
5313        self.event_receiver.is_terminated()
5314    }
5315}
5316
5317impl futures::Stream for RegistryEventStream {
5318    type Item = Result<RegistryEvent, fidl::Error>;
5319
5320    fn poll_next(
5321        mut self: std::pin::Pin<&mut Self>,
5322        cx: &mut std::task::Context<'_>,
5323    ) -> std::task::Poll<Option<Self::Item>> {
5324        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5325            &mut self.event_receiver,
5326            cx
5327        )?) {
5328            Some(buf) => std::task::Poll::Ready(Some(RegistryEvent::decode(buf))),
5329            None => std::task::Poll::Ready(None),
5330        }
5331    }
5332}
5333
5334#[derive(Debug)]
5335pub enum RegistryEvent {
5336    #[non_exhaustive]
5337    _UnknownEvent {
5338        /// Ordinal of the event that was sent.
5339        ordinal: u64,
5340    },
5341}
5342
5343impl RegistryEvent {
5344    /// Decodes a message buffer as a [`RegistryEvent`].
5345    fn decode(
5346        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5347    ) -> Result<RegistryEvent, fidl::Error> {
5348        let (bytes, _handles) = buf.split_mut();
5349        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5350        debug_assert_eq!(tx_header.tx_id, 0);
5351        match tx_header.ordinal {
5352            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5353                Ok(RegistryEvent::_UnknownEvent { ordinal: tx_header.ordinal })
5354            }
5355            _ => Err(fidl::Error::UnknownOrdinal {
5356                ordinal: tx_header.ordinal,
5357                protocol_name: <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5358            }),
5359        }
5360    }
5361}
5362
5363/// A Stream of incoming requests for fuchsia.audio.device/Registry.
5364pub struct RegistryRequestStream {
5365    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5366    is_terminated: bool,
5367}
5368
5369impl std::marker::Unpin for RegistryRequestStream {}
5370
5371impl futures::stream::FusedStream for RegistryRequestStream {
5372    fn is_terminated(&self) -> bool {
5373        self.is_terminated
5374    }
5375}
5376
5377impl fidl::endpoints::RequestStream for RegistryRequestStream {
5378    type Protocol = RegistryMarker;
5379    type ControlHandle = RegistryControlHandle;
5380
5381    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5382        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5383    }
5384
5385    fn control_handle(&self) -> Self::ControlHandle {
5386        RegistryControlHandle { inner: self.inner.clone() }
5387    }
5388
5389    fn into_inner(
5390        self,
5391    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5392    {
5393        (self.inner, self.is_terminated)
5394    }
5395
5396    fn from_inner(
5397        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5398        is_terminated: bool,
5399    ) -> Self {
5400        Self { inner, is_terminated }
5401    }
5402}
5403
5404impl futures::Stream for RegistryRequestStream {
5405    type Item = Result<RegistryRequest, fidl::Error>;
5406
5407    fn poll_next(
5408        mut self: std::pin::Pin<&mut Self>,
5409        cx: &mut std::task::Context<'_>,
5410    ) -> std::task::Poll<Option<Self::Item>> {
5411        let this = &mut *self;
5412        if this.inner.check_shutdown(cx) {
5413            this.is_terminated = true;
5414            return std::task::Poll::Ready(None);
5415        }
5416        if this.is_terminated {
5417            panic!("polled RegistryRequestStream after completion");
5418        }
5419        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5420            |bytes, handles| {
5421                match this.inner.channel().read_etc(cx, bytes, handles) {
5422                    std::task::Poll::Ready(Ok(())) => {}
5423                    std::task::Poll::Pending => return std::task::Poll::Pending,
5424                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5425                        this.is_terminated = true;
5426                        return std::task::Poll::Ready(None);
5427                    }
5428                    std::task::Poll::Ready(Err(e)) => {
5429                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5430                            e.into(),
5431                        ))))
5432                    }
5433                }
5434
5435                // A message has been received from the channel
5436                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5437
5438                std::task::Poll::Ready(Some(match header.ordinal {
5439                    0x562ca31f7c149def => {
5440                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5441                        let mut req = fidl::new_empty!(
5442                            fidl::encoding::EmptyPayload,
5443                            fidl::encoding::DefaultFuchsiaResourceDialect
5444                        );
5445                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5446                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
5447                        Ok(RegistryRequest::WatchDevicesAdded {
5448                            responder: RegistryWatchDevicesAddedResponder {
5449                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5450                                tx_id: header.tx_id,
5451                            },
5452                        })
5453                    }
5454                    0x6e67aabc99a502af => {
5455                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5456                        let mut req = fidl::new_empty!(
5457                            fidl::encoding::EmptyPayload,
5458                            fidl::encoding::DefaultFuchsiaResourceDialect
5459                        );
5460                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5461                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
5462                        Ok(RegistryRequest::WatchDeviceRemoved {
5463                            responder: RegistryWatchDeviceRemovedResponder {
5464                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5465                                tx_id: header.tx_id,
5466                            },
5467                        })
5468                    }
5469                    0x577bc322eb8d2bd1 => {
5470                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5471                        let mut req = fidl::new_empty!(
5472                            RegistryCreateObserverRequest,
5473                            fidl::encoding::DefaultFuchsiaResourceDialect
5474                        );
5475                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RegistryCreateObserverRequest>(&header, _body_bytes, handles, &mut req)?;
5476                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
5477                        Ok(RegistryRequest::CreateObserver {
5478                            payload: req,
5479                            responder: RegistryCreateObserverResponder {
5480                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5481                                tx_id: header.tx_id,
5482                            },
5483                        })
5484                    }
5485                    _ if header.tx_id == 0
5486                        && header
5487                            .dynamic_flags()
5488                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5489                    {
5490                        Ok(RegistryRequest::_UnknownMethod {
5491                            ordinal: header.ordinal,
5492                            control_handle: RegistryControlHandle { inner: this.inner.clone() },
5493                            method_type: fidl::MethodType::OneWay,
5494                        })
5495                    }
5496                    _ if header
5497                        .dynamic_flags()
5498                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5499                    {
5500                        this.inner.send_framework_err(
5501                            fidl::encoding::FrameworkErr::UnknownMethod,
5502                            header.tx_id,
5503                            header.ordinal,
5504                            header.dynamic_flags(),
5505                            (bytes, handles),
5506                        )?;
5507                        Ok(RegistryRequest::_UnknownMethod {
5508                            ordinal: header.ordinal,
5509                            control_handle: RegistryControlHandle { inner: this.inner.clone() },
5510                            method_type: fidl::MethodType::TwoWay,
5511                        })
5512                    }
5513                    _ => Err(fidl::Error::UnknownOrdinal {
5514                        ordinal: header.ordinal,
5515                        protocol_name:
5516                            <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5517                    }),
5518                }))
5519            },
5520        )
5521    }
5522}
5523
5524/// `Registry` instances notify clients as devices arrive and depart, and they
5525/// create observers (see `Observer`) that notify of more detailed state changes.
5526#[derive(Debug)]
5527pub enum RegistryRequest {
5528    /// Register for notification when one or more devices are added.
5529    /// The `devices` vector will always contain at least one `Info` entry.
5530    WatchDevicesAdded { responder: RegistryWatchDevicesAddedResponder },
5531    /// Register for notification when an (active, added) device is removed.
5532    /// Because the method only notifies of one removal, upon completion it
5533    /// should immediately be re-called, in case other removals have occurred.
5534    /// Calls to this method will pend until the removal of a device that was
5535    /// included in a previous `WatchDevicesAdded` response.
5536    WatchDeviceRemoved { responder: RegistryWatchDeviceRemovedResponder },
5537    /// Request an `Observer` for the specified device.
5538    CreateObserver {
5539        payload: RegistryCreateObserverRequest,
5540        responder: RegistryCreateObserverResponder,
5541    },
5542    /// An interaction was received which does not match any known method.
5543    #[non_exhaustive]
5544    _UnknownMethod {
5545        /// Ordinal of the method that was called.
5546        ordinal: u64,
5547        control_handle: RegistryControlHandle,
5548        method_type: fidl::MethodType,
5549    },
5550}
5551
5552impl RegistryRequest {
5553    #[allow(irrefutable_let_patterns)]
5554    pub fn into_watch_devices_added(self) -> Option<(RegistryWatchDevicesAddedResponder)> {
5555        if let RegistryRequest::WatchDevicesAdded { responder } = self {
5556            Some((responder))
5557        } else {
5558            None
5559        }
5560    }
5561
5562    #[allow(irrefutable_let_patterns)]
5563    pub fn into_watch_device_removed(self) -> Option<(RegistryWatchDeviceRemovedResponder)> {
5564        if let RegistryRequest::WatchDeviceRemoved { responder } = self {
5565            Some((responder))
5566        } else {
5567            None
5568        }
5569    }
5570
5571    #[allow(irrefutable_let_patterns)]
5572    pub fn into_create_observer(
5573        self,
5574    ) -> Option<(RegistryCreateObserverRequest, RegistryCreateObserverResponder)> {
5575        if let RegistryRequest::CreateObserver { payload, responder } = self {
5576            Some((payload, responder))
5577        } else {
5578            None
5579        }
5580    }
5581
5582    /// Name of the method defined in FIDL
5583    pub fn method_name(&self) -> &'static str {
5584        match *self {
5585            RegistryRequest::WatchDevicesAdded { .. } => "watch_devices_added",
5586            RegistryRequest::WatchDeviceRemoved { .. } => "watch_device_removed",
5587            RegistryRequest::CreateObserver { .. } => "create_observer",
5588            RegistryRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
5589                "unknown one-way method"
5590            }
5591            RegistryRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
5592                "unknown two-way method"
5593            }
5594        }
5595    }
5596}
5597
5598#[derive(Debug, Clone)]
5599pub struct RegistryControlHandle {
5600    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5601}
5602
5603impl fidl::endpoints::ControlHandle for RegistryControlHandle {
5604    fn shutdown(&self) {
5605        self.inner.shutdown()
5606    }
5607    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5608        self.inner.shutdown_with_epitaph(status)
5609    }
5610
5611    fn is_closed(&self) -> bool {
5612        self.inner.channel().is_closed()
5613    }
5614    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5615        self.inner.channel().on_closed()
5616    }
5617
5618    #[cfg(target_os = "fuchsia")]
5619    fn signal_peer(
5620        &self,
5621        clear_mask: zx::Signals,
5622        set_mask: zx::Signals,
5623    ) -> Result<(), zx_status::Status> {
5624        use fidl::Peered;
5625        self.inner.channel().signal_peer(clear_mask, set_mask)
5626    }
5627}
5628
5629impl RegistryControlHandle {}
5630
5631#[must_use = "FIDL methods require a response to be sent"]
5632#[derive(Debug)]
5633pub struct RegistryWatchDevicesAddedResponder {
5634    control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
5635    tx_id: u32,
5636}
5637
5638/// Set the the channel to be shutdown (see [`RegistryControlHandle::shutdown`])
5639/// if the responder is dropped without sending a response, so that the client
5640/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5641impl std::ops::Drop for RegistryWatchDevicesAddedResponder {
5642    fn drop(&mut self) {
5643        self.control_handle.shutdown();
5644        // Safety: drops once, never accessed again
5645        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5646    }
5647}
5648
5649impl fidl::endpoints::Responder for RegistryWatchDevicesAddedResponder {
5650    type ControlHandle = RegistryControlHandle;
5651
5652    fn control_handle(&self) -> &RegistryControlHandle {
5653        &self.control_handle
5654    }
5655
5656    fn drop_without_shutdown(mut self) {
5657        // Safety: drops once, never accessed again due to mem::forget
5658        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5659        // Prevent Drop from running (which would shut down the channel)
5660        std::mem::forget(self);
5661    }
5662}
5663
5664impl RegistryWatchDevicesAddedResponder {
5665    /// Sends a response to the FIDL transaction.
5666    ///
5667    /// Sets the channel to shutdown if an error occurs.
5668    pub fn send(
5669        self,
5670        mut result: Result<&RegistryWatchDevicesAddedResponse, RegistryWatchDevicesAddedError>,
5671    ) -> Result<(), fidl::Error> {
5672        let _result = self.send_raw(result);
5673        if _result.is_err() {
5674            self.control_handle.shutdown();
5675        }
5676        self.drop_without_shutdown();
5677        _result
5678    }
5679
5680    /// Similar to "send" but does not shutdown the channel if an error occurs.
5681    pub fn send_no_shutdown_on_err(
5682        self,
5683        mut result: Result<&RegistryWatchDevicesAddedResponse, RegistryWatchDevicesAddedError>,
5684    ) -> Result<(), fidl::Error> {
5685        let _result = self.send_raw(result);
5686        self.drop_without_shutdown();
5687        _result
5688    }
5689
5690    fn send_raw(
5691        &self,
5692        mut result: Result<&RegistryWatchDevicesAddedResponse, RegistryWatchDevicesAddedError>,
5693    ) -> Result<(), fidl::Error> {
5694        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5695            RegistryWatchDevicesAddedResponse,
5696            RegistryWatchDevicesAddedError,
5697        >>(
5698            fidl::encoding::FlexibleResult::new(result),
5699            self.tx_id,
5700            0x562ca31f7c149def,
5701            fidl::encoding::DynamicFlags::FLEXIBLE,
5702        )
5703    }
5704}
5705
5706#[must_use = "FIDL methods require a response to be sent"]
5707#[derive(Debug)]
5708pub struct RegistryWatchDeviceRemovedResponder {
5709    control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
5710    tx_id: u32,
5711}
5712
5713/// Set the the channel to be shutdown (see [`RegistryControlHandle::shutdown`])
5714/// if the responder is dropped without sending a response, so that the client
5715/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5716impl std::ops::Drop for RegistryWatchDeviceRemovedResponder {
5717    fn drop(&mut self) {
5718        self.control_handle.shutdown();
5719        // Safety: drops once, never accessed again
5720        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5721    }
5722}
5723
5724impl fidl::endpoints::Responder for RegistryWatchDeviceRemovedResponder {
5725    type ControlHandle = RegistryControlHandle;
5726
5727    fn control_handle(&self) -> &RegistryControlHandle {
5728        &self.control_handle
5729    }
5730
5731    fn drop_without_shutdown(mut self) {
5732        // Safety: drops once, never accessed again due to mem::forget
5733        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5734        // Prevent Drop from running (which would shut down the channel)
5735        std::mem::forget(self);
5736    }
5737}
5738
5739impl RegistryWatchDeviceRemovedResponder {
5740    /// Sends a response to the FIDL transaction.
5741    ///
5742    /// Sets the channel to shutdown if an error occurs.
5743    pub fn send(
5744        self,
5745        mut result: Result<&RegistryWatchDeviceRemovedResponse, RegistryWatchDeviceRemovedError>,
5746    ) -> Result<(), fidl::Error> {
5747        let _result = self.send_raw(result);
5748        if _result.is_err() {
5749            self.control_handle.shutdown();
5750        }
5751        self.drop_without_shutdown();
5752        _result
5753    }
5754
5755    /// Similar to "send" but does not shutdown the channel if an error occurs.
5756    pub fn send_no_shutdown_on_err(
5757        self,
5758        mut result: Result<&RegistryWatchDeviceRemovedResponse, RegistryWatchDeviceRemovedError>,
5759    ) -> Result<(), fidl::Error> {
5760        let _result = self.send_raw(result);
5761        self.drop_without_shutdown();
5762        _result
5763    }
5764
5765    fn send_raw(
5766        &self,
5767        mut result: Result<&RegistryWatchDeviceRemovedResponse, RegistryWatchDeviceRemovedError>,
5768    ) -> Result<(), fidl::Error> {
5769        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5770            RegistryWatchDeviceRemovedResponse,
5771            RegistryWatchDeviceRemovedError,
5772        >>(
5773            fidl::encoding::FlexibleResult::new(result),
5774            self.tx_id,
5775            0x6e67aabc99a502af,
5776            fidl::encoding::DynamicFlags::FLEXIBLE,
5777        )
5778    }
5779}
5780
5781#[must_use = "FIDL methods require a response to be sent"]
5782#[derive(Debug)]
5783pub struct RegistryCreateObserverResponder {
5784    control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
5785    tx_id: u32,
5786}
5787
5788/// Set the the channel to be shutdown (see [`RegistryControlHandle::shutdown`])
5789/// if the responder is dropped without sending a response, so that the client
5790/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5791impl std::ops::Drop for RegistryCreateObserverResponder {
5792    fn drop(&mut self) {
5793        self.control_handle.shutdown();
5794        // Safety: drops once, never accessed again
5795        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5796    }
5797}
5798
5799impl fidl::endpoints::Responder for RegistryCreateObserverResponder {
5800    type ControlHandle = RegistryControlHandle;
5801
5802    fn control_handle(&self) -> &RegistryControlHandle {
5803        &self.control_handle
5804    }
5805
5806    fn drop_without_shutdown(mut self) {
5807        // Safety: drops once, never accessed again due to mem::forget
5808        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5809        // Prevent Drop from running (which would shut down the channel)
5810        std::mem::forget(self);
5811    }
5812}
5813
5814impl RegistryCreateObserverResponder {
5815    /// Sends a response to the FIDL transaction.
5816    ///
5817    /// Sets the channel to shutdown if an error occurs.
5818    pub fn send(
5819        self,
5820        mut result: Result<&RegistryCreateObserverResponse, RegistryCreateObserverError>,
5821    ) -> Result<(), fidl::Error> {
5822        let _result = self.send_raw(result);
5823        if _result.is_err() {
5824            self.control_handle.shutdown();
5825        }
5826        self.drop_without_shutdown();
5827        _result
5828    }
5829
5830    /// Similar to "send" but does not shutdown the channel if an error occurs.
5831    pub fn send_no_shutdown_on_err(
5832        self,
5833        mut result: Result<&RegistryCreateObserverResponse, RegistryCreateObserverError>,
5834    ) -> Result<(), fidl::Error> {
5835        let _result = self.send_raw(result);
5836        self.drop_without_shutdown();
5837        _result
5838    }
5839
5840    fn send_raw(
5841        &self,
5842        mut result: Result<&RegistryCreateObserverResponse, RegistryCreateObserverError>,
5843    ) -> Result<(), fidl::Error> {
5844        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5845            RegistryCreateObserverResponse,
5846            RegistryCreateObserverError,
5847        >>(
5848            fidl::encoding::FlexibleResult::new(result),
5849            self.tx_id,
5850            0x577bc322eb8d2bd1,
5851            fidl::encoding::DynamicFlags::FLEXIBLE,
5852        )
5853    }
5854}
5855
5856#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5857pub struct RingBufferMarker;
5858
5859impl fidl::endpoints::ProtocolMarker for RingBufferMarker {
5860    type Proxy = RingBufferProxy;
5861    type RequestStream = RingBufferRequestStream;
5862    #[cfg(target_os = "fuchsia")]
5863    type SynchronousProxy = RingBufferSynchronousProxy;
5864
5865    const DEBUG_NAME: &'static str = "(anonymous) RingBuffer";
5866}
5867pub type RingBufferSetActiveChannelsResult =
5868    Result<RingBufferSetActiveChannelsResponse, RingBufferSetActiveChannelsError>;
5869pub type RingBufferStartResult = Result<RingBufferStartResponse, RingBufferStartError>;
5870pub type RingBufferStopResult = Result<RingBufferStopResponse, RingBufferStopError>;
5871pub type RingBufferWatchDelayInfoResult =
5872    Result<RingBufferWatchDelayInfoResponse, RingBufferWatchDelayInfoError>;
5873
5874pub trait RingBufferProxyInterface: Send + Sync {
5875    type SetActiveChannelsResponseFut: std::future::Future<Output = Result<RingBufferSetActiveChannelsResult, fidl::Error>>
5876        + Send;
5877    fn r#set_active_channels(
5878        &self,
5879        payload: &RingBufferSetActiveChannelsRequest,
5880    ) -> Self::SetActiveChannelsResponseFut;
5881    type StartResponseFut: std::future::Future<Output = Result<RingBufferStartResult, fidl::Error>>
5882        + Send;
5883    fn r#start(&self, payload: &RingBufferStartRequest) -> Self::StartResponseFut;
5884    type StopResponseFut: std::future::Future<Output = Result<RingBufferStopResult, fidl::Error>>
5885        + Send;
5886    fn r#stop(&self, payload: &RingBufferStopRequest) -> Self::StopResponseFut;
5887    type WatchDelayInfoResponseFut: std::future::Future<Output = Result<RingBufferWatchDelayInfoResult, fidl::Error>>
5888        + Send;
5889    fn r#watch_delay_info(&self) -> Self::WatchDelayInfoResponseFut;
5890}
5891#[derive(Debug)]
5892#[cfg(target_os = "fuchsia")]
5893pub struct RingBufferSynchronousProxy {
5894    client: fidl::client::sync::Client,
5895}
5896
5897#[cfg(target_os = "fuchsia")]
5898impl fidl::endpoints::SynchronousProxy for RingBufferSynchronousProxy {
5899    type Proxy = RingBufferProxy;
5900    type Protocol = RingBufferMarker;
5901
5902    fn from_channel(inner: fidl::Channel) -> Self {
5903        Self::new(inner)
5904    }
5905
5906    fn into_channel(self) -> fidl::Channel {
5907        self.client.into_channel()
5908    }
5909
5910    fn as_channel(&self) -> &fidl::Channel {
5911        self.client.as_channel()
5912    }
5913}
5914
5915#[cfg(target_os = "fuchsia")]
5916impl RingBufferSynchronousProxy {
5917    pub fn new(channel: fidl::Channel) -> Self {
5918        let protocol_name = <RingBufferMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5919        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5920    }
5921
5922    pub fn into_channel(self) -> fidl::Channel {
5923        self.client.into_channel()
5924    }
5925
5926    /// Waits until an event arrives and returns it. It is safe for other
5927    /// threads to make concurrent requests while waiting for an event.
5928    pub fn wait_for_event(
5929        &self,
5930        deadline: zx::MonotonicInstant,
5931    ) -> Result<RingBufferEvent, fidl::Error> {
5932        RingBufferEvent::decode(self.client.wait_for_event(deadline)?)
5933    }
5934
5935    /// Request that specific individual channels be powered down/up, if the
5936    /// device supports this. This is intended for idle power conservation.
5937    ///
5938    /// Channels are specified by bitmask; the least significant bit corresponds
5939    /// to channel 0. Each bit not set indicates that the channel can be
5940    /// deactivated. `SetActiveChannels` does not change how a ring buffer
5941    /// responds to `Start`/`Stop`, specifically with regards to position.
5942    ///
5943    /// Devices are not required to obey `SetActiveChannels`. For example, they
5944    /// are not required to zero-out an input stream's inactive channels, and
5945    /// data written to inactive channels of an output stream's ring buffer may
5946    /// still be played.
5947    ///
5948    /// If not called, then by default all channels will be active.
5949    pub fn r#set_active_channels(
5950        &self,
5951        mut payload: &RingBufferSetActiveChannelsRequest,
5952        ___deadline: zx::MonotonicInstant,
5953    ) -> Result<RingBufferSetActiveChannelsResult, fidl::Error> {
5954        let _response = self
5955            .client
5956            .send_query::<RingBufferSetActiveChannelsRequest, fidl::encoding::FlexibleResultType<
5957                RingBufferSetActiveChannelsResponse,
5958                RingBufferSetActiveChannelsError,
5959            >>(
5960                payload, 0x4276c43e4a3b59ee, fidl::encoding::DynamicFlags::FLEXIBLE, ___deadline
5961            )?
5962            .into_result::<RingBufferMarker>("set_active_channels")?;
5963        Ok(_response.map(|x| x))
5964    }
5965
5966    /// Start the ring buffer, beginning at the first frame of the ring buffer.
5967    pub fn r#start(
5968        &self,
5969        mut payload: &RingBufferStartRequest,
5970        ___deadline: zx::MonotonicInstant,
5971    ) -> Result<RingBufferStartResult, fidl::Error> {
5972        let _response = self.client.send_query::<
5973            RingBufferStartRequest,
5974            fidl::encoding::FlexibleResultType<RingBufferStartResponse, RingBufferStartError>,
5975        >(
5976            payload,
5977            0x5365a8609dc2dc5,
5978            fidl::encoding::DynamicFlags::FLEXIBLE,
5979            ___deadline,
5980        )?
5981        .into_result::<RingBufferMarker>("start")?;
5982        Ok(_response.map(|x| x))
5983    }
5984
5985    /// Stop the ring buffer.
5986    pub fn r#stop(
5987        &self,
5988        mut payload: &RingBufferStopRequest,
5989        ___deadline: zx::MonotonicInstant,
5990    ) -> Result<RingBufferStopResult, fidl::Error> {
5991        let _response = self.client.send_query::<
5992            RingBufferStopRequest,
5993            fidl::encoding::FlexibleResultType<RingBufferStopResponse, RingBufferStopError>,
5994        >(
5995            payload,
5996            0x5a238810af11e6e1,
5997            fidl::encoding::DynamicFlags::FLEXIBLE,
5998            ___deadline,
5999        )?
6000        .into_result::<RingBufferMarker>("stop")?;
6001        Ok(_response.map(|x| x))
6002    }
6003
6004    /// Request delay information via a hanging get. The RingBuffer will respond
6005    /// immediately to the first `WatchDelayInfo` call. Subsequent calls will
6006    /// only be completed when the delay info has changed from previously
6007    /// communicated values.
6008    pub fn r#watch_delay_info(
6009        &self,
6010        ___deadline: zx::MonotonicInstant,
6011    ) -> Result<RingBufferWatchDelayInfoResult, fidl::Error> {
6012        let _response = self
6013            .client
6014            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
6015                RingBufferWatchDelayInfoResponse,
6016                RingBufferWatchDelayInfoError,
6017            >>(
6018                (), 0x6d1dc5a928f38ad6, fidl::encoding::DynamicFlags::FLEXIBLE, ___deadline
6019            )?
6020            .into_result::<RingBufferMarker>("watch_delay_info")?;
6021        Ok(_response.map(|x| x))
6022    }
6023}
6024
6025#[derive(Debug, Clone)]
6026pub struct RingBufferProxy {
6027    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6028}
6029
6030impl fidl::endpoints::Proxy for RingBufferProxy {
6031    type Protocol = RingBufferMarker;
6032
6033    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6034        Self::new(inner)
6035    }
6036
6037    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6038        self.client.into_channel().map_err(|client| Self { client })
6039    }
6040
6041    fn as_channel(&self) -> &::fidl::AsyncChannel {
6042        self.client.as_channel()
6043    }
6044}
6045
6046impl RingBufferProxy {
6047    /// Create a new Proxy for fuchsia.audio.device/RingBuffer.
6048    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6049        let protocol_name = <RingBufferMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6050        Self { client: fidl::client::Client::new(channel, protocol_name) }
6051    }
6052
6053    /// Get a Stream of events from the remote end of the protocol.
6054    ///
6055    /// # Panics
6056    ///
6057    /// Panics if the event stream was already taken.
6058    pub fn take_event_stream(&self) -> RingBufferEventStream {
6059        RingBufferEventStream { event_receiver: self.client.take_event_receiver() }
6060    }
6061
6062    /// Request that specific individual channels be powered down/up, if the
6063    /// device supports this. This is intended for idle power conservation.
6064    ///
6065    /// Channels are specified by bitmask; the least significant bit corresponds
6066    /// to channel 0. Each bit not set indicates that the channel can be
6067    /// deactivated. `SetActiveChannels` does not change how a ring buffer
6068    /// responds to `Start`/`Stop`, specifically with regards to position.
6069    ///
6070    /// Devices are not required to obey `SetActiveChannels`. For example, they
6071    /// are not required to zero-out an input stream's inactive channels, and
6072    /// data written to inactive channels of an output stream's ring buffer may
6073    /// still be played.
6074    ///
6075    /// If not called, then by default all channels will be active.
6076    pub fn r#set_active_channels(
6077        &self,
6078        mut payload: &RingBufferSetActiveChannelsRequest,
6079    ) -> fidl::client::QueryResponseFut<
6080        RingBufferSetActiveChannelsResult,
6081        fidl::encoding::DefaultFuchsiaResourceDialect,
6082    > {
6083        RingBufferProxyInterface::r#set_active_channels(self, payload)
6084    }
6085
6086    /// Start the ring buffer, beginning at the first frame of the ring buffer.
6087    pub fn r#start(
6088        &self,
6089        mut payload: &RingBufferStartRequest,
6090    ) -> fidl::client::QueryResponseFut<
6091        RingBufferStartResult,
6092        fidl::encoding::DefaultFuchsiaResourceDialect,
6093    > {
6094        RingBufferProxyInterface::r#start(self, payload)
6095    }
6096
6097    /// Stop the ring buffer.
6098    pub fn r#stop(
6099        &self,
6100        mut payload: &RingBufferStopRequest,
6101    ) -> fidl::client::QueryResponseFut<
6102        RingBufferStopResult,
6103        fidl::encoding::DefaultFuchsiaResourceDialect,
6104    > {
6105        RingBufferProxyInterface::r#stop(self, payload)
6106    }
6107
6108    /// Request delay information via a hanging get. The RingBuffer will respond
6109    /// immediately to the first `WatchDelayInfo` call. Subsequent calls will
6110    /// only be completed when the delay info has changed from previously
6111    /// communicated values.
6112    pub fn r#watch_delay_info(
6113        &self,
6114    ) -> fidl::client::QueryResponseFut<
6115        RingBufferWatchDelayInfoResult,
6116        fidl::encoding::DefaultFuchsiaResourceDialect,
6117    > {
6118        RingBufferProxyInterface::r#watch_delay_info(self)
6119    }
6120}
6121
6122impl RingBufferProxyInterface for RingBufferProxy {
6123    type SetActiveChannelsResponseFut = fidl::client::QueryResponseFut<
6124        RingBufferSetActiveChannelsResult,
6125        fidl::encoding::DefaultFuchsiaResourceDialect,
6126    >;
6127    fn r#set_active_channels(
6128        &self,
6129        mut payload: &RingBufferSetActiveChannelsRequest,
6130    ) -> Self::SetActiveChannelsResponseFut {
6131        fn _decode(
6132            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6133        ) -> Result<RingBufferSetActiveChannelsResult, fidl::Error> {
6134            let _response = fidl::client::decode_transaction_body::<
6135                fidl::encoding::FlexibleResultType<
6136                    RingBufferSetActiveChannelsResponse,
6137                    RingBufferSetActiveChannelsError,
6138                >,
6139                fidl::encoding::DefaultFuchsiaResourceDialect,
6140                0x4276c43e4a3b59ee,
6141            >(_buf?)?
6142            .into_result::<RingBufferMarker>("set_active_channels")?;
6143            Ok(_response.map(|x| x))
6144        }
6145        self.client.send_query_and_decode::<
6146            RingBufferSetActiveChannelsRequest,
6147            RingBufferSetActiveChannelsResult,
6148        >(
6149            payload,
6150            0x4276c43e4a3b59ee,
6151            fidl::encoding::DynamicFlags::FLEXIBLE,
6152            _decode,
6153        )
6154    }
6155
6156    type StartResponseFut = fidl::client::QueryResponseFut<
6157        RingBufferStartResult,
6158        fidl::encoding::DefaultFuchsiaResourceDialect,
6159    >;
6160    fn r#start(&self, mut payload: &RingBufferStartRequest) -> Self::StartResponseFut {
6161        fn _decode(
6162            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6163        ) -> Result<RingBufferStartResult, fidl::Error> {
6164            let _response = fidl::client::decode_transaction_body::<
6165                fidl::encoding::FlexibleResultType<RingBufferStartResponse, RingBufferStartError>,
6166                fidl::encoding::DefaultFuchsiaResourceDialect,
6167                0x5365a8609dc2dc5,
6168            >(_buf?)?
6169            .into_result::<RingBufferMarker>("start")?;
6170            Ok(_response.map(|x| x))
6171        }
6172        self.client.send_query_and_decode::<RingBufferStartRequest, RingBufferStartResult>(
6173            payload,
6174            0x5365a8609dc2dc5,
6175            fidl::encoding::DynamicFlags::FLEXIBLE,
6176            _decode,
6177        )
6178    }
6179
6180    type StopResponseFut = fidl::client::QueryResponseFut<
6181        RingBufferStopResult,
6182        fidl::encoding::DefaultFuchsiaResourceDialect,
6183    >;
6184    fn r#stop(&self, mut payload: &RingBufferStopRequest) -> Self::StopResponseFut {
6185        fn _decode(
6186            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6187        ) -> Result<RingBufferStopResult, fidl::Error> {
6188            let _response = fidl::client::decode_transaction_body::<
6189                fidl::encoding::FlexibleResultType<RingBufferStopResponse, RingBufferStopError>,
6190                fidl::encoding::DefaultFuchsiaResourceDialect,
6191                0x5a238810af11e6e1,
6192            >(_buf?)?
6193            .into_result::<RingBufferMarker>("stop")?;
6194            Ok(_response.map(|x| x))
6195        }
6196        self.client.send_query_and_decode::<RingBufferStopRequest, RingBufferStopResult>(
6197            payload,
6198            0x5a238810af11e6e1,
6199            fidl::encoding::DynamicFlags::FLEXIBLE,
6200            _decode,
6201        )
6202    }
6203
6204    type WatchDelayInfoResponseFut = fidl::client::QueryResponseFut<
6205        RingBufferWatchDelayInfoResult,
6206        fidl::encoding::DefaultFuchsiaResourceDialect,
6207    >;
6208    fn r#watch_delay_info(&self) -> Self::WatchDelayInfoResponseFut {
6209        fn _decode(
6210            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6211        ) -> Result<RingBufferWatchDelayInfoResult, fidl::Error> {
6212            let _response = fidl::client::decode_transaction_body::<
6213                fidl::encoding::FlexibleResultType<
6214                    RingBufferWatchDelayInfoResponse,
6215                    RingBufferWatchDelayInfoError,
6216                >,
6217                fidl::encoding::DefaultFuchsiaResourceDialect,
6218                0x6d1dc5a928f38ad6,
6219            >(_buf?)?
6220            .into_result::<RingBufferMarker>("watch_delay_info")?;
6221            Ok(_response.map(|x| x))
6222        }
6223        self.client
6224            .send_query_and_decode::<fidl::encoding::EmptyPayload, RingBufferWatchDelayInfoResult>(
6225                (),
6226                0x6d1dc5a928f38ad6,
6227                fidl::encoding::DynamicFlags::FLEXIBLE,
6228                _decode,
6229            )
6230    }
6231}
6232
6233pub struct RingBufferEventStream {
6234    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6235}
6236
6237impl std::marker::Unpin for RingBufferEventStream {}
6238
6239impl futures::stream::FusedStream for RingBufferEventStream {
6240    fn is_terminated(&self) -> bool {
6241        self.event_receiver.is_terminated()
6242    }
6243}
6244
6245impl futures::Stream for RingBufferEventStream {
6246    type Item = Result<RingBufferEvent, fidl::Error>;
6247
6248    fn poll_next(
6249        mut self: std::pin::Pin<&mut Self>,
6250        cx: &mut std::task::Context<'_>,
6251    ) -> std::task::Poll<Option<Self::Item>> {
6252        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6253            &mut self.event_receiver,
6254            cx
6255        )?) {
6256            Some(buf) => std::task::Poll::Ready(Some(RingBufferEvent::decode(buf))),
6257            None => std::task::Poll::Ready(None),
6258        }
6259    }
6260}
6261
6262#[derive(Debug)]
6263pub enum RingBufferEvent {
6264    #[non_exhaustive]
6265    _UnknownEvent {
6266        /// Ordinal of the event that was sent.
6267        ordinal: u64,
6268    },
6269}
6270
6271impl RingBufferEvent {
6272    /// Decodes a message buffer as a [`RingBufferEvent`].
6273    fn decode(
6274        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6275    ) -> Result<RingBufferEvent, fidl::Error> {
6276        let (bytes, _handles) = buf.split_mut();
6277        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6278        debug_assert_eq!(tx_header.tx_id, 0);
6279        match tx_header.ordinal {
6280            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
6281                Ok(RingBufferEvent::_UnknownEvent { ordinal: tx_header.ordinal })
6282            }
6283            _ => Err(fidl::Error::UnknownOrdinal {
6284                ordinal: tx_header.ordinal,
6285                protocol_name: <RingBufferMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6286            }),
6287        }
6288    }
6289}
6290
6291/// A Stream of incoming requests for fuchsia.audio.device/RingBuffer.
6292pub struct RingBufferRequestStream {
6293    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6294    is_terminated: bool,
6295}
6296
6297impl std::marker::Unpin for RingBufferRequestStream {}
6298
6299impl futures::stream::FusedStream for RingBufferRequestStream {
6300    fn is_terminated(&self) -> bool {
6301        self.is_terminated
6302    }
6303}
6304
6305impl fidl::endpoints::RequestStream for RingBufferRequestStream {
6306    type Protocol = RingBufferMarker;
6307    type ControlHandle = RingBufferControlHandle;
6308
6309    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6310        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6311    }
6312
6313    fn control_handle(&self) -> Self::ControlHandle {
6314        RingBufferControlHandle { inner: self.inner.clone() }
6315    }
6316
6317    fn into_inner(
6318        self,
6319    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6320    {
6321        (self.inner, self.is_terminated)
6322    }
6323
6324    fn from_inner(
6325        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6326        is_terminated: bool,
6327    ) -> Self {
6328        Self { inner, is_terminated }
6329    }
6330}
6331
6332impl futures::Stream for RingBufferRequestStream {
6333    type Item = Result<RingBufferRequest, fidl::Error>;
6334
6335    fn poll_next(
6336        mut self: std::pin::Pin<&mut Self>,
6337        cx: &mut std::task::Context<'_>,
6338    ) -> std::task::Poll<Option<Self::Item>> {
6339        let this = &mut *self;
6340        if this.inner.check_shutdown(cx) {
6341            this.is_terminated = true;
6342            return std::task::Poll::Ready(None);
6343        }
6344        if this.is_terminated {
6345            panic!("polled RingBufferRequestStream after completion");
6346        }
6347        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6348            |bytes, handles| {
6349                match this.inner.channel().read_etc(cx, bytes, handles) {
6350                    std::task::Poll::Ready(Ok(())) => {}
6351                    std::task::Poll::Pending => return std::task::Poll::Pending,
6352                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6353                        this.is_terminated = true;
6354                        return std::task::Poll::Ready(None);
6355                    }
6356                    std::task::Poll::Ready(Err(e)) => {
6357                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6358                            e.into(),
6359                        ))))
6360                    }
6361                }
6362
6363                // A message has been received from the channel
6364                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6365
6366                std::task::Poll::Ready(Some(match header.ordinal {
6367                    0x4276c43e4a3b59ee => {
6368                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6369                        let mut req = fidl::new_empty!(
6370                            RingBufferSetActiveChannelsRequest,
6371                            fidl::encoding::DefaultFuchsiaResourceDialect
6372                        );
6373                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RingBufferSetActiveChannelsRequest>(&header, _body_bytes, handles, &mut req)?;
6374                        let control_handle = RingBufferControlHandle { inner: this.inner.clone() };
6375                        Ok(RingBufferRequest::SetActiveChannels {
6376                            payload: req,
6377                            responder: RingBufferSetActiveChannelsResponder {
6378                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6379                                tx_id: header.tx_id,
6380                            },
6381                        })
6382                    }
6383                    0x5365a8609dc2dc5 => {
6384                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6385                        let mut req = fidl::new_empty!(
6386                            RingBufferStartRequest,
6387                            fidl::encoding::DefaultFuchsiaResourceDialect
6388                        );
6389                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RingBufferStartRequest>(&header, _body_bytes, handles, &mut req)?;
6390                        let control_handle = RingBufferControlHandle { inner: this.inner.clone() };
6391                        Ok(RingBufferRequest::Start {
6392                            payload: req,
6393                            responder: RingBufferStartResponder {
6394                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6395                                tx_id: header.tx_id,
6396                            },
6397                        })
6398                    }
6399                    0x5a238810af11e6e1 => {
6400                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6401                        let mut req = fidl::new_empty!(
6402                            RingBufferStopRequest,
6403                            fidl::encoding::DefaultFuchsiaResourceDialect
6404                        );
6405                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RingBufferStopRequest>(&header, _body_bytes, handles, &mut req)?;
6406                        let control_handle = RingBufferControlHandle { inner: this.inner.clone() };
6407                        Ok(RingBufferRequest::Stop {
6408                            payload: req,
6409                            responder: RingBufferStopResponder {
6410                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6411                                tx_id: header.tx_id,
6412                            },
6413                        })
6414                    }
6415                    0x6d1dc5a928f38ad6 => {
6416                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6417                        let mut req = fidl::new_empty!(
6418                            fidl::encoding::EmptyPayload,
6419                            fidl::encoding::DefaultFuchsiaResourceDialect
6420                        );
6421                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6422                        let control_handle = RingBufferControlHandle { inner: this.inner.clone() };
6423                        Ok(RingBufferRequest::WatchDelayInfo {
6424                            responder: RingBufferWatchDelayInfoResponder {
6425                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6426                                tx_id: header.tx_id,
6427                            },
6428                        })
6429                    }
6430                    _ if header.tx_id == 0
6431                        && header
6432                            .dynamic_flags()
6433                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6434                    {
6435                        Ok(RingBufferRequest::_UnknownMethod {
6436                            ordinal: header.ordinal,
6437                            control_handle: RingBufferControlHandle { inner: this.inner.clone() },
6438                            method_type: fidl::MethodType::OneWay,
6439                        })
6440                    }
6441                    _ if header
6442                        .dynamic_flags()
6443                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6444                    {
6445                        this.inner.send_framework_err(
6446                            fidl::encoding::FrameworkErr::UnknownMethod,
6447                            header.tx_id,
6448                            header.ordinal,
6449                            header.dynamic_flags(),
6450                            (bytes, handles),
6451                        )?;
6452                        Ok(RingBufferRequest::_UnknownMethod {
6453                            ordinal: header.ordinal,
6454                            control_handle: RingBufferControlHandle { inner: this.inner.clone() },
6455                            method_type: fidl::MethodType::TwoWay,
6456                        })
6457                    }
6458                    _ => Err(fidl::Error::UnknownOrdinal {
6459                        ordinal: header.ordinal,
6460                        protocol_name:
6461                            <RingBufferMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6462                    }),
6463                }))
6464            },
6465        )
6466    }
6467}
6468
6469/// A `RingBuffer` instance controls data flow for the associated audio stream.
6470#[derive(Debug)]
6471pub enum RingBufferRequest {
6472    /// Request that specific individual channels be powered down/up, if the
6473    /// device supports this. This is intended for idle power conservation.
6474    ///
6475    /// Channels are specified by bitmask; the least significant bit corresponds
6476    /// to channel 0. Each bit not set indicates that the channel can be
6477    /// deactivated. `SetActiveChannels` does not change how a ring buffer
6478    /// responds to `Start`/`Stop`, specifically with regards to position.
6479    ///
6480    /// Devices are not required to obey `SetActiveChannels`. For example, they
6481    /// are not required to zero-out an input stream's inactive channels, and
6482    /// data written to inactive channels of an output stream's ring buffer may
6483    /// still be played.
6484    ///
6485    /// If not called, then by default all channels will be active.
6486    SetActiveChannels {
6487        payload: RingBufferSetActiveChannelsRequest,
6488        responder: RingBufferSetActiveChannelsResponder,
6489    },
6490    /// Start the ring buffer, beginning at the first frame of the ring buffer.
6491    Start { payload: RingBufferStartRequest, responder: RingBufferStartResponder },
6492    /// Stop the ring buffer.
6493    Stop { payload: RingBufferStopRequest, responder: RingBufferStopResponder },
6494    /// Request delay information via a hanging get. The RingBuffer will respond
6495    /// immediately to the first `WatchDelayInfo` call. Subsequent calls will
6496    /// only be completed when the delay info has changed from previously
6497    /// communicated values.
6498    WatchDelayInfo { responder: RingBufferWatchDelayInfoResponder },
6499    /// An interaction was received which does not match any known method.
6500    #[non_exhaustive]
6501    _UnknownMethod {
6502        /// Ordinal of the method that was called.
6503        ordinal: u64,
6504        control_handle: RingBufferControlHandle,
6505        method_type: fidl::MethodType,
6506    },
6507}
6508
6509impl RingBufferRequest {
6510    #[allow(irrefutable_let_patterns)]
6511    pub fn into_set_active_channels(
6512        self,
6513    ) -> Option<(RingBufferSetActiveChannelsRequest, RingBufferSetActiveChannelsResponder)> {
6514        if let RingBufferRequest::SetActiveChannels { payload, responder } = self {
6515            Some((payload, responder))
6516        } else {
6517            None
6518        }
6519    }
6520
6521    #[allow(irrefutable_let_patterns)]
6522    pub fn into_start(self) -> Option<(RingBufferStartRequest, RingBufferStartResponder)> {
6523        if let RingBufferRequest::Start { payload, responder } = self {
6524            Some((payload, responder))
6525        } else {
6526            None
6527        }
6528    }
6529
6530    #[allow(irrefutable_let_patterns)]
6531    pub fn into_stop(self) -> Option<(RingBufferStopRequest, RingBufferStopResponder)> {
6532        if let RingBufferRequest::Stop { payload, responder } = self {
6533            Some((payload, responder))
6534        } else {
6535            None
6536        }
6537    }
6538
6539    #[allow(irrefutable_let_patterns)]
6540    pub fn into_watch_delay_info(self) -> Option<(RingBufferWatchDelayInfoResponder)> {
6541        if let RingBufferRequest::WatchDelayInfo { responder } = self {
6542            Some((responder))
6543        } else {
6544            None
6545        }
6546    }
6547
6548    /// Name of the method defined in FIDL
6549    pub fn method_name(&self) -> &'static str {
6550        match *self {
6551            RingBufferRequest::SetActiveChannels { .. } => "set_active_channels",
6552            RingBufferRequest::Start { .. } => "start",
6553            RingBufferRequest::Stop { .. } => "stop",
6554            RingBufferRequest::WatchDelayInfo { .. } => "watch_delay_info",
6555            RingBufferRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
6556                "unknown one-way method"
6557            }
6558            RingBufferRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
6559                "unknown two-way method"
6560            }
6561        }
6562    }
6563}
6564
6565#[derive(Debug, Clone)]
6566pub struct RingBufferControlHandle {
6567    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6568}
6569
6570impl fidl::endpoints::ControlHandle for RingBufferControlHandle {
6571    fn shutdown(&self) {
6572        self.inner.shutdown()
6573    }
6574    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6575        self.inner.shutdown_with_epitaph(status)
6576    }
6577
6578    fn is_closed(&self) -> bool {
6579        self.inner.channel().is_closed()
6580    }
6581    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6582        self.inner.channel().on_closed()
6583    }
6584
6585    #[cfg(target_os = "fuchsia")]
6586    fn signal_peer(
6587        &self,
6588        clear_mask: zx::Signals,
6589        set_mask: zx::Signals,
6590    ) -> Result<(), zx_status::Status> {
6591        use fidl::Peered;
6592        self.inner.channel().signal_peer(clear_mask, set_mask)
6593    }
6594}
6595
6596impl RingBufferControlHandle {}
6597
6598#[must_use = "FIDL methods require a response to be sent"]
6599#[derive(Debug)]
6600pub struct RingBufferSetActiveChannelsResponder {
6601    control_handle: std::mem::ManuallyDrop<RingBufferControlHandle>,
6602    tx_id: u32,
6603}
6604
6605/// Set the the channel to be shutdown (see [`RingBufferControlHandle::shutdown`])
6606/// if the responder is dropped without sending a response, so that the client
6607/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6608impl std::ops::Drop for RingBufferSetActiveChannelsResponder {
6609    fn drop(&mut self) {
6610        self.control_handle.shutdown();
6611        // Safety: drops once, never accessed again
6612        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6613    }
6614}
6615
6616impl fidl::endpoints::Responder for RingBufferSetActiveChannelsResponder {
6617    type ControlHandle = RingBufferControlHandle;
6618
6619    fn control_handle(&self) -> &RingBufferControlHandle {
6620        &self.control_handle
6621    }
6622
6623    fn drop_without_shutdown(mut self) {
6624        // Safety: drops once, never accessed again due to mem::forget
6625        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6626        // Prevent Drop from running (which would shut down the channel)
6627        std::mem::forget(self);
6628    }
6629}
6630
6631impl RingBufferSetActiveChannelsResponder {
6632    /// Sends a response to the FIDL transaction.
6633    ///
6634    /// Sets the channel to shutdown if an error occurs.
6635    pub fn send(
6636        self,
6637        mut result: Result<&RingBufferSetActiveChannelsResponse, RingBufferSetActiveChannelsError>,
6638    ) -> Result<(), fidl::Error> {
6639        let _result = self.send_raw(result);
6640        if _result.is_err() {
6641            self.control_handle.shutdown();
6642        }
6643        self.drop_without_shutdown();
6644        _result
6645    }
6646
6647    /// Similar to "send" but does not shutdown the channel if an error occurs.
6648    pub fn send_no_shutdown_on_err(
6649        self,
6650        mut result: Result<&RingBufferSetActiveChannelsResponse, RingBufferSetActiveChannelsError>,
6651    ) -> Result<(), fidl::Error> {
6652        let _result = self.send_raw(result);
6653        self.drop_without_shutdown();
6654        _result
6655    }
6656
6657    fn send_raw(
6658        &self,
6659        mut result: Result<&RingBufferSetActiveChannelsResponse, RingBufferSetActiveChannelsError>,
6660    ) -> Result<(), fidl::Error> {
6661        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6662            RingBufferSetActiveChannelsResponse,
6663            RingBufferSetActiveChannelsError,
6664        >>(
6665            fidl::encoding::FlexibleResult::new(result),
6666            self.tx_id,
6667            0x4276c43e4a3b59ee,
6668            fidl::encoding::DynamicFlags::FLEXIBLE,
6669        )
6670    }
6671}
6672
6673#[must_use = "FIDL methods require a response to be sent"]
6674#[derive(Debug)]
6675pub struct RingBufferStartResponder {
6676    control_handle: std::mem::ManuallyDrop<RingBufferControlHandle>,
6677    tx_id: u32,
6678}
6679
6680/// Set the the channel to be shutdown (see [`RingBufferControlHandle::shutdown`])
6681/// if the responder is dropped without sending a response, so that the client
6682/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6683impl std::ops::Drop for RingBufferStartResponder {
6684    fn drop(&mut self) {
6685        self.control_handle.shutdown();
6686        // Safety: drops once, never accessed again
6687        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6688    }
6689}
6690
6691impl fidl::endpoints::Responder for RingBufferStartResponder {
6692    type ControlHandle = RingBufferControlHandle;
6693
6694    fn control_handle(&self) -> &RingBufferControlHandle {
6695        &self.control_handle
6696    }
6697
6698    fn drop_without_shutdown(mut self) {
6699        // Safety: drops once, never accessed again due to mem::forget
6700        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6701        // Prevent Drop from running (which would shut down the channel)
6702        std::mem::forget(self);
6703    }
6704}
6705
6706impl RingBufferStartResponder {
6707    /// Sends a response to the FIDL transaction.
6708    ///
6709    /// Sets the channel to shutdown if an error occurs.
6710    pub fn send(
6711        self,
6712        mut result: Result<&RingBufferStartResponse, RingBufferStartError>,
6713    ) -> Result<(), fidl::Error> {
6714        let _result = self.send_raw(result);
6715        if _result.is_err() {
6716            self.control_handle.shutdown();
6717        }
6718        self.drop_without_shutdown();
6719        _result
6720    }
6721
6722    /// Similar to "send" but does not shutdown the channel if an error occurs.
6723    pub fn send_no_shutdown_on_err(
6724        self,
6725        mut result: Result<&RingBufferStartResponse, RingBufferStartError>,
6726    ) -> Result<(), fidl::Error> {
6727        let _result = self.send_raw(result);
6728        self.drop_without_shutdown();
6729        _result
6730    }
6731
6732    fn send_raw(
6733        &self,
6734        mut result: Result<&RingBufferStartResponse, RingBufferStartError>,
6735    ) -> Result<(), fidl::Error> {
6736        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6737            RingBufferStartResponse,
6738            RingBufferStartError,
6739        >>(
6740            fidl::encoding::FlexibleResult::new(result),
6741            self.tx_id,
6742            0x5365a8609dc2dc5,
6743            fidl::encoding::DynamicFlags::FLEXIBLE,
6744        )
6745    }
6746}
6747
6748#[must_use = "FIDL methods require a response to be sent"]
6749#[derive(Debug)]
6750pub struct RingBufferStopResponder {
6751    control_handle: std::mem::ManuallyDrop<RingBufferControlHandle>,
6752    tx_id: u32,
6753}
6754
6755/// Set the the channel to be shutdown (see [`RingBufferControlHandle::shutdown`])
6756/// if the responder is dropped without sending a response, so that the client
6757/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6758impl std::ops::Drop for RingBufferStopResponder {
6759    fn drop(&mut self) {
6760        self.control_handle.shutdown();
6761        // Safety: drops once, never accessed again
6762        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6763    }
6764}
6765
6766impl fidl::endpoints::Responder for RingBufferStopResponder {
6767    type ControlHandle = RingBufferControlHandle;
6768
6769    fn control_handle(&self) -> &RingBufferControlHandle {
6770        &self.control_handle
6771    }
6772
6773    fn drop_without_shutdown(mut self) {
6774        // Safety: drops once, never accessed again due to mem::forget
6775        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6776        // Prevent Drop from running (which would shut down the channel)
6777        std::mem::forget(self);
6778    }
6779}
6780
6781impl RingBufferStopResponder {
6782    /// Sends a response to the FIDL transaction.
6783    ///
6784    /// Sets the channel to shutdown if an error occurs.
6785    pub fn send(
6786        self,
6787        mut result: Result<&RingBufferStopResponse, RingBufferStopError>,
6788    ) -> Result<(), fidl::Error> {
6789        let _result = self.send_raw(result);
6790        if _result.is_err() {
6791            self.control_handle.shutdown();
6792        }
6793        self.drop_without_shutdown();
6794        _result
6795    }
6796
6797    /// Similar to "send" but does not shutdown the channel if an error occurs.
6798    pub fn send_no_shutdown_on_err(
6799        self,
6800        mut result: Result<&RingBufferStopResponse, RingBufferStopError>,
6801    ) -> Result<(), fidl::Error> {
6802        let _result = self.send_raw(result);
6803        self.drop_without_shutdown();
6804        _result
6805    }
6806
6807    fn send_raw(
6808        &self,
6809        mut result: Result<&RingBufferStopResponse, RingBufferStopError>,
6810    ) -> Result<(), fidl::Error> {
6811        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6812            RingBufferStopResponse,
6813            RingBufferStopError,
6814        >>(
6815            fidl::encoding::FlexibleResult::new(result),
6816            self.tx_id,
6817            0x5a238810af11e6e1,
6818            fidl::encoding::DynamicFlags::FLEXIBLE,
6819        )
6820    }
6821}
6822
6823#[must_use = "FIDL methods require a response to be sent"]
6824#[derive(Debug)]
6825pub struct RingBufferWatchDelayInfoResponder {
6826    control_handle: std::mem::ManuallyDrop<RingBufferControlHandle>,
6827    tx_id: u32,
6828}
6829
6830/// Set the the channel to be shutdown (see [`RingBufferControlHandle::shutdown`])
6831/// if the responder is dropped without sending a response, so that the client
6832/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6833impl std::ops::Drop for RingBufferWatchDelayInfoResponder {
6834    fn drop(&mut self) {
6835        self.control_handle.shutdown();
6836        // Safety: drops once, never accessed again
6837        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6838    }
6839}
6840
6841impl fidl::endpoints::Responder for RingBufferWatchDelayInfoResponder {
6842    type ControlHandle = RingBufferControlHandle;
6843
6844    fn control_handle(&self) -> &RingBufferControlHandle {
6845        &self.control_handle
6846    }
6847
6848    fn drop_without_shutdown(mut self) {
6849        // Safety: drops once, never accessed again due to mem::forget
6850        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6851        // Prevent Drop from running (which would shut down the channel)
6852        std::mem::forget(self);
6853    }
6854}
6855
6856impl RingBufferWatchDelayInfoResponder {
6857    /// Sends a response to the FIDL transaction.
6858    ///
6859    /// Sets the channel to shutdown if an error occurs.
6860    pub fn send(
6861        self,
6862        mut result: Result<&RingBufferWatchDelayInfoResponse, RingBufferWatchDelayInfoError>,
6863    ) -> Result<(), fidl::Error> {
6864        let _result = self.send_raw(result);
6865        if _result.is_err() {
6866            self.control_handle.shutdown();
6867        }
6868        self.drop_without_shutdown();
6869        _result
6870    }
6871
6872    /// Similar to "send" but does not shutdown the channel if an error occurs.
6873    pub fn send_no_shutdown_on_err(
6874        self,
6875        mut result: Result<&RingBufferWatchDelayInfoResponse, RingBufferWatchDelayInfoError>,
6876    ) -> Result<(), fidl::Error> {
6877        let _result = self.send_raw(result);
6878        self.drop_without_shutdown();
6879        _result
6880    }
6881
6882    fn send_raw(
6883        &self,
6884        mut result: Result<&RingBufferWatchDelayInfoResponse, RingBufferWatchDelayInfoError>,
6885    ) -> Result<(), fidl::Error> {
6886        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6887            RingBufferWatchDelayInfoResponse,
6888            RingBufferWatchDelayInfoError,
6889        >>(
6890            fidl::encoding::FlexibleResult::new(result),
6891            self.tx_id,
6892            0x6d1dc5a928f38ad6,
6893            fidl::encoding::DynamicFlags::FLEXIBLE,
6894        )
6895    }
6896}
6897
6898mod internal {
6899    use super::*;
6900
6901    impl ControlCreateRingBufferRequest {
6902        #[inline(always)]
6903        fn max_ordinal_present(&self) -> u64 {
6904            if let Some(_) = self.ring_buffer_server {
6905                return 3;
6906            }
6907            if let Some(_) = self.options {
6908                return 2;
6909            }
6910            if let Some(_) = self.element_id {
6911                return 1;
6912            }
6913            0
6914        }
6915    }
6916
6917    impl fidl::encoding::ResourceTypeMarker for ControlCreateRingBufferRequest {
6918        type Borrowed<'a> = &'a mut Self;
6919        fn take_or_borrow<'a>(
6920            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6921        ) -> Self::Borrowed<'a> {
6922            value
6923        }
6924    }
6925
6926    unsafe impl fidl::encoding::TypeMarker for ControlCreateRingBufferRequest {
6927        type Owned = Self;
6928
6929        #[inline(always)]
6930        fn inline_align(_context: fidl::encoding::Context) -> usize {
6931            8
6932        }
6933
6934        #[inline(always)]
6935        fn inline_size(_context: fidl::encoding::Context) -> usize {
6936            16
6937        }
6938    }
6939
6940    unsafe impl
6941        fidl::encoding::Encode<
6942            ControlCreateRingBufferRequest,
6943            fidl::encoding::DefaultFuchsiaResourceDialect,
6944        > for &mut ControlCreateRingBufferRequest
6945    {
6946        unsafe fn encode(
6947            self,
6948            encoder: &mut fidl::encoding::Encoder<
6949                '_,
6950                fidl::encoding::DefaultFuchsiaResourceDialect,
6951            >,
6952            offset: usize,
6953            mut depth: fidl::encoding::Depth,
6954        ) -> fidl::Result<()> {
6955            encoder.debug_check_bounds::<ControlCreateRingBufferRequest>(offset);
6956            // Vector header
6957            let max_ordinal: u64 = self.max_ordinal_present();
6958            encoder.write_num(max_ordinal, offset);
6959            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6960            // Calling encoder.out_of_line_offset(0) is not allowed.
6961            if max_ordinal == 0 {
6962                return Ok(());
6963            }
6964            depth.increment()?;
6965            let envelope_size = 8;
6966            let bytes_len = max_ordinal as usize * envelope_size;
6967            #[allow(unused_variables)]
6968            let offset = encoder.out_of_line_offset(bytes_len);
6969            let mut _prev_end_offset: usize = 0;
6970            if 1 > max_ordinal {
6971                return Ok(());
6972            }
6973
6974            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6975            // are envelope_size bytes.
6976            let cur_offset: usize = (1 - 1) * envelope_size;
6977
6978            // Zero reserved fields.
6979            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6980
6981            // Safety:
6982            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6983            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6984            //   envelope_size bytes, there is always sufficient room.
6985            fidl::encoding::encode_in_envelope_optional::<
6986                u64,
6987                fidl::encoding::DefaultFuchsiaResourceDialect,
6988            >(
6989                self.element_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
6990                encoder,
6991                offset + cur_offset,
6992                depth,
6993            )?;
6994
6995            _prev_end_offset = cur_offset + envelope_size;
6996            if 2 > max_ordinal {
6997                return Ok(());
6998            }
6999
7000            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7001            // are envelope_size bytes.
7002            let cur_offset: usize = (2 - 1) * envelope_size;
7003
7004            // Zero reserved fields.
7005            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7006
7007            // Safety:
7008            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7009            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7010            //   envelope_size bytes, there is always sufficient room.
7011            fidl::encoding::encode_in_envelope_optional::<
7012                RingBufferOptions,
7013                fidl::encoding::DefaultFuchsiaResourceDialect,
7014            >(
7015                self.options
7016                    .as_ref()
7017                    .map(<RingBufferOptions as fidl::encoding::ValueTypeMarker>::borrow),
7018                encoder,
7019                offset + cur_offset,
7020                depth,
7021            )?;
7022
7023            _prev_end_offset = cur_offset + envelope_size;
7024            if 3 > max_ordinal {
7025                return Ok(());
7026            }
7027
7028            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7029            // are envelope_size bytes.
7030            let cur_offset: usize = (3 - 1) * envelope_size;
7031
7032            // Zero reserved fields.
7033            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7034
7035            // Safety:
7036            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7037            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7038            //   envelope_size bytes, there is always sufficient room.
7039            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RingBufferMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
7040            self.ring_buffer_server.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RingBufferMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
7041            encoder, offset + cur_offset, depth
7042        )?;
7043
7044            _prev_end_offset = cur_offset + envelope_size;
7045
7046            Ok(())
7047        }
7048    }
7049
7050    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7051        for ControlCreateRingBufferRequest
7052    {
7053        #[inline(always)]
7054        fn new_empty() -> Self {
7055            Self::default()
7056        }
7057
7058        unsafe fn decode(
7059            &mut self,
7060            decoder: &mut fidl::encoding::Decoder<
7061                '_,
7062                fidl::encoding::DefaultFuchsiaResourceDialect,
7063            >,
7064            offset: usize,
7065            mut depth: fidl::encoding::Depth,
7066        ) -> fidl::Result<()> {
7067            decoder.debug_check_bounds::<Self>(offset);
7068            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7069                None => return Err(fidl::Error::NotNullable),
7070                Some(len) => len,
7071            };
7072            // Calling decoder.out_of_line_offset(0) is not allowed.
7073            if len == 0 {
7074                return Ok(());
7075            };
7076            depth.increment()?;
7077            let envelope_size = 8;
7078            let bytes_len = len * envelope_size;
7079            let offset = decoder.out_of_line_offset(bytes_len)?;
7080            // Decode the envelope for each type.
7081            let mut _next_ordinal_to_read = 0;
7082            let mut next_offset = offset;
7083            let end_offset = offset + bytes_len;
7084            _next_ordinal_to_read += 1;
7085            if next_offset >= end_offset {
7086                return Ok(());
7087            }
7088
7089            // Decode unknown envelopes for gaps in ordinals.
7090            while _next_ordinal_to_read < 1 {
7091                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7092                _next_ordinal_to_read += 1;
7093                next_offset += envelope_size;
7094            }
7095
7096            let next_out_of_line = decoder.next_out_of_line();
7097            let handles_before = decoder.remaining_handles();
7098            if let Some((inlined, num_bytes, num_handles)) =
7099                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7100            {
7101                let member_inline_size =
7102                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7103                if inlined != (member_inline_size <= 4) {
7104                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7105                }
7106                let inner_offset;
7107                let mut inner_depth = depth.clone();
7108                if inlined {
7109                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7110                    inner_offset = next_offset;
7111                } else {
7112                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7113                    inner_depth.increment()?;
7114                }
7115                let val_ref = self.element_id.get_or_insert_with(|| {
7116                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
7117                });
7118                fidl::decode!(
7119                    u64,
7120                    fidl::encoding::DefaultFuchsiaResourceDialect,
7121                    val_ref,
7122                    decoder,
7123                    inner_offset,
7124                    inner_depth
7125                )?;
7126                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7127                {
7128                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7129                }
7130                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7131                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7132                }
7133            }
7134
7135            next_offset += envelope_size;
7136            _next_ordinal_to_read += 1;
7137            if next_offset >= end_offset {
7138                return Ok(());
7139            }
7140
7141            // Decode unknown envelopes for gaps in ordinals.
7142            while _next_ordinal_to_read < 2 {
7143                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7144                _next_ordinal_to_read += 1;
7145                next_offset += envelope_size;
7146            }
7147
7148            let next_out_of_line = decoder.next_out_of_line();
7149            let handles_before = decoder.remaining_handles();
7150            if let Some((inlined, num_bytes, num_handles)) =
7151                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7152            {
7153                let member_inline_size =
7154                    <RingBufferOptions as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7155                if inlined != (member_inline_size <= 4) {
7156                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7157                }
7158                let inner_offset;
7159                let mut inner_depth = depth.clone();
7160                if inlined {
7161                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7162                    inner_offset = next_offset;
7163                } else {
7164                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7165                    inner_depth.increment()?;
7166                }
7167                let val_ref = self.options.get_or_insert_with(|| {
7168                    fidl::new_empty!(
7169                        RingBufferOptions,
7170                        fidl::encoding::DefaultFuchsiaResourceDialect
7171                    )
7172                });
7173                fidl::decode!(
7174                    RingBufferOptions,
7175                    fidl::encoding::DefaultFuchsiaResourceDialect,
7176                    val_ref,
7177                    decoder,
7178                    inner_offset,
7179                    inner_depth
7180                )?;
7181                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7182                {
7183                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7184                }
7185                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7186                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7187                }
7188            }
7189
7190            next_offset += envelope_size;
7191            _next_ordinal_to_read += 1;
7192            if next_offset >= end_offset {
7193                return Ok(());
7194            }
7195
7196            // Decode unknown envelopes for gaps in ordinals.
7197            while _next_ordinal_to_read < 3 {
7198                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7199                _next_ordinal_to_read += 1;
7200                next_offset += envelope_size;
7201            }
7202
7203            let next_out_of_line = decoder.next_out_of_line();
7204            let handles_before = decoder.remaining_handles();
7205            if let Some((inlined, num_bytes, num_handles)) =
7206                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7207            {
7208                let member_inline_size = <fidl::encoding::Endpoint<
7209                    fidl::endpoints::ServerEnd<RingBufferMarker>,
7210                > as fidl::encoding::TypeMarker>::inline_size(
7211                    decoder.context
7212                );
7213                if inlined != (member_inline_size <= 4) {
7214                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7215                }
7216                let inner_offset;
7217                let mut inner_depth = depth.clone();
7218                if inlined {
7219                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7220                    inner_offset = next_offset;
7221                } else {
7222                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7223                    inner_depth.increment()?;
7224                }
7225                let val_ref = self.ring_buffer_server.get_or_insert_with(|| {
7226                    fidl::new_empty!(
7227                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RingBufferMarker>>,
7228                        fidl::encoding::DefaultFuchsiaResourceDialect
7229                    )
7230                });
7231                fidl::decode!(
7232                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RingBufferMarker>>,
7233                    fidl::encoding::DefaultFuchsiaResourceDialect,
7234                    val_ref,
7235                    decoder,
7236                    inner_offset,
7237                    inner_depth
7238                )?;
7239                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7240                {
7241                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7242                }
7243                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7244                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7245                }
7246            }
7247
7248            next_offset += envelope_size;
7249
7250            // Decode the remaining unknown envelopes.
7251            while next_offset < end_offset {
7252                _next_ordinal_to_read += 1;
7253                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7254                next_offset += envelope_size;
7255            }
7256
7257            Ok(())
7258        }
7259    }
7260
7261    impl ControlCreatorCreateRequest {
7262        #[inline(always)]
7263        fn max_ordinal_present(&self) -> u64 {
7264            if let Some(_) = self.control_server {
7265                return 2;
7266            }
7267            if let Some(_) = self.token_id {
7268                return 1;
7269            }
7270            0
7271        }
7272    }
7273
7274    impl fidl::encoding::ResourceTypeMarker for ControlCreatorCreateRequest {
7275        type Borrowed<'a> = &'a mut Self;
7276        fn take_or_borrow<'a>(
7277            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7278        ) -> Self::Borrowed<'a> {
7279            value
7280        }
7281    }
7282
7283    unsafe impl fidl::encoding::TypeMarker for ControlCreatorCreateRequest {
7284        type Owned = Self;
7285
7286        #[inline(always)]
7287        fn inline_align(_context: fidl::encoding::Context) -> usize {
7288            8
7289        }
7290
7291        #[inline(always)]
7292        fn inline_size(_context: fidl::encoding::Context) -> usize {
7293            16
7294        }
7295    }
7296
7297    unsafe impl
7298        fidl::encoding::Encode<
7299            ControlCreatorCreateRequest,
7300            fidl::encoding::DefaultFuchsiaResourceDialect,
7301        > for &mut ControlCreatorCreateRequest
7302    {
7303        unsafe fn encode(
7304            self,
7305            encoder: &mut fidl::encoding::Encoder<
7306                '_,
7307                fidl::encoding::DefaultFuchsiaResourceDialect,
7308            >,
7309            offset: usize,
7310            mut depth: fidl::encoding::Depth,
7311        ) -> fidl::Result<()> {
7312            encoder.debug_check_bounds::<ControlCreatorCreateRequest>(offset);
7313            // Vector header
7314            let max_ordinal: u64 = self.max_ordinal_present();
7315            encoder.write_num(max_ordinal, offset);
7316            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
7317            // Calling encoder.out_of_line_offset(0) is not allowed.
7318            if max_ordinal == 0 {
7319                return Ok(());
7320            }
7321            depth.increment()?;
7322            let envelope_size = 8;
7323            let bytes_len = max_ordinal as usize * envelope_size;
7324            #[allow(unused_variables)]
7325            let offset = encoder.out_of_line_offset(bytes_len);
7326            let mut _prev_end_offset: usize = 0;
7327            if 1 > max_ordinal {
7328                return Ok(());
7329            }
7330
7331            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7332            // are envelope_size bytes.
7333            let cur_offset: usize = (1 - 1) * envelope_size;
7334
7335            // Zero reserved fields.
7336            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7337
7338            // Safety:
7339            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7340            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7341            //   envelope_size bytes, there is always sufficient room.
7342            fidl::encoding::encode_in_envelope_optional::<
7343                u64,
7344                fidl::encoding::DefaultFuchsiaResourceDialect,
7345            >(
7346                self.token_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
7347                encoder,
7348                offset + cur_offset,
7349                depth,
7350            )?;
7351
7352            _prev_end_offset = cur_offset + envelope_size;
7353            if 2 > max_ordinal {
7354                return Ok(());
7355            }
7356
7357            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7358            // are envelope_size bytes.
7359            let cur_offset: usize = (2 - 1) * envelope_size;
7360
7361            // Zero reserved fields.
7362            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7363
7364            // Safety:
7365            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7366            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7367            //   envelope_size bytes, there is always sufficient room.
7368            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
7369            self.control_server.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
7370            encoder, offset + cur_offset, depth
7371        )?;
7372
7373            _prev_end_offset = cur_offset + envelope_size;
7374
7375            Ok(())
7376        }
7377    }
7378
7379    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7380        for ControlCreatorCreateRequest
7381    {
7382        #[inline(always)]
7383        fn new_empty() -> Self {
7384            Self::default()
7385        }
7386
7387        unsafe fn decode(
7388            &mut self,
7389            decoder: &mut fidl::encoding::Decoder<
7390                '_,
7391                fidl::encoding::DefaultFuchsiaResourceDialect,
7392            >,
7393            offset: usize,
7394            mut depth: fidl::encoding::Depth,
7395        ) -> fidl::Result<()> {
7396            decoder.debug_check_bounds::<Self>(offset);
7397            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7398                None => return Err(fidl::Error::NotNullable),
7399                Some(len) => len,
7400            };
7401            // Calling decoder.out_of_line_offset(0) is not allowed.
7402            if len == 0 {
7403                return Ok(());
7404            };
7405            depth.increment()?;
7406            let envelope_size = 8;
7407            let bytes_len = len * envelope_size;
7408            let offset = decoder.out_of_line_offset(bytes_len)?;
7409            // Decode the envelope for each type.
7410            let mut _next_ordinal_to_read = 0;
7411            let mut next_offset = offset;
7412            let end_offset = offset + bytes_len;
7413            _next_ordinal_to_read += 1;
7414            if next_offset >= end_offset {
7415                return Ok(());
7416            }
7417
7418            // Decode unknown envelopes for gaps in ordinals.
7419            while _next_ordinal_to_read < 1 {
7420                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7421                _next_ordinal_to_read += 1;
7422                next_offset += envelope_size;
7423            }
7424
7425            let next_out_of_line = decoder.next_out_of_line();
7426            let handles_before = decoder.remaining_handles();
7427            if let Some((inlined, num_bytes, num_handles)) =
7428                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7429            {
7430                let member_inline_size =
7431                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7432                if inlined != (member_inline_size <= 4) {
7433                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7434                }
7435                let inner_offset;
7436                let mut inner_depth = depth.clone();
7437                if inlined {
7438                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7439                    inner_offset = next_offset;
7440                } else {
7441                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7442                    inner_depth.increment()?;
7443                }
7444                let val_ref = self.token_id.get_or_insert_with(|| {
7445                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
7446                });
7447                fidl::decode!(
7448                    u64,
7449                    fidl::encoding::DefaultFuchsiaResourceDialect,
7450                    val_ref,
7451                    decoder,
7452                    inner_offset,
7453                    inner_depth
7454                )?;
7455                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7456                {
7457                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7458                }
7459                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7460                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7461                }
7462            }
7463
7464            next_offset += envelope_size;
7465            _next_ordinal_to_read += 1;
7466            if next_offset >= end_offset {
7467                return Ok(());
7468            }
7469
7470            // Decode unknown envelopes for gaps in ordinals.
7471            while _next_ordinal_to_read < 2 {
7472                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7473                _next_ordinal_to_read += 1;
7474                next_offset += envelope_size;
7475            }
7476
7477            let next_out_of_line = decoder.next_out_of_line();
7478            let handles_before = decoder.remaining_handles();
7479            if let Some((inlined, num_bytes, num_handles)) =
7480                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7481            {
7482                let member_inline_size = <fidl::encoding::Endpoint<
7483                    fidl::endpoints::ServerEnd<ControlMarker>,
7484                > as fidl::encoding::TypeMarker>::inline_size(
7485                    decoder.context
7486                );
7487                if inlined != (member_inline_size <= 4) {
7488                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7489                }
7490                let inner_offset;
7491                let mut inner_depth = depth.clone();
7492                if inlined {
7493                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7494                    inner_offset = next_offset;
7495                } else {
7496                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7497                    inner_depth.increment()?;
7498                }
7499                let val_ref = self.control_server.get_or_insert_with(|| {
7500                    fidl::new_empty!(
7501                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
7502                        fidl::encoding::DefaultFuchsiaResourceDialect
7503                    )
7504                });
7505                fidl::decode!(
7506                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
7507                    fidl::encoding::DefaultFuchsiaResourceDialect,
7508                    val_ref,
7509                    decoder,
7510                    inner_offset,
7511                    inner_depth
7512                )?;
7513                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7514                {
7515                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7516                }
7517                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7518                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7519                }
7520            }
7521
7522            next_offset += envelope_size;
7523
7524            // Decode the remaining unknown envelopes.
7525            while next_offset < end_offset {
7526                _next_ordinal_to_read += 1;
7527                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7528                next_offset += envelope_size;
7529            }
7530
7531            Ok(())
7532        }
7533    }
7534
7535    impl ControlCreateRingBufferResponse {
7536        #[inline(always)]
7537        fn max_ordinal_present(&self) -> u64 {
7538            if let Some(_) = self.ring_buffer {
7539                return 2;
7540            }
7541            if let Some(_) = self.properties {
7542                return 1;
7543            }
7544            0
7545        }
7546    }
7547
7548    impl fidl::encoding::ResourceTypeMarker for ControlCreateRingBufferResponse {
7549        type Borrowed<'a> = &'a mut Self;
7550        fn take_or_borrow<'a>(
7551            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7552        ) -> Self::Borrowed<'a> {
7553            value
7554        }
7555    }
7556
7557    unsafe impl fidl::encoding::TypeMarker for ControlCreateRingBufferResponse {
7558        type Owned = Self;
7559
7560        #[inline(always)]
7561        fn inline_align(_context: fidl::encoding::Context) -> usize {
7562            8
7563        }
7564
7565        #[inline(always)]
7566        fn inline_size(_context: fidl::encoding::Context) -> usize {
7567            16
7568        }
7569    }
7570
7571    unsafe impl
7572        fidl::encoding::Encode<
7573            ControlCreateRingBufferResponse,
7574            fidl::encoding::DefaultFuchsiaResourceDialect,
7575        > for &mut ControlCreateRingBufferResponse
7576    {
7577        unsafe fn encode(
7578            self,
7579            encoder: &mut fidl::encoding::Encoder<
7580                '_,
7581                fidl::encoding::DefaultFuchsiaResourceDialect,
7582            >,
7583            offset: usize,
7584            mut depth: fidl::encoding::Depth,
7585        ) -> fidl::Result<()> {
7586            encoder.debug_check_bounds::<ControlCreateRingBufferResponse>(offset);
7587            // Vector header
7588            let max_ordinal: u64 = self.max_ordinal_present();
7589            encoder.write_num(max_ordinal, offset);
7590            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
7591            // Calling encoder.out_of_line_offset(0) is not allowed.
7592            if max_ordinal == 0 {
7593                return Ok(());
7594            }
7595            depth.increment()?;
7596            let envelope_size = 8;
7597            let bytes_len = max_ordinal as usize * envelope_size;
7598            #[allow(unused_variables)]
7599            let offset = encoder.out_of_line_offset(bytes_len);
7600            let mut _prev_end_offset: usize = 0;
7601            if 1 > max_ordinal {
7602                return Ok(());
7603            }
7604
7605            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7606            // are envelope_size bytes.
7607            let cur_offset: usize = (1 - 1) * envelope_size;
7608
7609            // Zero reserved fields.
7610            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7611
7612            // Safety:
7613            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7614            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7615            //   envelope_size bytes, there is always sufficient room.
7616            fidl::encoding::encode_in_envelope_optional::<
7617                RingBufferProperties,
7618                fidl::encoding::DefaultFuchsiaResourceDialect,
7619            >(
7620                self.properties
7621                    .as_ref()
7622                    .map(<RingBufferProperties as fidl::encoding::ValueTypeMarker>::borrow),
7623                encoder,
7624                offset + cur_offset,
7625                depth,
7626            )?;
7627
7628            _prev_end_offset = cur_offset + envelope_size;
7629            if 2 > max_ordinal {
7630                return Ok(());
7631            }
7632
7633            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7634            // are envelope_size bytes.
7635            let cur_offset: usize = (2 - 1) * envelope_size;
7636
7637            // Zero reserved fields.
7638            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7639
7640            // Safety:
7641            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7642            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7643            //   envelope_size bytes, there is always sufficient room.
7644            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_audio::RingBuffer, fidl::encoding::DefaultFuchsiaResourceDialect>(
7645            self.ring_buffer.as_mut().map(<fidl_fuchsia_audio::RingBuffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
7646            encoder, offset + cur_offset, depth
7647        )?;
7648
7649            _prev_end_offset = cur_offset + envelope_size;
7650
7651            Ok(())
7652        }
7653    }
7654
7655    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7656        for ControlCreateRingBufferResponse
7657    {
7658        #[inline(always)]
7659        fn new_empty() -> Self {
7660            Self::default()
7661        }
7662
7663        unsafe fn decode(
7664            &mut self,
7665            decoder: &mut fidl::encoding::Decoder<
7666                '_,
7667                fidl::encoding::DefaultFuchsiaResourceDialect,
7668            >,
7669            offset: usize,
7670            mut depth: fidl::encoding::Depth,
7671        ) -> fidl::Result<()> {
7672            decoder.debug_check_bounds::<Self>(offset);
7673            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7674                None => return Err(fidl::Error::NotNullable),
7675                Some(len) => len,
7676            };
7677            // Calling decoder.out_of_line_offset(0) is not allowed.
7678            if len == 0 {
7679                return Ok(());
7680            };
7681            depth.increment()?;
7682            let envelope_size = 8;
7683            let bytes_len = len * envelope_size;
7684            let offset = decoder.out_of_line_offset(bytes_len)?;
7685            // Decode the envelope for each type.
7686            let mut _next_ordinal_to_read = 0;
7687            let mut next_offset = offset;
7688            let end_offset = offset + bytes_len;
7689            _next_ordinal_to_read += 1;
7690            if next_offset >= end_offset {
7691                return Ok(());
7692            }
7693
7694            // Decode unknown envelopes for gaps in ordinals.
7695            while _next_ordinal_to_read < 1 {
7696                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7697                _next_ordinal_to_read += 1;
7698                next_offset += envelope_size;
7699            }
7700
7701            let next_out_of_line = decoder.next_out_of_line();
7702            let handles_before = decoder.remaining_handles();
7703            if let Some((inlined, num_bytes, num_handles)) =
7704                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7705            {
7706                let member_inline_size =
7707                    <RingBufferProperties as fidl::encoding::TypeMarker>::inline_size(
7708                        decoder.context,
7709                    );
7710                if inlined != (member_inline_size <= 4) {
7711                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7712                }
7713                let inner_offset;
7714                let mut inner_depth = depth.clone();
7715                if inlined {
7716                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7717                    inner_offset = next_offset;
7718                } else {
7719                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7720                    inner_depth.increment()?;
7721                }
7722                let val_ref = self.properties.get_or_insert_with(|| {
7723                    fidl::new_empty!(
7724                        RingBufferProperties,
7725                        fidl::encoding::DefaultFuchsiaResourceDialect
7726                    )
7727                });
7728                fidl::decode!(
7729                    RingBufferProperties,
7730                    fidl::encoding::DefaultFuchsiaResourceDialect,
7731                    val_ref,
7732                    decoder,
7733                    inner_offset,
7734                    inner_depth
7735                )?;
7736                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7737                {
7738                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7739                }
7740                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7741                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7742                }
7743            }
7744
7745            next_offset += envelope_size;
7746            _next_ordinal_to_read += 1;
7747            if next_offset >= end_offset {
7748                return Ok(());
7749            }
7750
7751            // Decode unknown envelopes for gaps in ordinals.
7752            while _next_ordinal_to_read < 2 {
7753                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7754                _next_ordinal_to_read += 1;
7755                next_offset += envelope_size;
7756            }
7757
7758            let next_out_of_line = decoder.next_out_of_line();
7759            let handles_before = decoder.remaining_handles();
7760            if let Some((inlined, num_bytes, num_handles)) =
7761                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7762            {
7763                let member_inline_size =
7764                    <fidl_fuchsia_audio::RingBuffer as fidl::encoding::TypeMarker>::inline_size(
7765                        decoder.context,
7766                    );
7767                if inlined != (member_inline_size <= 4) {
7768                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7769                }
7770                let inner_offset;
7771                let mut inner_depth = depth.clone();
7772                if inlined {
7773                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7774                    inner_offset = next_offset;
7775                } else {
7776                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7777                    inner_depth.increment()?;
7778                }
7779                let val_ref = self.ring_buffer.get_or_insert_with(|| {
7780                    fidl::new_empty!(
7781                        fidl_fuchsia_audio::RingBuffer,
7782                        fidl::encoding::DefaultFuchsiaResourceDialect
7783                    )
7784                });
7785                fidl::decode!(
7786                    fidl_fuchsia_audio::RingBuffer,
7787                    fidl::encoding::DefaultFuchsiaResourceDialect,
7788                    val_ref,
7789                    decoder,
7790                    inner_offset,
7791                    inner_depth
7792                )?;
7793                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7794                {
7795                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7796                }
7797                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7798                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7799                }
7800            }
7801
7802            next_offset += envelope_size;
7803
7804            // Decode the remaining unknown envelopes.
7805            while next_offset < end_offset {
7806                _next_ordinal_to_read += 1;
7807                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7808                next_offset += envelope_size;
7809            }
7810
7811            Ok(())
7812        }
7813    }
7814
7815    impl ObserverGetReferenceClockResponse {
7816        #[inline(always)]
7817        fn max_ordinal_present(&self) -> u64 {
7818            if let Some(_) = self.reference_clock {
7819                return 1;
7820            }
7821            0
7822        }
7823    }
7824
7825    impl fidl::encoding::ResourceTypeMarker for ObserverGetReferenceClockResponse {
7826        type Borrowed<'a> = &'a mut Self;
7827        fn take_or_borrow<'a>(
7828            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7829        ) -> Self::Borrowed<'a> {
7830            value
7831        }
7832    }
7833
7834    unsafe impl fidl::encoding::TypeMarker for ObserverGetReferenceClockResponse {
7835        type Owned = Self;
7836
7837        #[inline(always)]
7838        fn inline_align(_context: fidl::encoding::Context) -> usize {
7839            8
7840        }
7841
7842        #[inline(always)]
7843        fn inline_size(_context: fidl::encoding::Context) -> usize {
7844            16
7845        }
7846    }
7847
7848    unsafe impl
7849        fidl::encoding::Encode<
7850            ObserverGetReferenceClockResponse,
7851            fidl::encoding::DefaultFuchsiaResourceDialect,
7852        > for &mut ObserverGetReferenceClockResponse
7853    {
7854        unsafe fn encode(
7855            self,
7856            encoder: &mut fidl::encoding::Encoder<
7857                '_,
7858                fidl::encoding::DefaultFuchsiaResourceDialect,
7859            >,
7860            offset: usize,
7861            mut depth: fidl::encoding::Depth,
7862        ) -> fidl::Result<()> {
7863            encoder.debug_check_bounds::<ObserverGetReferenceClockResponse>(offset);
7864            // Vector header
7865            let max_ordinal: u64 = self.max_ordinal_present();
7866            encoder.write_num(max_ordinal, offset);
7867            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
7868            // Calling encoder.out_of_line_offset(0) is not allowed.
7869            if max_ordinal == 0 {
7870                return Ok(());
7871            }
7872            depth.increment()?;
7873            let envelope_size = 8;
7874            let bytes_len = max_ordinal as usize * envelope_size;
7875            #[allow(unused_variables)]
7876            let offset = encoder.out_of_line_offset(bytes_len);
7877            let mut _prev_end_offset: usize = 0;
7878            if 1 > max_ordinal {
7879                return Ok(());
7880            }
7881
7882            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7883            // are envelope_size bytes.
7884            let cur_offset: usize = (1 - 1) * envelope_size;
7885
7886            // Zero reserved fields.
7887            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7888
7889            // Safety:
7890            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7891            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7892            //   envelope_size bytes, there is always sufficient room.
7893            fidl::encoding::encode_in_envelope_optional::<
7894                fidl::encoding::HandleType<
7895                    fidl::Clock,
7896                    { fidl::ObjectType::CLOCK.into_raw() },
7897                    2147483648,
7898                >,
7899                fidl::encoding::DefaultFuchsiaResourceDialect,
7900            >(
7901                self.reference_clock.as_mut().map(
7902                    <fidl::encoding::HandleType<
7903                        fidl::Clock,
7904                        { fidl::ObjectType::CLOCK.into_raw() },
7905                        2147483648,
7906                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
7907                ),
7908                encoder,
7909                offset + cur_offset,
7910                depth,
7911            )?;
7912
7913            _prev_end_offset = cur_offset + envelope_size;
7914
7915            Ok(())
7916        }
7917    }
7918
7919    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7920        for ObserverGetReferenceClockResponse
7921    {
7922        #[inline(always)]
7923        fn new_empty() -> Self {
7924            Self::default()
7925        }
7926
7927        unsafe fn decode(
7928            &mut self,
7929            decoder: &mut fidl::encoding::Decoder<
7930                '_,
7931                fidl::encoding::DefaultFuchsiaResourceDialect,
7932            >,
7933            offset: usize,
7934            mut depth: fidl::encoding::Depth,
7935        ) -> fidl::Result<()> {
7936            decoder.debug_check_bounds::<Self>(offset);
7937            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7938                None => return Err(fidl::Error::NotNullable),
7939                Some(len) => len,
7940            };
7941            // Calling decoder.out_of_line_offset(0) is not allowed.
7942            if len == 0 {
7943                return Ok(());
7944            };
7945            depth.increment()?;
7946            let envelope_size = 8;
7947            let bytes_len = len * envelope_size;
7948            let offset = decoder.out_of_line_offset(bytes_len)?;
7949            // Decode the envelope for each type.
7950            let mut _next_ordinal_to_read = 0;
7951            let mut next_offset = offset;
7952            let end_offset = offset + bytes_len;
7953            _next_ordinal_to_read += 1;
7954            if next_offset >= end_offset {
7955                return Ok(());
7956            }
7957
7958            // Decode unknown envelopes for gaps in ordinals.
7959            while _next_ordinal_to_read < 1 {
7960                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7961                _next_ordinal_to_read += 1;
7962                next_offset += envelope_size;
7963            }
7964
7965            let next_out_of_line = decoder.next_out_of_line();
7966            let handles_before = decoder.remaining_handles();
7967            if let Some((inlined, num_bytes, num_handles)) =
7968                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7969            {
7970                let member_inline_size = <fidl::encoding::HandleType<
7971                    fidl::Clock,
7972                    { fidl::ObjectType::CLOCK.into_raw() },
7973                    2147483648,
7974                > as fidl::encoding::TypeMarker>::inline_size(
7975                    decoder.context
7976                );
7977                if inlined != (member_inline_size <= 4) {
7978                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7979                }
7980                let inner_offset;
7981                let mut inner_depth = depth.clone();
7982                if inlined {
7983                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7984                    inner_offset = next_offset;
7985                } else {
7986                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7987                    inner_depth.increment()?;
7988                }
7989                let val_ref =
7990                self.reference_clock.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
7991                fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
7992                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7993                {
7994                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7995                }
7996                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7997                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7998                }
7999            }
8000
8001            next_offset += envelope_size;
8002
8003            // Decode the remaining unknown envelopes.
8004            while next_offset < end_offset {
8005                _next_ordinal_to_read += 1;
8006                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8007                next_offset += envelope_size;
8008            }
8009
8010            Ok(())
8011        }
8012    }
8013
8014    impl ProviderAddDeviceRequest {
8015        #[inline(always)]
8016        fn max_ordinal_present(&self) -> u64 {
8017            if let Some(_) = self.driver_client {
8018                return 3;
8019            }
8020            if let Some(_) = self.device_type {
8021                return 2;
8022            }
8023            if let Some(_) = self.device_name {
8024                return 1;
8025            }
8026            0
8027        }
8028    }
8029
8030    impl fidl::encoding::ResourceTypeMarker for ProviderAddDeviceRequest {
8031        type Borrowed<'a> = &'a mut Self;
8032        fn take_or_borrow<'a>(
8033            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8034        ) -> Self::Borrowed<'a> {
8035            value
8036        }
8037    }
8038
8039    unsafe impl fidl::encoding::TypeMarker for ProviderAddDeviceRequest {
8040        type Owned = Self;
8041
8042        #[inline(always)]
8043        fn inline_align(_context: fidl::encoding::Context) -> usize {
8044            8
8045        }
8046
8047        #[inline(always)]
8048        fn inline_size(_context: fidl::encoding::Context) -> usize {
8049            16
8050        }
8051    }
8052
8053    unsafe impl
8054        fidl::encoding::Encode<
8055            ProviderAddDeviceRequest,
8056            fidl::encoding::DefaultFuchsiaResourceDialect,
8057        > for &mut ProviderAddDeviceRequest
8058    {
8059        unsafe fn encode(
8060            self,
8061            encoder: &mut fidl::encoding::Encoder<
8062                '_,
8063                fidl::encoding::DefaultFuchsiaResourceDialect,
8064            >,
8065            offset: usize,
8066            mut depth: fidl::encoding::Depth,
8067        ) -> fidl::Result<()> {
8068            encoder.debug_check_bounds::<ProviderAddDeviceRequest>(offset);
8069            // Vector header
8070            let max_ordinal: u64 = self.max_ordinal_present();
8071            encoder.write_num(max_ordinal, offset);
8072            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8073            // Calling encoder.out_of_line_offset(0) is not allowed.
8074            if max_ordinal == 0 {
8075                return Ok(());
8076            }
8077            depth.increment()?;
8078            let envelope_size = 8;
8079            let bytes_len = max_ordinal as usize * envelope_size;
8080            #[allow(unused_variables)]
8081            let offset = encoder.out_of_line_offset(bytes_len);
8082            let mut _prev_end_offset: usize = 0;
8083            if 1 > max_ordinal {
8084                return Ok(());
8085            }
8086
8087            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8088            // are envelope_size bytes.
8089            let cur_offset: usize = (1 - 1) * envelope_size;
8090
8091            // Zero reserved fields.
8092            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8093
8094            // Safety:
8095            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8096            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8097            //   envelope_size bytes, there is always sufficient room.
8098            fidl::encoding::encode_in_envelope_optional::<
8099                fidl::encoding::BoundedString<256>,
8100                fidl::encoding::DefaultFuchsiaResourceDialect,
8101            >(
8102                self.device_name.as_ref().map(
8103                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow,
8104                ),
8105                encoder,
8106                offset + cur_offset,
8107                depth,
8108            )?;
8109
8110            _prev_end_offset = cur_offset + envelope_size;
8111            if 2 > max_ordinal {
8112                return Ok(());
8113            }
8114
8115            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8116            // are envelope_size bytes.
8117            let cur_offset: usize = (2 - 1) * envelope_size;
8118
8119            // Zero reserved fields.
8120            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8121
8122            // Safety:
8123            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8124            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8125            //   envelope_size bytes, there is always sufficient room.
8126            fidl::encoding::encode_in_envelope_optional::<
8127                DeviceType,
8128                fidl::encoding::DefaultFuchsiaResourceDialect,
8129            >(
8130                self.device_type
8131                    .as_ref()
8132                    .map(<DeviceType as fidl::encoding::ValueTypeMarker>::borrow),
8133                encoder,
8134                offset + cur_offset,
8135                depth,
8136            )?;
8137
8138            _prev_end_offset = cur_offset + envelope_size;
8139            if 3 > max_ordinal {
8140                return Ok(());
8141            }
8142
8143            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8144            // are envelope_size bytes.
8145            let cur_offset: usize = (3 - 1) * envelope_size;
8146
8147            // Zero reserved fields.
8148            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8149
8150            // Safety:
8151            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8152            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8153            //   envelope_size bytes, there is always sufficient room.
8154            fidl::encoding::encode_in_envelope_optional::<
8155                DriverClient,
8156                fidl::encoding::DefaultFuchsiaResourceDialect,
8157            >(
8158                self.driver_client
8159                    .as_mut()
8160                    .map(<DriverClient as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
8161                encoder,
8162                offset + cur_offset,
8163                depth,
8164            )?;
8165
8166            _prev_end_offset = cur_offset + envelope_size;
8167
8168            Ok(())
8169        }
8170    }
8171
8172    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8173        for ProviderAddDeviceRequest
8174    {
8175        #[inline(always)]
8176        fn new_empty() -> Self {
8177            Self::default()
8178        }
8179
8180        unsafe fn decode(
8181            &mut self,
8182            decoder: &mut fidl::encoding::Decoder<
8183                '_,
8184                fidl::encoding::DefaultFuchsiaResourceDialect,
8185            >,
8186            offset: usize,
8187            mut depth: fidl::encoding::Depth,
8188        ) -> fidl::Result<()> {
8189            decoder.debug_check_bounds::<Self>(offset);
8190            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8191                None => return Err(fidl::Error::NotNullable),
8192                Some(len) => len,
8193            };
8194            // Calling decoder.out_of_line_offset(0) is not allowed.
8195            if len == 0 {
8196                return Ok(());
8197            };
8198            depth.increment()?;
8199            let envelope_size = 8;
8200            let bytes_len = len * envelope_size;
8201            let offset = decoder.out_of_line_offset(bytes_len)?;
8202            // Decode the envelope for each type.
8203            let mut _next_ordinal_to_read = 0;
8204            let mut next_offset = offset;
8205            let end_offset = offset + bytes_len;
8206            _next_ordinal_to_read += 1;
8207            if next_offset >= end_offset {
8208                return Ok(());
8209            }
8210
8211            // Decode unknown envelopes for gaps in ordinals.
8212            while _next_ordinal_to_read < 1 {
8213                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8214                _next_ordinal_to_read += 1;
8215                next_offset += envelope_size;
8216            }
8217
8218            let next_out_of_line = decoder.next_out_of_line();
8219            let handles_before = decoder.remaining_handles();
8220            if let Some((inlined, num_bytes, num_handles)) =
8221                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8222            {
8223                let member_inline_size =
8224                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
8225                        decoder.context,
8226                    );
8227                if inlined != (member_inline_size <= 4) {
8228                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8229                }
8230                let inner_offset;
8231                let mut inner_depth = depth.clone();
8232                if inlined {
8233                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8234                    inner_offset = next_offset;
8235                } else {
8236                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8237                    inner_depth.increment()?;
8238                }
8239                let val_ref = self.device_name.get_or_insert_with(|| {
8240                    fidl::new_empty!(
8241                        fidl::encoding::BoundedString<256>,
8242                        fidl::encoding::DefaultFuchsiaResourceDialect
8243                    )
8244                });
8245                fidl::decode!(
8246                    fidl::encoding::BoundedString<256>,
8247                    fidl::encoding::DefaultFuchsiaResourceDialect,
8248                    val_ref,
8249                    decoder,
8250                    inner_offset,
8251                    inner_depth
8252                )?;
8253                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8254                {
8255                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8256                }
8257                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8258                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8259                }
8260            }
8261
8262            next_offset += envelope_size;
8263            _next_ordinal_to_read += 1;
8264            if next_offset >= end_offset {
8265                return Ok(());
8266            }
8267
8268            // Decode unknown envelopes for gaps in ordinals.
8269            while _next_ordinal_to_read < 2 {
8270                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8271                _next_ordinal_to_read += 1;
8272                next_offset += envelope_size;
8273            }
8274
8275            let next_out_of_line = decoder.next_out_of_line();
8276            let handles_before = decoder.remaining_handles();
8277            if let Some((inlined, num_bytes, num_handles)) =
8278                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8279            {
8280                let member_inline_size =
8281                    <DeviceType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8282                if inlined != (member_inline_size <= 4) {
8283                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8284                }
8285                let inner_offset;
8286                let mut inner_depth = depth.clone();
8287                if inlined {
8288                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8289                    inner_offset = next_offset;
8290                } else {
8291                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8292                    inner_depth.increment()?;
8293                }
8294                let val_ref = self.device_type.get_or_insert_with(|| {
8295                    fidl::new_empty!(DeviceType, fidl::encoding::DefaultFuchsiaResourceDialect)
8296                });
8297                fidl::decode!(
8298                    DeviceType,
8299                    fidl::encoding::DefaultFuchsiaResourceDialect,
8300                    val_ref,
8301                    decoder,
8302                    inner_offset,
8303                    inner_depth
8304                )?;
8305                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8306                {
8307                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8308                }
8309                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8310                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8311                }
8312            }
8313
8314            next_offset += envelope_size;
8315            _next_ordinal_to_read += 1;
8316            if next_offset >= end_offset {
8317                return Ok(());
8318            }
8319
8320            // Decode unknown envelopes for gaps in ordinals.
8321            while _next_ordinal_to_read < 3 {
8322                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8323                _next_ordinal_to_read += 1;
8324                next_offset += envelope_size;
8325            }
8326
8327            let next_out_of_line = decoder.next_out_of_line();
8328            let handles_before = decoder.remaining_handles();
8329            if let Some((inlined, num_bytes, num_handles)) =
8330                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8331            {
8332                let member_inline_size =
8333                    <DriverClient as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8334                if inlined != (member_inline_size <= 4) {
8335                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8336                }
8337                let inner_offset;
8338                let mut inner_depth = depth.clone();
8339                if inlined {
8340                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8341                    inner_offset = next_offset;
8342                } else {
8343                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8344                    inner_depth.increment()?;
8345                }
8346                let val_ref = self.driver_client.get_or_insert_with(|| {
8347                    fidl::new_empty!(DriverClient, fidl::encoding::DefaultFuchsiaResourceDialect)
8348                });
8349                fidl::decode!(
8350                    DriverClient,
8351                    fidl::encoding::DefaultFuchsiaResourceDialect,
8352                    val_ref,
8353                    decoder,
8354                    inner_offset,
8355                    inner_depth
8356                )?;
8357                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8358                {
8359                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8360                }
8361                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8362                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8363                }
8364            }
8365
8366            next_offset += envelope_size;
8367
8368            // Decode the remaining unknown envelopes.
8369            while next_offset < end_offset {
8370                _next_ordinal_to_read += 1;
8371                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8372                next_offset += envelope_size;
8373            }
8374
8375            Ok(())
8376        }
8377    }
8378
8379    impl RegistryCreateObserverRequest {
8380        #[inline(always)]
8381        fn max_ordinal_present(&self) -> u64 {
8382            if let Some(_) = self.observer_server {
8383                return 2;
8384            }
8385            if let Some(_) = self.token_id {
8386                return 1;
8387            }
8388            0
8389        }
8390    }
8391
8392    impl fidl::encoding::ResourceTypeMarker for RegistryCreateObserverRequest {
8393        type Borrowed<'a> = &'a mut Self;
8394        fn take_or_borrow<'a>(
8395            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8396        ) -> Self::Borrowed<'a> {
8397            value
8398        }
8399    }
8400
8401    unsafe impl fidl::encoding::TypeMarker for RegistryCreateObserverRequest {
8402        type Owned = Self;
8403
8404        #[inline(always)]
8405        fn inline_align(_context: fidl::encoding::Context) -> usize {
8406            8
8407        }
8408
8409        #[inline(always)]
8410        fn inline_size(_context: fidl::encoding::Context) -> usize {
8411            16
8412        }
8413    }
8414
8415    unsafe impl
8416        fidl::encoding::Encode<
8417            RegistryCreateObserverRequest,
8418            fidl::encoding::DefaultFuchsiaResourceDialect,
8419        > for &mut RegistryCreateObserverRequest
8420    {
8421        unsafe fn encode(
8422            self,
8423            encoder: &mut fidl::encoding::Encoder<
8424                '_,
8425                fidl::encoding::DefaultFuchsiaResourceDialect,
8426            >,
8427            offset: usize,
8428            mut depth: fidl::encoding::Depth,
8429        ) -> fidl::Result<()> {
8430            encoder.debug_check_bounds::<RegistryCreateObserverRequest>(offset);
8431            // Vector header
8432            let max_ordinal: u64 = self.max_ordinal_present();
8433            encoder.write_num(max_ordinal, offset);
8434            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8435            // Calling encoder.out_of_line_offset(0) is not allowed.
8436            if max_ordinal == 0 {
8437                return Ok(());
8438            }
8439            depth.increment()?;
8440            let envelope_size = 8;
8441            let bytes_len = max_ordinal as usize * envelope_size;
8442            #[allow(unused_variables)]
8443            let offset = encoder.out_of_line_offset(bytes_len);
8444            let mut _prev_end_offset: usize = 0;
8445            if 1 > max_ordinal {
8446                return Ok(());
8447            }
8448
8449            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8450            // are envelope_size bytes.
8451            let cur_offset: usize = (1 - 1) * envelope_size;
8452
8453            // Zero reserved fields.
8454            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8455
8456            // Safety:
8457            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8458            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8459            //   envelope_size bytes, there is always sufficient room.
8460            fidl::encoding::encode_in_envelope_optional::<
8461                u64,
8462                fidl::encoding::DefaultFuchsiaResourceDialect,
8463            >(
8464                self.token_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
8465                encoder,
8466                offset + cur_offset,
8467                depth,
8468            )?;
8469
8470            _prev_end_offset = cur_offset + envelope_size;
8471            if 2 > max_ordinal {
8472                return Ok(());
8473            }
8474
8475            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8476            // are envelope_size bytes.
8477            let cur_offset: usize = (2 - 1) * envelope_size;
8478
8479            // Zero reserved fields.
8480            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8481
8482            // Safety:
8483            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8484            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8485            //   envelope_size bytes, there is always sufficient room.
8486            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ObserverMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
8487            self.observer_server.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ObserverMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
8488            encoder, offset + cur_offset, depth
8489        )?;
8490
8491            _prev_end_offset = cur_offset + envelope_size;
8492
8493            Ok(())
8494        }
8495    }
8496
8497    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8498        for RegistryCreateObserverRequest
8499    {
8500        #[inline(always)]
8501        fn new_empty() -> Self {
8502            Self::default()
8503        }
8504
8505        unsafe fn decode(
8506            &mut self,
8507            decoder: &mut fidl::encoding::Decoder<
8508                '_,
8509                fidl::encoding::DefaultFuchsiaResourceDialect,
8510            >,
8511            offset: usize,
8512            mut depth: fidl::encoding::Depth,
8513        ) -> fidl::Result<()> {
8514            decoder.debug_check_bounds::<Self>(offset);
8515            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8516                None => return Err(fidl::Error::NotNullable),
8517                Some(len) => len,
8518            };
8519            // Calling decoder.out_of_line_offset(0) is not allowed.
8520            if len == 0 {
8521                return Ok(());
8522            };
8523            depth.increment()?;
8524            let envelope_size = 8;
8525            let bytes_len = len * envelope_size;
8526            let offset = decoder.out_of_line_offset(bytes_len)?;
8527            // Decode the envelope for each type.
8528            let mut _next_ordinal_to_read = 0;
8529            let mut next_offset = offset;
8530            let end_offset = offset + bytes_len;
8531            _next_ordinal_to_read += 1;
8532            if next_offset >= end_offset {
8533                return Ok(());
8534            }
8535
8536            // Decode unknown envelopes for gaps in ordinals.
8537            while _next_ordinal_to_read < 1 {
8538                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8539                _next_ordinal_to_read += 1;
8540                next_offset += envelope_size;
8541            }
8542
8543            let next_out_of_line = decoder.next_out_of_line();
8544            let handles_before = decoder.remaining_handles();
8545            if let Some((inlined, num_bytes, num_handles)) =
8546                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8547            {
8548                let member_inline_size =
8549                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8550                if inlined != (member_inline_size <= 4) {
8551                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8552                }
8553                let inner_offset;
8554                let mut inner_depth = depth.clone();
8555                if inlined {
8556                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8557                    inner_offset = next_offset;
8558                } else {
8559                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8560                    inner_depth.increment()?;
8561                }
8562                let val_ref = self.token_id.get_or_insert_with(|| {
8563                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
8564                });
8565                fidl::decode!(
8566                    u64,
8567                    fidl::encoding::DefaultFuchsiaResourceDialect,
8568                    val_ref,
8569                    decoder,
8570                    inner_offset,
8571                    inner_depth
8572                )?;
8573                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8574                {
8575                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8576                }
8577                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8578                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8579                }
8580            }
8581
8582            next_offset += envelope_size;
8583            _next_ordinal_to_read += 1;
8584            if next_offset >= end_offset {
8585                return Ok(());
8586            }
8587
8588            // Decode unknown envelopes for gaps in ordinals.
8589            while _next_ordinal_to_read < 2 {
8590                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8591                _next_ordinal_to_read += 1;
8592                next_offset += envelope_size;
8593            }
8594
8595            let next_out_of_line = decoder.next_out_of_line();
8596            let handles_before = decoder.remaining_handles();
8597            if let Some((inlined, num_bytes, num_handles)) =
8598                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8599            {
8600                let member_inline_size = <fidl::encoding::Endpoint<
8601                    fidl::endpoints::ServerEnd<ObserverMarker>,
8602                > as fidl::encoding::TypeMarker>::inline_size(
8603                    decoder.context
8604                );
8605                if inlined != (member_inline_size <= 4) {
8606                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8607                }
8608                let inner_offset;
8609                let mut inner_depth = depth.clone();
8610                if inlined {
8611                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8612                    inner_offset = next_offset;
8613                } else {
8614                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8615                    inner_depth.increment()?;
8616                }
8617                let val_ref = self.observer_server.get_or_insert_with(|| {
8618                    fidl::new_empty!(
8619                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ObserverMarker>>,
8620                        fidl::encoding::DefaultFuchsiaResourceDialect
8621                    )
8622                });
8623                fidl::decode!(
8624                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ObserverMarker>>,
8625                    fidl::encoding::DefaultFuchsiaResourceDialect,
8626                    val_ref,
8627                    decoder,
8628                    inner_offset,
8629                    inner_depth
8630                )?;
8631                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8632                {
8633                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8634                }
8635                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8636                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8637                }
8638            }
8639
8640            next_offset += envelope_size;
8641
8642            // Decode the remaining unknown envelopes.
8643            while next_offset < end_offset {
8644                _next_ordinal_to_read += 1;
8645                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8646                next_offset += envelope_size;
8647            }
8648
8649            Ok(())
8650        }
8651    }
8652
8653    impl fidl::encoding::ResourceTypeMarker for DriverClient {
8654        type Borrowed<'a> = &'a mut Self;
8655        fn take_or_borrow<'a>(
8656            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8657        ) -> Self::Borrowed<'a> {
8658            value
8659        }
8660    }
8661
8662    unsafe impl fidl::encoding::TypeMarker for DriverClient {
8663        type Owned = Self;
8664
8665        #[inline(always)]
8666        fn inline_align(_context: fidl::encoding::Context) -> usize {
8667            8
8668        }
8669
8670        #[inline(always)]
8671        fn inline_size(_context: fidl::encoding::Context) -> usize {
8672            16
8673        }
8674    }
8675
8676    unsafe impl fidl::encoding::Encode<DriverClient, fidl::encoding::DefaultFuchsiaResourceDialect>
8677        for &mut DriverClient
8678    {
8679        #[inline]
8680        unsafe fn encode(
8681            self,
8682            encoder: &mut fidl::encoding::Encoder<
8683                '_,
8684                fidl::encoding::DefaultFuchsiaResourceDialect,
8685            >,
8686            offset: usize,
8687            _depth: fidl::encoding::Depth,
8688        ) -> fidl::Result<()> {
8689            encoder.debug_check_bounds::<DriverClient>(offset);
8690            encoder.write_num::<u64>(self.ordinal(), offset);
8691            match self {
8692                DriverClient::Codec(ref mut val) => fidl::encoding::encode_in_envelope::<
8693                    fidl::encoding::Endpoint<
8694                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CodecMarker>,
8695                    >,
8696                    fidl::encoding::DefaultFuchsiaResourceDialect,
8697                >(
8698                    <fidl::encoding::Endpoint<
8699                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CodecMarker>,
8700                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8701                        val
8702                    ),
8703                    encoder,
8704                    offset + 8,
8705                    _depth,
8706                ),
8707                DriverClient::Composite(ref mut val) => fidl::encoding::encode_in_envelope::<
8708                    fidl::encoding::Endpoint<
8709                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CompositeMarker>,
8710                    >,
8711                    fidl::encoding::DefaultFuchsiaResourceDialect,
8712                >(
8713                    <fidl::encoding::Endpoint<
8714                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CompositeMarker>,
8715                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8716                        val
8717                    ),
8718                    encoder,
8719                    offset + 8,
8720                    _depth,
8721                ),
8722                DriverClient::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
8723            }
8724        }
8725    }
8726
8727    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for DriverClient {
8728        #[inline(always)]
8729        fn new_empty() -> Self {
8730            Self::__SourceBreaking { unknown_ordinal: 0 }
8731        }
8732
8733        #[inline]
8734        unsafe fn decode(
8735            &mut self,
8736            decoder: &mut fidl::encoding::Decoder<
8737                '_,
8738                fidl::encoding::DefaultFuchsiaResourceDialect,
8739            >,
8740            offset: usize,
8741            mut depth: fidl::encoding::Depth,
8742        ) -> fidl::Result<()> {
8743            decoder.debug_check_bounds::<Self>(offset);
8744            #[allow(unused_variables)]
8745            let next_out_of_line = decoder.next_out_of_line();
8746            let handles_before = decoder.remaining_handles();
8747            let (ordinal, inlined, num_bytes, num_handles) =
8748                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
8749
8750            let member_inline_size = match ordinal {
8751                1 => <fidl::encoding::Endpoint<
8752                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CodecMarker>,
8753                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
8754                2 => <fidl::encoding::Endpoint<
8755                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CompositeMarker>,
8756                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
8757                0 => return Err(fidl::Error::UnknownUnionTag),
8758                _ => num_bytes as usize,
8759            };
8760
8761            if inlined != (member_inline_size <= 4) {
8762                return Err(fidl::Error::InvalidInlineBitInEnvelope);
8763            }
8764            let _inner_offset;
8765            if inlined {
8766                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
8767                _inner_offset = offset + 8;
8768            } else {
8769                depth.increment()?;
8770                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8771            }
8772            match ordinal {
8773                1 => {
8774                    #[allow(irrefutable_let_patterns)]
8775                    if let DriverClient::Codec(_) = self {
8776                        // Do nothing, read the value into the object
8777                    } else {
8778                        // Initialize `self` to the right variant
8779                        *self = DriverClient::Codec(fidl::new_empty!(
8780                            fidl::encoding::Endpoint<
8781                                fidl::endpoints::ClientEnd<
8782                                    fidl_fuchsia_hardware_audio::CodecMarker,
8783                                >,
8784                            >,
8785                            fidl::encoding::DefaultFuchsiaResourceDialect
8786                        ));
8787                    }
8788                    #[allow(irrefutable_let_patterns)]
8789                    if let DriverClient::Codec(ref mut val) = self {
8790                        fidl::decode!(
8791                            fidl::encoding::Endpoint<
8792                                fidl::endpoints::ClientEnd<
8793                                    fidl_fuchsia_hardware_audio::CodecMarker,
8794                                >,
8795                            >,
8796                            fidl::encoding::DefaultFuchsiaResourceDialect,
8797                            val,
8798                            decoder,
8799                            _inner_offset,
8800                            depth
8801                        )?;
8802                    } else {
8803                        unreachable!()
8804                    }
8805                }
8806                2 => {
8807                    #[allow(irrefutable_let_patterns)]
8808                    if let DriverClient::Composite(_) = self {
8809                        // Do nothing, read the value into the object
8810                    } else {
8811                        // Initialize `self` to the right variant
8812                        *self = DriverClient::Composite(fidl::new_empty!(
8813                            fidl::encoding::Endpoint<
8814                                fidl::endpoints::ClientEnd<
8815                                    fidl_fuchsia_hardware_audio::CompositeMarker,
8816                                >,
8817                            >,
8818                            fidl::encoding::DefaultFuchsiaResourceDialect
8819                        ));
8820                    }
8821                    #[allow(irrefutable_let_patterns)]
8822                    if let DriverClient::Composite(ref mut val) = self {
8823                        fidl::decode!(
8824                            fidl::encoding::Endpoint<
8825                                fidl::endpoints::ClientEnd<
8826                                    fidl_fuchsia_hardware_audio::CompositeMarker,
8827                                >,
8828                            >,
8829                            fidl::encoding::DefaultFuchsiaResourceDialect,
8830                            val,
8831                            decoder,
8832                            _inner_offset,
8833                            depth
8834                        )?;
8835                    } else {
8836                        unreachable!()
8837                    }
8838                }
8839                #[allow(deprecated)]
8840                ordinal => {
8841                    for _ in 0..num_handles {
8842                        decoder.drop_next_handle()?;
8843                    }
8844                    *self = DriverClient::__SourceBreaking { unknown_ordinal: ordinal };
8845                }
8846            }
8847            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
8848                return Err(fidl::Error::InvalidNumBytesInEnvelope);
8849            }
8850            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8851                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8852            }
8853            Ok(())
8854        }
8855    }
8856}