fidl_fuchsia_audio_device/
fidl_fuchsia_audio_device.rs

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