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