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