Skip to main content

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