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