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 ControlCreatePacketStreamRequest {
16    /// The element ID for an `ENDPOINT` of type `PACKET_STREAM`.
17    ///
18    /// Required.
19    pub element_id: Option<u64>,
20    /// Additional configuration options for the packet stream being created.
21    ///
22    /// Required.
23    pub options: Option<PacketStreamOptions>,
24    /// The server_end of the `PacketStream` control protocol.
25    /// The client keeps the client_end to control the stream (Start/Stop/etc).
26    ///
27    /// Required.
28    pub packet_stream_server: Option<fidl::endpoints::ServerEnd<PacketStreamMarker>>,
29    #[doc(hidden)]
30    pub __source_breaking: fidl::marker::SourceBreaking,
31}
32
33impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
34    for ControlCreatePacketStreamRequest
35{
36}
37
38#[derive(Debug, Default, PartialEq)]
39pub struct ControlCreateRingBufferRequest {
40    /// The ID for an element of type `RING_BUFFER`.
41    ///
42    /// Required.
43    pub element_id: Option<u64>,
44    /// Additional requirements about the actual ring buffer being created.
45    ///
46    /// Required.
47    pub options: Option<RingBufferOptions>,
48    /// The server_end of the `RingBuffer` to be created.
49    ///
50    /// Required.
51    pub ring_buffer_server: Option<fidl::endpoints::ServerEnd<RingBufferMarker>>,
52    #[doc(hidden)]
53    pub __source_breaking: fidl::marker::SourceBreaking,
54}
55
56impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
57    for ControlCreateRingBufferRequest
58{
59}
60
61#[derive(Debug, Default, PartialEq)]
62pub struct ControlCreatorCreateRequest {
63    /// The token id for the device to be controlled.
64    ///
65    /// Required.
66    pub token_id: Option<u64>,
67    /// The server_end of the `Control` to be created.
68    ///
69    /// Required.
70    pub control_server: Option<fidl::endpoints::ServerEnd<ControlMarker>>,
71    #[doc(hidden)]
72    pub __source_breaking: fidl::marker::SourceBreaking,
73}
74
75impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
76    for ControlCreatorCreateRequest
77{
78}
79
80#[derive(Debug, Default, PartialEq)]
81pub struct ControlCreatePacketStreamResponse {
82    /// Properties of the created packet stream.
83    pub properties: Option<PacketStreamProperties>,
84    #[doc(hidden)]
85    pub __source_breaking: fidl::marker::SourceBreaking,
86}
87
88impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
89    for ControlCreatePacketStreamResponse
90{
91}
92
93#[derive(Debug, Default, PartialEq)]
94pub struct ControlCreateRingBufferResponse {
95    /// Properties about the ring buffer and active audio stream as created.
96    pub properties: Option<RingBufferProperties>,
97    /// An object that represents the audio stream and ring memory itself.
98    /// Note: ring-buffer VMO memory ranges must be cache-invalidated before
99    /// each read, and cache-flushed after each write.
100    pub ring_buffer: Option<fidl_fuchsia_audio::RingBuffer>,
101    #[doc(hidden)]
102    pub __source_breaking: fidl::marker::SourceBreaking,
103}
104
105impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
106    for ControlCreateRingBufferResponse
107{
108}
109
110#[derive(Debug, Default, PartialEq)]
111pub struct ObserverGetReferenceClockResponse {
112    /// The device's reference clock.
113    pub reference_clock: Option<fidl::Clock>,
114    #[doc(hidden)]
115    pub __source_breaking: fidl::marker::SourceBreaking,
116}
117
118impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
119    for ObserverGetReferenceClockResponse
120{
121}
122
123#[derive(Debug, Default, PartialEq)]
124pub struct PacketStreamBuffers {
125    /// Information about the VMOs used for this stream.
126    /// Populated if `allocate_info` was requested or if `register_info` was
127    /// passed in options.
128    ///
129    /// Optional.
130    pub vmo_infos: Option<Vec<fidl_fuchsia_hardware_audio::VmoInfo>>,
131    #[doc(hidden)]
132    pub __source_breaking: fidl::marker::SourceBreaking,
133}
134
135impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PacketStreamBuffers {}
136
137/// Parameters specified by a caller when creating a packet stream.
138#[derive(Debug, Default, PartialEq)]
139pub struct PacketStreamOptions {
140    /// The format (sample format, channelization, frame rate, encoding) of the
141    /// packet stream to be created.
142    ///
143    /// Required.
144    pub format: Option<PacketStreamFormat>,
145    #[doc(hidden)]
146    pub __source_breaking: fidl::marker::SourceBreaking,
147}
148
149impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PacketStreamOptions {}
150
151/// Information about the associated audio stream.
152#[derive(Debug, Default, PartialEq)]
153pub struct PacketStreamProperties {
154    /// The channel used to transmit audio data packets.
155    ///
156    /// Required.
157    pub data_sink:
158        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::PacketStreamSinkMarker>>,
159    /// The negotiated format of the audio data in the buffer.
160    ///
161    /// Required.
162    pub format: Option<PacketStreamFormat>,
163    /// The number of valid bits per sample.
164    ///
165    /// Required, if `format.pcm_format` is set.
166    pub valid_bits_per_sample: Option<u8>,
167    /// The memory ownership models supported by the driver for this stream.
168    ///
169    /// Required.
170    pub supported_buffer_types: Option<fidl_fuchsia_hardware_audio::BufferType>,
171    #[doc(hidden)]
172    pub __source_breaking: fidl::marker::SourceBreaking,
173}
174
175impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PacketStreamProperties {}
176
177#[derive(Debug, Default, PartialEq)]
178pub struct PacketStreamSetBuffersRequest {
179    /// Setup information for audio data transfer.
180    /// The options chosen should be supported by the driver as reported
181    /// in `PacketStreamProperties.supported_buffer_types`.
182    ///
183    /// Required.
184    pub vmo_info: Option<PacketStreamSetupVmoInfo>,
185    #[doc(hidden)]
186    pub __source_breaking: fidl::marker::SourceBreaking,
187}
188
189impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
190    for PacketStreamSetBuffersRequest
191{
192}
193
194#[derive(Debug, Default, PartialEq)]
195pub struct PacketStreamSetBuffersResponse {
196    /// An object that contains shared memory buffers required to transfer audio data.
197    ///
198    /// Note: The client must ensure proper cache coherency for the VMOs contained
199    /// within this struct. Memory ranges must be cache-invalidated before reads
200    /// (for capture) and cache-flushed after writes (for playback) if the
201    /// properties indicate a non-coherent domain.
202    pub packet_stream: Option<PacketStreamBuffers>,
203    #[doc(hidden)]
204    pub __source_breaking: fidl::marker::SourceBreaking,
205}
206
207impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
208    for PacketStreamSetBuffersResponse
209{
210}
211
212#[derive(Debug, Default, PartialEq)]
213pub struct ProviderAddDeviceRequest {
214    /// The device's high-level name. Must not be an empty string.
215    ///
216    /// Required.
217    pub device_name: Option<String>,
218    /// Indicates the protocol used by the device.
219    ///
220    /// Required.
221    pub device_type: Option<DeviceType>,
222    /// The client_end of the protocol channel (Codec or Composite)
223    /// that this service will use to configure/observe the device.
224    ///
225    /// Required.
226    /// # Deprecation
227    ///
228    /// Codec is not supported anymore, instead use an
229    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
230    /// , see
231    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
232    pub driver_client: Option<DriverClient>,
233    #[doc(hidden)]
234    pub __source_breaking: fidl::marker::SourceBreaking,
235}
236
237impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ProviderAddDeviceRequest {}
238
239#[derive(Debug, Default, PartialEq)]
240pub struct RegistryCreateObserverRequest {
241    /// The token of the device to be observed.
242    ///
243    /// Required.
244    pub token_id: Option<u64>,
245    /// The server end of the `Observer` that will be created.
246    ///
247    /// Required.
248    pub observer_server: Option<fidl::endpoints::ServerEnd<ObserverMarker>>,
249    #[doc(hidden)]
250    pub __source_breaking: fidl::marker::SourceBreaking,
251}
252
253impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
254    for RegistryCreateObserverRequest
255{
256}
257
258/// The protocol channel used to configure and observe a device.
259/// # Deprecation
260///
261/// Codec drivers are not supported anymore, instead use an
262/// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite), see
263/// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
264#[derive(Debug)]
265pub enum DriverClient {
266    /// Populated for drivers that use the `fuchsia_hardware_audio.Codec` interface.
267    Codec(fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CodecMarker>),
268    /// Populated for drivers that use the `fuchsia_hardware_audio.Composite` interface.
269    Composite(fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CompositeMarker>),
270    #[doc(hidden)]
271    __SourceBreaking { unknown_ordinal: u64 },
272}
273
274/// Pattern that matches an unknown `DriverClient` member.
275#[macro_export]
276macro_rules! DriverClientUnknown {
277    () => {
278        _
279    };
280}
281
282// Custom PartialEq so that unknown variants are not equal to themselves.
283impl PartialEq for DriverClient {
284    fn eq(&self, other: &Self) -> bool {
285        match (self, other) {
286            (Self::Codec(x), Self::Codec(y)) => *x == *y,
287            (Self::Composite(x), Self::Composite(y)) => *x == *y,
288            _ => false,
289        }
290    }
291}
292
293impl DriverClient {
294    #[inline]
295    pub fn ordinal(&self) -> u64 {
296        match *self {
297            Self::Codec(_) => 1,
298            Self::Composite(_) => 2,
299            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
300        }
301    }
302
303    #[inline]
304    pub fn unknown_variant_for_testing() -> Self {
305        Self::__SourceBreaking { unknown_ordinal: 0 }
306    }
307
308    #[inline]
309    pub fn is_unknown(&self) -> bool {
310        match self {
311            Self::__SourceBreaking { .. } => true,
312            _ => false,
313        }
314    }
315}
316
317impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DriverClient {}
318
319/// Configuration for VMO allocation or registration.
320#[derive(Debug)]
321pub enum PacketStreamSetupVmoInfo {
322    /// Configuration for driver-allocated VMOs.
323    AllocateInfo(fidl_fuchsia_hardware_audio::AllocateVmosConfig),
324    /// Configuration for client-allocated (registered) VMOs.
325    RegisterInfo(fidl_fuchsia_hardware_audio::RegisterVmosConfig),
326    #[doc(hidden)]
327    __SourceBreaking { unknown_ordinal: u64 },
328}
329
330/// Pattern that matches an unknown `PacketStreamSetupVmoInfo` member.
331#[macro_export]
332macro_rules! PacketStreamSetupVmoInfoUnknown {
333    () => {
334        _
335    };
336}
337
338// Custom PartialEq so that unknown variants are not equal to themselves.
339impl PartialEq for PacketStreamSetupVmoInfo {
340    fn eq(&self, other: &Self) -> bool {
341        match (self, other) {
342            (Self::AllocateInfo(x), Self::AllocateInfo(y)) => *x == *y,
343            (Self::RegisterInfo(x), Self::RegisterInfo(y)) => *x == *y,
344            _ => false,
345        }
346    }
347}
348
349impl PacketStreamSetupVmoInfo {
350    #[inline]
351    pub fn ordinal(&self) -> u64 {
352        match *self {
353            Self::AllocateInfo(_) => 1,
354            Self::RegisterInfo(_) => 2,
355            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
356        }
357    }
358
359    #[inline]
360    pub fn unknown_variant_for_testing() -> Self {
361        Self::__SourceBreaking { unknown_ordinal: 0 }
362    }
363
364    #[inline]
365    pub fn is_unknown(&self) -> bool {
366        match self {
367            Self::__SourceBreaking { .. } => true,
368            _ => false,
369        }
370    }
371}
372
373impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PacketStreamSetupVmoInfo {}
374
375#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
376pub struct ControlMarker;
377
378impl fidl::endpoints::ProtocolMarker for ControlMarker {
379    type Proxy = ControlProxy;
380    type RequestStream = ControlRequestStream;
381    #[cfg(target_os = "fuchsia")]
382    type SynchronousProxy = ControlSynchronousProxy;
383
384    const DEBUG_NAME: &'static str = "(anonymous) Control";
385}
386pub type ControlCreateRingBufferResult =
387    Result<ControlCreateRingBufferResponse, ControlCreateRingBufferError>;
388pub type ControlCreatePacketStreamResult =
389    Result<ControlCreatePacketStreamResponse, ControlCreatePacketStreamError>;
390pub type ControlSetDaiFormatResult = Result<ControlSetDaiFormatResponse, ControlSetDaiFormatError>;
391pub type ControlCodecStartResult = Result<ControlCodecStartResponse, ControlCodecStartError>;
392pub type ControlCodecStopResult = Result<ControlCodecStopResponse, ControlCodecStopError>;
393pub type ControlResetResult = Result<ControlResetResponse, ControlResetError>;
394
395pub trait ControlProxyInterface: Send + Sync {
396    type GetElementsResponseFut: std::future::Future<
397            Output = Result<
398                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
399                fidl::Error,
400            >,
401        > + Send;
402    fn r#get_elements(&self) -> Self::GetElementsResponseFut;
403    type WatchElementStateResponseFut: std::future::Future<
404            Output = Result<
405                fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
406                fidl::Error,
407            >,
408        > + Send;
409    fn r#watch_element_state(
410        &self,
411        processing_element_id: u64,
412    ) -> Self::WatchElementStateResponseFut;
413    type GetTopologiesResponseFut: std::future::Future<
414            Output = Result<
415                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
416                fidl::Error,
417            >,
418        > + Send;
419    fn r#get_topologies(&self) -> Self::GetTopologiesResponseFut;
420    type WatchTopologyResponseFut: std::future::Future<Output = Result<u64, fidl::Error>> + Send;
421    fn r#watch_topology(&self) -> Self::WatchTopologyResponseFut;
422    type SetTopologyResponseFut: std::future::Future<
423            Output = Result<
424                fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyResult,
425                fidl::Error,
426            >,
427        > + Send;
428    fn r#set_topology(&self, topology_id: u64) -> Self::SetTopologyResponseFut;
429    type SetElementStateResponseFut: std::future::Future<
430            Output = Result<
431                fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateResult,
432                fidl::Error,
433            >,
434        > + Send;
435    fn r#set_element_state(
436        &self,
437        processing_element_id: u64,
438        state: &fidl_fuchsia_hardware_audio_signalprocessing::SettableElementState,
439    ) -> Self::SetElementStateResponseFut;
440    type CreateRingBufferResponseFut: std::future::Future<Output = Result<ControlCreateRingBufferResult, fidl::Error>>
441        + Send;
442    fn r#create_ring_buffer(
443        &self,
444        payload: ControlCreateRingBufferRequest,
445    ) -> Self::CreateRingBufferResponseFut;
446    type CreatePacketStreamResponseFut: std::future::Future<Output = Result<ControlCreatePacketStreamResult, fidl::Error>>
447        + Send;
448    fn r#create_packet_stream(
449        &self,
450        payload: ControlCreatePacketStreamRequest,
451    ) -> Self::CreatePacketStreamResponseFut;
452    type SetDaiFormatResponseFut: std::future::Future<Output = Result<ControlSetDaiFormatResult, fidl::Error>>
453        + Send;
454    fn r#set_dai_format(
455        &self,
456        payload: &ControlSetDaiFormatRequest,
457    ) -> Self::SetDaiFormatResponseFut;
458    type CodecStartResponseFut: std::future::Future<Output = Result<ControlCodecStartResult, fidl::Error>>
459        + Send;
460    fn r#codec_start(&self) -> Self::CodecStartResponseFut;
461    type CodecStopResponseFut: std::future::Future<Output = Result<ControlCodecStopResult, fidl::Error>>
462        + Send;
463    fn r#codec_stop(&self) -> Self::CodecStopResponseFut;
464    type ResetResponseFut: std::future::Future<Output = Result<ControlResetResult, fidl::Error>>
465        + Send;
466    fn r#reset(&self) -> Self::ResetResponseFut;
467}
468#[derive(Debug)]
469#[cfg(target_os = "fuchsia")]
470pub struct ControlSynchronousProxy {
471    client: fidl::client::sync::Client,
472}
473
474#[cfg(target_os = "fuchsia")]
475impl fidl::endpoints::SynchronousProxy for ControlSynchronousProxy {
476    type Proxy = ControlProxy;
477    type Protocol = ControlMarker;
478
479    fn from_channel(inner: fidl::Channel) -> Self {
480        Self::new(inner)
481    }
482
483    fn into_channel(self) -> fidl::Channel {
484        self.client.into_channel()
485    }
486
487    fn as_channel(&self) -> &fidl::Channel {
488        self.client.as_channel()
489    }
490}
491
492#[cfg(target_os = "fuchsia")]
493impl ControlSynchronousProxy {
494    pub fn new(channel: fidl::Channel) -> Self {
495        Self { client: fidl::client::sync::Client::new(channel) }
496    }
497
498    pub fn into_channel(self) -> fidl::Channel {
499        self.client.into_channel()
500    }
501
502    /// Waits until an event arrives and returns it. It is safe for other
503    /// threads to make concurrent requests while waiting for an event.
504    pub fn wait_for_event(
505        &self,
506        deadline: zx::MonotonicInstant,
507    ) -> Result<ControlEvent, fidl::Error> {
508        ControlEvent::decode(self.client.wait_for_event::<ControlMarker>(deadline)?)
509    }
510
511    /// Returns a vector of supported processing elements.
512    /// This vector must include one or more processing elements.
513    pub fn r#get_elements(
514        &self,
515        ___deadline: zx::MonotonicInstant,
516    ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult, fidl::Error>
517    {
518        let _response =
519            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
520                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResponse,
521                i32,
522            >, ControlMarker>(
523                (),
524                0x1b14ff4adf5dc6f8,
525                fidl::encoding::DynamicFlags::empty(),
526                ___deadline,
527            )?;
528        Ok(_response.map(|x| x.processing_elements))
529    }
530
531    /// Get the processing element state via a hanging get.
532    /// For a given `processing_element_id`, the driver will immediately reply to the first
533    /// `WatchElementState` sent by the client. The driver will not respond to subsequent client
534    /// `WatchElementState` calls for that `processing_element_id` until any portion of the
535    /// `ElementState` has changed from what was most recently reported for that element.
536    ///
537    /// The driver will close the protocol channel with an error of `ZX_ERR_INVALID_ARGS`, if
538    /// `processing_element_id` does not match an ElementId returned by `GetElements`.
539    ///
540    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
541    /// method is called again while there is already a pending `WatchElementState` for this client
542    /// and `processing_element_id`.
543    pub fn r#watch_element_state(
544        &self,
545        mut processing_element_id: u64,
546        ___deadline: zx::MonotonicInstant,
547    ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ElementState, fidl::Error> {
548        let _response = self.client.send_query::<
549            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest,
550            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateResponse,
551            ControlMarker,
552        >(
553            (processing_element_id,),
554            0x524da8772a69056f,
555            fidl::encoding::DynamicFlags::empty(),
556            ___deadline,
557        )?;
558        Ok(_response.state)
559    }
560
561    /// Returns a vector of supported topologies.
562    /// This vector must include one or more topologies.
563    /// If more than one topology is returned, then the client may select any topology from the
564    /// list by calling `SetTopology`.
565    /// If only one topology is returned, `SetTopology` can still be called but causes no change.
566    ///
567    /// Each Element must be included in at least one Topology, but need not be included in every
568    /// Topology.
569    pub fn r#get_topologies(
570        &self,
571        ___deadline: zx::MonotonicInstant,
572    ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult, fidl::Error>
573    {
574        let _response =
575            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
576                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResponse,
577                i32,
578            >, ControlMarker>(
579                (),
580                0x73ffb73af24d30b6,
581                fidl::encoding::DynamicFlags::empty(),
582                ___deadline,
583            )?;
584        Ok(_response.map(|x| x.topologies))
585    }
586
587    /// Get the current topology via a hanging get.
588    /// The driver will immediately reply to the first `WatchTopology` sent by each client.
589    /// The driver will not respond to subsequent `WatchTopology` calls from that client until the
590    /// signal processing topology changes; this occurs as a result of a `SetTopology` call.
591    ///
592    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
593    /// method is called again while there is already a pending `WatchTopology` for this client.
594    pub fn r#watch_topology(&self, ___deadline: zx::MonotonicInstant) -> Result<u64, fidl::Error> {
595        let _response = self
596            .client
597            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleType<
598                fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchTopologyResponse,
599            >, ControlMarker>(
600                (),
601                0x66d172acdb36a729,
602                fidl::encoding::DynamicFlags::FLEXIBLE,
603                ___deadline,
604            )?
605            .into_result::<ControlMarker>("watch_topology")?;
606        Ok(_response.topology_id)
607    }
608
609    /// Sets the currently active topology by specifying a `topology_id`, which matches to an entry
610    /// in the vector returned by `GetTopologies`.
611    /// The currently active topology is communicated by `WatchTopology` responses. To change which
612    /// topology is active, a client uses `SetTopology`.
613    ///
614    /// If `GetTopologies` returns only one `Topology`, `SetTopology` is optional and has no effect.
615    ///
616    /// This call will fail and return `ZX_ERR_INVALID_ARGS` if the specified `topology_id` is not
617    /// found within the`topologies` returned by `GetTopologies`.
618    ///
619    /// `SetTopology` may be called before or after non-`SignalProcessing` protocol calls.
620    /// If called after non-`SignalProcessing` protocol calls, then `SetTopology` may return
621    /// `ZX_ERR_BAD_STATE` to indicate that the operation can not proceed without renegotiation of
622    /// the driver state. See `SetElementState` for further discussion.
623    pub fn r#set_topology(
624        &self,
625        mut topology_id: u64,
626        ___deadline: zx::MonotonicInstant,
627    ) -> Result<
628        fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyResult,
629        fidl::Error,
630    > {
631        let _response = self.client.send_query::<
632            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyRequest,
633            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
634            ControlMarker,
635        >(
636            (topology_id,),
637            0x1d9a7f9b8fee790c,
638            fidl::encoding::DynamicFlags::empty(),
639            ___deadline,
640        )?;
641        Ok(_response.map(|x| x))
642    }
643
644    /// Controls the processing element specified by `processing_element_id`, a unique ElementId
645    /// returned by `GetElements`.
646    /// The `state` specified in calls to `SetElementState` is a `SettableElementState`. This is a
647    /// subset of `ElementState` because some fields returned by `WatchElementState` (e.g. `latency`
648    /// or `plug_state`) can only be observed (not set) by the client.
649    ///
650    /// Returns `ZX_ERR_INVALID_ARGS` if `processing_element_id` does not match a known ElementId
651    /// returned by `GetElements`, or if `state` is not valid for the element. This entails any
652    /// violation of the rules specified in this protocol.
653    ///
654    /// Examples:
655    /// `state` specifies that an element should be stopped or bypassed, but the corresponding
656    ///     element does not specify (or explicitly set to false) `can_stop` or `can_bypass`.
657    /// `state` includes a `type_specific` entry, but that `SettableTypeSpecificElementState` does
658    ///     not match the `ElementType` of the element corresponding to `processing_element_id`.
659    /// `state` changes an `EqualizerBandState` for an `EQUALIZER` element (so far so good), but
660    ///     specifies a change to `frequency` when this element did not set `CAN_CONTROL_FREQUENCY`
661    ///     in its `supported_controls`.
662    /// `state` specifies a `GainElementState` for a `GAIN` element with a `gain` value that is
663    ///     -infinity, NAN, or outside the Element's stated [`min_gain`, `max_gain`] range.
664    ///
665    /// Callers may intersperse method calls to the `SignalProcessing` protocol with calls to other
666    /// driver protocols. Some non-`SignalProcessing` configuration changes may require a
667    /// renegotiation of the driver state before certain elements can receive a `SetElementState`.
668    /// For example, if a `DaiFormat` is changed, then `SetElementState` changing an `AGL` element's
669    /// parameters may not require renegotiation of driver state because changing gain parameters
670    /// usually does not change the set of supported audio formats.
671    /// By contrast, following the same `DaiFormat` change, before `SetElementState` can be called
672    /// on a `CONNECTION_POINT` element, the driver state may need to be reestablished because the
673    /// format change may invalidate the set of supported formats returned in a previous
674    /// `GetDaiFormats` protocol call for another part of the Topology.
675    ///
676    /// It is the driver's job to determine when renegotiation is required. When this is needed,
677    /// the related `SetElementState` call must return `ZX_ERR_BAD_STATE` and the client must
678    /// close the protocol channel entirely, such that the protocol negotiations are started over.
679    /// The client then must re-invoke the `SetElementState` call that returned
680    /// `ZX_ERR_BAD_STATE` before any non-`SignalProcessing` protocol calls.
681    pub fn r#set_element_state(
682        &self,
683        mut processing_element_id: u64,
684        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::SettableElementState,
685        ___deadline: zx::MonotonicInstant,
686    ) -> Result<
687        fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateResult,
688        fidl::Error,
689    > {
690        let _response = self.client.send_query::<
691            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateRequest,
692            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
693            ControlMarker,
694        >(
695            (processing_element_id, state,),
696            0x38c3b2d4bae698f4,
697            fidl::encoding::DynamicFlags::empty(),
698            ___deadline,
699        )?;
700        Ok(_response.map(|x| x))
701    }
702
703    /// Create the ring buffer used to pass audio to/from this device. If the device is
704    /// Composite, then the targeted RING_BUFFER element must be identified by `element_id`.
705    ///
706    /// Should only be called for Composite devices.
707    pub fn r#create_ring_buffer(
708        &self,
709        mut payload: ControlCreateRingBufferRequest,
710        ___deadline: zx::MonotonicInstant,
711    ) -> Result<ControlCreateRingBufferResult, fidl::Error> {
712        let _response = self
713            .client
714            .send_query::<ControlCreateRingBufferRequest, fidl::encoding::FlexibleResultType<
715                ControlCreateRingBufferResponse,
716                ControlCreateRingBufferError,
717            >, ControlMarker>(
718                &mut payload,
719                0x7462941cedb333db,
720                fidl::encoding::DynamicFlags::FLEXIBLE,
721                ___deadline,
722            )?
723            .into_result::<ControlMarker>("create_ring_buffer")?;
724        Ok(_response.map(|x| x))
725    }
726
727    /// Set the wire format for the digital interconnect associated with this element.
728    /// Creates a packet stream on the specified element.
729    pub fn r#create_packet_stream(
730        &self,
731        mut payload: ControlCreatePacketStreamRequest,
732        ___deadline: zx::MonotonicInstant,
733    ) -> Result<ControlCreatePacketStreamResult, fidl::Error> {
734        let _response = self
735            .client
736            .send_query::<ControlCreatePacketStreamRequest, fidl::encoding::FlexibleResultType<
737                ControlCreatePacketStreamResponse,
738                ControlCreatePacketStreamError,
739            >, ControlMarker>(
740                &mut payload,
741                0x5b2eacb5ad7df289,
742                fidl::encoding::DynamicFlags::FLEXIBLE,
743                ___deadline,
744            )?
745            .into_result::<ControlMarker>("create_packet_stream")?;
746        Ok(_response.map(|x| x))
747    }
748
749    /// Set the wire format for the digital interconnect connected to this Codec endpoint.
750    /// This method returns information related to the format that was set, including delay values.
751    /// If the device is Composite, then the targeted DAI_INTERCONNECT element must be identified
752    /// by `element_id`.
753    ///
754    /// Should only be called for Codec and Composite devices.
755    pub fn r#set_dai_format(
756        &self,
757        mut payload: &ControlSetDaiFormatRequest,
758        ___deadline: zx::MonotonicInstant,
759    ) -> Result<ControlSetDaiFormatResult, fidl::Error> {
760        let _response = self
761            .client
762            .send_query::<ControlSetDaiFormatRequest, fidl::encoding::FlexibleResultType<
763                ControlSetDaiFormatResponse,
764                ControlSetDaiFormatError,
765            >, ControlMarker>(
766                payload,
767                0x1d84f5a456a92216,
768                fidl::encoding::DynamicFlags::FLEXIBLE,
769                ___deadline,
770            )?
771            .into_result::<ControlMarker>("set_dai_format")?;
772        Ok(_response.map(|x| x))
773    }
774
775    /// Start the Codec hardware. If successful, this returns after the Codec was started and
776    /// `start_time` indicates the time when the hardware started. Note that the Codec's DaiFormat
777    /// must be set (by a successful `SetDaiFormat` call) before calling this method.
778    ///
779    /// Should only be called for Codec devices.
780    pub fn r#codec_start(
781        &self,
782        ___deadline: zx::MonotonicInstant,
783    ) -> Result<ControlCodecStartResult, fidl::Error> {
784        let _response =
785            self.client
786                .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
787                    ControlCodecStartResponse,
788                    ControlCodecStartError,
789                >, ControlMarker>(
790                    (),
791                    0x2a90a9d2958b997b,
792                    fidl::encoding::DynamicFlags::FLEXIBLE,
793                    ___deadline,
794                )?
795                .into_result::<ControlMarker>("codec_start")?;
796        Ok(_response.map(|x| x))
797    }
798
799    /// Stop the Codec hardware. If successful, this returns after the Codec was stopped and
800    /// `stop_time` indicates the time when the hardware stopped. Note that the Codec's DaiFormat
801    /// must be set (by a successful `SetDaiFormat` call) before calling this method.
802    ///
803    /// Should only be called for Codec devices.
804    pub fn r#codec_stop(
805        &self,
806        ___deadline: zx::MonotonicInstant,
807    ) -> Result<ControlCodecStopResult, fidl::Error> {
808        let _response = self.client.send_query::<
809            fidl::encoding::EmptyPayload,
810            fidl::encoding::FlexibleResultType<ControlCodecStopResponse, ControlCodecStopError>,
811            ControlMarker,
812        >(
813            (),
814            0x387297bb6bcad25f,
815            fidl::encoding::DynamicFlags::FLEXIBLE,
816            ___deadline,
817        )?
818        .into_result::<ControlMarker>("codec_stop")?;
819        Ok(_response.map(|x| x))
820    }
821
822    /// Reset the hardware -- stopping the hardware, releasing any ring buffers, and clearing any
823    /// DaiFormats or RingBufferFormats that were set.
824    ///
825    /// This method returns when the hardware reset is complete.
826    /// After calling this method, the device is still controlled, but any ring buffers must be
827    /// re-created and re-started.
828    /// For devices with DAI_INTERCONNECTs (such as Codecs and some Composites), `SetDaiFormat` and
829    /// `CodecStart` must be called again (in that order) to return the interconnect to the active
830    /// operational mode.
831    /// As applicable, `SetTopology` and `SetElementState` must also be called.
832    ///
833    /// Should only be called for Codec and Composite devices.
834    pub fn r#reset(
835        &self,
836        ___deadline: zx::MonotonicInstant,
837    ) -> Result<ControlResetResult, fidl::Error> {
838        let _response = self.client.send_query::<
839            fidl::encoding::EmptyPayload,
840            fidl::encoding::FlexibleResultType<ControlResetResponse, ControlResetError>,
841            ControlMarker,
842        >(
843            (),
844            0x49840db00a698996,
845            fidl::encoding::DynamicFlags::FLEXIBLE,
846            ___deadline,
847        )?
848        .into_result::<ControlMarker>("reset")?;
849        Ok(_response.map(|x| x))
850    }
851}
852
853#[cfg(target_os = "fuchsia")]
854impl From<ControlSynchronousProxy> for zx::NullableHandle {
855    fn from(value: ControlSynchronousProxy) -> Self {
856        value.into_channel().into()
857    }
858}
859
860#[cfg(target_os = "fuchsia")]
861impl From<fidl::Channel> for ControlSynchronousProxy {
862    fn from(value: fidl::Channel) -> Self {
863        Self::new(value)
864    }
865}
866
867#[cfg(target_os = "fuchsia")]
868impl fidl::endpoints::FromClient for ControlSynchronousProxy {
869    type Protocol = ControlMarker;
870
871    fn from_client(value: fidl::endpoints::ClientEnd<ControlMarker>) -> Self {
872        Self::new(value.into_channel())
873    }
874}
875
876#[derive(Debug, Clone)]
877pub struct ControlProxy {
878    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
879}
880
881impl fidl::endpoints::Proxy for ControlProxy {
882    type Protocol = ControlMarker;
883
884    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
885        Self::new(inner)
886    }
887
888    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
889        self.client.into_channel().map_err(|client| Self { client })
890    }
891
892    fn as_channel(&self) -> &::fidl::AsyncChannel {
893        self.client.as_channel()
894    }
895}
896
897impl ControlProxy {
898    /// Create a new Proxy for fuchsia.audio.device/Control.
899    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
900        let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
901        Self { client: fidl::client::Client::new(channel, protocol_name) }
902    }
903
904    /// Get a Stream of events from the remote end of the protocol.
905    ///
906    /// # Panics
907    ///
908    /// Panics if the event stream was already taken.
909    pub fn take_event_stream(&self) -> ControlEventStream {
910        ControlEventStream { event_receiver: self.client.take_event_receiver() }
911    }
912
913    /// Returns a vector of supported processing elements.
914    /// This vector must include one or more processing elements.
915    pub fn r#get_elements(
916        &self,
917    ) -> fidl::client::QueryResponseFut<
918        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
919        fidl::encoding::DefaultFuchsiaResourceDialect,
920    > {
921        ControlProxyInterface::r#get_elements(self)
922    }
923
924    /// Get the processing element state via a hanging get.
925    /// For a given `processing_element_id`, the driver will immediately reply to the first
926    /// `WatchElementState` sent by the client. The driver will not respond to subsequent client
927    /// `WatchElementState` calls for that `processing_element_id` until any portion of the
928    /// `ElementState` has changed from what was most recently reported for that element.
929    ///
930    /// The driver will close the protocol channel with an error of `ZX_ERR_INVALID_ARGS`, if
931    /// `processing_element_id` does not match an ElementId returned by `GetElements`.
932    ///
933    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
934    /// method is called again while there is already a pending `WatchElementState` for this client
935    /// and `processing_element_id`.
936    pub fn r#watch_element_state(
937        &self,
938        mut processing_element_id: u64,
939    ) -> fidl::client::QueryResponseFut<
940        fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
941        fidl::encoding::DefaultFuchsiaResourceDialect,
942    > {
943        ControlProxyInterface::r#watch_element_state(self, processing_element_id)
944    }
945
946    /// Returns a vector of supported topologies.
947    /// This vector must include one or more topologies.
948    /// If more than one topology is returned, then the client may select any topology from the
949    /// list by calling `SetTopology`.
950    /// If only one topology is returned, `SetTopology` can still be called but causes no change.
951    ///
952    /// Each Element must be included in at least one Topology, but need not be included in every
953    /// Topology.
954    pub fn r#get_topologies(
955        &self,
956    ) -> fidl::client::QueryResponseFut<
957        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
958        fidl::encoding::DefaultFuchsiaResourceDialect,
959    > {
960        ControlProxyInterface::r#get_topologies(self)
961    }
962
963    /// Get the current topology via a hanging get.
964    /// The driver will immediately reply to the first `WatchTopology` sent by each client.
965    /// The driver will not respond to subsequent `WatchTopology` calls from that client until the
966    /// signal processing topology changes; this occurs as a result of a `SetTopology` call.
967    ///
968    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
969    /// method is called again while there is already a pending `WatchTopology` for this client.
970    pub fn r#watch_topology(
971        &self,
972    ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
973        ControlProxyInterface::r#watch_topology(self)
974    }
975
976    /// Sets the currently active topology by specifying a `topology_id`, which matches to an entry
977    /// in the vector returned by `GetTopologies`.
978    /// The currently active topology is communicated by `WatchTopology` responses. To change which
979    /// topology is active, a client uses `SetTopology`.
980    ///
981    /// If `GetTopologies` returns only one `Topology`, `SetTopology` is optional and has no effect.
982    ///
983    /// This call will fail and return `ZX_ERR_INVALID_ARGS` if the specified `topology_id` is not
984    /// found within the`topologies` returned by `GetTopologies`.
985    ///
986    /// `SetTopology` may be called before or after non-`SignalProcessing` protocol calls.
987    /// If called after non-`SignalProcessing` protocol calls, then `SetTopology` may return
988    /// `ZX_ERR_BAD_STATE` to indicate that the operation can not proceed without renegotiation of
989    /// the driver state. See `SetElementState` for further discussion.
990    pub fn r#set_topology(
991        &self,
992        mut topology_id: u64,
993    ) -> fidl::client::QueryResponseFut<
994        fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyResult,
995        fidl::encoding::DefaultFuchsiaResourceDialect,
996    > {
997        ControlProxyInterface::r#set_topology(self, topology_id)
998    }
999
1000    /// Controls the processing element specified by `processing_element_id`, a unique ElementId
1001    /// returned by `GetElements`.
1002    /// The `state` specified in calls to `SetElementState` is a `SettableElementState`. This is a
1003    /// subset of `ElementState` because some fields returned by `WatchElementState` (e.g. `latency`
1004    /// or `plug_state`) can only be observed (not set) by the client.
1005    ///
1006    /// Returns `ZX_ERR_INVALID_ARGS` if `processing_element_id` does not match a known ElementId
1007    /// returned by `GetElements`, or if `state` is not valid for the element. This entails any
1008    /// violation of the rules specified in this protocol.
1009    ///
1010    /// Examples:
1011    /// `state` specifies that an element should be stopped or bypassed, but the corresponding
1012    ///     element does not specify (or explicitly set to false) `can_stop` or `can_bypass`.
1013    /// `state` includes a `type_specific` entry, but that `SettableTypeSpecificElementState` does
1014    ///     not match the `ElementType` of the element corresponding to `processing_element_id`.
1015    /// `state` changes an `EqualizerBandState` for an `EQUALIZER` element (so far so good), but
1016    ///     specifies a change to `frequency` when this element did not set `CAN_CONTROL_FREQUENCY`
1017    ///     in its `supported_controls`.
1018    /// `state` specifies a `GainElementState` for a `GAIN` element with a `gain` value that is
1019    ///     -infinity, NAN, or outside the Element's stated [`min_gain`, `max_gain`] range.
1020    ///
1021    /// Callers may intersperse method calls to the `SignalProcessing` protocol with calls to other
1022    /// driver protocols. Some non-`SignalProcessing` configuration changes may require a
1023    /// renegotiation of the driver state before certain elements can receive a `SetElementState`.
1024    /// For example, if a `DaiFormat` is changed, then `SetElementState` changing an `AGL` element's
1025    /// parameters may not require renegotiation of driver state because changing gain parameters
1026    /// usually does not change the set of supported audio formats.
1027    /// By contrast, following the same `DaiFormat` change, before `SetElementState` can be called
1028    /// on a `CONNECTION_POINT` element, the driver state may need to be reestablished because the
1029    /// format change may invalidate the set of supported formats returned in a previous
1030    /// `GetDaiFormats` protocol call for another part of the Topology.
1031    ///
1032    /// It is the driver's job to determine when renegotiation is required. When this is needed,
1033    /// the related `SetElementState` call must return `ZX_ERR_BAD_STATE` and the client must
1034    /// close the protocol channel entirely, such that the protocol negotiations are started over.
1035    /// The client then must re-invoke the `SetElementState` call that returned
1036    /// `ZX_ERR_BAD_STATE` before any non-`SignalProcessing` protocol calls.
1037    pub fn r#set_element_state(
1038        &self,
1039        mut processing_element_id: u64,
1040        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::SettableElementState,
1041    ) -> fidl::client::QueryResponseFut<
1042        fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateResult,
1043        fidl::encoding::DefaultFuchsiaResourceDialect,
1044    > {
1045        ControlProxyInterface::r#set_element_state(self, processing_element_id, state)
1046    }
1047
1048    /// Create the ring buffer used to pass audio to/from this device. If the device is
1049    /// Composite, then the targeted RING_BUFFER element must be identified by `element_id`.
1050    ///
1051    /// Should only be called for Composite devices.
1052    pub fn r#create_ring_buffer(
1053        &self,
1054        mut payload: ControlCreateRingBufferRequest,
1055    ) -> fidl::client::QueryResponseFut<
1056        ControlCreateRingBufferResult,
1057        fidl::encoding::DefaultFuchsiaResourceDialect,
1058    > {
1059        ControlProxyInterface::r#create_ring_buffer(self, payload)
1060    }
1061
1062    /// Set the wire format for the digital interconnect associated with this element.
1063    /// Creates a packet stream on the specified element.
1064    pub fn r#create_packet_stream(
1065        &self,
1066        mut payload: ControlCreatePacketStreamRequest,
1067    ) -> fidl::client::QueryResponseFut<
1068        ControlCreatePacketStreamResult,
1069        fidl::encoding::DefaultFuchsiaResourceDialect,
1070    > {
1071        ControlProxyInterface::r#create_packet_stream(self, payload)
1072    }
1073
1074    /// Set the wire format for the digital interconnect connected to this Codec endpoint.
1075    /// This method returns information related to the format that was set, including delay values.
1076    /// If the device is Composite, then the targeted DAI_INTERCONNECT element must be identified
1077    /// by `element_id`.
1078    ///
1079    /// Should only be called for Codec and Composite devices.
1080    pub fn r#set_dai_format(
1081        &self,
1082        mut payload: &ControlSetDaiFormatRequest,
1083    ) -> fidl::client::QueryResponseFut<
1084        ControlSetDaiFormatResult,
1085        fidl::encoding::DefaultFuchsiaResourceDialect,
1086    > {
1087        ControlProxyInterface::r#set_dai_format(self, payload)
1088    }
1089
1090    /// Start the Codec hardware. If successful, this returns after the Codec was started and
1091    /// `start_time` indicates the time when the hardware started. Note that the Codec's DaiFormat
1092    /// must be set (by a successful `SetDaiFormat` call) before calling this method.
1093    ///
1094    /// Should only be called for Codec devices.
1095    pub fn r#codec_start(
1096        &self,
1097    ) -> fidl::client::QueryResponseFut<
1098        ControlCodecStartResult,
1099        fidl::encoding::DefaultFuchsiaResourceDialect,
1100    > {
1101        ControlProxyInterface::r#codec_start(self)
1102    }
1103
1104    /// Stop the Codec hardware. If successful, this returns after the Codec was stopped and
1105    /// `stop_time` indicates the time when the hardware stopped. Note that the Codec's DaiFormat
1106    /// must be set (by a successful `SetDaiFormat` call) before calling this method.
1107    ///
1108    /// Should only be called for Codec devices.
1109    pub fn r#codec_stop(
1110        &self,
1111    ) -> fidl::client::QueryResponseFut<
1112        ControlCodecStopResult,
1113        fidl::encoding::DefaultFuchsiaResourceDialect,
1114    > {
1115        ControlProxyInterface::r#codec_stop(self)
1116    }
1117
1118    /// Reset the hardware -- stopping the hardware, releasing any ring buffers, and clearing any
1119    /// DaiFormats or RingBufferFormats that were set.
1120    ///
1121    /// This method returns when the hardware reset is complete.
1122    /// After calling this method, the device is still controlled, but any ring buffers must be
1123    /// re-created and re-started.
1124    /// For devices with DAI_INTERCONNECTs (such as Codecs and some Composites), `SetDaiFormat` and
1125    /// `CodecStart` must be called again (in that order) to return the interconnect to the active
1126    /// operational mode.
1127    /// As applicable, `SetTopology` and `SetElementState` must also be called.
1128    ///
1129    /// Should only be called for Codec and Composite devices.
1130    pub fn r#reset(
1131        &self,
1132    ) -> fidl::client::QueryResponseFut<
1133        ControlResetResult,
1134        fidl::encoding::DefaultFuchsiaResourceDialect,
1135    > {
1136        ControlProxyInterface::r#reset(self)
1137    }
1138}
1139
1140impl ControlProxyInterface for ControlProxy {
1141    type GetElementsResponseFut = fidl::client::QueryResponseFut<
1142        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
1143        fidl::encoding::DefaultFuchsiaResourceDialect,
1144    >;
1145    fn r#get_elements(&self) -> Self::GetElementsResponseFut {
1146        fn _decode(
1147            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1148        ) -> Result<
1149            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
1150            fidl::Error,
1151        > {
1152            let _response = fidl::client::decode_transaction_body::<
1153                fidl::encoding::ResultType<
1154                    fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResponse,
1155                    i32,
1156                >,
1157                fidl::encoding::DefaultFuchsiaResourceDialect,
1158                0x1b14ff4adf5dc6f8,
1159            >(_buf?)?;
1160            Ok(_response.map(|x| x.processing_elements))
1161        }
1162        self.client.send_query_and_decode::<
1163            fidl::encoding::EmptyPayload,
1164            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
1165        >(
1166            (),
1167            0x1b14ff4adf5dc6f8,
1168            fidl::encoding::DynamicFlags::empty(),
1169            _decode,
1170        )
1171    }
1172
1173    type WatchElementStateResponseFut = fidl::client::QueryResponseFut<
1174        fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
1175        fidl::encoding::DefaultFuchsiaResourceDialect,
1176    >;
1177    fn r#watch_element_state(
1178        &self,
1179        mut processing_element_id: u64,
1180    ) -> Self::WatchElementStateResponseFut {
1181        fn _decode(
1182            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1183        ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ElementState, fidl::Error>
1184        {
1185            let _response = fidl::client::decode_transaction_body::<
1186                fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateResponse,
1187                fidl::encoding::DefaultFuchsiaResourceDialect,
1188                0x524da8772a69056f,
1189            >(_buf?)?;
1190            Ok(_response.state)
1191        }
1192        self.client.send_query_and_decode::<
1193            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest,
1194            fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
1195        >(
1196            (processing_element_id,),
1197            0x524da8772a69056f,
1198            fidl::encoding::DynamicFlags::empty(),
1199            _decode,
1200        )
1201    }
1202
1203    type GetTopologiesResponseFut = fidl::client::QueryResponseFut<
1204        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
1205        fidl::encoding::DefaultFuchsiaResourceDialect,
1206    >;
1207    fn r#get_topologies(&self) -> Self::GetTopologiesResponseFut {
1208        fn _decode(
1209            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1210        ) -> Result<
1211            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
1212            fidl::Error,
1213        > {
1214            let _response = fidl::client::decode_transaction_body::<
1215                fidl::encoding::ResultType<
1216                    fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResponse,
1217                    i32,
1218                >,
1219                fidl::encoding::DefaultFuchsiaResourceDialect,
1220                0x73ffb73af24d30b6,
1221            >(_buf?)?;
1222            Ok(_response.map(|x| x.topologies))
1223        }
1224        self.client.send_query_and_decode::<
1225            fidl::encoding::EmptyPayload,
1226            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
1227        >(
1228            (),
1229            0x73ffb73af24d30b6,
1230            fidl::encoding::DynamicFlags::empty(),
1231            _decode,
1232        )
1233    }
1234
1235    type WatchTopologyResponseFut =
1236        fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
1237    fn r#watch_topology(&self) -> Self::WatchTopologyResponseFut {
1238        fn _decode(
1239            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1240        ) -> Result<u64, fidl::Error> {
1241            let _response = fidl::client::decode_transaction_body::<
1242                fidl::encoding::FlexibleType<
1243                    fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchTopologyResponse,
1244                >,
1245                fidl::encoding::DefaultFuchsiaResourceDialect,
1246                0x66d172acdb36a729,
1247            >(_buf?)?
1248            .into_result::<ControlMarker>("watch_topology")?;
1249            Ok(_response.topology_id)
1250        }
1251        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u64>(
1252            (),
1253            0x66d172acdb36a729,
1254            fidl::encoding::DynamicFlags::FLEXIBLE,
1255            _decode,
1256        )
1257    }
1258
1259    type SetTopologyResponseFut = fidl::client::QueryResponseFut<
1260        fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyResult,
1261        fidl::encoding::DefaultFuchsiaResourceDialect,
1262    >;
1263    fn r#set_topology(&self, mut topology_id: u64) -> Self::SetTopologyResponseFut {
1264        fn _decode(
1265            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1266        ) -> Result<
1267            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyResult,
1268            fidl::Error,
1269        > {
1270            let _response = fidl::client::decode_transaction_body::<
1271                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1272                fidl::encoding::DefaultFuchsiaResourceDialect,
1273                0x1d9a7f9b8fee790c,
1274            >(_buf?)?;
1275            Ok(_response.map(|x| x))
1276        }
1277        self.client.send_query_and_decode::<
1278            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyRequest,
1279            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyResult,
1280        >(
1281            (topology_id,),
1282            0x1d9a7f9b8fee790c,
1283            fidl::encoding::DynamicFlags::empty(),
1284            _decode,
1285        )
1286    }
1287
1288    type SetElementStateResponseFut = fidl::client::QueryResponseFut<
1289        fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateResult,
1290        fidl::encoding::DefaultFuchsiaResourceDialect,
1291    >;
1292    fn r#set_element_state(
1293        &self,
1294        mut processing_element_id: u64,
1295        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::SettableElementState,
1296    ) -> Self::SetElementStateResponseFut {
1297        fn _decode(
1298            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1299        ) -> Result<
1300            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateResult,
1301            fidl::Error,
1302        > {
1303            let _response = fidl::client::decode_transaction_body::<
1304                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1305                fidl::encoding::DefaultFuchsiaResourceDialect,
1306                0x38c3b2d4bae698f4,
1307            >(_buf?)?;
1308            Ok(_response.map(|x| x))
1309        }
1310        self.client.send_query_and_decode::<
1311            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateRequest,
1312            fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateResult,
1313        >(
1314            (processing_element_id, state,),
1315            0x38c3b2d4bae698f4,
1316            fidl::encoding::DynamicFlags::empty(),
1317            _decode,
1318        )
1319    }
1320
1321    type CreateRingBufferResponseFut = fidl::client::QueryResponseFut<
1322        ControlCreateRingBufferResult,
1323        fidl::encoding::DefaultFuchsiaResourceDialect,
1324    >;
1325    fn r#create_ring_buffer(
1326        &self,
1327        mut payload: ControlCreateRingBufferRequest,
1328    ) -> Self::CreateRingBufferResponseFut {
1329        fn _decode(
1330            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1331        ) -> Result<ControlCreateRingBufferResult, fidl::Error> {
1332            let _response = fidl::client::decode_transaction_body::<
1333                fidl::encoding::FlexibleResultType<
1334                    ControlCreateRingBufferResponse,
1335                    ControlCreateRingBufferError,
1336                >,
1337                fidl::encoding::DefaultFuchsiaResourceDialect,
1338                0x7462941cedb333db,
1339            >(_buf?)?
1340            .into_result::<ControlMarker>("create_ring_buffer")?;
1341            Ok(_response.map(|x| x))
1342        }
1343        self.client
1344            .send_query_and_decode::<ControlCreateRingBufferRequest, ControlCreateRingBufferResult>(
1345                &mut payload,
1346                0x7462941cedb333db,
1347                fidl::encoding::DynamicFlags::FLEXIBLE,
1348                _decode,
1349            )
1350    }
1351
1352    type CreatePacketStreamResponseFut = fidl::client::QueryResponseFut<
1353        ControlCreatePacketStreamResult,
1354        fidl::encoding::DefaultFuchsiaResourceDialect,
1355    >;
1356    fn r#create_packet_stream(
1357        &self,
1358        mut payload: ControlCreatePacketStreamRequest,
1359    ) -> Self::CreatePacketStreamResponseFut {
1360        fn _decode(
1361            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1362        ) -> Result<ControlCreatePacketStreamResult, fidl::Error> {
1363            let _response = fidl::client::decode_transaction_body::<
1364                fidl::encoding::FlexibleResultType<
1365                    ControlCreatePacketStreamResponse,
1366                    ControlCreatePacketStreamError,
1367                >,
1368                fidl::encoding::DefaultFuchsiaResourceDialect,
1369                0x5b2eacb5ad7df289,
1370            >(_buf?)?
1371            .into_result::<ControlMarker>("create_packet_stream")?;
1372            Ok(_response.map(|x| x))
1373        }
1374        self.client.send_query_and_decode::<
1375            ControlCreatePacketStreamRequest,
1376            ControlCreatePacketStreamResult,
1377        >(
1378            &mut payload,
1379            0x5b2eacb5ad7df289,
1380            fidl::encoding::DynamicFlags::FLEXIBLE,
1381            _decode,
1382        )
1383    }
1384
1385    type SetDaiFormatResponseFut = fidl::client::QueryResponseFut<
1386        ControlSetDaiFormatResult,
1387        fidl::encoding::DefaultFuchsiaResourceDialect,
1388    >;
1389    fn r#set_dai_format(
1390        &self,
1391        mut payload: &ControlSetDaiFormatRequest,
1392    ) -> Self::SetDaiFormatResponseFut {
1393        fn _decode(
1394            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1395        ) -> Result<ControlSetDaiFormatResult, fidl::Error> {
1396            let _response = fidl::client::decode_transaction_body::<
1397                fidl::encoding::FlexibleResultType<
1398                    ControlSetDaiFormatResponse,
1399                    ControlSetDaiFormatError,
1400                >,
1401                fidl::encoding::DefaultFuchsiaResourceDialect,
1402                0x1d84f5a456a92216,
1403            >(_buf?)?
1404            .into_result::<ControlMarker>("set_dai_format")?;
1405            Ok(_response.map(|x| x))
1406        }
1407        self.client.send_query_and_decode::<ControlSetDaiFormatRequest, ControlSetDaiFormatResult>(
1408            payload,
1409            0x1d84f5a456a92216,
1410            fidl::encoding::DynamicFlags::FLEXIBLE,
1411            _decode,
1412        )
1413    }
1414
1415    type CodecStartResponseFut = fidl::client::QueryResponseFut<
1416        ControlCodecStartResult,
1417        fidl::encoding::DefaultFuchsiaResourceDialect,
1418    >;
1419    fn r#codec_start(&self) -> Self::CodecStartResponseFut {
1420        fn _decode(
1421            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1422        ) -> Result<ControlCodecStartResult, fidl::Error> {
1423            let _response = fidl::client::decode_transaction_body::<
1424                fidl::encoding::FlexibleResultType<
1425                    ControlCodecStartResponse,
1426                    ControlCodecStartError,
1427                >,
1428                fidl::encoding::DefaultFuchsiaResourceDialect,
1429                0x2a90a9d2958b997b,
1430            >(_buf?)?
1431            .into_result::<ControlMarker>("codec_start")?;
1432            Ok(_response.map(|x| x))
1433        }
1434        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ControlCodecStartResult>(
1435            (),
1436            0x2a90a9d2958b997b,
1437            fidl::encoding::DynamicFlags::FLEXIBLE,
1438            _decode,
1439        )
1440    }
1441
1442    type CodecStopResponseFut = fidl::client::QueryResponseFut<
1443        ControlCodecStopResult,
1444        fidl::encoding::DefaultFuchsiaResourceDialect,
1445    >;
1446    fn r#codec_stop(&self) -> Self::CodecStopResponseFut {
1447        fn _decode(
1448            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1449        ) -> Result<ControlCodecStopResult, fidl::Error> {
1450            let _response = fidl::client::decode_transaction_body::<
1451                fidl::encoding::FlexibleResultType<ControlCodecStopResponse, ControlCodecStopError>,
1452                fidl::encoding::DefaultFuchsiaResourceDialect,
1453                0x387297bb6bcad25f,
1454            >(_buf?)?
1455            .into_result::<ControlMarker>("codec_stop")?;
1456            Ok(_response.map(|x| x))
1457        }
1458        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ControlCodecStopResult>(
1459            (),
1460            0x387297bb6bcad25f,
1461            fidl::encoding::DynamicFlags::FLEXIBLE,
1462            _decode,
1463        )
1464    }
1465
1466    type ResetResponseFut = fidl::client::QueryResponseFut<
1467        ControlResetResult,
1468        fidl::encoding::DefaultFuchsiaResourceDialect,
1469    >;
1470    fn r#reset(&self) -> Self::ResetResponseFut {
1471        fn _decode(
1472            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1473        ) -> Result<ControlResetResult, fidl::Error> {
1474            let _response = fidl::client::decode_transaction_body::<
1475                fidl::encoding::FlexibleResultType<ControlResetResponse, ControlResetError>,
1476                fidl::encoding::DefaultFuchsiaResourceDialect,
1477                0x49840db00a698996,
1478            >(_buf?)?
1479            .into_result::<ControlMarker>("reset")?;
1480            Ok(_response.map(|x| x))
1481        }
1482        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ControlResetResult>(
1483            (),
1484            0x49840db00a698996,
1485            fidl::encoding::DynamicFlags::FLEXIBLE,
1486            _decode,
1487        )
1488    }
1489}
1490
1491pub struct ControlEventStream {
1492    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1493}
1494
1495impl std::marker::Unpin for ControlEventStream {}
1496
1497impl futures::stream::FusedStream for ControlEventStream {
1498    fn is_terminated(&self) -> bool {
1499        self.event_receiver.is_terminated()
1500    }
1501}
1502
1503impl futures::Stream for ControlEventStream {
1504    type Item = Result<ControlEvent, fidl::Error>;
1505
1506    fn poll_next(
1507        mut self: std::pin::Pin<&mut Self>,
1508        cx: &mut std::task::Context<'_>,
1509    ) -> std::task::Poll<Option<Self::Item>> {
1510        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1511            &mut self.event_receiver,
1512            cx
1513        )?) {
1514            Some(buf) => std::task::Poll::Ready(Some(ControlEvent::decode(buf))),
1515            None => std::task::Poll::Ready(None),
1516        }
1517    }
1518}
1519
1520#[derive(Debug)]
1521pub enum ControlEvent {
1522    #[non_exhaustive]
1523    _UnknownEvent {
1524        /// Ordinal of the event that was sent.
1525        ordinal: u64,
1526    },
1527}
1528
1529impl ControlEvent {
1530    /// Decodes a message buffer as a [`ControlEvent`].
1531    fn decode(
1532        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1533    ) -> Result<ControlEvent, fidl::Error> {
1534        let (bytes, _handles) = buf.split_mut();
1535        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1536        debug_assert_eq!(tx_header.tx_id, 0);
1537        match tx_header.ordinal {
1538            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1539                Ok(ControlEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1540            }
1541            _ => Err(fidl::Error::UnknownOrdinal {
1542                ordinal: tx_header.ordinal,
1543                protocol_name: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1544            }),
1545        }
1546    }
1547}
1548
1549/// A Stream of incoming requests for fuchsia.audio.device/Control.
1550pub struct ControlRequestStream {
1551    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1552    is_terminated: bool,
1553}
1554
1555impl std::marker::Unpin for ControlRequestStream {}
1556
1557impl futures::stream::FusedStream for ControlRequestStream {
1558    fn is_terminated(&self) -> bool {
1559        self.is_terminated
1560    }
1561}
1562
1563impl fidl::endpoints::RequestStream for ControlRequestStream {
1564    type Protocol = ControlMarker;
1565    type ControlHandle = ControlControlHandle;
1566
1567    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1568        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1569    }
1570
1571    fn control_handle(&self) -> Self::ControlHandle {
1572        ControlControlHandle { inner: self.inner.clone() }
1573    }
1574
1575    fn into_inner(
1576        self,
1577    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1578    {
1579        (self.inner, self.is_terminated)
1580    }
1581
1582    fn from_inner(
1583        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1584        is_terminated: bool,
1585    ) -> Self {
1586        Self { inner, is_terminated }
1587    }
1588}
1589
1590impl futures::Stream for ControlRequestStream {
1591    type Item = Result<ControlRequest, fidl::Error>;
1592
1593    fn poll_next(
1594        mut self: std::pin::Pin<&mut Self>,
1595        cx: &mut std::task::Context<'_>,
1596    ) -> std::task::Poll<Option<Self::Item>> {
1597        let this = &mut *self;
1598        if this.inner.check_shutdown(cx) {
1599            this.is_terminated = true;
1600            return std::task::Poll::Ready(None);
1601        }
1602        if this.is_terminated {
1603            panic!("polled ControlRequestStream after completion");
1604        }
1605        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1606            |bytes, handles| {
1607                match this.inner.channel().read_etc(cx, bytes, handles) {
1608                    std::task::Poll::Ready(Ok(())) => {}
1609                    std::task::Poll::Pending => return std::task::Poll::Pending,
1610                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1611                        this.is_terminated = true;
1612                        return std::task::Poll::Ready(None);
1613                    }
1614                    std::task::Poll::Ready(Err(e)) => {
1615                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1616                            e.into(),
1617                        ))));
1618                    }
1619                }
1620
1621                // A message has been received from the channel
1622                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1623
1624                std::task::Poll::Ready(Some(match header.ordinal {
1625                    0x1b14ff4adf5dc6f8 => {
1626                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1627                        let mut req = fidl::new_empty!(
1628                            fidl::encoding::EmptyPayload,
1629                            fidl::encoding::DefaultFuchsiaResourceDialect
1630                        );
1631                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1632                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1633                        Ok(ControlRequest::GetElements {
1634                            responder: ControlGetElementsResponder {
1635                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1636                                tx_id: header.tx_id,
1637                            },
1638                        })
1639                    }
1640                    0x524da8772a69056f => {
1641                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1642                        let mut req = fidl::new_empty!(fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1643                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest>(&header, _body_bytes, handles, &mut req)?;
1644                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1645                        Ok(ControlRequest::WatchElementState {
1646                            processing_element_id: req.processing_element_id,
1647
1648                            responder: ControlWatchElementStateResponder {
1649                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1650                                tx_id: header.tx_id,
1651                            },
1652                        })
1653                    }
1654                    0x73ffb73af24d30b6 => {
1655                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1656                        let mut req = fidl::new_empty!(
1657                            fidl::encoding::EmptyPayload,
1658                            fidl::encoding::DefaultFuchsiaResourceDialect
1659                        );
1660                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1661                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1662                        Ok(ControlRequest::GetTopologies {
1663                            responder: ControlGetTopologiesResponder {
1664                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1665                                tx_id: header.tx_id,
1666                            },
1667                        })
1668                    }
1669                    0x66d172acdb36a729 => {
1670                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1671                        let mut req = fidl::new_empty!(
1672                            fidl::encoding::EmptyPayload,
1673                            fidl::encoding::DefaultFuchsiaResourceDialect
1674                        );
1675                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1676                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1677                        Ok(ControlRequest::WatchTopology {
1678                            responder: ControlWatchTopologyResponder {
1679                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1680                                tx_id: header.tx_id,
1681                            },
1682                        })
1683                    }
1684                    0x1d9a7f9b8fee790c => {
1685                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1686                        let mut req = fidl::new_empty!(fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1687                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetTopologyRequest>(&header, _body_bytes, handles, &mut req)?;
1688                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1689                        Ok(ControlRequest::SetTopology {
1690                            topology_id: req.topology_id,
1691
1692                            responder: ControlSetTopologyResponder {
1693                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1694                                tx_id: header.tx_id,
1695                            },
1696                        })
1697                    }
1698                    0x38c3b2d4bae698f4 => {
1699                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1700                        let mut req = fidl::new_empty!(fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1701                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateRequest>(&header, _body_bytes, handles, &mut req)?;
1702                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1703                        Ok(ControlRequest::SetElementState {
1704                            processing_element_id: req.processing_element_id,
1705                            state: req.state,
1706
1707                            responder: ControlSetElementStateResponder {
1708                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1709                                tx_id: header.tx_id,
1710                            },
1711                        })
1712                    }
1713                    0x7462941cedb333db => {
1714                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1715                        let mut req = fidl::new_empty!(
1716                            ControlCreateRingBufferRequest,
1717                            fidl::encoding::DefaultFuchsiaResourceDialect
1718                        );
1719                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlCreateRingBufferRequest>(&header, _body_bytes, handles, &mut req)?;
1720                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1721                        Ok(ControlRequest::CreateRingBuffer {
1722                            payload: req,
1723                            responder: ControlCreateRingBufferResponder {
1724                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1725                                tx_id: header.tx_id,
1726                            },
1727                        })
1728                    }
1729                    0x5b2eacb5ad7df289 => {
1730                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1731                        let mut req = fidl::new_empty!(
1732                            ControlCreatePacketStreamRequest,
1733                            fidl::encoding::DefaultFuchsiaResourceDialect
1734                        );
1735                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlCreatePacketStreamRequest>(&header, _body_bytes, handles, &mut req)?;
1736                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1737                        Ok(ControlRequest::CreatePacketStream {
1738                            payload: req,
1739                            responder: ControlCreatePacketStreamResponder {
1740                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1741                                tx_id: header.tx_id,
1742                            },
1743                        })
1744                    }
1745                    0x1d84f5a456a92216 => {
1746                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1747                        let mut req = fidl::new_empty!(
1748                            ControlSetDaiFormatRequest,
1749                            fidl::encoding::DefaultFuchsiaResourceDialect
1750                        );
1751                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetDaiFormatRequest>(&header, _body_bytes, handles, &mut req)?;
1752                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1753                        Ok(ControlRequest::SetDaiFormat {
1754                            payload: req,
1755                            responder: ControlSetDaiFormatResponder {
1756                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1757                                tx_id: header.tx_id,
1758                            },
1759                        })
1760                    }
1761                    0x2a90a9d2958b997b => {
1762                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1763                        let mut req = fidl::new_empty!(
1764                            fidl::encoding::EmptyPayload,
1765                            fidl::encoding::DefaultFuchsiaResourceDialect
1766                        );
1767                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1768                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1769                        Ok(ControlRequest::CodecStart {
1770                            responder: ControlCodecStartResponder {
1771                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1772                                tx_id: header.tx_id,
1773                            },
1774                        })
1775                    }
1776                    0x387297bb6bcad25f => {
1777                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1778                        let mut req = fidl::new_empty!(
1779                            fidl::encoding::EmptyPayload,
1780                            fidl::encoding::DefaultFuchsiaResourceDialect
1781                        );
1782                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1783                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1784                        Ok(ControlRequest::CodecStop {
1785                            responder: ControlCodecStopResponder {
1786                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1787                                tx_id: header.tx_id,
1788                            },
1789                        })
1790                    }
1791                    0x49840db00a698996 => {
1792                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1793                        let mut req = fidl::new_empty!(
1794                            fidl::encoding::EmptyPayload,
1795                            fidl::encoding::DefaultFuchsiaResourceDialect
1796                        );
1797                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1798                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
1799                        Ok(ControlRequest::Reset {
1800                            responder: ControlResetResponder {
1801                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1802                                tx_id: header.tx_id,
1803                            },
1804                        })
1805                    }
1806                    _ if header.tx_id == 0
1807                        && header
1808                            .dynamic_flags()
1809                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1810                    {
1811                        Ok(ControlRequest::_UnknownMethod {
1812                            ordinal: header.ordinal,
1813                            control_handle: ControlControlHandle { inner: this.inner.clone() },
1814                            method_type: fidl::MethodType::OneWay,
1815                        })
1816                    }
1817                    _ if header
1818                        .dynamic_flags()
1819                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1820                    {
1821                        this.inner.send_framework_err(
1822                            fidl::encoding::FrameworkErr::UnknownMethod,
1823                            header.tx_id,
1824                            header.ordinal,
1825                            header.dynamic_flags(),
1826                            (bytes, handles),
1827                        )?;
1828                        Ok(ControlRequest::_UnknownMethod {
1829                            ordinal: header.ordinal,
1830                            control_handle: ControlControlHandle { inner: this.inner.clone() },
1831                            method_type: fidl::MethodType::TwoWay,
1832                        })
1833                    }
1834                    _ => Err(fidl::Error::UnknownOrdinal {
1835                        ordinal: header.ordinal,
1836                        protocol_name:
1837                            <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1838                    }),
1839                }))
1840            },
1841        )
1842    }
1843}
1844
1845/// A `Control` instance is used to change the settings or state of an audio
1846/// device. It also creates the ring buffer used to pass audio data between
1847/// client and device. Each `Control` is associated with an initialized audio
1848/// device; conversely each device is associated with either zero or one
1849/// `Control` at any time.
1850#[derive(Debug)]
1851pub enum ControlRequest {
1852    /// Returns a vector of supported processing elements.
1853    /// This vector must include one or more processing elements.
1854    GetElements { responder: ControlGetElementsResponder },
1855    /// Get the processing element state via a hanging get.
1856    /// For a given `processing_element_id`, the driver will immediately reply to the first
1857    /// `WatchElementState` sent by the client. The driver will not respond to subsequent client
1858    /// `WatchElementState` calls for that `processing_element_id` until any portion of the
1859    /// `ElementState` has changed from what was most recently reported for that element.
1860    ///
1861    /// The driver will close the protocol channel with an error of `ZX_ERR_INVALID_ARGS`, if
1862    /// `processing_element_id` does not match an ElementId returned by `GetElements`.
1863    ///
1864    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
1865    /// method is called again while there is already a pending `WatchElementState` for this client
1866    /// and `processing_element_id`.
1867    WatchElementState { processing_element_id: u64, responder: ControlWatchElementStateResponder },
1868    /// Returns a vector of supported topologies.
1869    /// This vector must include one or more topologies.
1870    /// If more than one topology is returned, then the client may select any topology from the
1871    /// list by calling `SetTopology`.
1872    /// If only one topology is returned, `SetTopology` can still be called but causes no change.
1873    ///
1874    /// Each Element must be included in at least one Topology, but need not be included in every
1875    /// Topology.
1876    GetTopologies { responder: ControlGetTopologiesResponder },
1877    /// Get the current topology via a hanging get.
1878    /// The driver will immediately reply to the first `WatchTopology` sent by each client.
1879    /// The driver will not respond to subsequent `WatchTopology` calls from that client until the
1880    /// signal processing topology changes; this occurs as a result of a `SetTopology` call.
1881    ///
1882    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
1883    /// method is called again while there is already a pending `WatchTopology` for this client.
1884    WatchTopology { responder: ControlWatchTopologyResponder },
1885    /// Sets the currently active topology by specifying a `topology_id`, which matches to an entry
1886    /// in the vector returned by `GetTopologies`.
1887    /// The currently active topology is communicated by `WatchTopology` responses. To change which
1888    /// topology is active, a client uses `SetTopology`.
1889    ///
1890    /// If `GetTopologies` returns only one `Topology`, `SetTopology` is optional and has no effect.
1891    ///
1892    /// This call will fail and return `ZX_ERR_INVALID_ARGS` if the specified `topology_id` is not
1893    /// found within the`topologies` returned by `GetTopologies`.
1894    ///
1895    /// `SetTopology` may be called before or after non-`SignalProcessing` protocol calls.
1896    /// If called after non-`SignalProcessing` protocol calls, then `SetTopology` may return
1897    /// `ZX_ERR_BAD_STATE` to indicate that the operation can not proceed without renegotiation of
1898    /// the driver state. See `SetElementState` for further discussion.
1899    SetTopology { topology_id: u64, responder: ControlSetTopologyResponder },
1900    /// Controls the processing element specified by `processing_element_id`, a unique ElementId
1901    /// returned by `GetElements`.
1902    /// The `state` specified in calls to `SetElementState` is a `SettableElementState`. This is a
1903    /// subset of `ElementState` because some fields returned by `WatchElementState` (e.g. `latency`
1904    /// or `plug_state`) can only be observed (not set) by the client.
1905    ///
1906    /// Returns `ZX_ERR_INVALID_ARGS` if `processing_element_id` does not match a known ElementId
1907    /// returned by `GetElements`, or if `state` is not valid for the element. This entails any
1908    /// violation of the rules specified in this protocol.
1909    ///
1910    /// Examples:
1911    /// `state` specifies that an element should be stopped or bypassed, but the corresponding
1912    ///     element does not specify (or explicitly set to false) `can_stop` or `can_bypass`.
1913    /// `state` includes a `type_specific` entry, but that `SettableTypeSpecificElementState` does
1914    ///     not match the `ElementType` of the element corresponding to `processing_element_id`.
1915    /// `state` changes an `EqualizerBandState` for an `EQUALIZER` element (so far so good), but
1916    ///     specifies a change to `frequency` when this element did not set `CAN_CONTROL_FREQUENCY`
1917    ///     in its `supported_controls`.
1918    /// `state` specifies a `GainElementState` for a `GAIN` element with a `gain` value that is
1919    ///     -infinity, NAN, or outside the Element's stated [`min_gain`, `max_gain`] range.
1920    ///
1921    /// Callers may intersperse method calls to the `SignalProcessing` protocol with calls to other
1922    /// driver protocols. Some non-`SignalProcessing` configuration changes may require a
1923    /// renegotiation of the driver state before certain elements can receive a `SetElementState`.
1924    /// For example, if a `DaiFormat` is changed, then `SetElementState` changing an `AGL` element's
1925    /// parameters may not require renegotiation of driver state because changing gain parameters
1926    /// usually does not change the set of supported audio formats.
1927    /// By contrast, following the same `DaiFormat` change, before `SetElementState` can be called
1928    /// on a `CONNECTION_POINT` element, the driver state may need to be reestablished because the
1929    /// format change may invalidate the set of supported formats returned in a previous
1930    /// `GetDaiFormats` protocol call for another part of the Topology.
1931    ///
1932    /// It is the driver's job to determine when renegotiation is required. When this is needed,
1933    /// the related `SetElementState` call must return `ZX_ERR_BAD_STATE` and the client must
1934    /// close the protocol channel entirely, such that the protocol negotiations are started over.
1935    /// The client then must re-invoke the `SetElementState` call that returned
1936    /// `ZX_ERR_BAD_STATE` before any non-`SignalProcessing` protocol calls.
1937    SetElementState {
1938        processing_element_id: u64,
1939        state: fidl_fuchsia_hardware_audio_signalprocessing::SettableElementState,
1940        responder: ControlSetElementStateResponder,
1941    },
1942    /// Create the ring buffer used to pass audio to/from this device. If the device is
1943    /// Composite, then the targeted RING_BUFFER element must be identified by `element_id`.
1944    ///
1945    /// Should only be called for Composite devices.
1946    CreateRingBuffer {
1947        payload: ControlCreateRingBufferRequest,
1948        responder: ControlCreateRingBufferResponder,
1949    },
1950    /// Set the wire format for the digital interconnect associated with this element.
1951    /// Creates a packet stream on the specified element.
1952    CreatePacketStream {
1953        payload: ControlCreatePacketStreamRequest,
1954        responder: ControlCreatePacketStreamResponder,
1955    },
1956    /// Set the wire format for the digital interconnect connected to this Codec endpoint.
1957    /// This method returns information related to the format that was set, including delay values.
1958    /// If the device is Composite, then the targeted DAI_INTERCONNECT element must be identified
1959    /// by `element_id`.
1960    ///
1961    /// Should only be called for Codec and Composite devices.
1962    SetDaiFormat { payload: ControlSetDaiFormatRequest, responder: ControlSetDaiFormatResponder },
1963    /// Start the Codec hardware. If successful, this returns after the Codec was started and
1964    /// `start_time` indicates the time when the hardware started. Note that the Codec's DaiFormat
1965    /// must be set (by a successful `SetDaiFormat` call) before calling this method.
1966    ///
1967    /// Should only be called for Codec devices.
1968    CodecStart { responder: ControlCodecStartResponder },
1969    /// Stop the Codec hardware. If successful, this returns after the Codec was stopped and
1970    /// `stop_time` indicates the time when the hardware stopped. Note that the Codec's DaiFormat
1971    /// must be set (by a successful `SetDaiFormat` call) before calling this method.
1972    ///
1973    /// Should only be called for Codec devices.
1974    CodecStop { responder: ControlCodecStopResponder },
1975    /// Reset the hardware -- stopping the hardware, releasing any ring buffers, and clearing any
1976    /// DaiFormats or RingBufferFormats that were set.
1977    ///
1978    /// This method returns when the hardware reset is complete.
1979    /// After calling this method, the device is still controlled, but any ring buffers must be
1980    /// re-created and re-started.
1981    /// For devices with DAI_INTERCONNECTs (such as Codecs and some Composites), `SetDaiFormat` and
1982    /// `CodecStart` must be called again (in that order) to return the interconnect to the active
1983    /// operational mode.
1984    /// As applicable, `SetTopology` and `SetElementState` must also be called.
1985    ///
1986    /// Should only be called for Codec and Composite devices.
1987    Reset { responder: ControlResetResponder },
1988    /// An interaction was received which does not match any known method.
1989    #[non_exhaustive]
1990    _UnknownMethod {
1991        /// Ordinal of the method that was called.
1992        ordinal: u64,
1993        control_handle: ControlControlHandle,
1994        method_type: fidl::MethodType,
1995    },
1996}
1997
1998impl ControlRequest {
1999    #[allow(irrefutable_let_patterns)]
2000    pub fn into_get_elements(self) -> Option<(ControlGetElementsResponder)> {
2001        if let ControlRequest::GetElements { responder } = self { Some((responder)) } else { None }
2002    }
2003
2004    #[allow(irrefutable_let_patterns)]
2005    pub fn into_watch_element_state(self) -> Option<(u64, ControlWatchElementStateResponder)> {
2006        if let ControlRequest::WatchElementState { processing_element_id, responder } = self {
2007            Some((processing_element_id, responder))
2008        } else {
2009            None
2010        }
2011    }
2012
2013    #[allow(irrefutable_let_patterns)]
2014    pub fn into_get_topologies(self) -> Option<(ControlGetTopologiesResponder)> {
2015        if let ControlRequest::GetTopologies { responder } = self {
2016            Some((responder))
2017        } else {
2018            None
2019        }
2020    }
2021
2022    #[allow(irrefutable_let_patterns)]
2023    pub fn into_watch_topology(self) -> Option<(ControlWatchTopologyResponder)> {
2024        if let ControlRequest::WatchTopology { responder } = self {
2025            Some((responder))
2026        } else {
2027            None
2028        }
2029    }
2030
2031    #[allow(irrefutable_let_patterns)]
2032    pub fn into_set_topology(self) -> Option<(u64, ControlSetTopologyResponder)> {
2033        if let ControlRequest::SetTopology { topology_id, responder } = self {
2034            Some((topology_id, responder))
2035        } else {
2036            None
2037        }
2038    }
2039
2040    #[allow(irrefutable_let_patterns)]
2041    pub fn into_set_element_state(
2042        self,
2043    ) -> Option<(
2044        u64,
2045        fidl_fuchsia_hardware_audio_signalprocessing::SettableElementState,
2046        ControlSetElementStateResponder,
2047    )> {
2048        if let ControlRequest::SetElementState { processing_element_id, state, responder } = self {
2049            Some((processing_element_id, state, responder))
2050        } else {
2051            None
2052        }
2053    }
2054
2055    #[allow(irrefutable_let_patterns)]
2056    pub fn into_create_ring_buffer(
2057        self,
2058    ) -> Option<(ControlCreateRingBufferRequest, ControlCreateRingBufferResponder)> {
2059        if let ControlRequest::CreateRingBuffer { payload, responder } = self {
2060            Some((payload, responder))
2061        } else {
2062            None
2063        }
2064    }
2065
2066    #[allow(irrefutable_let_patterns)]
2067    pub fn into_create_packet_stream(
2068        self,
2069    ) -> Option<(ControlCreatePacketStreamRequest, ControlCreatePacketStreamResponder)> {
2070        if let ControlRequest::CreatePacketStream { payload, responder } = self {
2071            Some((payload, responder))
2072        } else {
2073            None
2074        }
2075    }
2076
2077    #[allow(irrefutable_let_patterns)]
2078    pub fn into_set_dai_format(
2079        self,
2080    ) -> Option<(ControlSetDaiFormatRequest, ControlSetDaiFormatResponder)> {
2081        if let ControlRequest::SetDaiFormat { payload, responder } = self {
2082            Some((payload, responder))
2083        } else {
2084            None
2085        }
2086    }
2087
2088    #[allow(irrefutable_let_patterns)]
2089    pub fn into_codec_start(self) -> Option<(ControlCodecStartResponder)> {
2090        if let ControlRequest::CodecStart { responder } = self { Some((responder)) } else { None }
2091    }
2092
2093    #[allow(irrefutable_let_patterns)]
2094    pub fn into_codec_stop(self) -> Option<(ControlCodecStopResponder)> {
2095        if let ControlRequest::CodecStop { responder } = self { Some((responder)) } else { None }
2096    }
2097
2098    #[allow(irrefutable_let_patterns)]
2099    pub fn into_reset(self) -> Option<(ControlResetResponder)> {
2100        if let ControlRequest::Reset { responder } = self { Some((responder)) } else { None }
2101    }
2102
2103    /// Name of the method defined in FIDL
2104    pub fn method_name(&self) -> &'static str {
2105        match *self {
2106            ControlRequest::GetElements { .. } => "get_elements",
2107            ControlRequest::WatchElementState { .. } => "watch_element_state",
2108            ControlRequest::GetTopologies { .. } => "get_topologies",
2109            ControlRequest::WatchTopology { .. } => "watch_topology",
2110            ControlRequest::SetTopology { .. } => "set_topology",
2111            ControlRequest::SetElementState { .. } => "set_element_state",
2112            ControlRequest::CreateRingBuffer { .. } => "create_ring_buffer",
2113            ControlRequest::CreatePacketStream { .. } => "create_packet_stream",
2114            ControlRequest::SetDaiFormat { .. } => "set_dai_format",
2115            ControlRequest::CodecStart { .. } => "codec_start",
2116            ControlRequest::CodecStop { .. } => "codec_stop",
2117            ControlRequest::Reset { .. } => "reset",
2118            ControlRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2119                "unknown one-way method"
2120            }
2121            ControlRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2122                "unknown two-way method"
2123            }
2124        }
2125    }
2126}
2127
2128#[derive(Debug, Clone)]
2129pub struct ControlControlHandle {
2130    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2131}
2132
2133impl ControlControlHandle {
2134    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2135        self.inner.shutdown_with_epitaph(status.into())
2136    }
2137}
2138
2139impl fidl::endpoints::ControlHandle for ControlControlHandle {
2140    fn shutdown(&self) {
2141        self.inner.shutdown()
2142    }
2143
2144    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2145        self.inner.shutdown_with_epitaph(status)
2146    }
2147
2148    fn is_closed(&self) -> bool {
2149        self.inner.channel().is_closed()
2150    }
2151    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2152        self.inner.channel().on_closed()
2153    }
2154
2155    #[cfg(target_os = "fuchsia")]
2156    fn signal_peer(
2157        &self,
2158        clear_mask: zx::Signals,
2159        set_mask: zx::Signals,
2160    ) -> Result<(), zx_status::Status> {
2161        use fidl::Peered;
2162        self.inner.channel().signal_peer(clear_mask, set_mask)
2163    }
2164}
2165
2166impl ControlControlHandle {}
2167
2168#[must_use = "FIDL methods require a response to be sent"]
2169#[derive(Debug)]
2170pub struct ControlGetElementsResponder {
2171    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2172    tx_id: u32,
2173}
2174
2175/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2176/// if the responder is dropped without sending a response, so that the client
2177/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2178impl std::ops::Drop for ControlGetElementsResponder {
2179    fn drop(&mut self) {
2180        self.control_handle.shutdown();
2181        // Safety: drops once, never accessed again
2182        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2183    }
2184}
2185
2186impl fidl::endpoints::Responder for ControlGetElementsResponder {
2187    type ControlHandle = ControlControlHandle;
2188
2189    fn control_handle(&self) -> &ControlControlHandle {
2190        &self.control_handle
2191    }
2192
2193    fn drop_without_shutdown(mut self) {
2194        // Safety: drops once, never accessed again due to mem::forget
2195        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2196        // Prevent Drop from running (which would shut down the channel)
2197        std::mem::forget(self);
2198    }
2199}
2200
2201impl ControlGetElementsResponder {
2202    /// Sends a response to the FIDL transaction.
2203    ///
2204    /// Sets the channel to shutdown if an error occurs.
2205    pub fn send(
2206        self,
2207        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Element], i32>,
2208    ) -> Result<(), fidl::Error> {
2209        let _result = self.send_raw(result);
2210        if _result.is_err() {
2211            self.control_handle.shutdown();
2212        }
2213        self.drop_without_shutdown();
2214        _result
2215    }
2216
2217    /// Similar to "send" but does not shutdown the channel if an error occurs.
2218    pub fn send_no_shutdown_on_err(
2219        self,
2220        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Element], i32>,
2221    ) -> Result<(), fidl::Error> {
2222        let _result = self.send_raw(result);
2223        self.drop_without_shutdown();
2224        _result
2225    }
2226
2227    fn send_raw(
2228        &self,
2229        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Element], i32>,
2230    ) -> Result<(), fidl::Error> {
2231        self.control_handle.inner.send::<fidl::encoding::ResultType<
2232            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResponse,
2233            i32,
2234        >>(
2235            result.map(|processing_elements| (processing_elements,)),
2236            self.tx_id,
2237            0x1b14ff4adf5dc6f8,
2238            fidl::encoding::DynamicFlags::empty(),
2239        )
2240    }
2241}
2242
2243#[must_use = "FIDL methods require a response to be sent"]
2244#[derive(Debug)]
2245pub struct ControlWatchElementStateResponder {
2246    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2247    tx_id: u32,
2248}
2249
2250/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2251/// if the responder is dropped without sending a response, so that the client
2252/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2253impl std::ops::Drop for ControlWatchElementStateResponder {
2254    fn drop(&mut self) {
2255        self.control_handle.shutdown();
2256        // Safety: drops once, never accessed again
2257        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2258    }
2259}
2260
2261impl fidl::endpoints::Responder for ControlWatchElementStateResponder {
2262    type ControlHandle = ControlControlHandle;
2263
2264    fn control_handle(&self) -> &ControlControlHandle {
2265        &self.control_handle
2266    }
2267
2268    fn drop_without_shutdown(mut self) {
2269        // Safety: drops once, never accessed again due to mem::forget
2270        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2271        // Prevent Drop from running (which would shut down the channel)
2272        std::mem::forget(self);
2273    }
2274}
2275
2276impl ControlWatchElementStateResponder {
2277    /// Sends a response to the FIDL transaction.
2278    ///
2279    /// Sets the channel to shutdown if an error occurs.
2280    pub fn send(
2281        self,
2282        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
2283    ) -> Result<(), fidl::Error> {
2284        let _result = self.send_raw(state);
2285        if _result.is_err() {
2286            self.control_handle.shutdown();
2287        }
2288        self.drop_without_shutdown();
2289        _result
2290    }
2291
2292    /// Similar to "send" but does not shutdown the channel if an error occurs.
2293    pub fn send_no_shutdown_on_err(
2294        self,
2295        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
2296    ) -> Result<(), fidl::Error> {
2297        let _result = self.send_raw(state);
2298        self.drop_without_shutdown();
2299        _result
2300    }
2301
2302    fn send_raw(
2303        &self,
2304        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
2305    ) -> Result<(), fidl::Error> {
2306        self.control_handle
2307            .inner
2308            .send::<fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateResponse>(
2309            (state,),
2310            self.tx_id,
2311            0x524da8772a69056f,
2312            fidl::encoding::DynamicFlags::empty(),
2313        )
2314    }
2315}
2316
2317#[must_use = "FIDL methods require a response to be sent"]
2318#[derive(Debug)]
2319pub struct ControlGetTopologiesResponder {
2320    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2321    tx_id: u32,
2322}
2323
2324/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2325/// if the responder is dropped without sending a response, so that the client
2326/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2327impl std::ops::Drop for ControlGetTopologiesResponder {
2328    fn drop(&mut self) {
2329        self.control_handle.shutdown();
2330        // Safety: drops once, never accessed again
2331        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2332    }
2333}
2334
2335impl fidl::endpoints::Responder for ControlGetTopologiesResponder {
2336    type ControlHandle = ControlControlHandle;
2337
2338    fn control_handle(&self) -> &ControlControlHandle {
2339        &self.control_handle
2340    }
2341
2342    fn drop_without_shutdown(mut self) {
2343        // Safety: drops once, never accessed again due to mem::forget
2344        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2345        // Prevent Drop from running (which would shut down the channel)
2346        std::mem::forget(self);
2347    }
2348}
2349
2350impl ControlGetTopologiesResponder {
2351    /// Sends a response to the FIDL transaction.
2352    ///
2353    /// Sets the channel to shutdown if an error occurs.
2354    pub fn send(
2355        self,
2356        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Topology], i32>,
2357    ) -> Result<(), fidl::Error> {
2358        let _result = self.send_raw(result);
2359        if _result.is_err() {
2360            self.control_handle.shutdown();
2361        }
2362        self.drop_without_shutdown();
2363        _result
2364    }
2365
2366    /// Similar to "send" but does not shutdown the channel if an error occurs.
2367    pub fn send_no_shutdown_on_err(
2368        self,
2369        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Topology], i32>,
2370    ) -> Result<(), fidl::Error> {
2371        let _result = self.send_raw(result);
2372        self.drop_without_shutdown();
2373        _result
2374    }
2375
2376    fn send_raw(
2377        &self,
2378        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Topology], i32>,
2379    ) -> Result<(), fidl::Error> {
2380        self.control_handle.inner.send::<fidl::encoding::ResultType<
2381            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResponse,
2382            i32,
2383        >>(
2384            result.map(|topologies| (topologies,)),
2385            self.tx_id,
2386            0x73ffb73af24d30b6,
2387            fidl::encoding::DynamicFlags::empty(),
2388        )
2389    }
2390}
2391
2392#[must_use = "FIDL methods require a response to be sent"]
2393#[derive(Debug)]
2394pub struct ControlWatchTopologyResponder {
2395    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2396    tx_id: u32,
2397}
2398
2399/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2400/// if the responder is dropped without sending a response, so that the client
2401/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2402impl std::ops::Drop for ControlWatchTopologyResponder {
2403    fn drop(&mut self) {
2404        self.control_handle.shutdown();
2405        // Safety: drops once, never accessed again
2406        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2407    }
2408}
2409
2410impl fidl::endpoints::Responder for ControlWatchTopologyResponder {
2411    type ControlHandle = ControlControlHandle;
2412
2413    fn control_handle(&self) -> &ControlControlHandle {
2414        &self.control_handle
2415    }
2416
2417    fn drop_without_shutdown(mut self) {
2418        // Safety: drops once, never accessed again due to mem::forget
2419        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2420        // Prevent Drop from running (which would shut down the channel)
2421        std::mem::forget(self);
2422    }
2423}
2424
2425impl ControlWatchTopologyResponder {
2426    /// Sends a response to the FIDL transaction.
2427    ///
2428    /// Sets the channel to shutdown if an error occurs.
2429    pub fn send(self, mut topology_id: u64) -> Result<(), fidl::Error> {
2430        let _result = self.send_raw(topology_id);
2431        if _result.is_err() {
2432            self.control_handle.shutdown();
2433        }
2434        self.drop_without_shutdown();
2435        _result
2436    }
2437
2438    /// Similar to "send" but does not shutdown the channel if an error occurs.
2439    pub fn send_no_shutdown_on_err(self, mut topology_id: u64) -> Result<(), fidl::Error> {
2440        let _result = self.send_raw(topology_id);
2441        self.drop_without_shutdown();
2442        _result
2443    }
2444
2445    fn send_raw(&self, mut topology_id: u64) -> Result<(), fidl::Error> {
2446        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
2447            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchTopologyResponse,
2448        >>(
2449            fidl::encoding::Flexible::new((topology_id,)),
2450            self.tx_id,
2451            0x66d172acdb36a729,
2452            fidl::encoding::DynamicFlags::FLEXIBLE,
2453        )
2454    }
2455}
2456
2457#[must_use = "FIDL methods require a response to be sent"]
2458#[derive(Debug)]
2459pub struct ControlSetTopologyResponder {
2460    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2461    tx_id: u32,
2462}
2463
2464/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2465/// if the responder is dropped without sending a response, so that the client
2466/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2467impl std::ops::Drop for ControlSetTopologyResponder {
2468    fn drop(&mut self) {
2469        self.control_handle.shutdown();
2470        // Safety: drops once, never accessed again
2471        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2472    }
2473}
2474
2475impl fidl::endpoints::Responder for ControlSetTopologyResponder {
2476    type ControlHandle = ControlControlHandle;
2477
2478    fn control_handle(&self) -> &ControlControlHandle {
2479        &self.control_handle
2480    }
2481
2482    fn drop_without_shutdown(mut self) {
2483        // Safety: drops once, never accessed again due to mem::forget
2484        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2485        // Prevent Drop from running (which would shut down the channel)
2486        std::mem::forget(self);
2487    }
2488}
2489
2490impl ControlSetTopologyResponder {
2491    /// Sends a response to the FIDL transaction.
2492    ///
2493    /// Sets the channel to shutdown if an error occurs.
2494    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2495        let _result = self.send_raw(result);
2496        if _result.is_err() {
2497            self.control_handle.shutdown();
2498        }
2499        self.drop_without_shutdown();
2500        _result
2501    }
2502
2503    /// Similar to "send" but does not shutdown the channel if an error occurs.
2504    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2505        let _result = self.send_raw(result);
2506        self.drop_without_shutdown();
2507        _result
2508    }
2509
2510    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2511        self.control_handle
2512            .inner
2513            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2514                result,
2515                self.tx_id,
2516                0x1d9a7f9b8fee790c,
2517                fidl::encoding::DynamicFlags::empty(),
2518            )
2519    }
2520}
2521
2522#[must_use = "FIDL methods require a response to be sent"]
2523#[derive(Debug)]
2524pub struct ControlSetElementStateResponder {
2525    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2526    tx_id: u32,
2527}
2528
2529/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2530/// if the responder is dropped without sending a response, so that the client
2531/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2532impl std::ops::Drop for ControlSetElementStateResponder {
2533    fn drop(&mut self) {
2534        self.control_handle.shutdown();
2535        // Safety: drops once, never accessed again
2536        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2537    }
2538}
2539
2540impl fidl::endpoints::Responder for ControlSetElementStateResponder {
2541    type ControlHandle = ControlControlHandle;
2542
2543    fn control_handle(&self) -> &ControlControlHandle {
2544        &self.control_handle
2545    }
2546
2547    fn drop_without_shutdown(mut self) {
2548        // Safety: drops once, never accessed again due to mem::forget
2549        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2550        // Prevent Drop from running (which would shut down the channel)
2551        std::mem::forget(self);
2552    }
2553}
2554
2555impl ControlSetElementStateResponder {
2556    /// Sends a response to the FIDL transaction.
2557    ///
2558    /// Sets the channel to shutdown if an error occurs.
2559    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2560        let _result = self.send_raw(result);
2561        if _result.is_err() {
2562            self.control_handle.shutdown();
2563        }
2564        self.drop_without_shutdown();
2565        _result
2566    }
2567
2568    /// Similar to "send" but does not shutdown the channel if an error occurs.
2569    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2570        let _result = self.send_raw(result);
2571        self.drop_without_shutdown();
2572        _result
2573    }
2574
2575    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2576        self.control_handle
2577            .inner
2578            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2579                result,
2580                self.tx_id,
2581                0x38c3b2d4bae698f4,
2582                fidl::encoding::DynamicFlags::empty(),
2583            )
2584    }
2585}
2586
2587#[must_use = "FIDL methods require a response to be sent"]
2588#[derive(Debug)]
2589pub struct ControlCreateRingBufferResponder {
2590    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2591    tx_id: u32,
2592}
2593
2594/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2595/// if the responder is dropped without sending a response, so that the client
2596/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2597impl std::ops::Drop for ControlCreateRingBufferResponder {
2598    fn drop(&mut self) {
2599        self.control_handle.shutdown();
2600        // Safety: drops once, never accessed again
2601        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2602    }
2603}
2604
2605impl fidl::endpoints::Responder for ControlCreateRingBufferResponder {
2606    type ControlHandle = ControlControlHandle;
2607
2608    fn control_handle(&self) -> &ControlControlHandle {
2609        &self.control_handle
2610    }
2611
2612    fn drop_without_shutdown(mut self) {
2613        // Safety: drops once, never accessed again due to mem::forget
2614        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2615        // Prevent Drop from running (which would shut down the channel)
2616        std::mem::forget(self);
2617    }
2618}
2619
2620impl ControlCreateRingBufferResponder {
2621    /// Sends a response to the FIDL transaction.
2622    ///
2623    /// Sets the channel to shutdown if an error occurs.
2624    pub fn send(
2625        self,
2626        mut result: Result<ControlCreateRingBufferResponse, ControlCreateRingBufferError>,
2627    ) -> Result<(), fidl::Error> {
2628        let _result = self.send_raw(result);
2629        if _result.is_err() {
2630            self.control_handle.shutdown();
2631        }
2632        self.drop_without_shutdown();
2633        _result
2634    }
2635
2636    /// Similar to "send" but does not shutdown the channel if an error occurs.
2637    pub fn send_no_shutdown_on_err(
2638        self,
2639        mut result: Result<ControlCreateRingBufferResponse, ControlCreateRingBufferError>,
2640    ) -> Result<(), fidl::Error> {
2641        let _result = self.send_raw(result);
2642        self.drop_without_shutdown();
2643        _result
2644    }
2645
2646    fn send_raw(
2647        &self,
2648        mut result: Result<ControlCreateRingBufferResponse, ControlCreateRingBufferError>,
2649    ) -> Result<(), fidl::Error> {
2650        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2651            ControlCreateRingBufferResponse,
2652            ControlCreateRingBufferError,
2653        >>(
2654            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
2655            self.tx_id,
2656            0x7462941cedb333db,
2657            fidl::encoding::DynamicFlags::FLEXIBLE,
2658        )
2659    }
2660}
2661
2662#[must_use = "FIDL methods require a response to be sent"]
2663#[derive(Debug)]
2664pub struct ControlCreatePacketStreamResponder {
2665    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2666    tx_id: u32,
2667}
2668
2669/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2670/// if the responder is dropped without sending a response, so that the client
2671/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2672impl std::ops::Drop for ControlCreatePacketStreamResponder {
2673    fn drop(&mut self) {
2674        self.control_handle.shutdown();
2675        // Safety: drops once, never accessed again
2676        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2677    }
2678}
2679
2680impl fidl::endpoints::Responder for ControlCreatePacketStreamResponder {
2681    type ControlHandle = ControlControlHandle;
2682
2683    fn control_handle(&self) -> &ControlControlHandle {
2684        &self.control_handle
2685    }
2686
2687    fn drop_without_shutdown(mut self) {
2688        // Safety: drops once, never accessed again due to mem::forget
2689        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2690        // Prevent Drop from running (which would shut down the channel)
2691        std::mem::forget(self);
2692    }
2693}
2694
2695impl ControlCreatePacketStreamResponder {
2696    /// Sends a response to the FIDL transaction.
2697    ///
2698    /// Sets the channel to shutdown if an error occurs.
2699    pub fn send(
2700        self,
2701        mut result: Result<ControlCreatePacketStreamResponse, ControlCreatePacketStreamError>,
2702    ) -> Result<(), fidl::Error> {
2703        let _result = self.send_raw(result);
2704        if _result.is_err() {
2705            self.control_handle.shutdown();
2706        }
2707        self.drop_without_shutdown();
2708        _result
2709    }
2710
2711    /// Similar to "send" but does not shutdown the channel if an error occurs.
2712    pub fn send_no_shutdown_on_err(
2713        self,
2714        mut result: Result<ControlCreatePacketStreamResponse, ControlCreatePacketStreamError>,
2715    ) -> Result<(), fidl::Error> {
2716        let _result = self.send_raw(result);
2717        self.drop_without_shutdown();
2718        _result
2719    }
2720
2721    fn send_raw(
2722        &self,
2723        mut result: Result<ControlCreatePacketStreamResponse, ControlCreatePacketStreamError>,
2724    ) -> Result<(), fidl::Error> {
2725        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2726            ControlCreatePacketStreamResponse,
2727            ControlCreatePacketStreamError,
2728        >>(
2729            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
2730            self.tx_id,
2731            0x5b2eacb5ad7df289,
2732            fidl::encoding::DynamicFlags::FLEXIBLE,
2733        )
2734    }
2735}
2736
2737#[must_use = "FIDL methods require a response to be sent"]
2738#[derive(Debug)]
2739pub struct ControlSetDaiFormatResponder {
2740    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2741    tx_id: u32,
2742}
2743
2744/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2745/// if the responder is dropped without sending a response, so that the client
2746/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2747impl std::ops::Drop for ControlSetDaiFormatResponder {
2748    fn drop(&mut self) {
2749        self.control_handle.shutdown();
2750        // Safety: drops once, never accessed again
2751        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2752    }
2753}
2754
2755impl fidl::endpoints::Responder for ControlSetDaiFormatResponder {
2756    type ControlHandle = ControlControlHandle;
2757
2758    fn control_handle(&self) -> &ControlControlHandle {
2759        &self.control_handle
2760    }
2761
2762    fn drop_without_shutdown(mut self) {
2763        // Safety: drops once, never accessed again due to mem::forget
2764        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2765        // Prevent Drop from running (which would shut down the channel)
2766        std::mem::forget(self);
2767    }
2768}
2769
2770impl ControlSetDaiFormatResponder {
2771    /// Sends a response to the FIDL transaction.
2772    ///
2773    /// Sets the channel to shutdown if an error occurs.
2774    pub fn send(
2775        self,
2776        mut result: Result<&ControlSetDaiFormatResponse, ControlSetDaiFormatError>,
2777    ) -> Result<(), fidl::Error> {
2778        let _result = self.send_raw(result);
2779        if _result.is_err() {
2780            self.control_handle.shutdown();
2781        }
2782        self.drop_without_shutdown();
2783        _result
2784    }
2785
2786    /// Similar to "send" but does not shutdown the channel if an error occurs.
2787    pub fn send_no_shutdown_on_err(
2788        self,
2789        mut result: Result<&ControlSetDaiFormatResponse, ControlSetDaiFormatError>,
2790    ) -> Result<(), fidl::Error> {
2791        let _result = self.send_raw(result);
2792        self.drop_without_shutdown();
2793        _result
2794    }
2795
2796    fn send_raw(
2797        &self,
2798        mut result: Result<&ControlSetDaiFormatResponse, ControlSetDaiFormatError>,
2799    ) -> Result<(), fidl::Error> {
2800        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2801            ControlSetDaiFormatResponse,
2802            ControlSetDaiFormatError,
2803        >>(
2804            fidl::encoding::FlexibleResult::new(result),
2805            self.tx_id,
2806            0x1d84f5a456a92216,
2807            fidl::encoding::DynamicFlags::FLEXIBLE,
2808        )
2809    }
2810}
2811
2812#[must_use = "FIDL methods require a response to be sent"]
2813#[derive(Debug)]
2814pub struct ControlCodecStartResponder {
2815    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2816    tx_id: u32,
2817}
2818
2819/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2820/// if the responder is dropped without sending a response, so that the client
2821/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2822impl std::ops::Drop for ControlCodecStartResponder {
2823    fn drop(&mut self) {
2824        self.control_handle.shutdown();
2825        // Safety: drops once, never accessed again
2826        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2827    }
2828}
2829
2830impl fidl::endpoints::Responder for ControlCodecStartResponder {
2831    type ControlHandle = ControlControlHandle;
2832
2833    fn control_handle(&self) -> &ControlControlHandle {
2834        &self.control_handle
2835    }
2836
2837    fn drop_without_shutdown(mut self) {
2838        // Safety: drops once, never accessed again due to mem::forget
2839        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2840        // Prevent Drop from running (which would shut down the channel)
2841        std::mem::forget(self);
2842    }
2843}
2844
2845impl ControlCodecStartResponder {
2846    /// Sends a response to the FIDL transaction.
2847    ///
2848    /// Sets the channel to shutdown if an error occurs.
2849    pub fn send(
2850        self,
2851        mut result: Result<&ControlCodecStartResponse, ControlCodecStartError>,
2852    ) -> Result<(), fidl::Error> {
2853        let _result = self.send_raw(result);
2854        if _result.is_err() {
2855            self.control_handle.shutdown();
2856        }
2857        self.drop_without_shutdown();
2858        _result
2859    }
2860
2861    /// Similar to "send" but does not shutdown the channel if an error occurs.
2862    pub fn send_no_shutdown_on_err(
2863        self,
2864        mut result: Result<&ControlCodecStartResponse, ControlCodecStartError>,
2865    ) -> Result<(), fidl::Error> {
2866        let _result = self.send_raw(result);
2867        self.drop_without_shutdown();
2868        _result
2869    }
2870
2871    fn send_raw(
2872        &self,
2873        mut result: Result<&ControlCodecStartResponse, ControlCodecStartError>,
2874    ) -> Result<(), fidl::Error> {
2875        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2876            ControlCodecStartResponse,
2877            ControlCodecStartError,
2878        >>(
2879            fidl::encoding::FlexibleResult::new(result),
2880            self.tx_id,
2881            0x2a90a9d2958b997b,
2882            fidl::encoding::DynamicFlags::FLEXIBLE,
2883        )
2884    }
2885}
2886
2887#[must_use = "FIDL methods require a response to be sent"]
2888#[derive(Debug)]
2889pub struct ControlCodecStopResponder {
2890    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2891    tx_id: u32,
2892}
2893
2894/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2895/// if the responder is dropped without sending a response, so that the client
2896/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2897impl std::ops::Drop for ControlCodecStopResponder {
2898    fn drop(&mut self) {
2899        self.control_handle.shutdown();
2900        // Safety: drops once, never accessed again
2901        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2902    }
2903}
2904
2905impl fidl::endpoints::Responder for ControlCodecStopResponder {
2906    type ControlHandle = ControlControlHandle;
2907
2908    fn control_handle(&self) -> &ControlControlHandle {
2909        &self.control_handle
2910    }
2911
2912    fn drop_without_shutdown(mut self) {
2913        // Safety: drops once, never accessed again due to mem::forget
2914        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2915        // Prevent Drop from running (which would shut down the channel)
2916        std::mem::forget(self);
2917    }
2918}
2919
2920impl ControlCodecStopResponder {
2921    /// Sends a response to the FIDL transaction.
2922    ///
2923    /// Sets the channel to shutdown if an error occurs.
2924    pub fn send(
2925        self,
2926        mut result: Result<&ControlCodecStopResponse, ControlCodecStopError>,
2927    ) -> Result<(), fidl::Error> {
2928        let _result = self.send_raw(result);
2929        if _result.is_err() {
2930            self.control_handle.shutdown();
2931        }
2932        self.drop_without_shutdown();
2933        _result
2934    }
2935
2936    /// Similar to "send" but does not shutdown the channel if an error occurs.
2937    pub fn send_no_shutdown_on_err(
2938        self,
2939        mut result: Result<&ControlCodecStopResponse, ControlCodecStopError>,
2940    ) -> Result<(), fidl::Error> {
2941        let _result = self.send_raw(result);
2942        self.drop_without_shutdown();
2943        _result
2944    }
2945
2946    fn send_raw(
2947        &self,
2948        mut result: Result<&ControlCodecStopResponse, ControlCodecStopError>,
2949    ) -> Result<(), fidl::Error> {
2950        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2951            ControlCodecStopResponse,
2952            ControlCodecStopError,
2953        >>(
2954            fidl::encoding::FlexibleResult::new(result),
2955            self.tx_id,
2956            0x387297bb6bcad25f,
2957            fidl::encoding::DynamicFlags::FLEXIBLE,
2958        )
2959    }
2960}
2961
2962#[must_use = "FIDL methods require a response to be sent"]
2963#[derive(Debug)]
2964pub struct ControlResetResponder {
2965    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
2966    tx_id: u32,
2967}
2968
2969/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
2970/// if the responder is dropped without sending a response, so that the client
2971/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2972impl std::ops::Drop for ControlResetResponder {
2973    fn drop(&mut self) {
2974        self.control_handle.shutdown();
2975        // Safety: drops once, never accessed again
2976        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2977    }
2978}
2979
2980impl fidl::endpoints::Responder for ControlResetResponder {
2981    type ControlHandle = ControlControlHandle;
2982
2983    fn control_handle(&self) -> &ControlControlHandle {
2984        &self.control_handle
2985    }
2986
2987    fn drop_without_shutdown(mut self) {
2988        // Safety: drops once, never accessed again due to mem::forget
2989        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2990        // Prevent Drop from running (which would shut down the channel)
2991        std::mem::forget(self);
2992    }
2993}
2994
2995impl ControlResetResponder {
2996    /// Sends a response to the FIDL transaction.
2997    ///
2998    /// Sets the channel to shutdown if an error occurs.
2999    pub fn send(
3000        self,
3001        mut result: Result<&ControlResetResponse, ControlResetError>,
3002    ) -> Result<(), fidl::Error> {
3003        let _result = self.send_raw(result);
3004        if _result.is_err() {
3005            self.control_handle.shutdown();
3006        }
3007        self.drop_without_shutdown();
3008        _result
3009    }
3010
3011    /// Similar to "send" but does not shutdown the channel if an error occurs.
3012    pub fn send_no_shutdown_on_err(
3013        self,
3014        mut result: Result<&ControlResetResponse, ControlResetError>,
3015    ) -> Result<(), fidl::Error> {
3016        let _result = self.send_raw(result);
3017        self.drop_without_shutdown();
3018        _result
3019    }
3020
3021    fn send_raw(
3022        &self,
3023        mut result: Result<&ControlResetResponse, ControlResetError>,
3024    ) -> Result<(), fidl::Error> {
3025        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3026            ControlResetResponse,
3027            ControlResetError,
3028        >>(
3029            fidl::encoding::FlexibleResult::new(result),
3030            self.tx_id,
3031            0x49840db00a698996,
3032            fidl::encoding::DynamicFlags::FLEXIBLE,
3033        )
3034    }
3035}
3036
3037#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3038pub struct ControlCreatorMarker;
3039
3040impl fidl::endpoints::ProtocolMarker for ControlCreatorMarker {
3041    type Proxy = ControlCreatorProxy;
3042    type RequestStream = ControlCreatorRequestStream;
3043    #[cfg(target_os = "fuchsia")]
3044    type SynchronousProxy = ControlCreatorSynchronousProxy;
3045
3046    const DEBUG_NAME: &'static str = "fuchsia.audio.device.ControlCreator";
3047}
3048impl fidl::endpoints::DiscoverableProtocolMarker for ControlCreatorMarker {}
3049pub type ControlCreatorCreateResult = Result<ControlCreatorCreateResponse, ControlCreatorError>;
3050
3051pub trait ControlCreatorProxyInterface: Send + Sync {
3052    type CreateResponseFut: std::future::Future<Output = Result<ControlCreatorCreateResult, fidl::Error>>
3053        + Send;
3054    fn r#create(&self, payload: ControlCreatorCreateRequest) -> Self::CreateResponseFut;
3055}
3056#[derive(Debug)]
3057#[cfg(target_os = "fuchsia")]
3058pub struct ControlCreatorSynchronousProxy {
3059    client: fidl::client::sync::Client,
3060}
3061
3062#[cfg(target_os = "fuchsia")]
3063impl fidl::endpoints::SynchronousProxy for ControlCreatorSynchronousProxy {
3064    type Proxy = ControlCreatorProxy;
3065    type Protocol = ControlCreatorMarker;
3066
3067    fn from_channel(inner: fidl::Channel) -> Self {
3068        Self::new(inner)
3069    }
3070
3071    fn into_channel(self) -> fidl::Channel {
3072        self.client.into_channel()
3073    }
3074
3075    fn as_channel(&self) -> &fidl::Channel {
3076        self.client.as_channel()
3077    }
3078}
3079
3080#[cfg(target_os = "fuchsia")]
3081impl ControlCreatorSynchronousProxy {
3082    pub fn new(channel: fidl::Channel) -> Self {
3083        Self { client: fidl::client::sync::Client::new(channel) }
3084    }
3085
3086    pub fn into_channel(self) -> fidl::Channel {
3087        self.client.into_channel()
3088    }
3089
3090    /// Waits until an event arrives and returns it. It is safe for other
3091    /// threads to make concurrent requests while waiting for an event.
3092    pub fn wait_for_event(
3093        &self,
3094        deadline: zx::MonotonicInstant,
3095    ) -> Result<ControlCreatorEvent, fidl::Error> {
3096        ControlCreatorEvent::decode(self.client.wait_for_event::<ControlCreatorMarker>(deadline)?)
3097    }
3098
3099    /// Create a `Control` for the specified device.
3100    pub fn r#create(
3101        &self,
3102        mut payload: ControlCreatorCreateRequest,
3103        ___deadline: zx::MonotonicInstant,
3104    ) -> Result<ControlCreatorCreateResult, fidl::Error> {
3105        let _response =
3106            self.client
3107                .send_query::<ControlCreatorCreateRequest, fidl::encoding::FlexibleResultType<
3108                    ControlCreatorCreateResponse,
3109                    ControlCreatorError,
3110                >, ControlCreatorMarker>(
3111                    &mut payload,
3112                    0x341bdc9f49103a31,
3113                    fidl::encoding::DynamicFlags::FLEXIBLE,
3114                    ___deadline,
3115                )?
3116                .into_result::<ControlCreatorMarker>("create")?;
3117        Ok(_response.map(|x| x))
3118    }
3119}
3120
3121#[cfg(target_os = "fuchsia")]
3122impl From<ControlCreatorSynchronousProxy> for zx::NullableHandle {
3123    fn from(value: ControlCreatorSynchronousProxy) -> Self {
3124        value.into_channel().into()
3125    }
3126}
3127
3128#[cfg(target_os = "fuchsia")]
3129impl From<fidl::Channel> for ControlCreatorSynchronousProxy {
3130    fn from(value: fidl::Channel) -> Self {
3131        Self::new(value)
3132    }
3133}
3134
3135#[cfg(target_os = "fuchsia")]
3136impl fidl::endpoints::FromClient for ControlCreatorSynchronousProxy {
3137    type Protocol = ControlCreatorMarker;
3138
3139    fn from_client(value: fidl::endpoints::ClientEnd<ControlCreatorMarker>) -> Self {
3140        Self::new(value.into_channel())
3141    }
3142}
3143
3144#[derive(Debug, Clone)]
3145pub struct ControlCreatorProxy {
3146    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3147}
3148
3149impl fidl::endpoints::Proxy for ControlCreatorProxy {
3150    type Protocol = ControlCreatorMarker;
3151
3152    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3153        Self::new(inner)
3154    }
3155
3156    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3157        self.client.into_channel().map_err(|client| Self { client })
3158    }
3159
3160    fn as_channel(&self) -> &::fidl::AsyncChannel {
3161        self.client.as_channel()
3162    }
3163}
3164
3165impl ControlCreatorProxy {
3166    /// Create a new Proxy for fuchsia.audio.device/ControlCreator.
3167    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3168        let protocol_name = <ControlCreatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3169        Self { client: fidl::client::Client::new(channel, protocol_name) }
3170    }
3171
3172    /// Get a Stream of events from the remote end of the protocol.
3173    ///
3174    /// # Panics
3175    ///
3176    /// Panics if the event stream was already taken.
3177    pub fn take_event_stream(&self) -> ControlCreatorEventStream {
3178        ControlCreatorEventStream { event_receiver: self.client.take_event_receiver() }
3179    }
3180
3181    /// Create a `Control` for the specified device.
3182    pub fn r#create(
3183        &self,
3184        mut payload: ControlCreatorCreateRequest,
3185    ) -> fidl::client::QueryResponseFut<
3186        ControlCreatorCreateResult,
3187        fidl::encoding::DefaultFuchsiaResourceDialect,
3188    > {
3189        ControlCreatorProxyInterface::r#create(self, payload)
3190    }
3191}
3192
3193impl ControlCreatorProxyInterface for ControlCreatorProxy {
3194    type CreateResponseFut = fidl::client::QueryResponseFut<
3195        ControlCreatorCreateResult,
3196        fidl::encoding::DefaultFuchsiaResourceDialect,
3197    >;
3198    fn r#create(&self, mut payload: ControlCreatorCreateRequest) -> Self::CreateResponseFut {
3199        fn _decode(
3200            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3201        ) -> Result<ControlCreatorCreateResult, fidl::Error> {
3202            let _response = fidl::client::decode_transaction_body::<
3203                fidl::encoding::FlexibleResultType<
3204                    ControlCreatorCreateResponse,
3205                    ControlCreatorError,
3206                >,
3207                fidl::encoding::DefaultFuchsiaResourceDialect,
3208                0x341bdc9f49103a31,
3209            >(_buf?)?
3210            .into_result::<ControlCreatorMarker>("create")?;
3211            Ok(_response.map(|x| x))
3212        }
3213        self.client
3214            .send_query_and_decode::<ControlCreatorCreateRequest, ControlCreatorCreateResult>(
3215                &mut payload,
3216                0x341bdc9f49103a31,
3217                fidl::encoding::DynamicFlags::FLEXIBLE,
3218                _decode,
3219            )
3220    }
3221}
3222
3223pub struct ControlCreatorEventStream {
3224    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3225}
3226
3227impl std::marker::Unpin for ControlCreatorEventStream {}
3228
3229impl futures::stream::FusedStream for ControlCreatorEventStream {
3230    fn is_terminated(&self) -> bool {
3231        self.event_receiver.is_terminated()
3232    }
3233}
3234
3235impl futures::Stream for ControlCreatorEventStream {
3236    type Item = Result<ControlCreatorEvent, fidl::Error>;
3237
3238    fn poll_next(
3239        mut self: std::pin::Pin<&mut Self>,
3240        cx: &mut std::task::Context<'_>,
3241    ) -> std::task::Poll<Option<Self::Item>> {
3242        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3243            &mut self.event_receiver,
3244            cx
3245        )?) {
3246            Some(buf) => std::task::Poll::Ready(Some(ControlCreatorEvent::decode(buf))),
3247            None => std::task::Poll::Ready(None),
3248        }
3249    }
3250}
3251
3252#[derive(Debug)]
3253pub enum ControlCreatorEvent {
3254    #[non_exhaustive]
3255    _UnknownEvent {
3256        /// Ordinal of the event that was sent.
3257        ordinal: u64,
3258    },
3259}
3260
3261impl ControlCreatorEvent {
3262    /// Decodes a message buffer as a [`ControlCreatorEvent`].
3263    fn decode(
3264        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3265    ) -> Result<ControlCreatorEvent, fidl::Error> {
3266        let (bytes, _handles) = buf.split_mut();
3267        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3268        debug_assert_eq!(tx_header.tx_id, 0);
3269        match tx_header.ordinal {
3270            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3271                Ok(ControlCreatorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3272            }
3273            _ => Err(fidl::Error::UnknownOrdinal {
3274                ordinal: tx_header.ordinal,
3275                protocol_name:
3276                    <ControlCreatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3277            }),
3278        }
3279    }
3280}
3281
3282/// A Stream of incoming requests for fuchsia.audio.device/ControlCreator.
3283pub struct ControlCreatorRequestStream {
3284    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3285    is_terminated: bool,
3286}
3287
3288impl std::marker::Unpin for ControlCreatorRequestStream {}
3289
3290impl futures::stream::FusedStream for ControlCreatorRequestStream {
3291    fn is_terminated(&self) -> bool {
3292        self.is_terminated
3293    }
3294}
3295
3296impl fidl::endpoints::RequestStream for ControlCreatorRequestStream {
3297    type Protocol = ControlCreatorMarker;
3298    type ControlHandle = ControlCreatorControlHandle;
3299
3300    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3301        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3302    }
3303
3304    fn control_handle(&self) -> Self::ControlHandle {
3305        ControlCreatorControlHandle { inner: self.inner.clone() }
3306    }
3307
3308    fn into_inner(
3309        self,
3310    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3311    {
3312        (self.inner, self.is_terminated)
3313    }
3314
3315    fn from_inner(
3316        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3317        is_terminated: bool,
3318    ) -> Self {
3319        Self { inner, is_terminated }
3320    }
3321}
3322
3323impl futures::Stream for ControlCreatorRequestStream {
3324    type Item = Result<ControlCreatorRequest, fidl::Error>;
3325
3326    fn poll_next(
3327        mut self: std::pin::Pin<&mut Self>,
3328        cx: &mut std::task::Context<'_>,
3329    ) -> std::task::Poll<Option<Self::Item>> {
3330        let this = &mut *self;
3331        if this.inner.check_shutdown(cx) {
3332            this.is_terminated = true;
3333            return std::task::Poll::Ready(None);
3334        }
3335        if this.is_terminated {
3336            panic!("polled ControlCreatorRequestStream after completion");
3337        }
3338        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3339            |bytes, handles| {
3340                match this.inner.channel().read_etc(cx, bytes, handles) {
3341                    std::task::Poll::Ready(Ok(())) => {}
3342                    std::task::Poll::Pending => return std::task::Poll::Pending,
3343                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3344                        this.is_terminated = true;
3345                        return std::task::Poll::Ready(None);
3346                    }
3347                    std::task::Poll::Ready(Err(e)) => {
3348                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3349                            e.into(),
3350                        ))));
3351                    }
3352                }
3353
3354                // A message has been received from the channel
3355                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3356
3357                std::task::Poll::Ready(Some(match header.ordinal {
3358                    0x341bdc9f49103a31 => {
3359                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3360                        let mut req = fidl::new_empty!(
3361                            ControlCreatorCreateRequest,
3362                            fidl::encoding::DefaultFuchsiaResourceDialect
3363                        );
3364                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlCreatorCreateRequest>(&header, _body_bytes, handles, &mut req)?;
3365                        let control_handle =
3366                            ControlCreatorControlHandle { inner: this.inner.clone() };
3367                        Ok(ControlCreatorRequest::Create {
3368                            payload: req,
3369                            responder: ControlCreatorCreateResponder {
3370                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3371                                tx_id: header.tx_id,
3372                            },
3373                        })
3374                    }
3375                    _ if header.tx_id == 0
3376                        && header
3377                            .dynamic_flags()
3378                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3379                    {
3380                        Ok(ControlCreatorRequest::_UnknownMethod {
3381                            ordinal: header.ordinal,
3382                            control_handle: ControlCreatorControlHandle {
3383                                inner: this.inner.clone(),
3384                            },
3385                            method_type: fidl::MethodType::OneWay,
3386                        })
3387                    }
3388                    _ if header
3389                        .dynamic_flags()
3390                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3391                    {
3392                        this.inner.send_framework_err(
3393                            fidl::encoding::FrameworkErr::UnknownMethod,
3394                            header.tx_id,
3395                            header.ordinal,
3396                            header.dynamic_flags(),
3397                            (bytes, handles),
3398                        )?;
3399                        Ok(ControlCreatorRequest::_UnknownMethod {
3400                            ordinal: header.ordinal,
3401                            control_handle: ControlCreatorControlHandle {
3402                                inner: this.inner.clone(),
3403                            },
3404                            method_type: fidl::MethodType::TwoWay,
3405                        })
3406                    }
3407                    _ => Err(fidl::Error::UnknownOrdinal {
3408                        ordinal: header.ordinal,
3409                        protocol_name:
3410                            <ControlCreatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3411                    }),
3412                }))
3413            },
3414        )
3415    }
3416}
3417
3418/// A `ControlCreator` interface creates `Control` instances. Each `Control` binds
3419/// to a single device. A device can only be bound to one `Control` at any time.
3420#[derive(Debug)]
3421pub enum ControlCreatorRequest {
3422    /// Create a `Control` for the specified device.
3423    Create { payload: ControlCreatorCreateRequest, responder: ControlCreatorCreateResponder },
3424    /// An interaction was received which does not match any known method.
3425    #[non_exhaustive]
3426    _UnknownMethod {
3427        /// Ordinal of the method that was called.
3428        ordinal: u64,
3429        control_handle: ControlCreatorControlHandle,
3430        method_type: fidl::MethodType,
3431    },
3432}
3433
3434impl ControlCreatorRequest {
3435    #[allow(irrefutable_let_patterns)]
3436    pub fn into_create(
3437        self,
3438    ) -> Option<(ControlCreatorCreateRequest, ControlCreatorCreateResponder)> {
3439        if let ControlCreatorRequest::Create { payload, responder } = self {
3440            Some((payload, responder))
3441        } else {
3442            None
3443        }
3444    }
3445
3446    /// Name of the method defined in FIDL
3447    pub fn method_name(&self) -> &'static str {
3448        match *self {
3449            ControlCreatorRequest::Create { .. } => "create",
3450            ControlCreatorRequest::_UnknownMethod {
3451                method_type: fidl::MethodType::OneWay, ..
3452            } => "unknown one-way method",
3453            ControlCreatorRequest::_UnknownMethod {
3454                method_type: fidl::MethodType::TwoWay, ..
3455            } => "unknown two-way method",
3456        }
3457    }
3458}
3459
3460#[derive(Debug, Clone)]
3461pub struct ControlCreatorControlHandle {
3462    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3463}
3464
3465impl ControlCreatorControlHandle {
3466    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
3467        self.inner.shutdown_with_epitaph(status.into())
3468    }
3469}
3470
3471impl fidl::endpoints::ControlHandle for ControlCreatorControlHandle {
3472    fn shutdown(&self) {
3473        self.inner.shutdown()
3474    }
3475
3476    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
3477        self.inner.shutdown_with_epitaph(status)
3478    }
3479
3480    fn is_closed(&self) -> bool {
3481        self.inner.channel().is_closed()
3482    }
3483    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3484        self.inner.channel().on_closed()
3485    }
3486
3487    #[cfg(target_os = "fuchsia")]
3488    fn signal_peer(
3489        &self,
3490        clear_mask: zx::Signals,
3491        set_mask: zx::Signals,
3492    ) -> Result<(), zx_status::Status> {
3493        use fidl::Peered;
3494        self.inner.channel().signal_peer(clear_mask, set_mask)
3495    }
3496}
3497
3498impl ControlCreatorControlHandle {}
3499
3500#[must_use = "FIDL methods require a response to be sent"]
3501#[derive(Debug)]
3502pub struct ControlCreatorCreateResponder {
3503    control_handle: std::mem::ManuallyDrop<ControlCreatorControlHandle>,
3504    tx_id: u32,
3505}
3506
3507/// Set the the channel to be shutdown (see [`ControlCreatorControlHandle::shutdown`])
3508/// if the responder is dropped without sending a response, so that the client
3509/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3510impl std::ops::Drop for ControlCreatorCreateResponder {
3511    fn drop(&mut self) {
3512        self.control_handle.shutdown();
3513        // Safety: drops once, never accessed again
3514        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3515    }
3516}
3517
3518impl fidl::endpoints::Responder for ControlCreatorCreateResponder {
3519    type ControlHandle = ControlCreatorControlHandle;
3520
3521    fn control_handle(&self) -> &ControlCreatorControlHandle {
3522        &self.control_handle
3523    }
3524
3525    fn drop_without_shutdown(mut self) {
3526        // Safety: drops once, never accessed again due to mem::forget
3527        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3528        // Prevent Drop from running (which would shut down the channel)
3529        std::mem::forget(self);
3530    }
3531}
3532
3533impl ControlCreatorCreateResponder {
3534    /// Sends a response to the FIDL transaction.
3535    ///
3536    /// Sets the channel to shutdown if an error occurs.
3537    pub fn send(
3538        self,
3539        mut result: Result<&ControlCreatorCreateResponse, ControlCreatorError>,
3540    ) -> Result<(), fidl::Error> {
3541        let _result = self.send_raw(result);
3542        if _result.is_err() {
3543            self.control_handle.shutdown();
3544        }
3545        self.drop_without_shutdown();
3546        _result
3547    }
3548
3549    /// Similar to "send" but does not shutdown the channel if an error occurs.
3550    pub fn send_no_shutdown_on_err(
3551        self,
3552        mut result: Result<&ControlCreatorCreateResponse, ControlCreatorError>,
3553    ) -> Result<(), fidl::Error> {
3554        let _result = self.send_raw(result);
3555        self.drop_without_shutdown();
3556        _result
3557    }
3558
3559    fn send_raw(
3560        &self,
3561        mut result: Result<&ControlCreatorCreateResponse, ControlCreatorError>,
3562    ) -> Result<(), fidl::Error> {
3563        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3564            ControlCreatorCreateResponse,
3565            ControlCreatorError,
3566        >>(
3567            fidl::encoding::FlexibleResult::new(result),
3568            self.tx_id,
3569            0x341bdc9f49103a31,
3570            fidl::encoding::DynamicFlags::FLEXIBLE,
3571        )
3572    }
3573}
3574
3575#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3576pub struct ObserverMarker;
3577
3578impl fidl::endpoints::ProtocolMarker for ObserverMarker {
3579    type Proxy = ObserverProxy;
3580    type RequestStream = ObserverRequestStream;
3581    #[cfg(target_os = "fuchsia")]
3582    type SynchronousProxy = ObserverSynchronousProxy;
3583
3584    const DEBUG_NAME: &'static str = "(anonymous) Observer";
3585}
3586pub type ObserverWatchPlugStateResult =
3587    Result<ObserverWatchPlugStateResponse, ObserverWatchPlugStateError>;
3588pub type ObserverGetReferenceClockResult =
3589    Result<ObserverGetReferenceClockResponse, ObserverGetReferenceClockError>;
3590
3591pub trait ObserverProxyInterface: Send + Sync {
3592    type GetElementsResponseFut: std::future::Future<
3593            Output = Result<
3594                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
3595                fidl::Error,
3596            >,
3597        > + Send;
3598    fn r#get_elements(&self) -> Self::GetElementsResponseFut;
3599    type WatchElementStateResponseFut: std::future::Future<
3600            Output = Result<
3601                fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
3602                fidl::Error,
3603            >,
3604        > + Send;
3605    fn r#watch_element_state(
3606        &self,
3607        processing_element_id: u64,
3608    ) -> Self::WatchElementStateResponseFut;
3609    type GetTopologiesResponseFut: std::future::Future<
3610            Output = Result<
3611                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
3612                fidl::Error,
3613            >,
3614        > + Send;
3615    fn r#get_topologies(&self) -> Self::GetTopologiesResponseFut;
3616    type WatchTopologyResponseFut: std::future::Future<Output = Result<u64, fidl::Error>> + Send;
3617    fn r#watch_topology(&self) -> Self::WatchTopologyResponseFut;
3618    type WatchPlugStateResponseFut: std::future::Future<Output = Result<ObserverWatchPlugStateResult, fidl::Error>>
3619        + Send;
3620    fn r#watch_plug_state(&self) -> Self::WatchPlugStateResponseFut;
3621    type GetReferenceClockResponseFut: std::future::Future<Output = Result<ObserverGetReferenceClockResult, fidl::Error>>
3622        + Send;
3623    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
3624}
3625#[derive(Debug)]
3626#[cfg(target_os = "fuchsia")]
3627pub struct ObserverSynchronousProxy {
3628    client: fidl::client::sync::Client,
3629}
3630
3631#[cfg(target_os = "fuchsia")]
3632impl fidl::endpoints::SynchronousProxy for ObserverSynchronousProxy {
3633    type Proxy = ObserverProxy;
3634    type Protocol = ObserverMarker;
3635
3636    fn from_channel(inner: fidl::Channel) -> Self {
3637        Self::new(inner)
3638    }
3639
3640    fn into_channel(self) -> fidl::Channel {
3641        self.client.into_channel()
3642    }
3643
3644    fn as_channel(&self) -> &fidl::Channel {
3645        self.client.as_channel()
3646    }
3647}
3648
3649#[cfg(target_os = "fuchsia")]
3650impl ObserverSynchronousProxy {
3651    pub fn new(channel: fidl::Channel) -> Self {
3652        Self { client: fidl::client::sync::Client::new(channel) }
3653    }
3654
3655    pub fn into_channel(self) -> fidl::Channel {
3656        self.client.into_channel()
3657    }
3658
3659    /// Waits until an event arrives and returns it. It is safe for other
3660    /// threads to make concurrent requests while waiting for an event.
3661    pub fn wait_for_event(
3662        &self,
3663        deadline: zx::MonotonicInstant,
3664    ) -> Result<ObserverEvent, fidl::Error> {
3665        ObserverEvent::decode(self.client.wait_for_event::<ObserverMarker>(deadline)?)
3666    }
3667
3668    /// Returns a vector of supported processing elements.
3669    /// This vector must include one or more processing elements.
3670    pub fn r#get_elements(
3671        &self,
3672        ___deadline: zx::MonotonicInstant,
3673    ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult, fidl::Error>
3674    {
3675        let _response =
3676            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
3677                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResponse,
3678                i32,
3679            >, ObserverMarker>(
3680                (),
3681                0x1b14ff4adf5dc6f8,
3682                fidl::encoding::DynamicFlags::empty(),
3683                ___deadline,
3684            )?;
3685        Ok(_response.map(|x| x.processing_elements))
3686    }
3687
3688    /// Get the processing element state via a hanging get.
3689    /// For a given `processing_element_id`, the driver will immediately reply to the first
3690    /// `WatchElementState` sent by the client. The driver will not respond to subsequent client
3691    /// `WatchElementState` calls for that `processing_element_id` until any portion of the
3692    /// `ElementState` has changed from what was most recently reported for that element.
3693    ///
3694    /// The driver will close the protocol channel with an error of `ZX_ERR_INVALID_ARGS`, if
3695    /// `processing_element_id` does not match an ElementId returned by `GetElements`.
3696    ///
3697    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
3698    /// method is called again while there is already a pending `WatchElementState` for this client
3699    /// and `processing_element_id`.
3700    pub fn r#watch_element_state(
3701        &self,
3702        mut processing_element_id: u64,
3703        ___deadline: zx::MonotonicInstant,
3704    ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ElementState, fidl::Error> {
3705        let _response = self.client.send_query::<
3706            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest,
3707            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateResponse,
3708            ObserverMarker,
3709        >(
3710            (processing_element_id,),
3711            0x524da8772a69056f,
3712            fidl::encoding::DynamicFlags::empty(),
3713            ___deadline,
3714        )?;
3715        Ok(_response.state)
3716    }
3717
3718    /// Returns a vector of supported topologies.
3719    /// This vector must include one or more topologies.
3720    /// If more than one topology is returned, then the client may select any topology from the
3721    /// list by calling `SetTopology`.
3722    /// If only one topology is returned, `SetTopology` can still be called but causes no change.
3723    ///
3724    /// Each Element must be included in at least one Topology, but need not be included in every
3725    /// Topology.
3726    pub fn r#get_topologies(
3727        &self,
3728        ___deadline: zx::MonotonicInstant,
3729    ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult, fidl::Error>
3730    {
3731        let _response =
3732            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
3733                fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResponse,
3734                i32,
3735            >, ObserverMarker>(
3736                (),
3737                0x73ffb73af24d30b6,
3738                fidl::encoding::DynamicFlags::empty(),
3739                ___deadline,
3740            )?;
3741        Ok(_response.map(|x| x.topologies))
3742    }
3743
3744    /// Get the current topology via a hanging get.
3745    /// The driver will immediately reply to the first `WatchTopology` sent by each client.
3746    /// The driver will not respond to subsequent `WatchTopology` calls from that client until the
3747    /// signal processing topology changes; this occurs as a result of a `SetTopology` call.
3748    ///
3749    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
3750    /// method is called again while there is already a pending `WatchTopology` for this client.
3751    pub fn r#watch_topology(&self, ___deadline: zx::MonotonicInstant) -> Result<u64, fidl::Error> {
3752        let _response = self
3753            .client
3754            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleType<
3755                fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchTopologyResponse,
3756            >, ObserverMarker>(
3757                (),
3758                0x66d172acdb36a729,
3759                fidl::encoding::DynamicFlags::FLEXIBLE,
3760                ___deadline,
3761            )?
3762            .into_result::<ObserverMarker>("watch_topology")?;
3763        Ok(_response.topology_id)
3764    }
3765
3766    /// Request notification of any change to the device's plug state. When
3767    /// called for the first time, it will return immediately.
3768    ///
3769    /// Should only be called for Codec devices.
3770    pub fn r#watch_plug_state(
3771        &self,
3772        ___deadline: zx::MonotonicInstant,
3773    ) -> Result<ObserverWatchPlugStateResult, fidl::Error> {
3774        let _response = self
3775            .client
3776            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
3777                ObserverWatchPlugStateResponse,
3778                ObserverWatchPlugStateError,
3779            >, ObserverMarker>(
3780                (),
3781                0x6312bce495d2907a,
3782                fidl::encoding::DynamicFlags::FLEXIBLE,
3783                ___deadline,
3784            )?
3785            .into_result::<ObserverMarker>("watch_plug_state")?;
3786        Ok(_response.map(|x| x))
3787    }
3788
3789    /// Retrieve the device's reference clock.
3790    ///
3791    /// This clock will be in the domain specified in the device's `Info` table.
3792    ///
3793    /// Should only be called for Composite devices.
3794    pub fn r#get_reference_clock(
3795        &self,
3796        ___deadline: zx::MonotonicInstant,
3797    ) -> Result<ObserverGetReferenceClockResult, fidl::Error> {
3798        let _response = self
3799            .client
3800            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
3801                ObserverGetReferenceClockResponse,
3802                ObserverGetReferenceClockError,
3803            >, ObserverMarker>(
3804                (),
3805                0x3819c5e0f9574c39,
3806                fidl::encoding::DynamicFlags::FLEXIBLE,
3807                ___deadline,
3808            )?
3809            .into_result::<ObserverMarker>("get_reference_clock")?;
3810        Ok(_response.map(|x| x))
3811    }
3812}
3813
3814#[cfg(target_os = "fuchsia")]
3815impl From<ObserverSynchronousProxy> for zx::NullableHandle {
3816    fn from(value: ObserverSynchronousProxy) -> Self {
3817        value.into_channel().into()
3818    }
3819}
3820
3821#[cfg(target_os = "fuchsia")]
3822impl From<fidl::Channel> for ObserverSynchronousProxy {
3823    fn from(value: fidl::Channel) -> Self {
3824        Self::new(value)
3825    }
3826}
3827
3828#[cfg(target_os = "fuchsia")]
3829impl fidl::endpoints::FromClient for ObserverSynchronousProxy {
3830    type Protocol = ObserverMarker;
3831
3832    fn from_client(value: fidl::endpoints::ClientEnd<ObserverMarker>) -> Self {
3833        Self::new(value.into_channel())
3834    }
3835}
3836
3837#[derive(Debug, Clone)]
3838pub struct ObserverProxy {
3839    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3840}
3841
3842impl fidl::endpoints::Proxy for ObserverProxy {
3843    type Protocol = ObserverMarker;
3844
3845    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3846        Self::new(inner)
3847    }
3848
3849    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3850        self.client.into_channel().map_err(|client| Self { client })
3851    }
3852
3853    fn as_channel(&self) -> &::fidl::AsyncChannel {
3854        self.client.as_channel()
3855    }
3856}
3857
3858impl ObserverProxy {
3859    /// Create a new Proxy for fuchsia.audio.device/Observer.
3860    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3861        let protocol_name = <ObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3862        Self { client: fidl::client::Client::new(channel, protocol_name) }
3863    }
3864
3865    /// Get a Stream of events from the remote end of the protocol.
3866    ///
3867    /// # Panics
3868    ///
3869    /// Panics if the event stream was already taken.
3870    pub fn take_event_stream(&self) -> ObserverEventStream {
3871        ObserverEventStream { event_receiver: self.client.take_event_receiver() }
3872    }
3873
3874    /// Returns a vector of supported processing elements.
3875    /// This vector must include one or more processing elements.
3876    pub fn r#get_elements(
3877        &self,
3878    ) -> fidl::client::QueryResponseFut<
3879        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
3880        fidl::encoding::DefaultFuchsiaResourceDialect,
3881    > {
3882        ObserverProxyInterface::r#get_elements(self)
3883    }
3884
3885    /// Get the processing element state via a hanging get.
3886    /// For a given `processing_element_id`, the driver will immediately reply to the first
3887    /// `WatchElementState` sent by the client. The driver will not respond to subsequent client
3888    /// `WatchElementState` calls for that `processing_element_id` until any portion of the
3889    /// `ElementState` has changed from what was most recently reported for that element.
3890    ///
3891    /// The driver will close the protocol channel with an error of `ZX_ERR_INVALID_ARGS`, if
3892    /// `processing_element_id` does not match an ElementId returned by `GetElements`.
3893    ///
3894    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
3895    /// method is called again while there is already a pending `WatchElementState` for this client
3896    /// and `processing_element_id`.
3897    pub fn r#watch_element_state(
3898        &self,
3899        mut processing_element_id: u64,
3900    ) -> fidl::client::QueryResponseFut<
3901        fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
3902        fidl::encoding::DefaultFuchsiaResourceDialect,
3903    > {
3904        ObserverProxyInterface::r#watch_element_state(self, processing_element_id)
3905    }
3906
3907    /// Returns a vector of supported topologies.
3908    /// This vector must include one or more topologies.
3909    /// If more than one topology is returned, then the client may select any topology from the
3910    /// list by calling `SetTopology`.
3911    /// If only one topology is returned, `SetTopology` can still be called but causes no change.
3912    ///
3913    /// Each Element must be included in at least one Topology, but need not be included in every
3914    /// Topology.
3915    pub fn r#get_topologies(
3916        &self,
3917    ) -> fidl::client::QueryResponseFut<
3918        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
3919        fidl::encoding::DefaultFuchsiaResourceDialect,
3920    > {
3921        ObserverProxyInterface::r#get_topologies(self)
3922    }
3923
3924    /// Get the current topology via a hanging get.
3925    /// The driver will immediately reply to the first `WatchTopology` sent by each client.
3926    /// The driver will not respond to subsequent `WatchTopology` calls from that client until the
3927    /// signal processing topology changes; this occurs as a result of a `SetTopology` call.
3928    ///
3929    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
3930    /// method is called again while there is already a pending `WatchTopology` for this client.
3931    pub fn r#watch_topology(
3932        &self,
3933    ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
3934        ObserverProxyInterface::r#watch_topology(self)
3935    }
3936
3937    /// Request notification of any change to the device's plug state. When
3938    /// called for the first time, it will return immediately.
3939    ///
3940    /// Should only be called for Codec devices.
3941    pub fn r#watch_plug_state(
3942        &self,
3943    ) -> fidl::client::QueryResponseFut<
3944        ObserverWatchPlugStateResult,
3945        fidl::encoding::DefaultFuchsiaResourceDialect,
3946    > {
3947        ObserverProxyInterface::r#watch_plug_state(self)
3948    }
3949
3950    /// Retrieve the device's reference clock.
3951    ///
3952    /// This clock will be in the domain specified in the device's `Info` table.
3953    ///
3954    /// Should only be called for Composite devices.
3955    pub fn r#get_reference_clock(
3956        &self,
3957    ) -> fidl::client::QueryResponseFut<
3958        ObserverGetReferenceClockResult,
3959        fidl::encoding::DefaultFuchsiaResourceDialect,
3960    > {
3961        ObserverProxyInterface::r#get_reference_clock(self)
3962    }
3963}
3964
3965impl ObserverProxyInterface for ObserverProxy {
3966    type GetElementsResponseFut = fidl::client::QueryResponseFut<
3967        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
3968        fidl::encoding::DefaultFuchsiaResourceDialect,
3969    >;
3970    fn r#get_elements(&self) -> Self::GetElementsResponseFut {
3971        fn _decode(
3972            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3973        ) -> Result<
3974            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
3975            fidl::Error,
3976        > {
3977            let _response = fidl::client::decode_transaction_body::<
3978                fidl::encoding::ResultType<
3979                    fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResponse,
3980                    i32,
3981                >,
3982                fidl::encoding::DefaultFuchsiaResourceDialect,
3983                0x1b14ff4adf5dc6f8,
3984            >(_buf?)?;
3985            Ok(_response.map(|x| x.processing_elements))
3986        }
3987        self.client.send_query_and_decode::<
3988            fidl::encoding::EmptyPayload,
3989            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResult,
3990        >(
3991            (),
3992            0x1b14ff4adf5dc6f8,
3993            fidl::encoding::DynamicFlags::empty(),
3994            _decode,
3995        )
3996    }
3997
3998    type WatchElementStateResponseFut = fidl::client::QueryResponseFut<
3999        fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
4000        fidl::encoding::DefaultFuchsiaResourceDialect,
4001    >;
4002    fn r#watch_element_state(
4003        &self,
4004        mut processing_element_id: u64,
4005    ) -> Self::WatchElementStateResponseFut {
4006        fn _decode(
4007            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4008        ) -> Result<fidl_fuchsia_hardware_audio_signalprocessing::ElementState, fidl::Error>
4009        {
4010            let _response = fidl::client::decode_transaction_body::<
4011                fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateResponse,
4012                fidl::encoding::DefaultFuchsiaResourceDialect,
4013                0x524da8772a69056f,
4014            >(_buf?)?;
4015            Ok(_response.state)
4016        }
4017        self.client.send_query_and_decode::<
4018            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest,
4019            fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
4020        >(
4021            (processing_element_id,),
4022            0x524da8772a69056f,
4023            fidl::encoding::DynamicFlags::empty(),
4024            _decode,
4025        )
4026    }
4027
4028    type GetTopologiesResponseFut = fidl::client::QueryResponseFut<
4029        fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
4030        fidl::encoding::DefaultFuchsiaResourceDialect,
4031    >;
4032    fn r#get_topologies(&self) -> Self::GetTopologiesResponseFut {
4033        fn _decode(
4034            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4035        ) -> Result<
4036            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
4037            fidl::Error,
4038        > {
4039            let _response = fidl::client::decode_transaction_body::<
4040                fidl::encoding::ResultType<
4041                    fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResponse,
4042                    i32,
4043                >,
4044                fidl::encoding::DefaultFuchsiaResourceDialect,
4045                0x73ffb73af24d30b6,
4046            >(_buf?)?;
4047            Ok(_response.map(|x| x.topologies))
4048        }
4049        self.client.send_query_and_decode::<
4050            fidl::encoding::EmptyPayload,
4051            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResult,
4052        >(
4053            (),
4054            0x73ffb73af24d30b6,
4055            fidl::encoding::DynamicFlags::empty(),
4056            _decode,
4057        )
4058    }
4059
4060    type WatchTopologyResponseFut =
4061        fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
4062    fn r#watch_topology(&self) -> Self::WatchTopologyResponseFut {
4063        fn _decode(
4064            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4065        ) -> Result<u64, fidl::Error> {
4066            let _response = fidl::client::decode_transaction_body::<
4067                fidl::encoding::FlexibleType<
4068                    fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchTopologyResponse,
4069                >,
4070                fidl::encoding::DefaultFuchsiaResourceDialect,
4071                0x66d172acdb36a729,
4072            >(_buf?)?
4073            .into_result::<ObserverMarker>("watch_topology")?;
4074            Ok(_response.topology_id)
4075        }
4076        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u64>(
4077            (),
4078            0x66d172acdb36a729,
4079            fidl::encoding::DynamicFlags::FLEXIBLE,
4080            _decode,
4081        )
4082    }
4083
4084    type WatchPlugStateResponseFut = fidl::client::QueryResponseFut<
4085        ObserverWatchPlugStateResult,
4086        fidl::encoding::DefaultFuchsiaResourceDialect,
4087    >;
4088    fn r#watch_plug_state(&self) -> Self::WatchPlugStateResponseFut {
4089        fn _decode(
4090            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4091        ) -> Result<ObserverWatchPlugStateResult, fidl::Error> {
4092            let _response = fidl::client::decode_transaction_body::<
4093                fidl::encoding::FlexibleResultType<
4094                    ObserverWatchPlugStateResponse,
4095                    ObserverWatchPlugStateError,
4096                >,
4097                fidl::encoding::DefaultFuchsiaResourceDialect,
4098                0x6312bce495d2907a,
4099            >(_buf?)?
4100            .into_result::<ObserverMarker>("watch_plug_state")?;
4101            Ok(_response.map(|x| x))
4102        }
4103        self.client
4104            .send_query_and_decode::<fidl::encoding::EmptyPayload, ObserverWatchPlugStateResult>(
4105                (),
4106                0x6312bce495d2907a,
4107                fidl::encoding::DynamicFlags::FLEXIBLE,
4108                _decode,
4109            )
4110    }
4111
4112    type GetReferenceClockResponseFut = fidl::client::QueryResponseFut<
4113        ObserverGetReferenceClockResult,
4114        fidl::encoding::DefaultFuchsiaResourceDialect,
4115    >;
4116    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
4117        fn _decode(
4118            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4119        ) -> Result<ObserverGetReferenceClockResult, fidl::Error> {
4120            let _response = fidl::client::decode_transaction_body::<
4121                fidl::encoding::FlexibleResultType<
4122                    ObserverGetReferenceClockResponse,
4123                    ObserverGetReferenceClockError,
4124                >,
4125                fidl::encoding::DefaultFuchsiaResourceDialect,
4126                0x3819c5e0f9574c39,
4127            >(_buf?)?
4128            .into_result::<ObserverMarker>("get_reference_clock")?;
4129            Ok(_response.map(|x| x))
4130        }
4131        self.client
4132            .send_query_and_decode::<fidl::encoding::EmptyPayload, ObserverGetReferenceClockResult>(
4133                (),
4134                0x3819c5e0f9574c39,
4135                fidl::encoding::DynamicFlags::FLEXIBLE,
4136                _decode,
4137            )
4138    }
4139}
4140
4141pub struct ObserverEventStream {
4142    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4143}
4144
4145impl std::marker::Unpin for ObserverEventStream {}
4146
4147impl futures::stream::FusedStream for ObserverEventStream {
4148    fn is_terminated(&self) -> bool {
4149        self.event_receiver.is_terminated()
4150    }
4151}
4152
4153impl futures::Stream for ObserverEventStream {
4154    type Item = Result<ObserverEvent, fidl::Error>;
4155
4156    fn poll_next(
4157        mut self: std::pin::Pin<&mut Self>,
4158        cx: &mut std::task::Context<'_>,
4159    ) -> std::task::Poll<Option<Self::Item>> {
4160        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4161            &mut self.event_receiver,
4162            cx
4163        )?) {
4164            Some(buf) => std::task::Poll::Ready(Some(ObserverEvent::decode(buf))),
4165            None => std::task::Poll::Ready(None),
4166        }
4167    }
4168}
4169
4170#[derive(Debug)]
4171pub enum ObserverEvent {
4172    #[non_exhaustive]
4173    _UnknownEvent {
4174        /// Ordinal of the event that was sent.
4175        ordinal: u64,
4176    },
4177}
4178
4179impl ObserverEvent {
4180    /// Decodes a message buffer as a [`ObserverEvent`].
4181    fn decode(
4182        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4183    ) -> Result<ObserverEvent, fidl::Error> {
4184        let (bytes, _handles) = buf.split_mut();
4185        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4186        debug_assert_eq!(tx_header.tx_id, 0);
4187        match tx_header.ordinal {
4188            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4189                Ok(ObserverEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4190            }
4191            _ => Err(fidl::Error::UnknownOrdinal {
4192                ordinal: tx_header.ordinal,
4193                protocol_name: <ObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4194            }),
4195        }
4196    }
4197}
4198
4199/// A Stream of incoming requests for fuchsia.audio.device/Observer.
4200pub struct ObserverRequestStream {
4201    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4202    is_terminated: bool,
4203}
4204
4205impl std::marker::Unpin for ObserverRequestStream {}
4206
4207impl futures::stream::FusedStream for ObserverRequestStream {
4208    fn is_terminated(&self) -> bool {
4209        self.is_terminated
4210    }
4211}
4212
4213impl fidl::endpoints::RequestStream for ObserverRequestStream {
4214    type Protocol = ObserverMarker;
4215    type ControlHandle = ObserverControlHandle;
4216
4217    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4218        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4219    }
4220
4221    fn control_handle(&self) -> Self::ControlHandle {
4222        ObserverControlHandle { inner: self.inner.clone() }
4223    }
4224
4225    fn into_inner(
4226        self,
4227    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4228    {
4229        (self.inner, self.is_terminated)
4230    }
4231
4232    fn from_inner(
4233        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4234        is_terminated: bool,
4235    ) -> Self {
4236        Self { inner, is_terminated }
4237    }
4238}
4239
4240impl futures::Stream for ObserverRequestStream {
4241    type Item = Result<ObserverRequest, fidl::Error>;
4242
4243    fn poll_next(
4244        mut self: std::pin::Pin<&mut Self>,
4245        cx: &mut std::task::Context<'_>,
4246    ) -> std::task::Poll<Option<Self::Item>> {
4247        let this = &mut *self;
4248        if this.inner.check_shutdown(cx) {
4249            this.is_terminated = true;
4250            return std::task::Poll::Ready(None);
4251        }
4252        if this.is_terminated {
4253            panic!("polled ObserverRequestStream after completion");
4254        }
4255        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4256            |bytes, handles| {
4257                match this.inner.channel().read_etc(cx, bytes, handles) {
4258                    std::task::Poll::Ready(Ok(())) => {}
4259                    std::task::Poll::Pending => return std::task::Poll::Pending,
4260                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4261                        this.is_terminated = true;
4262                        return std::task::Poll::Ready(None);
4263                    }
4264                    std::task::Poll::Ready(Err(e)) => {
4265                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4266                            e.into(),
4267                        ))));
4268                    }
4269                }
4270
4271                // A message has been received from the channel
4272                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4273
4274                std::task::Poll::Ready(Some(match header.ordinal {
4275                    0x1b14ff4adf5dc6f8 => {
4276                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4277                        let mut req = fidl::new_empty!(
4278                            fidl::encoding::EmptyPayload,
4279                            fidl::encoding::DefaultFuchsiaResourceDialect
4280                        );
4281                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4282                        let control_handle = ObserverControlHandle { inner: this.inner.clone() };
4283                        Ok(ObserverRequest::GetElements {
4284                            responder: ObserverGetElementsResponder {
4285                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4286                                tx_id: header.tx_id,
4287                            },
4288                        })
4289                    }
4290                    0x524da8772a69056f => {
4291                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4292                        let mut req = fidl::new_empty!(fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
4293                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateRequest>(&header, _body_bytes, handles, &mut req)?;
4294                        let control_handle = ObserverControlHandle { inner: this.inner.clone() };
4295                        Ok(ObserverRequest::WatchElementState {
4296                            processing_element_id: req.processing_element_id,
4297
4298                            responder: ObserverWatchElementStateResponder {
4299                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4300                                tx_id: header.tx_id,
4301                            },
4302                        })
4303                    }
4304                    0x73ffb73af24d30b6 => {
4305                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4306                        let mut req = fidl::new_empty!(
4307                            fidl::encoding::EmptyPayload,
4308                            fidl::encoding::DefaultFuchsiaResourceDialect
4309                        );
4310                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4311                        let control_handle = ObserverControlHandle { inner: this.inner.clone() };
4312                        Ok(ObserverRequest::GetTopologies {
4313                            responder: ObserverGetTopologiesResponder {
4314                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4315                                tx_id: header.tx_id,
4316                            },
4317                        })
4318                    }
4319                    0x66d172acdb36a729 => {
4320                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4321                        let mut req = fidl::new_empty!(
4322                            fidl::encoding::EmptyPayload,
4323                            fidl::encoding::DefaultFuchsiaResourceDialect
4324                        );
4325                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4326                        let control_handle = ObserverControlHandle { inner: this.inner.clone() };
4327                        Ok(ObserverRequest::WatchTopology {
4328                            responder: ObserverWatchTopologyResponder {
4329                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4330                                tx_id: header.tx_id,
4331                            },
4332                        })
4333                    }
4334                    0x6312bce495d2907a => {
4335                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4336                        let mut req = fidl::new_empty!(
4337                            fidl::encoding::EmptyPayload,
4338                            fidl::encoding::DefaultFuchsiaResourceDialect
4339                        );
4340                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4341                        let control_handle = ObserverControlHandle { inner: this.inner.clone() };
4342                        Ok(ObserverRequest::WatchPlugState {
4343                            responder: ObserverWatchPlugStateResponder {
4344                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4345                                tx_id: header.tx_id,
4346                            },
4347                        })
4348                    }
4349                    0x3819c5e0f9574c39 => {
4350                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4351                        let mut req = fidl::new_empty!(
4352                            fidl::encoding::EmptyPayload,
4353                            fidl::encoding::DefaultFuchsiaResourceDialect
4354                        );
4355                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4356                        let control_handle = ObserverControlHandle { inner: this.inner.clone() };
4357                        Ok(ObserverRequest::GetReferenceClock {
4358                            responder: ObserverGetReferenceClockResponder {
4359                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4360                                tx_id: header.tx_id,
4361                            },
4362                        })
4363                    }
4364                    _ if header.tx_id == 0
4365                        && header
4366                            .dynamic_flags()
4367                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4368                    {
4369                        Ok(ObserverRequest::_UnknownMethod {
4370                            ordinal: header.ordinal,
4371                            control_handle: ObserverControlHandle { inner: this.inner.clone() },
4372                            method_type: fidl::MethodType::OneWay,
4373                        })
4374                    }
4375                    _ if header
4376                        .dynamic_flags()
4377                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4378                    {
4379                        this.inner.send_framework_err(
4380                            fidl::encoding::FrameworkErr::UnknownMethod,
4381                            header.tx_id,
4382                            header.ordinal,
4383                            header.dynamic_flags(),
4384                            (bytes, handles),
4385                        )?;
4386                        Ok(ObserverRequest::_UnknownMethod {
4387                            ordinal: header.ordinal,
4388                            control_handle: ObserverControlHandle { inner: this.inner.clone() },
4389                            method_type: fidl::MethodType::TwoWay,
4390                        })
4391                    }
4392                    _ => Err(fidl::Error::UnknownOrdinal {
4393                        ordinal: header.ordinal,
4394                        protocol_name:
4395                            <ObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4396                    }),
4397                }))
4398            },
4399        )
4400    }
4401}
4402
4403/// `Observer` instances are used to learn the capabilities and state of an
4404/// audio device, and to stay informed as its state changes over time. Each
4405/// `Observer` is associated with an initialized audio device. An audio device
4406/// may be observed by multiple `Observer` instances.
4407#[derive(Debug)]
4408pub enum ObserverRequest {
4409    /// Returns a vector of supported processing elements.
4410    /// This vector must include one or more processing elements.
4411    GetElements { responder: ObserverGetElementsResponder },
4412    /// Get the processing element state via a hanging get.
4413    /// For a given `processing_element_id`, the driver will immediately reply to the first
4414    /// `WatchElementState` sent by the client. The driver will not respond to subsequent client
4415    /// `WatchElementState` calls for that `processing_element_id` until any portion of the
4416    /// `ElementState` has changed from what was most recently reported for that element.
4417    ///
4418    /// The driver will close the protocol channel with an error of `ZX_ERR_INVALID_ARGS`, if
4419    /// `processing_element_id` does not match an ElementId returned by `GetElements`.
4420    ///
4421    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
4422    /// method is called again while there is already a pending `WatchElementState` for this client
4423    /// and `processing_element_id`.
4424    WatchElementState { processing_element_id: u64, responder: ObserverWatchElementStateResponder },
4425    /// Returns a vector of supported topologies.
4426    /// This vector must include one or more topologies.
4427    /// If more than one topology is returned, then the client may select any topology from the
4428    /// list by calling `SetTopology`.
4429    /// If only one topology is returned, `SetTopology` can still be called but causes no change.
4430    ///
4431    /// Each Element must be included in at least one Topology, but need not be included in every
4432    /// Topology.
4433    GetTopologies { responder: ObserverGetTopologiesResponder },
4434    /// Get the current topology via a hanging get.
4435    /// The driver will immediately reply to the first `WatchTopology` sent by each client.
4436    /// The driver will not respond to subsequent `WatchTopology` calls from that client until the
4437    /// signal processing topology changes; this occurs as a result of a `SetTopology` call.
4438    ///
4439    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
4440    /// method is called again while there is already a pending `WatchTopology` for this client.
4441    WatchTopology { responder: ObserverWatchTopologyResponder },
4442    /// Request notification of any change to the device's plug state. When
4443    /// called for the first time, it will return immediately.
4444    ///
4445    /// Should only be called for Codec devices.
4446    WatchPlugState { responder: ObserverWatchPlugStateResponder },
4447    /// Retrieve the device's reference clock.
4448    ///
4449    /// This clock will be in the domain specified in the device's `Info` table.
4450    ///
4451    /// Should only be called for Composite devices.
4452    GetReferenceClock { responder: ObserverGetReferenceClockResponder },
4453    /// An interaction was received which does not match any known method.
4454    #[non_exhaustive]
4455    _UnknownMethod {
4456        /// Ordinal of the method that was called.
4457        ordinal: u64,
4458        control_handle: ObserverControlHandle,
4459        method_type: fidl::MethodType,
4460    },
4461}
4462
4463impl ObserverRequest {
4464    #[allow(irrefutable_let_patterns)]
4465    pub fn into_get_elements(self) -> Option<(ObserverGetElementsResponder)> {
4466        if let ObserverRequest::GetElements { responder } = self { Some((responder)) } else { None }
4467    }
4468
4469    #[allow(irrefutable_let_patterns)]
4470    pub fn into_watch_element_state(self) -> Option<(u64, ObserverWatchElementStateResponder)> {
4471        if let ObserverRequest::WatchElementState { processing_element_id, responder } = self {
4472            Some((processing_element_id, responder))
4473        } else {
4474            None
4475        }
4476    }
4477
4478    #[allow(irrefutable_let_patterns)]
4479    pub fn into_get_topologies(self) -> Option<(ObserverGetTopologiesResponder)> {
4480        if let ObserverRequest::GetTopologies { responder } = self {
4481            Some((responder))
4482        } else {
4483            None
4484        }
4485    }
4486
4487    #[allow(irrefutable_let_patterns)]
4488    pub fn into_watch_topology(self) -> Option<(ObserverWatchTopologyResponder)> {
4489        if let ObserverRequest::WatchTopology { responder } = self {
4490            Some((responder))
4491        } else {
4492            None
4493        }
4494    }
4495
4496    #[allow(irrefutable_let_patterns)]
4497    pub fn into_watch_plug_state(self) -> Option<(ObserverWatchPlugStateResponder)> {
4498        if let ObserverRequest::WatchPlugState { responder } = self {
4499            Some((responder))
4500        } else {
4501            None
4502        }
4503    }
4504
4505    #[allow(irrefutable_let_patterns)]
4506    pub fn into_get_reference_clock(self) -> Option<(ObserverGetReferenceClockResponder)> {
4507        if let ObserverRequest::GetReferenceClock { responder } = self {
4508            Some((responder))
4509        } else {
4510            None
4511        }
4512    }
4513
4514    /// Name of the method defined in FIDL
4515    pub fn method_name(&self) -> &'static str {
4516        match *self {
4517            ObserverRequest::GetElements { .. } => "get_elements",
4518            ObserverRequest::WatchElementState { .. } => "watch_element_state",
4519            ObserverRequest::GetTopologies { .. } => "get_topologies",
4520            ObserverRequest::WatchTopology { .. } => "watch_topology",
4521            ObserverRequest::WatchPlugState { .. } => "watch_plug_state",
4522            ObserverRequest::GetReferenceClock { .. } => "get_reference_clock",
4523            ObserverRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
4524                "unknown one-way method"
4525            }
4526            ObserverRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
4527                "unknown two-way method"
4528            }
4529        }
4530    }
4531}
4532
4533#[derive(Debug, Clone)]
4534pub struct ObserverControlHandle {
4535    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4536}
4537
4538impl ObserverControlHandle {
4539    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
4540        self.inner.shutdown_with_epitaph(status.into())
4541    }
4542}
4543
4544impl fidl::endpoints::ControlHandle for ObserverControlHandle {
4545    fn shutdown(&self) {
4546        self.inner.shutdown()
4547    }
4548
4549    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
4550        self.inner.shutdown_with_epitaph(status)
4551    }
4552
4553    fn is_closed(&self) -> bool {
4554        self.inner.channel().is_closed()
4555    }
4556    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4557        self.inner.channel().on_closed()
4558    }
4559
4560    #[cfg(target_os = "fuchsia")]
4561    fn signal_peer(
4562        &self,
4563        clear_mask: zx::Signals,
4564        set_mask: zx::Signals,
4565    ) -> Result<(), zx_status::Status> {
4566        use fidl::Peered;
4567        self.inner.channel().signal_peer(clear_mask, set_mask)
4568    }
4569}
4570
4571impl ObserverControlHandle {}
4572
4573#[must_use = "FIDL methods require a response to be sent"]
4574#[derive(Debug)]
4575pub struct ObserverGetElementsResponder {
4576    control_handle: std::mem::ManuallyDrop<ObserverControlHandle>,
4577    tx_id: u32,
4578}
4579
4580/// Set the the channel to be shutdown (see [`ObserverControlHandle::shutdown`])
4581/// if the responder is dropped without sending a response, so that the client
4582/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4583impl std::ops::Drop for ObserverGetElementsResponder {
4584    fn drop(&mut self) {
4585        self.control_handle.shutdown();
4586        // Safety: drops once, never accessed again
4587        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4588    }
4589}
4590
4591impl fidl::endpoints::Responder for ObserverGetElementsResponder {
4592    type ControlHandle = ObserverControlHandle;
4593
4594    fn control_handle(&self) -> &ObserverControlHandle {
4595        &self.control_handle
4596    }
4597
4598    fn drop_without_shutdown(mut self) {
4599        // Safety: drops once, never accessed again due to mem::forget
4600        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4601        // Prevent Drop from running (which would shut down the channel)
4602        std::mem::forget(self);
4603    }
4604}
4605
4606impl ObserverGetElementsResponder {
4607    /// Sends a response to the FIDL transaction.
4608    ///
4609    /// Sets the channel to shutdown if an error occurs.
4610    pub fn send(
4611        self,
4612        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Element], i32>,
4613    ) -> Result<(), fidl::Error> {
4614        let _result = self.send_raw(result);
4615        if _result.is_err() {
4616            self.control_handle.shutdown();
4617        }
4618        self.drop_without_shutdown();
4619        _result
4620    }
4621
4622    /// Similar to "send" but does not shutdown the channel if an error occurs.
4623    pub fn send_no_shutdown_on_err(
4624        self,
4625        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Element], i32>,
4626    ) -> Result<(), fidl::Error> {
4627        let _result = self.send_raw(result);
4628        self.drop_without_shutdown();
4629        _result
4630    }
4631
4632    fn send_raw(
4633        &self,
4634        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Element], i32>,
4635    ) -> Result<(), fidl::Error> {
4636        self.control_handle.inner.send::<fidl::encoding::ResultType<
4637            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetElementsResponse,
4638            i32,
4639        >>(
4640            result.map(|processing_elements| (processing_elements,)),
4641            self.tx_id,
4642            0x1b14ff4adf5dc6f8,
4643            fidl::encoding::DynamicFlags::empty(),
4644        )
4645    }
4646}
4647
4648#[must_use = "FIDL methods require a response to be sent"]
4649#[derive(Debug)]
4650pub struct ObserverWatchElementStateResponder {
4651    control_handle: std::mem::ManuallyDrop<ObserverControlHandle>,
4652    tx_id: u32,
4653}
4654
4655/// Set the the channel to be shutdown (see [`ObserverControlHandle::shutdown`])
4656/// if the responder is dropped without sending a response, so that the client
4657/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4658impl std::ops::Drop for ObserverWatchElementStateResponder {
4659    fn drop(&mut self) {
4660        self.control_handle.shutdown();
4661        // Safety: drops once, never accessed again
4662        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4663    }
4664}
4665
4666impl fidl::endpoints::Responder for ObserverWatchElementStateResponder {
4667    type ControlHandle = ObserverControlHandle;
4668
4669    fn control_handle(&self) -> &ObserverControlHandle {
4670        &self.control_handle
4671    }
4672
4673    fn drop_without_shutdown(mut self) {
4674        // Safety: drops once, never accessed again due to mem::forget
4675        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4676        // Prevent Drop from running (which would shut down the channel)
4677        std::mem::forget(self);
4678    }
4679}
4680
4681impl ObserverWatchElementStateResponder {
4682    /// Sends a response to the FIDL transaction.
4683    ///
4684    /// Sets the channel to shutdown if an error occurs.
4685    pub fn send(
4686        self,
4687        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
4688    ) -> Result<(), fidl::Error> {
4689        let _result = self.send_raw(state);
4690        if _result.is_err() {
4691            self.control_handle.shutdown();
4692        }
4693        self.drop_without_shutdown();
4694        _result
4695    }
4696
4697    /// Similar to "send" but does not shutdown the channel if an error occurs.
4698    pub fn send_no_shutdown_on_err(
4699        self,
4700        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
4701    ) -> Result<(), fidl::Error> {
4702        let _result = self.send_raw(state);
4703        self.drop_without_shutdown();
4704        _result
4705    }
4706
4707    fn send_raw(
4708        &self,
4709        mut state: &fidl_fuchsia_hardware_audio_signalprocessing::ElementState,
4710    ) -> Result<(), fidl::Error> {
4711        self.control_handle
4712            .inner
4713            .send::<fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchElementStateResponse>(
4714            (state,),
4715            self.tx_id,
4716            0x524da8772a69056f,
4717            fidl::encoding::DynamicFlags::empty(),
4718        )
4719    }
4720}
4721
4722#[must_use = "FIDL methods require a response to be sent"]
4723#[derive(Debug)]
4724pub struct ObserverGetTopologiesResponder {
4725    control_handle: std::mem::ManuallyDrop<ObserverControlHandle>,
4726    tx_id: u32,
4727}
4728
4729/// Set the the channel to be shutdown (see [`ObserverControlHandle::shutdown`])
4730/// if the responder is dropped without sending a response, so that the client
4731/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4732impl std::ops::Drop for ObserverGetTopologiesResponder {
4733    fn drop(&mut self) {
4734        self.control_handle.shutdown();
4735        // Safety: drops once, never accessed again
4736        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4737    }
4738}
4739
4740impl fidl::endpoints::Responder for ObserverGetTopologiesResponder {
4741    type ControlHandle = ObserverControlHandle;
4742
4743    fn control_handle(&self) -> &ObserverControlHandle {
4744        &self.control_handle
4745    }
4746
4747    fn drop_without_shutdown(mut self) {
4748        // Safety: drops once, never accessed again due to mem::forget
4749        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4750        // Prevent Drop from running (which would shut down the channel)
4751        std::mem::forget(self);
4752    }
4753}
4754
4755impl ObserverGetTopologiesResponder {
4756    /// Sends a response to the FIDL transaction.
4757    ///
4758    /// Sets the channel to shutdown if an error occurs.
4759    pub fn send(
4760        self,
4761        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Topology], i32>,
4762    ) -> Result<(), fidl::Error> {
4763        let _result = self.send_raw(result);
4764        if _result.is_err() {
4765            self.control_handle.shutdown();
4766        }
4767        self.drop_without_shutdown();
4768        _result
4769    }
4770
4771    /// Similar to "send" but does not shutdown the channel if an error occurs.
4772    pub fn send_no_shutdown_on_err(
4773        self,
4774        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Topology], i32>,
4775    ) -> Result<(), fidl::Error> {
4776        let _result = self.send_raw(result);
4777        self.drop_without_shutdown();
4778        _result
4779    }
4780
4781    fn send_raw(
4782        &self,
4783        mut result: Result<&[fidl_fuchsia_hardware_audio_signalprocessing::Topology], i32>,
4784    ) -> Result<(), fidl::Error> {
4785        self.control_handle.inner.send::<fidl::encoding::ResultType<
4786            fidl_fuchsia_hardware_audio_signalprocessing::ReaderGetTopologiesResponse,
4787            i32,
4788        >>(
4789            result.map(|topologies| (topologies,)),
4790            self.tx_id,
4791            0x73ffb73af24d30b6,
4792            fidl::encoding::DynamicFlags::empty(),
4793        )
4794    }
4795}
4796
4797#[must_use = "FIDL methods require a response to be sent"]
4798#[derive(Debug)]
4799pub struct ObserverWatchTopologyResponder {
4800    control_handle: std::mem::ManuallyDrop<ObserverControlHandle>,
4801    tx_id: u32,
4802}
4803
4804/// Set the the channel to be shutdown (see [`ObserverControlHandle::shutdown`])
4805/// if the responder is dropped without sending a response, so that the client
4806/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4807impl std::ops::Drop for ObserverWatchTopologyResponder {
4808    fn drop(&mut self) {
4809        self.control_handle.shutdown();
4810        // Safety: drops once, never accessed again
4811        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4812    }
4813}
4814
4815impl fidl::endpoints::Responder for ObserverWatchTopologyResponder {
4816    type ControlHandle = ObserverControlHandle;
4817
4818    fn control_handle(&self) -> &ObserverControlHandle {
4819        &self.control_handle
4820    }
4821
4822    fn drop_without_shutdown(mut self) {
4823        // Safety: drops once, never accessed again due to mem::forget
4824        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4825        // Prevent Drop from running (which would shut down the channel)
4826        std::mem::forget(self);
4827    }
4828}
4829
4830impl ObserverWatchTopologyResponder {
4831    /// Sends a response to the FIDL transaction.
4832    ///
4833    /// Sets the channel to shutdown if an error occurs.
4834    pub fn send(self, mut topology_id: u64) -> Result<(), fidl::Error> {
4835        let _result = self.send_raw(topology_id);
4836        if _result.is_err() {
4837            self.control_handle.shutdown();
4838        }
4839        self.drop_without_shutdown();
4840        _result
4841    }
4842
4843    /// Similar to "send" but does not shutdown the channel if an error occurs.
4844    pub fn send_no_shutdown_on_err(self, mut topology_id: u64) -> Result<(), fidl::Error> {
4845        let _result = self.send_raw(topology_id);
4846        self.drop_without_shutdown();
4847        _result
4848    }
4849
4850    fn send_raw(&self, mut topology_id: u64) -> Result<(), fidl::Error> {
4851        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
4852            fidl_fuchsia_hardware_audio_signalprocessing::ReaderWatchTopologyResponse,
4853        >>(
4854            fidl::encoding::Flexible::new((topology_id,)),
4855            self.tx_id,
4856            0x66d172acdb36a729,
4857            fidl::encoding::DynamicFlags::FLEXIBLE,
4858        )
4859    }
4860}
4861
4862#[must_use = "FIDL methods require a response to be sent"]
4863#[derive(Debug)]
4864pub struct ObserverWatchPlugStateResponder {
4865    control_handle: std::mem::ManuallyDrop<ObserverControlHandle>,
4866    tx_id: u32,
4867}
4868
4869/// Set the the channel to be shutdown (see [`ObserverControlHandle::shutdown`])
4870/// if the responder is dropped without sending a response, so that the client
4871/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4872impl std::ops::Drop for ObserverWatchPlugStateResponder {
4873    fn drop(&mut self) {
4874        self.control_handle.shutdown();
4875        // Safety: drops once, never accessed again
4876        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4877    }
4878}
4879
4880impl fidl::endpoints::Responder for ObserverWatchPlugStateResponder {
4881    type ControlHandle = ObserverControlHandle;
4882
4883    fn control_handle(&self) -> &ObserverControlHandle {
4884        &self.control_handle
4885    }
4886
4887    fn drop_without_shutdown(mut self) {
4888        // Safety: drops once, never accessed again due to mem::forget
4889        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4890        // Prevent Drop from running (which would shut down the channel)
4891        std::mem::forget(self);
4892    }
4893}
4894
4895impl ObserverWatchPlugStateResponder {
4896    /// Sends a response to the FIDL transaction.
4897    ///
4898    /// Sets the channel to shutdown if an error occurs.
4899    pub fn send(
4900        self,
4901        mut result: Result<&ObserverWatchPlugStateResponse, ObserverWatchPlugStateError>,
4902    ) -> Result<(), fidl::Error> {
4903        let _result = self.send_raw(result);
4904        if _result.is_err() {
4905            self.control_handle.shutdown();
4906        }
4907        self.drop_without_shutdown();
4908        _result
4909    }
4910
4911    /// Similar to "send" but does not shutdown the channel if an error occurs.
4912    pub fn send_no_shutdown_on_err(
4913        self,
4914        mut result: Result<&ObserverWatchPlugStateResponse, ObserverWatchPlugStateError>,
4915    ) -> Result<(), fidl::Error> {
4916        let _result = self.send_raw(result);
4917        self.drop_without_shutdown();
4918        _result
4919    }
4920
4921    fn send_raw(
4922        &self,
4923        mut result: Result<&ObserverWatchPlugStateResponse, ObserverWatchPlugStateError>,
4924    ) -> Result<(), fidl::Error> {
4925        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4926            ObserverWatchPlugStateResponse,
4927            ObserverWatchPlugStateError,
4928        >>(
4929            fidl::encoding::FlexibleResult::new(result),
4930            self.tx_id,
4931            0x6312bce495d2907a,
4932            fidl::encoding::DynamicFlags::FLEXIBLE,
4933        )
4934    }
4935}
4936
4937#[must_use = "FIDL methods require a response to be sent"]
4938#[derive(Debug)]
4939pub struct ObserverGetReferenceClockResponder {
4940    control_handle: std::mem::ManuallyDrop<ObserverControlHandle>,
4941    tx_id: u32,
4942}
4943
4944/// Set the the channel to be shutdown (see [`ObserverControlHandle::shutdown`])
4945/// if the responder is dropped without sending a response, so that the client
4946/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4947impl std::ops::Drop for ObserverGetReferenceClockResponder {
4948    fn drop(&mut self) {
4949        self.control_handle.shutdown();
4950        // Safety: drops once, never accessed again
4951        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4952    }
4953}
4954
4955impl fidl::endpoints::Responder for ObserverGetReferenceClockResponder {
4956    type ControlHandle = ObserverControlHandle;
4957
4958    fn control_handle(&self) -> &ObserverControlHandle {
4959        &self.control_handle
4960    }
4961
4962    fn drop_without_shutdown(mut self) {
4963        // Safety: drops once, never accessed again due to mem::forget
4964        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4965        // Prevent Drop from running (which would shut down the channel)
4966        std::mem::forget(self);
4967    }
4968}
4969
4970impl ObserverGetReferenceClockResponder {
4971    /// Sends a response to the FIDL transaction.
4972    ///
4973    /// Sets the channel to shutdown if an error occurs.
4974    pub fn send(
4975        self,
4976        mut result: Result<ObserverGetReferenceClockResponse, ObserverGetReferenceClockError>,
4977    ) -> Result<(), fidl::Error> {
4978        let _result = self.send_raw(result);
4979        if _result.is_err() {
4980            self.control_handle.shutdown();
4981        }
4982        self.drop_without_shutdown();
4983        _result
4984    }
4985
4986    /// Similar to "send" but does not shutdown the channel if an error occurs.
4987    pub fn send_no_shutdown_on_err(
4988        self,
4989        mut result: Result<ObserverGetReferenceClockResponse, ObserverGetReferenceClockError>,
4990    ) -> Result<(), fidl::Error> {
4991        let _result = self.send_raw(result);
4992        self.drop_without_shutdown();
4993        _result
4994    }
4995
4996    fn send_raw(
4997        &self,
4998        mut result: Result<ObserverGetReferenceClockResponse, ObserverGetReferenceClockError>,
4999    ) -> Result<(), fidl::Error> {
5000        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5001            ObserverGetReferenceClockResponse,
5002            ObserverGetReferenceClockError,
5003        >>(
5004            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
5005            self.tx_id,
5006            0x3819c5e0f9574c39,
5007            fidl::encoding::DynamicFlags::FLEXIBLE,
5008        )
5009    }
5010}
5011
5012#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5013pub struct PacketStreamMarker;
5014
5015impl fidl::endpoints::ProtocolMarker for PacketStreamMarker {
5016    type Proxy = PacketStreamProxy;
5017    type RequestStream = PacketStreamRequestStream;
5018    #[cfg(target_os = "fuchsia")]
5019    type SynchronousProxy = PacketStreamSynchronousProxy;
5020
5021    const DEBUG_NAME: &'static str = "(anonymous) PacketStream";
5022}
5023pub type PacketStreamSetBuffersResult =
5024    Result<PacketStreamSetBuffersResponse, PacketStreamSetBufferError>;
5025pub type PacketStreamStartResult = Result<PacketStreamStartResponse, PacketStreamStartError>;
5026pub type PacketStreamStopResult = Result<PacketStreamStopResponse, PacketStreamStopError>;
5027
5028pub trait PacketStreamProxyInterface: Send + Sync {
5029    type SetBuffersResponseFut: std::future::Future<Output = Result<PacketStreamSetBuffersResult, fidl::Error>>
5030        + Send;
5031    fn r#set_buffers(&self, payload: PacketStreamSetBuffersRequest) -> Self::SetBuffersResponseFut;
5032    type StartResponseFut: std::future::Future<Output = Result<PacketStreamStartResult, fidl::Error>>
5033        + Send;
5034    fn r#start(&self, payload: &PacketStreamStartRequest) -> Self::StartResponseFut;
5035    type StopResponseFut: std::future::Future<Output = Result<PacketStreamStopResult, fidl::Error>>
5036        + Send;
5037    fn r#stop(&self, payload: &PacketStreamStopRequest) -> Self::StopResponseFut;
5038}
5039#[derive(Debug)]
5040#[cfg(target_os = "fuchsia")]
5041pub struct PacketStreamSynchronousProxy {
5042    client: fidl::client::sync::Client,
5043}
5044
5045#[cfg(target_os = "fuchsia")]
5046impl fidl::endpoints::SynchronousProxy for PacketStreamSynchronousProxy {
5047    type Proxy = PacketStreamProxy;
5048    type Protocol = PacketStreamMarker;
5049
5050    fn from_channel(inner: fidl::Channel) -> Self {
5051        Self::new(inner)
5052    }
5053
5054    fn into_channel(self) -> fidl::Channel {
5055        self.client.into_channel()
5056    }
5057
5058    fn as_channel(&self) -> &fidl::Channel {
5059        self.client.as_channel()
5060    }
5061}
5062
5063#[cfg(target_os = "fuchsia")]
5064impl PacketStreamSynchronousProxy {
5065    pub fn new(channel: fidl::Channel) -> Self {
5066        Self { client: fidl::client::sync::Client::new(channel) }
5067    }
5068
5069    pub fn into_channel(self) -> fidl::Channel {
5070        self.client.into_channel()
5071    }
5072
5073    /// Waits until an event arrives and returns it. It is safe for other
5074    /// threads to make concurrent requests while waiting for an event.
5075    pub fn wait_for_event(
5076        &self,
5077        deadline: zx::MonotonicInstant,
5078    ) -> Result<PacketStreamEvent, fidl::Error> {
5079        PacketStreamEvent::decode(self.client.wait_for_event::<PacketStreamMarker>(deadline)?)
5080    }
5081
5082    /// Configures the shared memory buffers used to transfer audio data.
5083    ///
5084    /// This method must be called before `Start` unless INLINE buffer type is supported
5085    /// and the client intends to exclusively use inline data transfer.
5086    pub fn r#set_buffers(
5087        &self,
5088        mut payload: PacketStreamSetBuffersRequest,
5089        ___deadline: zx::MonotonicInstant,
5090    ) -> Result<PacketStreamSetBuffersResult, fidl::Error> {
5091        let _response = self
5092            .client
5093            .send_query::<PacketStreamSetBuffersRequest, fidl::encoding::FlexibleResultType<
5094                PacketStreamSetBuffersResponse,
5095                PacketStreamSetBufferError,
5096            >, PacketStreamMarker>(
5097                &mut payload,
5098                0x5ccdec88e71cf564,
5099                fidl::encoding::DynamicFlags::FLEXIBLE,
5100                ___deadline,
5101            )?
5102            .into_result::<PacketStreamMarker>("set_buffers")?;
5103        Ok(_response.map(|x| x))
5104    }
5105
5106    /// Start the packet stream.
5107    pub fn r#start(
5108        &self,
5109        mut payload: &PacketStreamStartRequest,
5110        ___deadline: zx::MonotonicInstant,
5111    ) -> Result<PacketStreamStartResult, fidl::Error> {
5112        let _response =
5113            self.client
5114                .send_query::<PacketStreamStartRequest, fidl::encoding::FlexibleResultType<
5115                    PacketStreamStartResponse,
5116                    PacketStreamStartError,
5117                >, PacketStreamMarker>(
5118                    payload,
5119                    0x70710dba352debdd,
5120                    fidl::encoding::DynamicFlags::FLEXIBLE,
5121                    ___deadline,
5122                )?
5123                .into_result::<PacketStreamMarker>("start")?;
5124        Ok(_response.map(|x| x))
5125    }
5126
5127    /// Stop the packet stream.
5128    pub fn r#stop(
5129        &self,
5130        mut payload: &PacketStreamStopRequest,
5131        ___deadline: zx::MonotonicInstant,
5132    ) -> Result<PacketStreamStopResult, fidl::Error> {
5133        let _response = self.client.send_query::<
5134            PacketStreamStopRequest,
5135            fidl::encoding::FlexibleResultType<PacketStreamStopResponse, PacketStreamStopError>,
5136            PacketStreamMarker,
5137        >(
5138            payload,
5139            0x11db078485b7d51e,
5140            fidl::encoding::DynamicFlags::FLEXIBLE,
5141            ___deadline,
5142        )?
5143        .into_result::<PacketStreamMarker>("stop")?;
5144        Ok(_response.map(|x| x))
5145    }
5146}
5147
5148#[cfg(target_os = "fuchsia")]
5149impl From<PacketStreamSynchronousProxy> for zx::NullableHandle {
5150    fn from(value: PacketStreamSynchronousProxy) -> Self {
5151        value.into_channel().into()
5152    }
5153}
5154
5155#[cfg(target_os = "fuchsia")]
5156impl From<fidl::Channel> for PacketStreamSynchronousProxy {
5157    fn from(value: fidl::Channel) -> Self {
5158        Self::new(value)
5159    }
5160}
5161
5162#[cfg(target_os = "fuchsia")]
5163impl fidl::endpoints::FromClient for PacketStreamSynchronousProxy {
5164    type Protocol = PacketStreamMarker;
5165
5166    fn from_client(value: fidl::endpoints::ClientEnd<PacketStreamMarker>) -> Self {
5167        Self::new(value.into_channel())
5168    }
5169}
5170
5171#[derive(Debug, Clone)]
5172pub struct PacketStreamProxy {
5173    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5174}
5175
5176impl fidl::endpoints::Proxy for PacketStreamProxy {
5177    type Protocol = PacketStreamMarker;
5178
5179    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5180        Self::new(inner)
5181    }
5182
5183    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5184        self.client.into_channel().map_err(|client| Self { client })
5185    }
5186
5187    fn as_channel(&self) -> &::fidl::AsyncChannel {
5188        self.client.as_channel()
5189    }
5190}
5191
5192impl PacketStreamProxy {
5193    /// Create a new Proxy for fuchsia.audio.device/PacketStream.
5194    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5195        let protocol_name = <PacketStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5196        Self { client: fidl::client::Client::new(channel, protocol_name) }
5197    }
5198
5199    /// Get a Stream of events from the remote end of the protocol.
5200    ///
5201    /// # Panics
5202    ///
5203    /// Panics if the event stream was already taken.
5204    pub fn take_event_stream(&self) -> PacketStreamEventStream {
5205        PacketStreamEventStream { event_receiver: self.client.take_event_receiver() }
5206    }
5207
5208    /// Configures the shared memory buffers used to transfer audio data.
5209    ///
5210    /// This method must be called before `Start` unless INLINE buffer type is supported
5211    /// and the client intends to exclusively use inline data transfer.
5212    pub fn r#set_buffers(
5213        &self,
5214        mut payload: PacketStreamSetBuffersRequest,
5215    ) -> fidl::client::QueryResponseFut<
5216        PacketStreamSetBuffersResult,
5217        fidl::encoding::DefaultFuchsiaResourceDialect,
5218    > {
5219        PacketStreamProxyInterface::r#set_buffers(self, payload)
5220    }
5221
5222    /// Start the packet stream.
5223    pub fn r#start(
5224        &self,
5225        mut payload: &PacketStreamStartRequest,
5226    ) -> fidl::client::QueryResponseFut<
5227        PacketStreamStartResult,
5228        fidl::encoding::DefaultFuchsiaResourceDialect,
5229    > {
5230        PacketStreamProxyInterface::r#start(self, payload)
5231    }
5232
5233    /// Stop the packet stream.
5234    pub fn r#stop(
5235        &self,
5236        mut payload: &PacketStreamStopRequest,
5237    ) -> fidl::client::QueryResponseFut<
5238        PacketStreamStopResult,
5239        fidl::encoding::DefaultFuchsiaResourceDialect,
5240    > {
5241        PacketStreamProxyInterface::r#stop(self, payload)
5242    }
5243}
5244
5245impl PacketStreamProxyInterface for PacketStreamProxy {
5246    type SetBuffersResponseFut = fidl::client::QueryResponseFut<
5247        PacketStreamSetBuffersResult,
5248        fidl::encoding::DefaultFuchsiaResourceDialect,
5249    >;
5250    fn r#set_buffers(
5251        &self,
5252        mut payload: PacketStreamSetBuffersRequest,
5253    ) -> Self::SetBuffersResponseFut {
5254        fn _decode(
5255            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5256        ) -> Result<PacketStreamSetBuffersResult, fidl::Error> {
5257            let _response = fidl::client::decode_transaction_body::<
5258                fidl::encoding::FlexibleResultType<
5259                    PacketStreamSetBuffersResponse,
5260                    PacketStreamSetBufferError,
5261                >,
5262                fidl::encoding::DefaultFuchsiaResourceDialect,
5263                0x5ccdec88e71cf564,
5264            >(_buf?)?
5265            .into_result::<PacketStreamMarker>("set_buffers")?;
5266            Ok(_response.map(|x| x))
5267        }
5268        self.client
5269            .send_query_and_decode::<PacketStreamSetBuffersRequest, PacketStreamSetBuffersResult>(
5270                &mut payload,
5271                0x5ccdec88e71cf564,
5272                fidl::encoding::DynamicFlags::FLEXIBLE,
5273                _decode,
5274            )
5275    }
5276
5277    type StartResponseFut = fidl::client::QueryResponseFut<
5278        PacketStreamStartResult,
5279        fidl::encoding::DefaultFuchsiaResourceDialect,
5280    >;
5281    fn r#start(&self, mut payload: &PacketStreamStartRequest) -> Self::StartResponseFut {
5282        fn _decode(
5283            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5284        ) -> Result<PacketStreamStartResult, fidl::Error> {
5285            let _response = fidl::client::decode_transaction_body::<
5286                fidl::encoding::FlexibleResultType<
5287                    PacketStreamStartResponse,
5288                    PacketStreamStartError,
5289                >,
5290                fidl::encoding::DefaultFuchsiaResourceDialect,
5291                0x70710dba352debdd,
5292            >(_buf?)?
5293            .into_result::<PacketStreamMarker>("start")?;
5294            Ok(_response.map(|x| x))
5295        }
5296        self.client.send_query_and_decode::<PacketStreamStartRequest, PacketStreamStartResult>(
5297            payload,
5298            0x70710dba352debdd,
5299            fidl::encoding::DynamicFlags::FLEXIBLE,
5300            _decode,
5301        )
5302    }
5303
5304    type StopResponseFut = fidl::client::QueryResponseFut<
5305        PacketStreamStopResult,
5306        fidl::encoding::DefaultFuchsiaResourceDialect,
5307    >;
5308    fn r#stop(&self, mut payload: &PacketStreamStopRequest) -> Self::StopResponseFut {
5309        fn _decode(
5310            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5311        ) -> Result<PacketStreamStopResult, fidl::Error> {
5312            let _response = fidl::client::decode_transaction_body::<
5313                fidl::encoding::FlexibleResultType<PacketStreamStopResponse, PacketStreamStopError>,
5314                fidl::encoding::DefaultFuchsiaResourceDialect,
5315                0x11db078485b7d51e,
5316            >(_buf?)?
5317            .into_result::<PacketStreamMarker>("stop")?;
5318            Ok(_response.map(|x| x))
5319        }
5320        self.client.send_query_and_decode::<PacketStreamStopRequest, PacketStreamStopResult>(
5321            payload,
5322            0x11db078485b7d51e,
5323            fidl::encoding::DynamicFlags::FLEXIBLE,
5324            _decode,
5325        )
5326    }
5327}
5328
5329pub struct PacketStreamEventStream {
5330    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5331}
5332
5333impl std::marker::Unpin for PacketStreamEventStream {}
5334
5335impl futures::stream::FusedStream for PacketStreamEventStream {
5336    fn is_terminated(&self) -> bool {
5337        self.event_receiver.is_terminated()
5338    }
5339}
5340
5341impl futures::Stream for PacketStreamEventStream {
5342    type Item = Result<PacketStreamEvent, fidl::Error>;
5343
5344    fn poll_next(
5345        mut self: std::pin::Pin<&mut Self>,
5346        cx: &mut std::task::Context<'_>,
5347    ) -> std::task::Poll<Option<Self::Item>> {
5348        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5349            &mut self.event_receiver,
5350            cx
5351        )?) {
5352            Some(buf) => std::task::Poll::Ready(Some(PacketStreamEvent::decode(buf))),
5353            None => std::task::Poll::Ready(None),
5354        }
5355    }
5356}
5357
5358#[derive(Debug)]
5359pub enum PacketStreamEvent {
5360    #[non_exhaustive]
5361    _UnknownEvent {
5362        /// Ordinal of the event that was sent.
5363        ordinal: u64,
5364    },
5365}
5366
5367impl PacketStreamEvent {
5368    /// Decodes a message buffer as a [`PacketStreamEvent`].
5369    fn decode(
5370        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5371    ) -> Result<PacketStreamEvent, fidl::Error> {
5372        let (bytes, _handles) = buf.split_mut();
5373        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5374        debug_assert_eq!(tx_header.tx_id, 0);
5375        match tx_header.ordinal {
5376            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5377                Ok(PacketStreamEvent::_UnknownEvent { ordinal: tx_header.ordinal })
5378            }
5379            _ => Err(fidl::Error::UnknownOrdinal {
5380                ordinal: tx_header.ordinal,
5381                protocol_name: <PacketStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5382            }),
5383        }
5384    }
5385}
5386
5387/// A Stream of incoming requests for fuchsia.audio.device/PacketStream.
5388pub struct PacketStreamRequestStream {
5389    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5390    is_terminated: bool,
5391}
5392
5393impl std::marker::Unpin for PacketStreamRequestStream {}
5394
5395impl futures::stream::FusedStream for PacketStreamRequestStream {
5396    fn is_terminated(&self) -> bool {
5397        self.is_terminated
5398    }
5399}
5400
5401impl fidl::endpoints::RequestStream for PacketStreamRequestStream {
5402    type Protocol = PacketStreamMarker;
5403    type ControlHandle = PacketStreamControlHandle;
5404
5405    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5406        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5407    }
5408
5409    fn control_handle(&self) -> Self::ControlHandle {
5410        PacketStreamControlHandle { inner: self.inner.clone() }
5411    }
5412
5413    fn into_inner(
5414        self,
5415    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5416    {
5417        (self.inner, self.is_terminated)
5418    }
5419
5420    fn from_inner(
5421        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5422        is_terminated: bool,
5423    ) -> Self {
5424        Self { inner, is_terminated }
5425    }
5426}
5427
5428impl futures::Stream for PacketStreamRequestStream {
5429    type Item = Result<PacketStreamRequest, fidl::Error>;
5430
5431    fn poll_next(
5432        mut self: std::pin::Pin<&mut Self>,
5433        cx: &mut std::task::Context<'_>,
5434    ) -> std::task::Poll<Option<Self::Item>> {
5435        let this = &mut *self;
5436        if this.inner.check_shutdown(cx) {
5437            this.is_terminated = true;
5438            return std::task::Poll::Ready(None);
5439        }
5440        if this.is_terminated {
5441            panic!("polled PacketStreamRequestStream after completion");
5442        }
5443        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5444            |bytes, handles| {
5445                match this.inner.channel().read_etc(cx, bytes, handles) {
5446                    std::task::Poll::Ready(Ok(())) => {}
5447                    std::task::Poll::Pending => return std::task::Poll::Pending,
5448                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5449                        this.is_terminated = true;
5450                        return std::task::Poll::Ready(None);
5451                    }
5452                    std::task::Poll::Ready(Err(e)) => {
5453                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5454                            e.into(),
5455                        ))));
5456                    }
5457                }
5458
5459                // A message has been received from the channel
5460                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5461
5462                std::task::Poll::Ready(Some(match header.ordinal {
5463                    0x5ccdec88e71cf564 => {
5464                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5465                        let mut req = fidl::new_empty!(
5466                            PacketStreamSetBuffersRequest,
5467                            fidl::encoding::DefaultFuchsiaResourceDialect
5468                        );
5469                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PacketStreamSetBuffersRequest>(&header, _body_bytes, handles, &mut req)?;
5470                        let control_handle =
5471                            PacketStreamControlHandle { inner: this.inner.clone() };
5472                        Ok(PacketStreamRequest::SetBuffers {
5473                            payload: req,
5474                            responder: PacketStreamSetBuffersResponder {
5475                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5476                                tx_id: header.tx_id,
5477                            },
5478                        })
5479                    }
5480                    0x70710dba352debdd => {
5481                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5482                        let mut req = fidl::new_empty!(
5483                            PacketStreamStartRequest,
5484                            fidl::encoding::DefaultFuchsiaResourceDialect
5485                        );
5486                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PacketStreamStartRequest>(&header, _body_bytes, handles, &mut req)?;
5487                        let control_handle =
5488                            PacketStreamControlHandle { inner: this.inner.clone() };
5489                        Ok(PacketStreamRequest::Start {
5490                            payload: req,
5491                            responder: PacketStreamStartResponder {
5492                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5493                                tx_id: header.tx_id,
5494                            },
5495                        })
5496                    }
5497                    0x11db078485b7d51e => {
5498                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5499                        let mut req = fidl::new_empty!(
5500                            PacketStreamStopRequest,
5501                            fidl::encoding::DefaultFuchsiaResourceDialect
5502                        );
5503                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PacketStreamStopRequest>(&header, _body_bytes, handles, &mut req)?;
5504                        let control_handle =
5505                            PacketStreamControlHandle { inner: this.inner.clone() };
5506                        Ok(PacketStreamRequest::Stop {
5507                            payload: req,
5508                            responder: PacketStreamStopResponder {
5509                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5510                                tx_id: header.tx_id,
5511                            },
5512                        })
5513                    }
5514                    _ if header.tx_id == 0
5515                        && header
5516                            .dynamic_flags()
5517                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5518                    {
5519                        Ok(PacketStreamRequest::_UnknownMethod {
5520                            ordinal: header.ordinal,
5521                            control_handle: PacketStreamControlHandle { inner: this.inner.clone() },
5522                            method_type: fidl::MethodType::OneWay,
5523                        })
5524                    }
5525                    _ if header
5526                        .dynamic_flags()
5527                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5528                    {
5529                        this.inner.send_framework_err(
5530                            fidl::encoding::FrameworkErr::UnknownMethod,
5531                            header.tx_id,
5532                            header.ordinal,
5533                            header.dynamic_flags(),
5534                            (bytes, handles),
5535                        )?;
5536                        Ok(PacketStreamRequest::_UnknownMethod {
5537                            ordinal: header.ordinal,
5538                            control_handle: PacketStreamControlHandle { inner: this.inner.clone() },
5539                            method_type: fidl::MethodType::TwoWay,
5540                        })
5541                    }
5542                    _ => Err(fidl::Error::UnknownOrdinal {
5543                        ordinal: header.ordinal,
5544                        protocol_name:
5545                            <PacketStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5546                    }),
5547                }))
5548            },
5549        )
5550    }
5551}
5552
5553/// A `PacketStream` instance controls data flow for the associated audio stream.
5554#[derive(Debug)]
5555pub enum PacketStreamRequest {
5556    /// Configures the shared memory buffers used to transfer audio data.
5557    ///
5558    /// This method must be called before `Start` unless INLINE buffer type is supported
5559    /// and the client intends to exclusively use inline data transfer.
5560    SetBuffers {
5561        payload: PacketStreamSetBuffersRequest,
5562        responder: PacketStreamSetBuffersResponder,
5563    },
5564    /// Start the packet stream.
5565    Start { payload: PacketStreamStartRequest, responder: PacketStreamStartResponder },
5566    /// Stop the packet stream.
5567    Stop { payload: PacketStreamStopRequest, responder: PacketStreamStopResponder },
5568    /// An interaction was received which does not match any known method.
5569    #[non_exhaustive]
5570    _UnknownMethod {
5571        /// Ordinal of the method that was called.
5572        ordinal: u64,
5573        control_handle: PacketStreamControlHandle,
5574        method_type: fidl::MethodType,
5575    },
5576}
5577
5578impl PacketStreamRequest {
5579    #[allow(irrefutable_let_patterns)]
5580    pub fn into_set_buffers(
5581        self,
5582    ) -> Option<(PacketStreamSetBuffersRequest, PacketStreamSetBuffersResponder)> {
5583        if let PacketStreamRequest::SetBuffers { payload, responder } = self {
5584            Some((payload, responder))
5585        } else {
5586            None
5587        }
5588    }
5589
5590    #[allow(irrefutable_let_patterns)]
5591    pub fn into_start(self) -> Option<(PacketStreamStartRequest, PacketStreamStartResponder)> {
5592        if let PacketStreamRequest::Start { payload, responder } = self {
5593            Some((payload, responder))
5594        } else {
5595            None
5596        }
5597    }
5598
5599    #[allow(irrefutable_let_patterns)]
5600    pub fn into_stop(self) -> Option<(PacketStreamStopRequest, PacketStreamStopResponder)> {
5601        if let PacketStreamRequest::Stop { payload, responder } = self {
5602            Some((payload, responder))
5603        } else {
5604            None
5605        }
5606    }
5607
5608    /// Name of the method defined in FIDL
5609    pub fn method_name(&self) -> &'static str {
5610        match *self {
5611            PacketStreamRequest::SetBuffers { .. } => "set_buffers",
5612            PacketStreamRequest::Start { .. } => "start",
5613            PacketStreamRequest::Stop { .. } => "stop",
5614            PacketStreamRequest::_UnknownMethod {
5615                method_type: fidl::MethodType::OneWay, ..
5616            } => "unknown one-way method",
5617            PacketStreamRequest::_UnknownMethod {
5618                method_type: fidl::MethodType::TwoWay, ..
5619            } => "unknown two-way method",
5620        }
5621    }
5622}
5623
5624#[derive(Debug, Clone)]
5625pub struct PacketStreamControlHandle {
5626    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5627}
5628
5629impl PacketStreamControlHandle {
5630    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
5631        self.inner.shutdown_with_epitaph(status.into())
5632    }
5633}
5634
5635impl fidl::endpoints::ControlHandle for PacketStreamControlHandle {
5636    fn shutdown(&self) {
5637        self.inner.shutdown()
5638    }
5639
5640    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
5641        self.inner.shutdown_with_epitaph(status)
5642    }
5643
5644    fn is_closed(&self) -> bool {
5645        self.inner.channel().is_closed()
5646    }
5647    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5648        self.inner.channel().on_closed()
5649    }
5650
5651    #[cfg(target_os = "fuchsia")]
5652    fn signal_peer(
5653        &self,
5654        clear_mask: zx::Signals,
5655        set_mask: zx::Signals,
5656    ) -> Result<(), zx_status::Status> {
5657        use fidl::Peered;
5658        self.inner.channel().signal_peer(clear_mask, set_mask)
5659    }
5660}
5661
5662impl PacketStreamControlHandle {}
5663
5664#[must_use = "FIDL methods require a response to be sent"]
5665#[derive(Debug)]
5666pub struct PacketStreamSetBuffersResponder {
5667    control_handle: std::mem::ManuallyDrop<PacketStreamControlHandle>,
5668    tx_id: u32,
5669}
5670
5671/// Set the the channel to be shutdown (see [`PacketStreamControlHandle::shutdown`])
5672/// if the responder is dropped without sending a response, so that the client
5673/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5674impl std::ops::Drop for PacketStreamSetBuffersResponder {
5675    fn drop(&mut self) {
5676        self.control_handle.shutdown();
5677        // Safety: drops once, never accessed again
5678        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5679    }
5680}
5681
5682impl fidl::endpoints::Responder for PacketStreamSetBuffersResponder {
5683    type ControlHandle = PacketStreamControlHandle;
5684
5685    fn control_handle(&self) -> &PacketStreamControlHandle {
5686        &self.control_handle
5687    }
5688
5689    fn drop_without_shutdown(mut self) {
5690        // Safety: drops once, never accessed again due to mem::forget
5691        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5692        // Prevent Drop from running (which would shut down the channel)
5693        std::mem::forget(self);
5694    }
5695}
5696
5697impl PacketStreamSetBuffersResponder {
5698    /// Sends a response to the FIDL transaction.
5699    ///
5700    /// Sets the channel to shutdown if an error occurs.
5701    pub fn send(
5702        self,
5703        mut result: Result<PacketStreamSetBuffersResponse, PacketStreamSetBufferError>,
5704    ) -> Result<(), fidl::Error> {
5705        let _result = self.send_raw(result);
5706        if _result.is_err() {
5707            self.control_handle.shutdown();
5708        }
5709        self.drop_without_shutdown();
5710        _result
5711    }
5712
5713    /// Similar to "send" but does not shutdown the channel if an error occurs.
5714    pub fn send_no_shutdown_on_err(
5715        self,
5716        mut result: Result<PacketStreamSetBuffersResponse, PacketStreamSetBufferError>,
5717    ) -> Result<(), fidl::Error> {
5718        let _result = self.send_raw(result);
5719        self.drop_without_shutdown();
5720        _result
5721    }
5722
5723    fn send_raw(
5724        &self,
5725        mut result: Result<PacketStreamSetBuffersResponse, PacketStreamSetBufferError>,
5726    ) -> Result<(), fidl::Error> {
5727        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5728            PacketStreamSetBuffersResponse,
5729            PacketStreamSetBufferError,
5730        >>(
5731            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
5732            self.tx_id,
5733            0x5ccdec88e71cf564,
5734            fidl::encoding::DynamicFlags::FLEXIBLE,
5735        )
5736    }
5737}
5738
5739#[must_use = "FIDL methods require a response to be sent"]
5740#[derive(Debug)]
5741pub struct PacketStreamStartResponder {
5742    control_handle: std::mem::ManuallyDrop<PacketStreamControlHandle>,
5743    tx_id: u32,
5744}
5745
5746/// Set the the channel to be shutdown (see [`PacketStreamControlHandle::shutdown`])
5747/// if the responder is dropped without sending a response, so that the client
5748/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5749impl std::ops::Drop for PacketStreamStartResponder {
5750    fn drop(&mut self) {
5751        self.control_handle.shutdown();
5752        // Safety: drops once, never accessed again
5753        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5754    }
5755}
5756
5757impl fidl::endpoints::Responder for PacketStreamStartResponder {
5758    type ControlHandle = PacketStreamControlHandle;
5759
5760    fn control_handle(&self) -> &PacketStreamControlHandle {
5761        &self.control_handle
5762    }
5763
5764    fn drop_without_shutdown(mut self) {
5765        // Safety: drops once, never accessed again due to mem::forget
5766        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5767        // Prevent Drop from running (which would shut down the channel)
5768        std::mem::forget(self);
5769    }
5770}
5771
5772impl PacketStreamStartResponder {
5773    /// Sends a response to the FIDL transaction.
5774    ///
5775    /// Sets the channel to shutdown if an error occurs.
5776    pub fn send(
5777        self,
5778        mut result: Result<&PacketStreamStartResponse, PacketStreamStartError>,
5779    ) -> Result<(), fidl::Error> {
5780        let _result = self.send_raw(result);
5781        if _result.is_err() {
5782            self.control_handle.shutdown();
5783        }
5784        self.drop_without_shutdown();
5785        _result
5786    }
5787
5788    /// Similar to "send" but does not shutdown the channel if an error occurs.
5789    pub fn send_no_shutdown_on_err(
5790        self,
5791        mut result: Result<&PacketStreamStartResponse, PacketStreamStartError>,
5792    ) -> Result<(), fidl::Error> {
5793        let _result = self.send_raw(result);
5794        self.drop_without_shutdown();
5795        _result
5796    }
5797
5798    fn send_raw(
5799        &self,
5800        mut result: Result<&PacketStreamStartResponse, PacketStreamStartError>,
5801    ) -> Result<(), fidl::Error> {
5802        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5803            PacketStreamStartResponse,
5804            PacketStreamStartError,
5805        >>(
5806            fidl::encoding::FlexibleResult::new(result),
5807            self.tx_id,
5808            0x70710dba352debdd,
5809            fidl::encoding::DynamicFlags::FLEXIBLE,
5810        )
5811    }
5812}
5813
5814#[must_use = "FIDL methods require a response to be sent"]
5815#[derive(Debug)]
5816pub struct PacketStreamStopResponder {
5817    control_handle: std::mem::ManuallyDrop<PacketStreamControlHandle>,
5818    tx_id: u32,
5819}
5820
5821/// Set the the channel to be shutdown (see [`PacketStreamControlHandle::shutdown`])
5822/// if the responder is dropped without sending a response, so that the client
5823/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5824impl std::ops::Drop for PacketStreamStopResponder {
5825    fn drop(&mut self) {
5826        self.control_handle.shutdown();
5827        // Safety: drops once, never accessed again
5828        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5829    }
5830}
5831
5832impl fidl::endpoints::Responder for PacketStreamStopResponder {
5833    type ControlHandle = PacketStreamControlHandle;
5834
5835    fn control_handle(&self) -> &PacketStreamControlHandle {
5836        &self.control_handle
5837    }
5838
5839    fn drop_without_shutdown(mut self) {
5840        // Safety: drops once, never accessed again due to mem::forget
5841        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5842        // Prevent Drop from running (which would shut down the channel)
5843        std::mem::forget(self);
5844    }
5845}
5846
5847impl PacketStreamStopResponder {
5848    /// Sends a response to the FIDL transaction.
5849    ///
5850    /// Sets the channel to shutdown if an error occurs.
5851    pub fn send(
5852        self,
5853        mut result: Result<&PacketStreamStopResponse, PacketStreamStopError>,
5854    ) -> Result<(), fidl::Error> {
5855        let _result = self.send_raw(result);
5856        if _result.is_err() {
5857            self.control_handle.shutdown();
5858        }
5859        self.drop_without_shutdown();
5860        _result
5861    }
5862
5863    /// Similar to "send" but does not shutdown the channel if an error occurs.
5864    pub fn send_no_shutdown_on_err(
5865        self,
5866        mut result: Result<&PacketStreamStopResponse, PacketStreamStopError>,
5867    ) -> Result<(), fidl::Error> {
5868        let _result = self.send_raw(result);
5869        self.drop_without_shutdown();
5870        _result
5871    }
5872
5873    fn send_raw(
5874        &self,
5875        mut result: Result<&PacketStreamStopResponse, PacketStreamStopError>,
5876    ) -> Result<(), fidl::Error> {
5877        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
5878            PacketStreamStopResponse,
5879            PacketStreamStopError,
5880        >>(
5881            fidl::encoding::FlexibleResult::new(result),
5882            self.tx_id,
5883            0x11db078485b7d51e,
5884            fidl::encoding::DynamicFlags::FLEXIBLE,
5885        )
5886    }
5887}
5888
5889#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5890pub struct ProviderMarker;
5891
5892impl fidl::endpoints::ProtocolMarker for ProviderMarker {
5893    type Proxy = ProviderProxy;
5894    type RequestStream = ProviderRequestStream;
5895    #[cfg(target_os = "fuchsia")]
5896    type SynchronousProxy = ProviderSynchronousProxy;
5897
5898    const DEBUG_NAME: &'static str = "fuchsia.audio.device.Provider";
5899}
5900impl fidl::endpoints::DiscoverableProtocolMarker for ProviderMarker {}
5901pub type ProviderAddDeviceResult = Result<ProviderAddDeviceResponse, ProviderAddDeviceError>;
5902
5903pub trait ProviderProxyInterface: Send + Sync {
5904    type AddDeviceResponseFut: std::future::Future<Output = Result<ProviderAddDeviceResult, fidl::Error>>
5905        + Send;
5906    fn r#add_device(&self, payload: ProviderAddDeviceRequest) -> Self::AddDeviceResponseFut;
5907}
5908#[derive(Debug)]
5909#[cfg(target_os = "fuchsia")]
5910pub struct ProviderSynchronousProxy {
5911    client: fidl::client::sync::Client,
5912}
5913
5914#[cfg(target_os = "fuchsia")]
5915impl fidl::endpoints::SynchronousProxy for ProviderSynchronousProxy {
5916    type Proxy = ProviderProxy;
5917    type Protocol = ProviderMarker;
5918
5919    fn from_channel(inner: fidl::Channel) -> Self {
5920        Self::new(inner)
5921    }
5922
5923    fn into_channel(self) -> fidl::Channel {
5924        self.client.into_channel()
5925    }
5926
5927    fn as_channel(&self) -> &fidl::Channel {
5928        self.client.as_channel()
5929    }
5930}
5931
5932#[cfg(target_os = "fuchsia")]
5933impl ProviderSynchronousProxy {
5934    pub fn new(channel: fidl::Channel) -> Self {
5935        Self { client: fidl::client::sync::Client::new(channel) }
5936    }
5937
5938    pub fn into_channel(self) -> fidl::Channel {
5939        self.client.into_channel()
5940    }
5941
5942    /// Waits until an event arrives and returns it. It is safe for other
5943    /// threads to make concurrent requests while waiting for an event.
5944    pub fn wait_for_event(
5945        &self,
5946        deadline: zx::MonotonicInstant,
5947    ) -> Result<ProviderEvent, fidl::Error> {
5948        ProviderEvent::decode(self.client.wait_for_event::<ProviderMarker>(deadline)?)
5949    }
5950
5951    pub fn r#add_device(
5952        &self,
5953        mut payload: ProviderAddDeviceRequest,
5954        ___deadline: zx::MonotonicInstant,
5955    ) -> Result<ProviderAddDeviceResult, fidl::Error> {
5956        let _response =
5957            self.client
5958                .send_query::<ProviderAddDeviceRequest, fidl::encoding::FlexibleResultType<
5959                    ProviderAddDeviceResponse,
5960                    ProviderAddDeviceError,
5961                >, ProviderMarker>(
5962                    &mut payload,
5963                    0x685fdfd91937758b,
5964                    fidl::encoding::DynamicFlags::FLEXIBLE,
5965                    ___deadline,
5966                )?
5967                .into_result::<ProviderMarker>("add_device")?;
5968        Ok(_response.map(|x| x))
5969    }
5970}
5971
5972#[cfg(target_os = "fuchsia")]
5973impl From<ProviderSynchronousProxy> for zx::NullableHandle {
5974    fn from(value: ProviderSynchronousProxy) -> Self {
5975        value.into_channel().into()
5976    }
5977}
5978
5979#[cfg(target_os = "fuchsia")]
5980impl From<fidl::Channel> for ProviderSynchronousProxy {
5981    fn from(value: fidl::Channel) -> Self {
5982        Self::new(value)
5983    }
5984}
5985
5986#[cfg(target_os = "fuchsia")]
5987impl fidl::endpoints::FromClient for ProviderSynchronousProxy {
5988    type Protocol = ProviderMarker;
5989
5990    fn from_client(value: fidl::endpoints::ClientEnd<ProviderMarker>) -> Self {
5991        Self::new(value.into_channel())
5992    }
5993}
5994
5995#[derive(Debug, Clone)]
5996pub struct ProviderProxy {
5997    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5998}
5999
6000impl fidl::endpoints::Proxy for ProviderProxy {
6001    type Protocol = ProviderMarker;
6002
6003    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6004        Self::new(inner)
6005    }
6006
6007    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6008        self.client.into_channel().map_err(|client| Self { client })
6009    }
6010
6011    fn as_channel(&self) -> &::fidl::AsyncChannel {
6012        self.client.as_channel()
6013    }
6014}
6015
6016impl ProviderProxy {
6017    /// Create a new Proxy for fuchsia.audio.device/Provider.
6018    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6019        let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6020        Self { client: fidl::client::Client::new(channel, protocol_name) }
6021    }
6022
6023    /// Get a Stream of events from the remote end of the protocol.
6024    ///
6025    /// # Panics
6026    ///
6027    /// Panics if the event stream was already taken.
6028    pub fn take_event_stream(&self) -> ProviderEventStream {
6029        ProviderEventStream { event_receiver: self.client.take_event_receiver() }
6030    }
6031
6032    pub fn r#add_device(
6033        &self,
6034        mut payload: ProviderAddDeviceRequest,
6035    ) -> fidl::client::QueryResponseFut<
6036        ProviderAddDeviceResult,
6037        fidl::encoding::DefaultFuchsiaResourceDialect,
6038    > {
6039        ProviderProxyInterface::r#add_device(self, payload)
6040    }
6041}
6042
6043impl ProviderProxyInterface for ProviderProxy {
6044    type AddDeviceResponseFut = fidl::client::QueryResponseFut<
6045        ProviderAddDeviceResult,
6046        fidl::encoding::DefaultFuchsiaResourceDialect,
6047    >;
6048    fn r#add_device(&self, mut payload: ProviderAddDeviceRequest) -> Self::AddDeviceResponseFut {
6049        fn _decode(
6050            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6051        ) -> Result<ProviderAddDeviceResult, fidl::Error> {
6052            let _response = fidl::client::decode_transaction_body::<
6053                fidl::encoding::FlexibleResultType<
6054                    ProviderAddDeviceResponse,
6055                    ProviderAddDeviceError,
6056                >,
6057                fidl::encoding::DefaultFuchsiaResourceDialect,
6058                0x685fdfd91937758b,
6059            >(_buf?)?
6060            .into_result::<ProviderMarker>("add_device")?;
6061            Ok(_response.map(|x| x))
6062        }
6063        self.client.send_query_and_decode::<ProviderAddDeviceRequest, ProviderAddDeviceResult>(
6064            &mut payload,
6065            0x685fdfd91937758b,
6066            fidl::encoding::DynamicFlags::FLEXIBLE,
6067            _decode,
6068        )
6069    }
6070}
6071
6072pub struct ProviderEventStream {
6073    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6074}
6075
6076impl std::marker::Unpin for ProviderEventStream {}
6077
6078impl futures::stream::FusedStream for ProviderEventStream {
6079    fn is_terminated(&self) -> bool {
6080        self.event_receiver.is_terminated()
6081    }
6082}
6083
6084impl futures::Stream for ProviderEventStream {
6085    type Item = Result<ProviderEvent, fidl::Error>;
6086
6087    fn poll_next(
6088        mut self: std::pin::Pin<&mut Self>,
6089        cx: &mut std::task::Context<'_>,
6090    ) -> std::task::Poll<Option<Self::Item>> {
6091        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6092            &mut self.event_receiver,
6093            cx
6094        )?) {
6095            Some(buf) => std::task::Poll::Ready(Some(ProviderEvent::decode(buf))),
6096            None => std::task::Poll::Ready(None),
6097        }
6098    }
6099}
6100
6101#[derive(Debug)]
6102pub enum ProviderEvent {
6103    #[non_exhaustive]
6104    _UnknownEvent {
6105        /// Ordinal of the event that was sent.
6106        ordinal: u64,
6107    },
6108}
6109
6110impl ProviderEvent {
6111    /// Decodes a message buffer as a [`ProviderEvent`].
6112    fn decode(
6113        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6114    ) -> Result<ProviderEvent, fidl::Error> {
6115        let (bytes, _handles) = buf.split_mut();
6116        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6117        debug_assert_eq!(tx_header.tx_id, 0);
6118        match tx_header.ordinal {
6119            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
6120                Ok(ProviderEvent::_UnknownEvent { ordinal: tx_header.ordinal })
6121            }
6122            _ => Err(fidl::Error::UnknownOrdinal {
6123                ordinal: tx_header.ordinal,
6124                protocol_name: <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6125            }),
6126        }
6127    }
6128}
6129
6130/// A Stream of incoming requests for fuchsia.audio.device/Provider.
6131pub struct ProviderRequestStream {
6132    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6133    is_terminated: bool,
6134}
6135
6136impl std::marker::Unpin for ProviderRequestStream {}
6137
6138impl futures::stream::FusedStream for ProviderRequestStream {
6139    fn is_terminated(&self) -> bool {
6140        self.is_terminated
6141    }
6142}
6143
6144impl fidl::endpoints::RequestStream for ProviderRequestStream {
6145    type Protocol = ProviderMarker;
6146    type ControlHandle = ProviderControlHandle;
6147
6148    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6149        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6150    }
6151
6152    fn control_handle(&self) -> Self::ControlHandle {
6153        ProviderControlHandle { inner: self.inner.clone() }
6154    }
6155
6156    fn into_inner(
6157        self,
6158    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6159    {
6160        (self.inner, self.is_terminated)
6161    }
6162
6163    fn from_inner(
6164        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6165        is_terminated: bool,
6166    ) -> Self {
6167        Self { inner, is_terminated }
6168    }
6169}
6170
6171impl futures::Stream for ProviderRequestStream {
6172    type Item = Result<ProviderRequest, fidl::Error>;
6173
6174    fn poll_next(
6175        mut self: std::pin::Pin<&mut Self>,
6176        cx: &mut std::task::Context<'_>,
6177    ) -> std::task::Poll<Option<Self::Item>> {
6178        let this = &mut *self;
6179        if this.inner.check_shutdown(cx) {
6180            this.is_terminated = true;
6181            return std::task::Poll::Ready(None);
6182        }
6183        if this.is_terminated {
6184            panic!("polled ProviderRequestStream after completion");
6185        }
6186        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6187            |bytes, handles| {
6188                match this.inner.channel().read_etc(cx, bytes, handles) {
6189                    std::task::Poll::Ready(Ok(())) => {}
6190                    std::task::Poll::Pending => return std::task::Poll::Pending,
6191                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6192                        this.is_terminated = true;
6193                        return std::task::Poll::Ready(None);
6194                    }
6195                    std::task::Poll::Ready(Err(e)) => {
6196                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6197                            e.into(),
6198                        ))));
6199                    }
6200                }
6201
6202                // A message has been received from the channel
6203                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6204
6205                std::task::Poll::Ready(Some(match header.ordinal {
6206                    0x685fdfd91937758b => {
6207                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6208                        let mut req = fidl::new_empty!(
6209                            ProviderAddDeviceRequest,
6210                            fidl::encoding::DefaultFuchsiaResourceDialect
6211                        );
6212                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderAddDeviceRequest>(&header, _body_bytes, handles, &mut req)?;
6213                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
6214                        Ok(ProviderRequest::AddDevice {
6215                            payload: req,
6216                            responder: ProviderAddDeviceResponder {
6217                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6218                                tx_id: header.tx_id,
6219                            },
6220                        })
6221                    }
6222                    _ if header.tx_id == 0
6223                        && header
6224                            .dynamic_flags()
6225                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6226                    {
6227                        Ok(ProviderRequest::_UnknownMethod {
6228                            ordinal: header.ordinal,
6229                            control_handle: ProviderControlHandle { inner: this.inner.clone() },
6230                            method_type: fidl::MethodType::OneWay,
6231                        })
6232                    }
6233                    _ if header
6234                        .dynamic_flags()
6235                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6236                    {
6237                        this.inner.send_framework_err(
6238                            fidl::encoding::FrameworkErr::UnknownMethod,
6239                            header.tx_id,
6240                            header.ordinal,
6241                            header.dynamic_flags(),
6242                            (bytes, handles),
6243                        )?;
6244                        Ok(ProviderRequest::_UnknownMethod {
6245                            ordinal: header.ordinal,
6246                            control_handle: ProviderControlHandle { inner: this.inner.clone() },
6247                            method_type: fidl::MethodType::TwoWay,
6248                        })
6249                    }
6250                    _ => Err(fidl::Error::UnknownOrdinal {
6251                        ordinal: header.ordinal,
6252                        protocol_name:
6253                            <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6254                    }),
6255                }))
6256            },
6257        )
6258    }
6259}
6260
6261/// Use the `Provider` interface to manually add devices that do not use the devfs
6262/// mechanism. (Devices that use devfs are automatically added, upon detection.)
6263#[derive(Debug)]
6264pub enum ProviderRequest {
6265    AddDevice {
6266        payload: ProviderAddDeviceRequest,
6267        responder: ProviderAddDeviceResponder,
6268    },
6269    /// An interaction was received which does not match any known method.
6270    #[non_exhaustive]
6271    _UnknownMethod {
6272        /// Ordinal of the method that was called.
6273        ordinal: u64,
6274        control_handle: ProviderControlHandle,
6275        method_type: fidl::MethodType,
6276    },
6277}
6278
6279impl ProviderRequest {
6280    #[allow(irrefutable_let_patterns)]
6281    pub fn into_add_device(self) -> Option<(ProviderAddDeviceRequest, ProviderAddDeviceResponder)> {
6282        if let ProviderRequest::AddDevice { payload, responder } = self {
6283            Some((payload, responder))
6284        } else {
6285            None
6286        }
6287    }
6288
6289    /// Name of the method defined in FIDL
6290    pub fn method_name(&self) -> &'static str {
6291        match *self {
6292            ProviderRequest::AddDevice { .. } => "add_device",
6293            ProviderRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
6294                "unknown one-way method"
6295            }
6296            ProviderRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
6297                "unknown two-way method"
6298            }
6299        }
6300    }
6301}
6302
6303#[derive(Debug, Clone)]
6304pub struct ProviderControlHandle {
6305    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6306}
6307
6308impl ProviderControlHandle {
6309    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
6310        self.inner.shutdown_with_epitaph(status.into())
6311    }
6312}
6313
6314impl fidl::endpoints::ControlHandle for ProviderControlHandle {
6315    fn shutdown(&self) {
6316        self.inner.shutdown()
6317    }
6318
6319    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
6320        self.inner.shutdown_with_epitaph(status)
6321    }
6322
6323    fn is_closed(&self) -> bool {
6324        self.inner.channel().is_closed()
6325    }
6326    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6327        self.inner.channel().on_closed()
6328    }
6329
6330    #[cfg(target_os = "fuchsia")]
6331    fn signal_peer(
6332        &self,
6333        clear_mask: zx::Signals,
6334        set_mask: zx::Signals,
6335    ) -> Result<(), zx_status::Status> {
6336        use fidl::Peered;
6337        self.inner.channel().signal_peer(clear_mask, set_mask)
6338    }
6339}
6340
6341impl ProviderControlHandle {}
6342
6343#[must_use = "FIDL methods require a response to be sent"]
6344#[derive(Debug)]
6345pub struct ProviderAddDeviceResponder {
6346    control_handle: std::mem::ManuallyDrop<ProviderControlHandle>,
6347    tx_id: u32,
6348}
6349
6350/// Set the the channel to be shutdown (see [`ProviderControlHandle::shutdown`])
6351/// if the responder is dropped without sending a response, so that the client
6352/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6353impl std::ops::Drop for ProviderAddDeviceResponder {
6354    fn drop(&mut self) {
6355        self.control_handle.shutdown();
6356        // Safety: drops once, never accessed again
6357        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6358    }
6359}
6360
6361impl fidl::endpoints::Responder for ProviderAddDeviceResponder {
6362    type ControlHandle = ProviderControlHandle;
6363
6364    fn control_handle(&self) -> &ProviderControlHandle {
6365        &self.control_handle
6366    }
6367
6368    fn drop_without_shutdown(mut self) {
6369        // Safety: drops once, never accessed again due to mem::forget
6370        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6371        // Prevent Drop from running (which would shut down the channel)
6372        std::mem::forget(self);
6373    }
6374}
6375
6376impl ProviderAddDeviceResponder {
6377    /// Sends a response to the FIDL transaction.
6378    ///
6379    /// Sets the channel to shutdown if an error occurs.
6380    pub fn send(
6381        self,
6382        mut result: Result<&ProviderAddDeviceResponse, ProviderAddDeviceError>,
6383    ) -> Result<(), fidl::Error> {
6384        let _result = self.send_raw(result);
6385        if _result.is_err() {
6386            self.control_handle.shutdown();
6387        }
6388        self.drop_without_shutdown();
6389        _result
6390    }
6391
6392    /// Similar to "send" but does not shutdown the channel if an error occurs.
6393    pub fn send_no_shutdown_on_err(
6394        self,
6395        mut result: Result<&ProviderAddDeviceResponse, ProviderAddDeviceError>,
6396    ) -> Result<(), fidl::Error> {
6397        let _result = self.send_raw(result);
6398        self.drop_without_shutdown();
6399        _result
6400    }
6401
6402    fn send_raw(
6403        &self,
6404        mut result: Result<&ProviderAddDeviceResponse, ProviderAddDeviceError>,
6405    ) -> Result<(), fidl::Error> {
6406        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6407            ProviderAddDeviceResponse,
6408            ProviderAddDeviceError,
6409        >>(
6410            fidl::encoding::FlexibleResult::new(result),
6411            self.tx_id,
6412            0x685fdfd91937758b,
6413            fidl::encoding::DynamicFlags::FLEXIBLE,
6414        )
6415    }
6416}
6417
6418#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6419pub struct RegistryMarker;
6420
6421impl fidl::endpoints::ProtocolMarker for RegistryMarker {
6422    type Proxy = RegistryProxy;
6423    type RequestStream = RegistryRequestStream;
6424    #[cfg(target_os = "fuchsia")]
6425    type SynchronousProxy = RegistrySynchronousProxy;
6426
6427    const DEBUG_NAME: &'static str = "fuchsia.audio.device.Registry";
6428}
6429impl fidl::endpoints::DiscoverableProtocolMarker for RegistryMarker {}
6430pub type RegistryWatchDevicesAddedResult =
6431    Result<RegistryWatchDevicesAddedResponse, RegistryWatchDevicesAddedError>;
6432pub type RegistryWatchDeviceRemovedResult =
6433    Result<RegistryWatchDeviceRemovedResponse, RegistryWatchDeviceRemovedError>;
6434pub type RegistryCreateObserverResult =
6435    Result<RegistryCreateObserverResponse, RegistryCreateObserverError>;
6436
6437pub trait RegistryProxyInterface: Send + Sync {
6438    type WatchDevicesAddedResponseFut: std::future::Future<Output = Result<RegistryWatchDevicesAddedResult, fidl::Error>>
6439        + Send;
6440    fn r#watch_devices_added(&self) -> Self::WatchDevicesAddedResponseFut;
6441    type WatchDeviceRemovedResponseFut: std::future::Future<Output = Result<RegistryWatchDeviceRemovedResult, fidl::Error>>
6442        + Send;
6443    fn r#watch_device_removed(&self) -> Self::WatchDeviceRemovedResponseFut;
6444    type CreateObserverResponseFut: std::future::Future<Output = Result<RegistryCreateObserverResult, fidl::Error>>
6445        + Send;
6446    fn r#create_observer(
6447        &self,
6448        payload: RegistryCreateObserverRequest,
6449    ) -> Self::CreateObserverResponseFut;
6450}
6451#[derive(Debug)]
6452#[cfg(target_os = "fuchsia")]
6453pub struct RegistrySynchronousProxy {
6454    client: fidl::client::sync::Client,
6455}
6456
6457#[cfg(target_os = "fuchsia")]
6458impl fidl::endpoints::SynchronousProxy for RegistrySynchronousProxy {
6459    type Proxy = RegistryProxy;
6460    type Protocol = RegistryMarker;
6461
6462    fn from_channel(inner: fidl::Channel) -> Self {
6463        Self::new(inner)
6464    }
6465
6466    fn into_channel(self) -> fidl::Channel {
6467        self.client.into_channel()
6468    }
6469
6470    fn as_channel(&self) -> &fidl::Channel {
6471        self.client.as_channel()
6472    }
6473}
6474
6475#[cfg(target_os = "fuchsia")]
6476impl RegistrySynchronousProxy {
6477    pub fn new(channel: fidl::Channel) -> Self {
6478        Self { client: fidl::client::sync::Client::new(channel) }
6479    }
6480
6481    pub fn into_channel(self) -> fidl::Channel {
6482        self.client.into_channel()
6483    }
6484
6485    /// Waits until an event arrives and returns it. It is safe for other
6486    /// threads to make concurrent requests while waiting for an event.
6487    pub fn wait_for_event(
6488        &self,
6489        deadline: zx::MonotonicInstant,
6490    ) -> Result<RegistryEvent, fidl::Error> {
6491        RegistryEvent::decode(self.client.wait_for_event::<RegistryMarker>(deadline)?)
6492    }
6493
6494    /// Register for notification when one or more devices are added.
6495    /// The `devices` vector will always contain at least one `Info` entry.
6496    pub fn r#watch_devices_added(
6497        &self,
6498        ___deadline: zx::MonotonicInstant,
6499    ) -> Result<RegistryWatchDevicesAddedResult, fidl::Error> {
6500        let _response = self
6501            .client
6502            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
6503                RegistryWatchDevicesAddedResponse,
6504                RegistryWatchDevicesAddedError,
6505            >, RegistryMarker>(
6506                (),
6507                0x562ca31f7c149def,
6508                fidl::encoding::DynamicFlags::FLEXIBLE,
6509                ___deadline,
6510            )?
6511            .into_result::<RegistryMarker>("watch_devices_added")?;
6512        Ok(_response.map(|x| x))
6513    }
6514
6515    /// Register for notification when an (active, added) device is removed.
6516    /// Because the method only notifies of one removal, upon completion it
6517    /// should immediately be re-called, in case other removals have occurred.
6518    /// Calls to this method will pend until the removal of a device that was
6519    /// included in a previous `WatchDevicesAdded` response.
6520    pub fn r#watch_device_removed(
6521        &self,
6522        ___deadline: zx::MonotonicInstant,
6523    ) -> Result<RegistryWatchDeviceRemovedResult, fidl::Error> {
6524        let _response = self
6525            .client
6526            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
6527                RegistryWatchDeviceRemovedResponse,
6528                RegistryWatchDeviceRemovedError,
6529            >, RegistryMarker>(
6530                (),
6531                0x6e67aabc99a502af,
6532                fidl::encoding::DynamicFlags::FLEXIBLE,
6533                ___deadline,
6534            )?
6535            .into_result::<RegistryMarker>("watch_device_removed")?;
6536        Ok(_response.map(|x| x))
6537    }
6538
6539    /// Request an `Observer` for the specified device.
6540    pub fn r#create_observer(
6541        &self,
6542        mut payload: RegistryCreateObserverRequest,
6543        ___deadline: zx::MonotonicInstant,
6544    ) -> Result<RegistryCreateObserverResult, fidl::Error> {
6545        let _response = self
6546            .client
6547            .send_query::<RegistryCreateObserverRequest, fidl::encoding::FlexibleResultType<
6548                RegistryCreateObserverResponse,
6549                RegistryCreateObserverError,
6550            >, RegistryMarker>(
6551                &mut payload,
6552                0x577bc322eb8d2bd1,
6553                fidl::encoding::DynamicFlags::FLEXIBLE,
6554                ___deadline,
6555            )?
6556            .into_result::<RegistryMarker>("create_observer")?;
6557        Ok(_response.map(|x| x))
6558    }
6559}
6560
6561#[cfg(target_os = "fuchsia")]
6562impl From<RegistrySynchronousProxy> for zx::NullableHandle {
6563    fn from(value: RegistrySynchronousProxy) -> Self {
6564        value.into_channel().into()
6565    }
6566}
6567
6568#[cfg(target_os = "fuchsia")]
6569impl From<fidl::Channel> for RegistrySynchronousProxy {
6570    fn from(value: fidl::Channel) -> Self {
6571        Self::new(value)
6572    }
6573}
6574
6575#[cfg(target_os = "fuchsia")]
6576impl fidl::endpoints::FromClient for RegistrySynchronousProxy {
6577    type Protocol = RegistryMarker;
6578
6579    fn from_client(value: fidl::endpoints::ClientEnd<RegistryMarker>) -> Self {
6580        Self::new(value.into_channel())
6581    }
6582}
6583
6584#[derive(Debug, Clone)]
6585pub struct RegistryProxy {
6586    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6587}
6588
6589impl fidl::endpoints::Proxy for RegistryProxy {
6590    type Protocol = RegistryMarker;
6591
6592    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6593        Self::new(inner)
6594    }
6595
6596    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6597        self.client.into_channel().map_err(|client| Self { client })
6598    }
6599
6600    fn as_channel(&self) -> &::fidl::AsyncChannel {
6601        self.client.as_channel()
6602    }
6603}
6604
6605impl RegistryProxy {
6606    /// Create a new Proxy for fuchsia.audio.device/Registry.
6607    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6608        let protocol_name = <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6609        Self { client: fidl::client::Client::new(channel, protocol_name) }
6610    }
6611
6612    /// Get a Stream of events from the remote end of the protocol.
6613    ///
6614    /// # Panics
6615    ///
6616    /// Panics if the event stream was already taken.
6617    pub fn take_event_stream(&self) -> RegistryEventStream {
6618        RegistryEventStream { event_receiver: self.client.take_event_receiver() }
6619    }
6620
6621    /// Register for notification when one or more devices are added.
6622    /// The `devices` vector will always contain at least one `Info` entry.
6623    pub fn r#watch_devices_added(
6624        &self,
6625    ) -> fidl::client::QueryResponseFut<
6626        RegistryWatchDevicesAddedResult,
6627        fidl::encoding::DefaultFuchsiaResourceDialect,
6628    > {
6629        RegistryProxyInterface::r#watch_devices_added(self)
6630    }
6631
6632    /// Register for notification when an (active, added) device is removed.
6633    /// Because the method only notifies of one removal, upon completion it
6634    /// should immediately be re-called, in case other removals have occurred.
6635    /// Calls to this method will pend until the removal of a device that was
6636    /// included in a previous `WatchDevicesAdded` response.
6637    pub fn r#watch_device_removed(
6638        &self,
6639    ) -> fidl::client::QueryResponseFut<
6640        RegistryWatchDeviceRemovedResult,
6641        fidl::encoding::DefaultFuchsiaResourceDialect,
6642    > {
6643        RegistryProxyInterface::r#watch_device_removed(self)
6644    }
6645
6646    /// Request an `Observer` for the specified device.
6647    pub fn r#create_observer(
6648        &self,
6649        mut payload: RegistryCreateObserverRequest,
6650    ) -> fidl::client::QueryResponseFut<
6651        RegistryCreateObserverResult,
6652        fidl::encoding::DefaultFuchsiaResourceDialect,
6653    > {
6654        RegistryProxyInterface::r#create_observer(self, payload)
6655    }
6656}
6657
6658impl RegistryProxyInterface for RegistryProxy {
6659    type WatchDevicesAddedResponseFut = fidl::client::QueryResponseFut<
6660        RegistryWatchDevicesAddedResult,
6661        fidl::encoding::DefaultFuchsiaResourceDialect,
6662    >;
6663    fn r#watch_devices_added(&self) -> Self::WatchDevicesAddedResponseFut {
6664        fn _decode(
6665            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6666        ) -> Result<RegistryWatchDevicesAddedResult, fidl::Error> {
6667            let _response = fidl::client::decode_transaction_body::<
6668                fidl::encoding::FlexibleResultType<
6669                    RegistryWatchDevicesAddedResponse,
6670                    RegistryWatchDevicesAddedError,
6671                >,
6672                fidl::encoding::DefaultFuchsiaResourceDialect,
6673                0x562ca31f7c149def,
6674            >(_buf?)?
6675            .into_result::<RegistryMarker>("watch_devices_added")?;
6676            Ok(_response.map(|x| x))
6677        }
6678        self.client
6679            .send_query_and_decode::<fidl::encoding::EmptyPayload, RegistryWatchDevicesAddedResult>(
6680                (),
6681                0x562ca31f7c149def,
6682                fidl::encoding::DynamicFlags::FLEXIBLE,
6683                _decode,
6684            )
6685    }
6686
6687    type WatchDeviceRemovedResponseFut = fidl::client::QueryResponseFut<
6688        RegistryWatchDeviceRemovedResult,
6689        fidl::encoding::DefaultFuchsiaResourceDialect,
6690    >;
6691    fn r#watch_device_removed(&self) -> Self::WatchDeviceRemovedResponseFut {
6692        fn _decode(
6693            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6694        ) -> Result<RegistryWatchDeviceRemovedResult, fidl::Error> {
6695            let _response = fidl::client::decode_transaction_body::<
6696                fidl::encoding::FlexibleResultType<
6697                    RegistryWatchDeviceRemovedResponse,
6698                    RegistryWatchDeviceRemovedError,
6699                >,
6700                fidl::encoding::DefaultFuchsiaResourceDialect,
6701                0x6e67aabc99a502af,
6702            >(_buf?)?
6703            .into_result::<RegistryMarker>("watch_device_removed")?;
6704            Ok(_response.map(|x| x))
6705        }
6706        self.client.send_query_and_decode::<
6707            fidl::encoding::EmptyPayload,
6708            RegistryWatchDeviceRemovedResult,
6709        >(
6710            (),
6711            0x6e67aabc99a502af,
6712            fidl::encoding::DynamicFlags::FLEXIBLE,
6713            _decode,
6714        )
6715    }
6716
6717    type CreateObserverResponseFut = fidl::client::QueryResponseFut<
6718        RegistryCreateObserverResult,
6719        fidl::encoding::DefaultFuchsiaResourceDialect,
6720    >;
6721    fn r#create_observer(
6722        &self,
6723        mut payload: RegistryCreateObserverRequest,
6724    ) -> Self::CreateObserverResponseFut {
6725        fn _decode(
6726            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6727        ) -> Result<RegistryCreateObserverResult, fidl::Error> {
6728            let _response = fidl::client::decode_transaction_body::<
6729                fidl::encoding::FlexibleResultType<
6730                    RegistryCreateObserverResponse,
6731                    RegistryCreateObserverError,
6732                >,
6733                fidl::encoding::DefaultFuchsiaResourceDialect,
6734                0x577bc322eb8d2bd1,
6735            >(_buf?)?
6736            .into_result::<RegistryMarker>("create_observer")?;
6737            Ok(_response.map(|x| x))
6738        }
6739        self.client
6740            .send_query_and_decode::<RegistryCreateObserverRequest, RegistryCreateObserverResult>(
6741                &mut payload,
6742                0x577bc322eb8d2bd1,
6743                fidl::encoding::DynamicFlags::FLEXIBLE,
6744                _decode,
6745            )
6746    }
6747}
6748
6749pub struct RegistryEventStream {
6750    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6751}
6752
6753impl std::marker::Unpin for RegistryEventStream {}
6754
6755impl futures::stream::FusedStream for RegistryEventStream {
6756    fn is_terminated(&self) -> bool {
6757        self.event_receiver.is_terminated()
6758    }
6759}
6760
6761impl futures::Stream for RegistryEventStream {
6762    type Item = Result<RegistryEvent, fidl::Error>;
6763
6764    fn poll_next(
6765        mut self: std::pin::Pin<&mut Self>,
6766        cx: &mut std::task::Context<'_>,
6767    ) -> std::task::Poll<Option<Self::Item>> {
6768        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6769            &mut self.event_receiver,
6770            cx
6771        )?) {
6772            Some(buf) => std::task::Poll::Ready(Some(RegistryEvent::decode(buf))),
6773            None => std::task::Poll::Ready(None),
6774        }
6775    }
6776}
6777
6778#[derive(Debug)]
6779pub enum RegistryEvent {
6780    #[non_exhaustive]
6781    _UnknownEvent {
6782        /// Ordinal of the event that was sent.
6783        ordinal: u64,
6784    },
6785}
6786
6787impl RegistryEvent {
6788    /// Decodes a message buffer as a [`RegistryEvent`].
6789    fn decode(
6790        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6791    ) -> Result<RegistryEvent, fidl::Error> {
6792        let (bytes, _handles) = buf.split_mut();
6793        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6794        debug_assert_eq!(tx_header.tx_id, 0);
6795        match tx_header.ordinal {
6796            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
6797                Ok(RegistryEvent::_UnknownEvent { ordinal: tx_header.ordinal })
6798            }
6799            _ => Err(fidl::Error::UnknownOrdinal {
6800                ordinal: tx_header.ordinal,
6801                protocol_name: <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6802            }),
6803        }
6804    }
6805}
6806
6807/// A Stream of incoming requests for fuchsia.audio.device/Registry.
6808pub struct RegistryRequestStream {
6809    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6810    is_terminated: bool,
6811}
6812
6813impl std::marker::Unpin for RegistryRequestStream {}
6814
6815impl futures::stream::FusedStream for RegistryRequestStream {
6816    fn is_terminated(&self) -> bool {
6817        self.is_terminated
6818    }
6819}
6820
6821impl fidl::endpoints::RequestStream for RegistryRequestStream {
6822    type Protocol = RegistryMarker;
6823    type ControlHandle = RegistryControlHandle;
6824
6825    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6826        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6827    }
6828
6829    fn control_handle(&self) -> Self::ControlHandle {
6830        RegistryControlHandle { inner: self.inner.clone() }
6831    }
6832
6833    fn into_inner(
6834        self,
6835    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6836    {
6837        (self.inner, self.is_terminated)
6838    }
6839
6840    fn from_inner(
6841        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6842        is_terminated: bool,
6843    ) -> Self {
6844        Self { inner, is_terminated }
6845    }
6846}
6847
6848impl futures::Stream for RegistryRequestStream {
6849    type Item = Result<RegistryRequest, fidl::Error>;
6850
6851    fn poll_next(
6852        mut self: std::pin::Pin<&mut Self>,
6853        cx: &mut std::task::Context<'_>,
6854    ) -> std::task::Poll<Option<Self::Item>> {
6855        let this = &mut *self;
6856        if this.inner.check_shutdown(cx) {
6857            this.is_terminated = true;
6858            return std::task::Poll::Ready(None);
6859        }
6860        if this.is_terminated {
6861            panic!("polled RegistryRequestStream after completion");
6862        }
6863        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6864            |bytes, handles| {
6865                match this.inner.channel().read_etc(cx, bytes, handles) {
6866                    std::task::Poll::Ready(Ok(())) => {}
6867                    std::task::Poll::Pending => return std::task::Poll::Pending,
6868                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6869                        this.is_terminated = true;
6870                        return std::task::Poll::Ready(None);
6871                    }
6872                    std::task::Poll::Ready(Err(e)) => {
6873                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6874                            e.into(),
6875                        ))));
6876                    }
6877                }
6878
6879                // A message has been received from the channel
6880                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6881
6882                std::task::Poll::Ready(Some(match header.ordinal {
6883                    0x562ca31f7c149def => {
6884                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6885                        let mut req = fidl::new_empty!(
6886                            fidl::encoding::EmptyPayload,
6887                            fidl::encoding::DefaultFuchsiaResourceDialect
6888                        );
6889                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6890                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
6891                        Ok(RegistryRequest::WatchDevicesAdded {
6892                            responder: RegistryWatchDevicesAddedResponder {
6893                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6894                                tx_id: header.tx_id,
6895                            },
6896                        })
6897                    }
6898                    0x6e67aabc99a502af => {
6899                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6900                        let mut req = fidl::new_empty!(
6901                            fidl::encoding::EmptyPayload,
6902                            fidl::encoding::DefaultFuchsiaResourceDialect
6903                        );
6904                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6905                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
6906                        Ok(RegistryRequest::WatchDeviceRemoved {
6907                            responder: RegistryWatchDeviceRemovedResponder {
6908                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6909                                tx_id: header.tx_id,
6910                            },
6911                        })
6912                    }
6913                    0x577bc322eb8d2bd1 => {
6914                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6915                        let mut req = fidl::new_empty!(
6916                            RegistryCreateObserverRequest,
6917                            fidl::encoding::DefaultFuchsiaResourceDialect
6918                        );
6919                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RegistryCreateObserverRequest>(&header, _body_bytes, handles, &mut req)?;
6920                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
6921                        Ok(RegistryRequest::CreateObserver {
6922                            payload: req,
6923                            responder: RegistryCreateObserverResponder {
6924                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6925                                tx_id: header.tx_id,
6926                            },
6927                        })
6928                    }
6929                    _ if header.tx_id == 0
6930                        && header
6931                            .dynamic_flags()
6932                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6933                    {
6934                        Ok(RegistryRequest::_UnknownMethod {
6935                            ordinal: header.ordinal,
6936                            control_handle: RegistryControlHandle { inner: this.inner.clone() },
6937                            method_type: fidl::MethodType::OneWay,
6938                        })
6939                    }
6940                    _ if header
6941                        .dynamic_flags()
6942                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6943                    {
6944                        this.inner.send_framework_err(
6945                            fidl::encoding::FrameworkErr::UnknownMethod,
6946                            header.tx_id,
6947                            header.ordinal,
6948                            header.dynamic_flags(),
6949                            (bytes, handles),
6950                        )?;
6951                        Ok(RegistryRequest::_UnknownMethod {
6952                            ordinal: header.ordinal,
6953                            control_handle: RegistryControlHandle { inner: this.inner.clone() },
6954                            method_type: fidl::MethodType::TwoWay,
6955                        })
6956                    }
6957                    _ => Err(fidl::Error::UnknownOrdinal {
6958                        ordinal: header.ordinal,
6959                        protocol_name:
6960                            <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6961                    }),
6962                }))
6963            },
6964        )
6965    }
6966}
6967
6968/// `Registry` instances notify clients as devices arrive and depart, and they
6969/// create observers (see `Observer`) that notify of more detailed state changes.
6970#[derive(Debug)]
6971pub enum RegistryRequest {
6972    /// Register for notification when one or more devices are added.
6973    /// The `devices` vector will always contain at least one `Info` entry.
6974    WatchDevicesAdded { responder: RegistryWatchDevicesAddedResponder },
6975    /// Register for notification when an (active, added) device is removed.
6976    /// Because the method only notifies of one removal, upon completion it
6977    /// should immediately be re-called, in case other removals have occurred.
6978    /// Calls to this method will pend until the removal of a device that was
6979    /// included in a previous `WatchDevicesAdded` response.
6980    WatchDeviceRemoved { responder: RegistryWatchDeviceRemovedResponder },
6981    /// Request an `Observer` for the specified device.
6982    CreateObserver {
6983        payload: RegistryCreateObserverRequest,
6984        responder: RegistryCreateObserverResponder,
6985    },
6986    /// An interaction was received which does not match any known method.
6987    #[non_exhaustive]
6988    _UnknownMethod {
6989        /// Ordinal of the method that was called.
6990        ordinal: u64,
6991        control_handle: RegistryControlHandle,
6992        method_type: fidl::MethodType,
6993    },
6994}
6995
6996impl RegistryRequest {
6997    #[allow(irrefutable_let_patterns)]
6998    pub fn into_watch_devices_added(self) -> Option<(RegistryWatchDevicesAddedResponder)> {
6999        if let RegistryRequest::WatchDevicesAdded { responder } = self {
7000            Some((responder))
7001        } else {
7002            None
7003        }
7004    }
7005
7006    #[allow(irrefutable_let_patterns)]
7007    pub fn into_watch_device_removed(self) -> Option<(RegistryWatchDeviceRemovedResponder)> {
7008        if let RegistryRequest::WatchDeviceRemoved { responder } = self {
7009            Some((responder))
7010        } else {
7011            None
7012        }
7013    }
7014
7015    #[allow(irrefutable_let_patterns)]
7016    pub fn into_create_observer(
7017        self,
7018    ) -> Option<(RegistryCreateObserverRequest, RegistryCreateObserverResponder)> {
7019        if let RegistryRequest::CreateObserver { payload, responder } = self {
7020            Some((payload, responder))
7021        } else {
7022            None
7023        }
7024    }
7025
7026    /// Name of the method defined in FIDL
7027    pub fn method_name(&self) -> &'static str {
7028        match *self {
7029            RegistryRequest::WatchDevicesAdded { .. } => "watch_devices_added",
7030            RegistryRequest::WatchDeviceRemoved { .. } => "watch_device_removed",
7031            RegistryRequest::CreateObserver { .. } => "create_observer",
7032            RegistryRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
7033                "unknown one-way method"
7034            }
7035            RegistryRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
7036                "unknown two-way method"
7037            }
7038        }
7039    }
7040}
7041
7042#[derive(Debug, Clone)]
7043pub struct RegistryControlHandle {
7044    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7045}
7046
7047impl RegistryControlHandle {
7048    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
7049        self.inner.shutdown_with_epitaph(status.into())
7050    }
7051}
7052
7053impl fidl::endpoints::ControlHandle for RegistryControlHandle {
7054    fn shutdown(&self) {
7055        self.inner.shutdown()
7056    }
7057
7058    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
7059        self.inner.shutdown_with_epitaph(status)
7060    }
7061
7062    fn is_closed(&self) -> bool {
7063        self.inner.channel().is_closed()
7064    }
7065    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7066        self.inner.channel().on_closed()
7067    }
7068
7069    #[cfg(target_os = "fuchsia")]
7070    fn signal_peer(
7071        &self,
7072        clear_mask: zx::Signals,
7073        set_mask: zx::Signals,
7074    ) -> Result<(), zx_status::Status> {
7075        use fidl::Peered;
7076        self.inner.channel().signal_peer(clear_mask, set_mask)
7077    }
7078}
7079
7080impl RegistryControlHandle {}
7081
7082#[must_use = "FIDL methods require a response to be sent"]
7083#[derive(Debug)]
7084pub struct RegistryWatchDevicesAddedResponder {
7085    control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
7086    tx_id: u32,
7087}
7088
7089/// Set the the channel to be shutdown (see [`RegistryControlHandle::shutdown`])
7090/// if the responder is dropped without sending a response, so that the client
7091/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7092impl std::ops::Drop for RegistryWatchDevicesAddedResponder {
7093    fn drop(&mut self) {
7094        self.control_handle.shutdown();
7095        // Safety: drops once, never accessed again
7096        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7097    }
7098}
7099
7100impl fidl::endpoints::Responder for RegistryWatchDevicesAddedResponder {
7101    type ControlHandle = RegistryControlHandle;
7102
7103    fn control_handle(&self) -> &RegistryControlHandle {
7104        &self.control_handle
7105    }
7106
7107    fn drop_without_shutdown(mut self) {
7108        // Safety: drops once, never accessed again due to mem::forget
7109        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7110        // Prevent Drop from running (which would shut down the channel)
7111        std::mem::forget(self);
7112    }
7113}
7114
7115impl RegistryWatchDevicesAddedResponder {
7116    /// Sends a response to the FIDL transaction.
7117    ///
7118    /// Sets the channel to shutdown if an error occurs.
7119    pub fn send(
7120        self,
7121        mut result: Result<&RegistryWatchDevicesAddedResponse, RegistryWatchDevicesAddedError>,
7122    ) -> Result<(), fidl::Error> {
7123        let _result = self.send_raw(result);
7124        if _result.is_err() {
7125            self.control_handle.shutdown();
7126        }
7127        self.drop_without_shutdown();
7128        _result
7129    }
7130
7131    /// Similar to "send" but does not shutdown the channel if an error occurs.
7132    pub fn send_no_shutdown_on_err(
7133        self,
7134        mut result: Result<&RegistryWatchDevicesAddedResponse, RegistryWatchDevicesAddedError>,
7135    ) -> Result<(), fidl::Error> {
7136        let _result = self.send_raw(result);
7137        self.drop_without_shutdown();
7138        _result
7139    }
7140
7141    fn send_raw(
7142        &self,
7143        mut result: Result<&RegistryWatchDevicesAddedResponse, RegistryWatchDevicesAddedError>,
7144    ) -> Result<(), fidl::Error> {
7145        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7146            RegistryWatchDevicesAddedResponse,
7147            RegistryWatchDevicesAddedError,
7148        >>(
7149            fidl::encoding::FlexibleResult::new(result),
7150            self.tx_id,
7151            0x562ca31f7c149def,
7152            fidl::encoding::DynamicFlags::FLEXIBLE,
7153        )
7154    }
7155}
7156
7157#[must_use = "FIDL methods require a response to be sent"]
7158#[derive(Debug)]
7159pub struct RegistryWatchDeviceRemovedResponder {
7160    control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
7161    tx_id: u32,
7162}
7163
7164/// Set the the channel to be shutdown (see [`RegistryControlHandle::shutdown`])
7165/// if the responder is dropped without sending a response, so that the client
7166/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7167impl std::ops::Drop for RegistryWatchDeviceRemovedResponder {
7168    fn drop(&mut self) {
7169        self.control_handle.shutdown();
7170        // Safety: drops once, never accessed again
7171        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7172    }
7173}
7174
7175impl fidl::endpoints::Responder for RegistryWatchDeviceRemovedResponder {
7176    type ControlHandle = RegistryControlHandle;
7177
7178    fn control_handle(&self) -> &RegistryControlHandle {
7179        &self.control_handle
7180    }
7181
7182    fn drop_without_shutdown(mut self) {
7183        // Safety: drops once, never accessed again due to mem::forget
7184        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7185        // Prevent Drop from running (which would shut down the channel)
7186        std::mem::forget(self);
7187    }
7188}
7189
7190impl RegistryWatchDeviceRemovedResponder {
7191    /// Sends a response to the FIDL transaction.
7192    ///
7193    /// Sets the channel to shutdown if an error occurs.
7194    pub fn send(
7195        self,
7196        mut result: Result<&RegistryWatchDeviceRemovedResponse, RegistryWatchDeviceRemovedError>,
7197    ) -> Result<(), fidl::Error> {
7198        let _result = self.send_raw(result);
7199        if _result.is_err() {
7200            self.control_handle.shutdown();
7201        }
7202        self.drop_without_shutdown();
7203        _result
7204    }
7205
7206    /// Similar to "send" but does not shutdown the channel if an error occurs.
7207    pub fn send_no_shutdown_on_err(
7208        self,
7209        mut result: Result<&RegistryWatchDeviceRemovedResponse, RegistryWatchDeviceRemovedError>,
7210    ) -> Result<(), fidl::Error> {
7211        let _result = self.send_raw(result);
7212        self.drop_without_shutdown();
7213        _result
7214    }
7215
7216    fn send_raw(
7217        &self,
7218        mut result: Result<&RegistryWatchDeviceRemovedResponse, RegistryWatchDeviceRemovedError>,
7219    ) -> Result<(), fidl::Error> {
7220        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7221            RegistryWatchDeviceRemovedResponse,
7222            RegistryWatchDeviceRemovedError,
7223        >>(
7224            fidl::encoding::FlexibleResult::new(result),
7225            self.tx_id,
7226            0x6e67aabc99a502af,
7227            fidl::encoding::DynamicFlags::FLEXIBLE,
7228        )
7229    }
7230}
7231
7232#[must_use = "FIDL methods require a response to be sent"]
7233#[derive(Debug)]
7234pub struct RegistryCreateObserverResponder {
7235    control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
7236    tx_id: u32,
7237}
7238
7239/// Set the the channel to be shutdown (see [`RegistryControlHandle::shutdown`])
7240/// if the responder is dropped without sending a response, so that the client
7241/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7242impl std::ops::Drop for RegistryCreateObserverResponder {
7243    fn drop(&mut self) {
7244        self.control_handle.shutdown();
7245        // Safety: drops once, never accessed again
7246        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7247    }
7248}
7249
7250impl fidl::endpoints::Responder for RegistryCreateObserverResponder {
7251    type ControlHandle = RegistryControlHandle;
7252
7253    fn control_handle(&self) -> &RegistryControlHandle {
7254        &self.control_handle
7255    }
7256
7257    fn drop_without_shutdown(mut self) {
7258        // Safety: drops once, never accessed again due to mem::forget
7259        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7260        // Prevent Drop from running (which would shut down the channel)
7261        std::mem::forget(self);
7262    }
7263}
7264
7265impl RegistryCreateObserverResponder {
7266    /// Sends a response to the FIDL transaction.
7267    ///
7268    /// Sets the channel to shutdown if an error occurs.
7269    pub fn send(
7270        self,
7271        mut result: Result<&RegistryCreateObserverResponse, RegistryCreateObserverError>,
7272    ) -> Result<(), fidl::Error> {
7273        let _result = self.send_raw(result);
7274        if _result.is_err() {
7275            self.control_handle.shutdown();
7276        }
7277        self.drop_without_shutdown();
7278        _result
7279    }
7280
7281    /// Similar to "send" but does not shutdown the channel if an error occurs.
7282    pub fn send_no_shutdown_on_err(
7283        self,
7284        mut result: Result<&RegistryCreateObserverResponse, RegistryCreateObserverError>,
7285    ) -> Result<(), fidl::Error> {
7286        let _result = self.send_raw(result);
7287        self.drop_without_shutdown();
7288        _result
7289    }
7290
7291    fn send_raw(
7292        &self,
7293        mut result: Result<&RegistryCreateObserverResponse, RegistryCreateObserverError>,
7294    ) -> Result<(), fidl::Error> {
7295        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7296            RegistryCreateObserverResponse,
7297            RegistryCreateObserverError,
7298        >>(
7299            fidl::encoding::FlexibleResult::new(result),
7300            self.tx_id,
7301            0x577bc322eb8d2bd1,
7302            fidl::encoding::DynamicFlags::FLEXIBLE,
7303        )
7304    }
7305}
7306
7307#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7308pub struct RingBufferMarker;
7309
7310impl fidl::endpoints::ProtocolMarker for RingBufferMarker {
7311    type Proxy = RingBufferProxy;
7312    type RequestStream = RingBufferRequestStream;
7313    #[cfg(target_os = "fuchsia")]
7314    type SynchronousProxy = RingBufferSynchronousProxy;
7315
7316    const DEBUG_NAME: &'static str = "(anonymous) RingBuffer";
7317}
7318pub type RingBufferSetActiveChannelsResult =
7319    Result<RingBufferSetActiveChannelsResponse, RingBufferSetActiveChannelsError>;
7320pub type RingBufferStartResult = Result<RingBufferStartResponse, RingBufferStartError>;
7321pub type RingBufferStopResult = Result<RingBufferStopResponse, RingBufferStopError>;
7322pub type RingBufferWatchDelayInfoResult =
7323    Result<RingBufferWatchDelayInfoResponse, RingBufferWatchDelayInfoError>;
7324
7325pub trait RingBufferProxyInterface: Send + Sync {
7326    type SetActiveChannelsResponseFut: std::future::Future<Output = Result<RingBufferSetActiveChannelsResult, fidl::Error>>
7327        + Send;
7328    fn r#set_active_channels(
7329        &self,
7330        payload: &RingBufferSetActiveChannelsRequest,
7331    ) -> Self::SetActiveChannelsResponseFut;
7332    type StartResponseFut: std::future::Future<Output = Result<RingBufferStartResult, fidl::Error>>
7333        + Send;
7334    fn r#start(&self, payload: &RingBufferStartRequest) -> Self::StartResponseFut;
7335    type StopResponseFut: std::future::Future<Output = Result<RingBufferStopResult, fidl::Error>>
7336        + Send;
7337    fn r#stop(&self, payload: &RingBufferStopRequest) -> Self::StopResponseFut;
7338    type WatchDelayInfoResponseFut: std::future::Future<Output = Result<RingBufferWatchDelayInfoResult, fidl::Error>>
7339        + Send;
7340    fn r#watch_delay_info(&self) -> Self::WatchDelayInfoResponseFut;
7341}
7342#[derive(Debug)]
7343#[cfg(target_os = "fuchsia")]
7344pub struct RingBufferSynchronousProxy {
7345    client: fidl::client::sync::Client,
7346}
7347
7348#[cfg(target_os = "fuchsia")]
7349impl fidl::endpoints::SynchronousProxy for RingBufferSynchronousProxy {
7350    type Proxy = RingBufferProxy;
7351    type Protocol = RingBufferMarker;
7352
7353    fn from_channel(inner: fidl::Channel) -> Self {
7354        Self::new(inner)
7355    }
7356
7357    fn into_channel(self) -> fidl::Channel {
7358        self.client.into_channel()
7359    }
7360
7361    fn as_channel(&self) -> &fidl::Channel {
7362        self.client.as_channel()
7363    }
7364}
7365
7366#[cfg(target_os = "fuchsia")]
7367impl RingBufferSynchronousProxy {
7368    pub fn new(channel: fidl::Channel) -> Self {
7369        Self { client: fidl::client::sync::Client::new(channel) }
7370    }
7371
7372    pub fn into_channel(self) -> fidl::Channel {
7373        self.client.into_channel()
7374    }
7375
7376    /// Waits until an event arrives and returns it. It is safe for other
7377    /// threads to make concurrent requests while waiting for an event.
7378    pub fn wait_for_event(
7379        &self,
7380        deadline: zx::MonotonicInstant,
7381    ) -> Result<RingBufferEvent, fidl::Error> {
7382        RingBufferEvent::decode(self.client.wait_for_event::<RingBufferMarker>(deadline)?)
7383    }
7384
7385    /// Request that specific individual channels be powered down/up, if the
7386    /// device supports this. This is intended for idle power conservation.
7387    ///
7388    /// Channels are specified by bitmask; the least significant bit corresponds
7389    /// to channel 0. Each bit not set indicates that the channel can be
7390    /// deactivated. `SetActiveChannels` does not change how a ring buffer
7391    /// responds to `Start`/`Stop`, specifically with regards to position.
7392    ///
7393    /// Devices are not required to obey `SetActiveChannels`. For example, they
7394    /// are not required to zero-out an input stream's inactive channels, and
7395    /// data written to inactive channels of an output stream's ring buffer may
7396    /// still be played.
7397    ///
7398    /// If not called, then by default all channels will be active.
7399    pub fn r#set_active_channels(
7400        &self,
7401        mut payload: &RingBufferSetActiveChannelsRequest,
7402        ___deadline: zx::MonotonicInstant,
7403    ) -> Result<RingBufferSetActiveChannelsResult, fidl::Error> {
7404        let _response = self
7405            .client
7406            .send_query::<RingBufferSetActiveChannelsRequest, fidl::encoding::FlexibleResultType<
7407                RingBufferSetActiveChannelsResponse,
7408                RingBufferSetActiveChannelsError,
7409            >, RingBufferMarker>(
7410                payload,
7411                0x4276c43e4a3b59ee,
7412                fidl::encoding::DynamicFlags::FLEXIBLE,
7413                ___deadline,
7414            )?
7415            .into_result::<RingBufferMarker>("set_active_channels")?;
7416        Ok(_response.map(|x| x))
7417    }
7418
7419    /// Start the ring buffer, beginning at the first frame of the ring buffer.
7420    pub fn r#start(
7421        &self,
7422        mut payload: &RingBufferStartRequest,
7423        ___deadline: zx::MonotonicInstant,
7424    ) -> Result<RingBufferStartResult, fidl::Error> {
7425        let _response = self.client.send_query::<
7426            RingBufferStartRequest,
7427            fidl::encoding::FlexibleResultType<RingBufferStartResponse, RingBufferStartError>,
7428            RingBufferMarker,
7429        >(
7430            payload,
7431            0x5365a8609dc2dc5,
7432            fidl::encoding::DynamicFlags::FLEXIBLE,
7433            ___deadline,
7434        )?
7435        .into_result::<RingBufferMarker>("start")?;
7436        Ok(_response.map(|x| x))
7437    }
7438
7439    /// Stop the ring buffer.
7440    pub fn r#stop(
7441        &self,
7442        mut payload: &RingBufferStopRequest,
7443        ___deadline: zx::MonotonicInstant,
7444    ) -> Result<RingBufferStopResult, fidl::Error> {
7445        let _response = self.client.send_query::<
7446            RingBufferStopRequest,
7447            fidl::encoding::FlexibleResultType<RingBufferStopResponse, RingBufferStopError>,
7448            RingBufferMarker,
7449        >(
7450            payload,
7451            0x5a238810af11e6e1,
7452            fidl::encoding::DynamicFlags::FLEXIBLE,
7453            ___deadline,
7454        )?
7455        .into_result::<RingBufferMarker>("stop")?;
7456        Ok(_response.map(|x| x))
7457    }
7458
7459    /// Request delay information via a hanging get. The RingBuffer will respond
7460    /// immediately to the first `WatchDelayInfo` call. Subsequent calls will
7461    /// only be completed when the delay info has changed from previously
7462    /// communicated values.
7463    pub fn r#watch_delay_info(
7464        &self,
7465        ___deadline: zx::MonotonicInstant,
7466    ) -> Result<RingBufferWatchDelayInfoResult, fidl::Error> {
7467        let _response = self
7468            .client
7469            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
7470                RingBufferWatchDelayInfoResponse,
7471                RingBufferWatchDelayInfoError,
7472            >, RingBufferMarker>(
7473                (),
7474                0x6d1dc5a928f38ad6,
7475                fidl::encoding::DynamicFlags::FLEXIBLE,
7476                ___deadline,
7477            )?
7478            .into_result::<RingBufferMarker>("watch_delay_info")?;
7479        Ok(_response.map(|x| x))
7480    }
7481}
7482
7483#[cfg(target_os = "fuchsia")]
7484impl From<RingBufferSynchronousProxy> for zx::NullableHandle {
7485    fn from(value: RingBufferSynchronousProxy) -> Self {
7486        value.into_channel().into()
7487    }
7488}
7489
7490#[cfg(target_os = "fuchsia")]
7491impl From<fidl::Channel> for RingBufferSynchronousProxy {
7492    fn from(value: fidl::Channel) -> Self {
7493        Self::new(value)
7494    }
7495}
7496
7497#[cfg(target_os = "fuchsia")]
7498impl fidl::endpoints::FromClient for RingBufferSynchronousProxy {
7499    type Protocol = RingBufferMarker;
7500
7501    fn from_client(value: fidl::endpoints::ClientEnd<RingBufferMarker>) -> Self {
7502        Self::new(value.into_channel())
7503    }
7504}
7505
7506#[derive(Debug, Clone)]
7507pub struct RingBufferProxy {
7508    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7509}
7510
7511impl fidl::endpoints::Proxy for RingBufferProxy {
7512    type Protocol = RingBufferMarker;
7513
7514    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7515        Self::new(inner)
7516    }
7517
7518    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7519        self.client.into_channel().map_err(|client| Self { client })
7520    }
7521
7522    fn as_channel(&self) -> &::fidl::AsyncChannel {
7523        self.client.as_channel()
7524    }
7525}
7526
7527impl RingBufferProxy {
7528    /// Create a new Proxy for fuchsia.audio.device/RingBuffer.
7529    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7530        let protocol_name = <RingBufferMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7531        Self { client: fidl::client::Client::new(channel, protocol_name) }
7532    }
7533
7534    /// Get a Stream of events from the remote end of the protocol.
7535    ///
7536    /// # Panics
7537    ///
7538    /// Panics if the event stream was already taken.
7539    pub fn take_event_stream(&self) -> RingBufferEventStream {
7540        RingBufferEventStream { event_receiver: self.client.take_event_receiver() }
7541    }
7542
7543    /// Request that specific individual channels be powered down/up, if the
7544    /// device supports this. This is intended for idle power conservation.
7545    ///
7546    /// Channels are specified by bitmask; the least significant bit corresponds
7547    /// to channel 0. Each bit not set indicates that the channel can be
7548    /// deactivated. `SetActiveChannels` does not change how a ring buffer
7549    /// responds to `Start`/`Stop`, specifically with regards to position.
7550    ///
7551    /// Devices are not required to obey `SetActiveChannels`. For example, they
7552    /// are not required to zero-out an input stream's inactive channels, and
7553    /// data written to inactive channels of an output stream's ring buffer may
7554    /// still be played.
7555    ///
7556    /// If not called, then by default all channels will be active.
7557    pub fn r#set_active_channels(
7558        &self,
7559        mut payload: &RingBufferSetActiveChannelsRequest,
7560    ) -> fidl::client::QueryResponseFut<
7561        RingBufferSetActiveChannelsResult,
7562        fidl::encoding::DefaultFuchsiaResourceDialect,
7563    > {
7564        RingBufferProxyInterface::r#set_active_channels(self, payload)
7565    }
7566
7567    /// Start the ring buffer, beginning at the first frame of the ring buffer.
7568    pub fn r#start(
7569        &self,
7570        mut payload: &RingBufferStartRequest,
7571    ) -> fidl::client::QueryResponseFut<
7572        RingBufferStartResult,
7573        fidl::encoding::DefaultFuchsiaResourceDialect,
7574    > {
7575        RingBufferProxyInterface::r#start(self, payload)
7576    }
7577
7578    /// Stop the ring buffer.
7579    pub fn r#stop(
7580        &self,
7581        mut payload: &RingBufferStopRequest,
7582    ) -> fidl::client::QueryResponseFut<
7583        RingBufferStopResult,
7584        fidl::encoding::DefaultFuchsiaResourceDialect,
7585    > {
7586        RingBufferProxyInterface::r#stop(self, payload)
7587    }
7588
7589    /// Request delay information via a hanging get. The RingBuffer will respond
7590    /// immediately to the first `WatchDelayInfo` call. Subsequent calls will
7591    /// only be completed when the delay info has changed from previously
7592    /// communicated values.
7593    pub fn r#watch_delay_info(
7594        &self,
7595    ) -> fidl::client::QueryResponseFut<
7596        RingBufferWatchDelayInfoResult,
7597        fidl::encoding::DefaultFuchsiaResourceDialect,
7598    > {
7599        RingBufferProxyInterface::r#watch_delay_info(self)
7600    }
7601}
7602
7603impl RingBufferProxyInterface for RingBufferProxy {
7604    type SetActiveChannelsResponseFut = fidl::client::QueryResponseFut<
7605        RingBufferSetActiveChannelsResult,
7606        fidl::encoding::DefaultFuchsiaResourceDialect,
7607    >;
7608    fn r#set_active_channels(
7609        &self,
7610        mut payload: &RingBufferSetActiveChannelsRequest,
7611    ) -> Self::SetActiveChannelsResponseFut {
7612        fn _decode(
7613            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7614        ) -> Result<RingBufferSetActiveChannelsResult, fidl::Error> {
7615            let _response = fidl::client::decode_transaction_body::<
7616                fidl::encoding::FlexibleResultType<
7617                    RingBufferSetActiveChannelsResponse,
7618                    RingBufferSetActiveChannelsError,
7619                >,
7620                fidl::encoding::DefaultFuchsiaResourceDialect,
7621                0x4276c43e4a3b59ee,
7622            >(_buf?)?
7623            .into_result::<RingBufferMarker>("set_active_channels")?;
7624            Ok(_response.map(|x| x))
7625        }
7626        self.client.send_query_and_decode::<
7627            RingBufferSetActiveChannelsRequest,
7628            RingBufferSetActiveChannelsResult,
7629        >(
7630            payload,
7631            0x4276c43e4a3b59ee,
7632            fidl::encoding::DynamicFlags::FLEXIBLE,
7633            _decode,
7634        )
7635    }
7636
7637    type StartResponseFut = fidl::client::QueryResponseFut<
7638        RingBufferStartResult,
7639        fidl::encoding::DefaultFuchsiaResourceDialect,
7640    >;
7641    fn r#start(&self, mut payload: &RingBufferStartRequest) -> Self::StartResponseFut {
7642        fn _decode(
7643            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7644        ) -> Result<RingBufferStartResult, fidl::Error> {
7645            let _response = fidl::client::decode_transaction_body::<
7646                fidl::encoding::FlexibleResultType<RingBufferStartResponse, RingBufferStartError>,
7647                fidl::encoding::DefaultFuchsiaResourceDialect,
7648                0x5365a8609dc2dc5,
7649            >(_buf?)?
7650            .into_result::<RingBufferMarker>("start")?;
7651            Ok(_response.map(|x| x))
7652        }
7653        self.client.send_query_and_decode::<RingBufferStartRequest, RingBufferStartResult>(
7654            payload,
7655            0x5365a8609dc2dc5,
7656            fidl::encoding::DynamicFlags::FLEXIBLE,
7657            _decode,
7658        )
7659    }
7660
7661    type StopResponseFut = fidl::client::QueryResponseFut<
7662        RingBufferStopResult,
7663        fidl::encoding::DefaultFuchsiaResourceDialect,
7664    >;
7665    fn r#stop(&self, mut payload: &RingBufferStopRequest) -> Self::StopResponseFut {
7666        fn _decode(
7667            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7668        ) -> Result<RingBufferStopResult, fidl::Error> {
7669            let _response = fidl::client::decode_transaction_body::<
7670                fidl::encoding::FlexibleResultType<RingBufferStopResponse, RingBufferStopError>,
7671                fidl::encoding::DefaultFuchsiaResourceDialect,
7672                0x5a238810af11e6e1,
7673            >(_buf?)?
7674            .into_result::<RingBufferMarker>("stop")?;
7675            Ok(_response.map(|x| x))
7676        }
7677        self.client.send_query_and_decode::<RingBufferStopRequest, RingBufferStopResult>(
7678            payload,
7679            0x5a238810af11e6e1,
7680            fidl::encoding::DynamicFlags::FLEXIBLE,
7681            _decode,
7682        )
7683    }
7684
7685    type WatchDelayInfoResponseFut = fidl::client::QueryResponseFut<
7686        RingBufferWatchDelayInfoResult,
7687        fidl::encoding::DefaultFuchsiaResourceDialect,
7688    >;
7689    fn r#watch_delay_info(&self) -> Self::WatchDelayInfoResponseFut {
7690        fn _decode(
7691            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7692        ) -> Result<RingBufferWatchDelayInfoResult, fidl::Error> {
7693            let _response = fidl::client::decode_transaction_body::<
7694                fidl::encoding::FlexibleResultType<
7695                    RingBufferWatchDelayInfoResponse,
7696                    RingBufferWatchDelayInfoError,
7697                >,
7698                fidl::encoding::DefaultFuchsiaResourceDialect,
7699                0x6d1dc5a928f38ad6,
7700            >(_buf?)?
7701            .into_result::<RingBufferMarker>("watch_delay_info")?;
7702            Ok(_response.map(|x| x))
7703        }
7704        self.client
7705            .send_query_and_decode::<fidl::encoding::EmptyPayload, RingBufferWatchDelayInfoResult>(
7706                (),
7707                0x6d1dc5a928f38ad6,
7708                fidl::encoding::DynamicFlags::FLEXIBLE,
7709                _decode,
7710            )
7711    }
7712}
7713
7714pub struct RingBufferEventStream {
7715    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7716}
7717
7718impl std::marker::Unpin for RingBufferEventStream {}
7719
7720impl futures::stream::FusedStream for RingBufferEventStream {
7721    fn is_terminated(&self) -> bool {
7722        self.event_receiver.is_terminated()
7723    }
7724}
7725
7726impl futures::Stream for RingBufferEventStream {
7727    type Item = Result<RingBufferEvent, fidl::Error>;
7728
7729    fn poll_next(
7730        mut self: std::pin::Pin<&mut Self>,
7731        cx: &mut std::task::Context<'_>,
7732    ) -> std::task::Poll<Option<Self::Item>> {
7733        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7734            &mut self.event_receiver,
7735            cx
7736        )?) {
7737            Some(buf) => std::task::Poll::Ready(Some(RingBufferEvent::decode(buf))),
7738            None => std::task::Poll::Ready(None),
7739        }
7740    }
7741}
7742
7743#[derive(Debug)]
7744pub enum RingBufferEvent {
7745    #[non_exhaustive]
7746    _UnknownEvent {
7747        /// Ordinal of the event that was sent.
7748        ordinal: u64,
7749    },
7750}
7751
7752impl RingBufferEvent {
7753    /// Decodes a message buffer as a [`RingBufferEvent`].
7754    fn decode(
7755        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7756    ) -> Result<RingBufferEvent, fidl::Error> {
7757        let (bytes, _handles) = buf.split_mut();
7758        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7759        debug_assert_eq!(tx_header.tx_id, 0);
7760        match tx_header.ordinal {
7761            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7762                Ok(RingBufferEvent::_UnknownEvent { ordinal: tx_header.ordinal })
7763            }
7764            _ => Err(fidl::Error::UnknownOrdinal {
7765                ordinal: tx_header.ordinal,
7766                protocol_name: <RingBufferMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7767            }),
7768        }
7769    }
7770}
7771
7772/// A Stream of incoming requests for fuchsia.audio.device/RingBuffer.
7773pub struct RingBufferRequestStream {
7774    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7775    is_terminated: bool,
7776}
7777
7778impl std::marker::Unpin for RingBufferRequestStream {}
7779
7780impl futures::stream::FusedStream for RingBufferRequestStream {
7781    fn is_terminated(&self) -> bool {
7782        self.is_terminated
7783    }
7784}
7785
7786impl fidl::endpoints::RequestStream for RingBufferRequestStream {
7787    type Protocol = RingBufferMarker;
7788    type ControlHandle = RingBufferControlHandle;
7789
7790    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7791        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7792    }
7793
7794    fn control_handle(&self) -> Self::ControlHandle {
7795        RingBufferControlHandle { inner: self.inner.clone() }
7796    }
7797
7798    fn into_inner(
7799        self,
7800    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7801    {
7802        (self.inner, self.is_terminated)
7803    }
7804
7805    fn from_inner(
7806        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7807        is_terminated: bool,
7808    ) -> Self {
7809        Self { inner, is_terminated }
7810    }
7811}
7812
7813impl futures::Stream for RingBufferRequestStream {
7814    type Item = Result<RingBufferRequest, fidl::Error>;
7815
7816    fn poll_next(
7817        mut self: std::pin::Pin<&mut Self>,
7818        cx: &mut std::task::Context<'_>,
7819    ) -> std::task::Poll<Option<Self::Item>> {
7820        let this = &mut *self;
7821        if this.inner.check_shutdown(cx) {
7822            this.is_terminated = true;
7823            return std::task::Poll::Ready(None);
7824        }
7825        if this.is_terminated {
7826            panic!("polled RingBufferRequestStream after completion");
7827        }
7828        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7829            |bytes, handles| {
7830                match this.inner.channel().read_etc(cx, bytes, handles) {
7831                    std::task::Poll::Ready(Ok(())) => {}
7832                    std::task::Poll::Pending => return std::task::Poll::Pending,
7833                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7834                        this.is_terminated = true;
7835                        return std::task::Poll::Ready(None);
7836                    }
7837                    std::task::Poll::Ready(Err(e)) => {
7838                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7839                            e.into(),
7840                        ))));
7841                    }
7842                }
7843
7844                // A message has been received from the channel
7845                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7846
7847                std::task::Poll::Ready(Some(match header.ordinal {
7848                    0x4276c43e4a3b59ee => {
7849                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7850                        let mut req = fidl::new_empty!(
7851                            RingBufferSetActiveChannelsRequest,
7852                            fidl::encoding::DefaultFuchsiaResourceDialect
7853                        );
7854                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RingBufferSetActiveChannelsRequest>(&header, _body_bytes, handles, &mut req)?;
7855                        let control_handle = RingBufferControlHandle { inner: this.inner.clone() };
7856                        Ok(RingBufferRequest::SetActiveChannels {
7857                            payload: req,
7858                            responder: RingBufferSetActiveChannelsResponder {
7859                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7860                                tx_id: header.tx_id,
7861                            },
7862                        })
7863                    }
7864                    0x5365a8609dc2dc5 => {
7865                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7866                        let mut req = fidl::new_empty!(
7867                            RingBufferStartRequest,
7868                            fidl::encoding::DefaultFuchsiaResourceDialect
7869                        );
7870                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RingBufferStartRequest>(&header, _body_bytes, handles, &mut req)?;
7871                        let control_handle = RingBufferControlHandle { inner: this.inner.clone() };
7872                        Ok(RingBufferRequest::Start {
7873                            payload: req,
7874                            responder: RingBufferStartResponder {
7875                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7876                                tx_id: header.tx_id,
7877                            },
7878                        })
7879                    }
7880                    0x5a238810af11e6e1 => {
7881                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7882                        let mut req = fidl::new_empty!(
7883                            RingBufferStopRequest,
7884                            fidl::encoding::DefaultFuchsiaResourceDialect
7885                        );
7886                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RingBufferStopRequest>(&header, _body_bytes, handles, &mut req)?;
7887                        let control_handle = RingBufferControlHandle { inner: this.inner.clone() };
7888                        Ok(RingBufferRequest::Stop {
7889                            payload: req,
7890                            responder: RingBufferStopResponder {
7891                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7892                                tx_id: header.tx_id,
7893                            },
7894                        })
7895                    }
7896                    0x6d1dc5a928f38ad6 => {
7897                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7898                        let mut req = fidl::new_empty!(
7899                            fidl::encoding::EmptyPayload,
7900                            fidl::encoding::DefaultFuchsiaResourceDialect
7901                        );
7902                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7903                        let control_handle = RingBufferControlHandle { inner: this.inner.clone() };
7904                        Ok(RingBufferRequest::WatchDelayInfo {
7905                            responder: RingBufferWatchDelayInfoResponder {
7906                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7907                                tx_id: header.tx_id,
7908                            },
7909                        })
7910                    }
7911                    _ if header.tx_id == 0
7912                        && header
7913                            .dynamic_flags()
7914                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
7915                    {
7916                        Ok(RingBufferRequest::_UnknownMethod {
7917                            ordinal: header.ordinal,
7918                            control_handle: RingBufferControlHandle { inner: this.inner.clone() },
7919                            method_type: fidl::MethodType::OneWay,
7920                        })
7921                    }
7922                    _ if header
7923                        .dynamic_flags()
7924                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
7925                    {
7926                        this.inner.send_framework_err(
7927                            fidl::encoding::FrameworkErr::UnknownMethod,
7928                            header.tx_id,
7929                            header.ordinal,
7930                            header.dynamic_flags(),
7931                            (bytes, handles),
7932                        )?;
7933                        Ok(RingBufferRequest::_UnknownMethod {
7934                            ordinal: header.ordinal,
7935                            control_handle: RingBufferControlHandle { inner: this.inner.clone() },
7936                            method_type: fidl::MethodType::TwoWay,
7937                        })
7938                    }
7939                    _ => Err(fidl::Error::UnknownOrdinal {
7940                        ordinal: header.ordinal,
7941                        protocol_name:
7942                            <RingBufferMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7943                    }),
7944                }))
7945            },
7946        )
7947    }
7948}
7949
7950/// A `RingBuffer` instance controls data flow for the associated audio stream.
7951#[derive(Debug)]
7952pub enum RingBufferRequest {
7953    /// Request that specific individual channels be powered down/up, if the
7954    /// device supports this. This is intended for idle power conservation.
7955    ///
7956    /// Channels are specified by bitmask; the least significant bit corresponds
7957    /// to channel 0. Each bit not set indicates that the channel can be
7958    /// deactivated. `SetActiveChannels` does not change how a ring buffer
7959    /// responds to `Start`/`Stop`, specifically with regards to position.
7960    ///
7961    /// Devices are not required to obey `SetActiveChannels`. For example, they
7962    /// are not required to zero-out an input stream's inactive channels, and
7963    /// data written to inactive channels of an output stream's ring buffer may
7964    /// still be played.
7965    ///
7966    /// If not called, then by default all channels will be active.
7967    SetActiveChannels {
7968        payload: RingBufferSetActiveChannelsRequest,
7969        responder: RingBufferSetActiveChannelsResponder,
7970    },
7971    /// Start the ring buffer, beginning at the first frame of the ring buffer.
7972    Start { payload: RingBufferStartRequest, responder: RingBufferStartResponder },
7973    /// Stop the ring buffer.
7974    Stop { payload: RingBufferStopRequest, responder: RingBufferStopResponder },
7975    /// Request delay information via a hanging get. The RingBuffer will respond
7976    /// immediately to the first `WatchDelayInfo` call. Subsequent calls will
7977    /// only be completed when the delay info has changed from previously
7978    /// communicated values.
7979    WatchDelayInfo { responder: RingBufferWatchDelayInfoResponder },
7980    /// An interaction was received which does not match any known method.
7981    #[non_exhaustive]
7982    _UnknownMethod {
7983        /// Ordinal of the method that was called.
7984        ordinal: u64,
7985        control_handle: RingBufferControlHandle,
7986        method_type: fidl::MethodType,
7987    },
7988}
7989
7990impl RingBufferRequest {
7991    #[allow(irrefutable_let_patterns)]
7992    pub fn into_set_active_channels(
7993        self,
7994    ) -> Option<(RingBufferSetActiveChannelsRequest, RingBufferSetActiveChannelsResponder)> {
7995        if let RingBufferRequest::SetActiveChannels { payload, responder } = self {
7996            Some((payload, responder))
7997        } else {
7998            None
7999        }
8000    }
8001
8002    #[allow(irrefutable_let_patterns)]
8003    pub fn into_start(self) -> Option<(RingBufferStartRequest, RingBufferStartResponder)> {
8004        if let RingBufferRequest::Start { payload, responder } = self {
8005            Some((payload, responder))
8006        } else {
8007            None
8008        }
8009    }
8010
8011    #[allow(irrefutable_let_patterns)]
8012    pub fn into_stop(self) -> Option<(RingBufferStopRequest, RingBufferStopResponder)> {
8013        if let RingBufferRequest::Stop { payload, responder } = self {
8014            Some((payload, responder))
8015        } else {
8016            None
8017        }
8018    }
8019
8020    #[allow(irrefutable_let_patterns)]
8021    pub fn into_watch_delay_info(self) -> Option<(RingBufferWatchDelayInfoResponder)> {
8022        if let RingBufferRequest::WatchDelayInfo { responder } = self {
8023            Some((responder))
8024        } else {
8025            None
8026        }
8027    }
8028
8029    /// Name of the method defined in FIDL
8030    pub fn method_name(&self) -> &'static str {
8031        match *self {
8032            RingBufferRequest::SetActiveChannels { .. } => "set_active_channels",
8033            RingBufferRequest::Start { .. } => "start",
8034            RingBufferRequest::Stop { .. } => "stop",
8035            RingBufferRequest::WatchDelayInfo { .. } => "watch_delay_info",
8036            RingBufferRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
8037                "unknown one-way method"
8038            }
8039            RingBufferRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
8040                "unknown two-way method"
8041            }
8042        }
8043    }
8044}
8045
8046#[derive(Debug, Clone)]
8047pub struct RingBufferControlHandle {
8048    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8049}
8050
8051impl RingBufferControlHandle {
8052    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
8053        self.inner.shutdown_with_epitaph(status.into())
8054    }
8055}
8056
8057impl fidl::endpoints::ControlHandle for RingBufferControlHandle {
8058    fn shutdown(&self) {
8059        self.inner.shutdown()
8060    }
8061
8062    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
8063        self.inner.shutdown_with_epitaph(status)
8064    }
8065
8066    fn is_closed(&self) -> bool {
8067        self.inner.channel().is_closed()
8068    }
8069    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8070        self.inner.channel().on_closed()
8071    }
8072
8073    #[cfg(target_os = "fuchsia")]
8074    fn signal_peer(
8075        &self,
8076        clear_mask: zx::Signals,
8077        set_mask: zx::Signals,
8078    ) -> Result<(), zx_status::Status> {
8079        use fidl::Peered;
8080        self.inner.channel().signal_peer(clear_mask, set_mask)
8081    }
8082}
8083
8084impl RingBufferControlHandle {}
8085
8086#[must_use = "FIDL methods require a response to be sent"]
8087#[derive(Debug)]
8088pub struct RingBufferSetActiveChannelsResponder {
8089    control_handle: std::mem::ManuallyDrop<RingBufferControlHandle>,
8090    tx_id: u32,
8091}
8092
8093/// Set the the channel to be shutdown (see [`RingBufferControlHandle::shutdown`])
8094/// if the responder is dropped without sending a response, so that the client
8095/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8096impl std::ops::Drop for RingBufferSetActiveChannelsResponder {
8097    fn drop(&mut self) {
8098        self.control_handle.shutdown();
8099        // Safety: drops once, never accessed again
8100        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8101    }
8102}
8103
8104impl fidl::endpoints::Responder for RingBufferSetActiveChannelsResponder {
8105    type ControlHandle = RingBufferControlHandle;
8106
8107    fn control_handle(&self) -> &RingBufferControlHandle {
8108        &self.control_handle
8109    }
8110
8111    fn drop_without_shutdown(mut self) {
8112        // Safety: drops once, never accessed again due to mem::forget
8113        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8114        // Prevent Drop from running (which would shut down the channel)
8115        std::mem::forget(self);
8116    }
8117}
8118
8119impl RingBufferSetActiveChannelsResponder {
8120    /// Sends a response to the FIDL transaction.
8121    ///
8122    /// Sets the channel to shutdown if an error occurs.
8123    pub fn send(
8124        self,
8125        mut result: Result<&RingBufferSetActiveChannelsResponse, RingBufferSetActiveChannelsError>,
8126    ) -> Result<(), fidl::Error> {
8127        let _result = self.send_raw(result);
8128        if _result.is_err() {
8129            self.control_handle.shutdown();
8130        }
8131        self.drop_without_shutdown();
8132        _result
8133    }
8134
8135    /// Similar to "send" but does not shutdown the channel if an error occurs.
8136    pub fn send_no_shutdown_on_err(
8137        self,
8138        mut result: Result<&RingBufferSetActiveChannelsResponse, RingBufferSetActiveChannelsError>,
8139    ) -> Result<(), fidl::Error> {
8140        let _result = self.send_raw(result);
8141        self.drop_without_shutdown();
8142        _result
8143    }
8144
8145    fn send_raw(
8146        &self,
8147        mut result: Result<&RingBufferSetActiveChannelsResponse, RingBufferSetActiveChannelsError>,
8148    ) -> Result<(), fidl::Error> {
8149        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
8150            RingBufferSetActiveChannelsResponse,
8151            RingBufferSetActiveChannelsError,
8152        >>(
8153            fidl::encoding::FlexibleResult::new(result),
8154            self.tx_id,
8155            0x4276c43e4a3b59ee,
8156            fidl::encoding::DynamicFlags::FLEXIBLE,
8157        )
8158    }
8159}
8160
8161#[must_use = "FIDL methods require a response to be sent"]
8162#[derive(Debug)]
8163pub struct RingBufferStartResponder {
8164    control_handle: std::mem::ManuallyDrop<RingBufferControlHandle>,
8165    tx_id: u32,
8166}
8167
8168/// Set the the channel to be shutdown (see [`RingBufferControlHandle::shutdown`])
8169/// if the responder is dropped without sending a response, so that the client
8170/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8171impl std::ops::Drop for RingBufferStartResponder {
8172    fn drop(&mut self) {
8173        self.control_handle.shutdown();
8174        // Safety: drops once, never accessed again
8175        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8176    }
8177}
8178
8179impl fidl::endpoints::Responder for RingBufferStartResponder {
8180    type ControlHandle = RingBufferControlHandle;
8181
8182    fn control_handle(&self) -> &RingBufferControlHandle {
8183        &self.control_handle
8184    }
8185
8186    fn drop_without_shutdown(mut self) {
8187        // Safety: drops once, never accessed again due to mem::forget
8188        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8189        // Prevent Drop from running (which would shut down the channel)
8190        std::mem::forget(self);
8191    }
8192}
8193
8194impl RingBufferStartResponder {
8195    /// Sends a response to the FIDL transaction.
8196    ///
8197    /// Sets the channel to shutdown if an error occurs.
8198    pub fn send(
8199        self,
8200        mut result: Result<&RingBufferStartResponse, RingBufferStartError>,
8201    ) -> Result<(), fidl::Error> {
8202        let _result = self.send_raw(result);
8203        if _result.is_err() {
8204            self.control_handle.shutdown();
8205        }
8206        self.drop_without_shutdown();
8207        _result
8208    }
8209
8210    /// Similar to "send" but does not shutdown the channel if an error occurs.
8211    pub fn send_no_shutdown_on_err(
8212        self,
8213        mut result: Result<&RingBufferStartResponse, RingBufferStartError>,
8214    ) -> Result<(), fidl::Error> {
8215        let _result = self.send_raw(result);
8216        self.drop_without_shutdown();
8217        _result
8218    }
8219
8220    fn send_raw(
8221        &self,
8222        mut result: Result<&RingBufferStartResponse, RingBufferStartError>,
8223    ) -> Result<(), fidl::Error> {
8224        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
8225            RingBufferStartResponse,
8226            RingBufferStartError,
8227        >>(
8228            fidl::encoding::FlexibleResult::new(result),
8229            self.tx_id,
8230            0x5365a8609dc2dc5,
8231            fidl::encoding::DynamicFlags::FLEXIBLE,
8232        )
8233    }
8234}
8235
8236#[must_use = "FIDL methods require a response to be sent"]
8237#[derive(Debug)]
8238pub struct RingBufferStopResponder {
8239    control_handle: std::mem::ManuallyDrop<RingBufferControlHandle>,
8240    tx_id: u32,
8241}
8242
8243/// Set the the channel to be shutdown (see [`RingBufferControlHandle::shutdown`])
8244/// if the responder is dropped without sending a response, so that the client
8245/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8246impl std::ops::Drop for RingBufferStopResponder {
8247    fn drop(&mut self) {
8248        self.control_handle.shutdown();
8249        // Safety: drops once, never accessed again
8250        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8251    }
8252}
8253
8254impl fidl::endpoints::Responder for RingBufferStopResponder {
8255    type ControlHandle = RingBufferControlHandle;
8256
8257    fn control_handle(&self) -> &RingBufferControlHandle {
8258        &self.control_handle
8259    }
8260
8261    fn drop_without_shutdown(mut self) {
8262        // Safety: drops once, never accessed again due to mem::forget
8263        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8264        // Prevent Drop from running (which would shut down the channel)
8265        std::mem::forget(self);
8266    }
8267}
8268
8269impl RingBufferStopResponder {
8270    /// Sends a response to the FIDL transaction.
8271    ///
8272    /// Sets the channel to shutdown if an error occurs.
8273    pub fn send(
8274        self,
8275        mut result: Result<&RingBufferStopResponse, RingBufferStopError>,
8276    ) -> Result<(), fidl::Error> {
8277        let _result = self.send_raw(result);
8278        if _result.is_err() {
8279            self.control_handle.shutdown();
8280        }
8281        self.drop_without_shutdown();
8282        _result
8283    }
8284
8285    /// Similar to "send" but does not shutdown the channel if an error occurs.
8286    pub fn send_no_shutdown_on_err(
8287        self,
8288        mut result: Result<&RingBufferStopResponse, RingBufferStopError>,
8289    ) -> Result<(), fidl::Error> {
8290        let _result = self.send_raw(result);
8291        self.drop_without_shutdown();
8292        _result
8293    }
8294
8295    fn send_raw(
8296        &self,
8297        mut result: Result<&RingBufferStopResponse, RingBufferStopError>,
8298    ) -> Result<(), fidl::Error> {
8299        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
8300            RingBufferStopResponse,
8301            RingBufferStopError,
8302        >>(
8303            fidl::encoding::FlexibleResult::new(result),
8304            self.tx_id,
8305            0x5a238810af11e6e1,
8306            fidl::encoding::DynamicFlags::FLEXIBLE,
8307        )
8308    }
8309}
8310
8311#[must_use = "FIDL methods require a response to be sent"]
8312#[derive(Debug)]
8313pub struct RingBufferWatchDelayInfoResponder {
8314    control_handle: std::mem::ManuallyDrop<RingBufferControlHandle>,
8315    tx_id: u32,
8316}
8317
8318/// Set the the channel to be shutdown (see [`RingBufferControlHandle::shutdown`])
8319/// if the responder is dropped without sending a response, so that the client
8320/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8321impl std::ops::Drop for RingBufferWatchDelayInfoResponder {
8322    fn drop(&mut self) {
8323        self.control_handle.shutdown();
8324        // Safety: drops once, never accessed again
8325        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8326    }
8327}
8328
8329impl fidl::endpoints::Responder for RingBufferWatchDelayInfoResponder {
8330    type ControlHandle = RingBufferControlHandle;
8331
8332    fn control_handle(&self) -> &RingBufferControlHandle {
8333        &self.control_handle
8334    }
8335
8336    fn drop_without_shutdown(mut self) {
8337        // Safety: drops once, never accessed again due to mem::forget
8338        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8339        // Prevent Drop from running (which would shut down the channel)
8340        std::mem::forget(self);
8341    }
8342}
8343
8344impl RingBufferWatchDelayInfoResponder {
8345    /// Sends a response to the FIDL transaction.
8346    ///
8347    /// Sets the channel to shutdown if an error occurs.
8348    pub fn send(
8349        self,
8350        mut result: Result<&RingBufferWatchDelayInfoResponse, RingBufferWatchDelayInfoError>,
8351    ) -> Result<(), fidl::Error> {
8352        let _result = self.send_raw(result);
8353        if _result.is_err() {
8354            self.control_handle.shutdown();
8355        }
8356        self.drop_without_shutdown();
8357        _result
8358    }
8359
8360    /// Similar to "send" but does not shutdown the channel if an error occurs.
8361    pub fn send_no_shutdown_on_err(
8362        self,
8363        mut result: Result<&RingBufferWatchDelayInfoResponse, RingBufferWatchDelayInfoError>,
8364    ) -> Result<(), fidl::Error> {
8365        let _result = self.send_raw(result);
8366        self.drop_without_shutdown();
8367        _result
8368    }
8369
8370    fn send_raw(
8371        &self,
8372        mut result: Result<&RingBufferWatchDelayInfoResponse, RingBufferWatchDelayInfoError>,
8373    ) -> Result<(), fidl::Error> {
8374        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
8375            RingBufferWatchDelayInfoResponse,
8376            RingBufferWatchDelayInfoError,
8377        >>(
8378            fidl::encoding::FlexibleResult::new(result),
8379            self.tx_id,
8380            0x6d1dc5a928f38ad6,
8381            fidl::encoding::DynamicFlags::FLEXIBLE,
8382        )
8383    }
8384}
8385
8386mod internal {
8387    use super::*;
8388
8389    impl ControlCreatePacketStreamRequest {
8390        #[inline(always)]
8391        fn max_ordinal_present(&self) -> u64 {
8392            if let Some(_) = self.packet_stream_server {
8393                return 3;
8394            }
8395            if let Some(_) = self.options {
8396                return 2;
8397            }
8398            if let Some(_) = self.element_id {
8399                return 1;
8400            }
8401            0
8402        }
8403    }
8404
8405    impl fidl::encoding::ResourceTypeMarker for ControlCreatePacketStreamRequest {
8406        type Borrowed<'a> = &'a mut Self;
8407        fn take_or_borrow<'a>(
8408            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8409        ) -> Self::Borrowed<'a> {
8410            value
8411        }
8412    }
8413
8414    unsafe impl fidl::encoding::TypeMarker for ControlCreatePacketStreamRequest {
8415        type Owned = Self;
8416
8417        #[inline(always)]
8418        fn inline_align(_context: fidl::encoding::Context) -> usize {
8419            8
8420        }
8421
8422        #[inline(always)]
8423        fn inline_size(_context: fidl::encoding::Context) -> usize {
8424            16
8425        }
8426    }
8427
8428    unsafe impl
8429        fidl::encoding::Encode<
8430            ControlCreatePacketStreamRequest,
8431            fidl::encoding::DefaultFuchsiaResourceDialect,
8432        > for &mut ControlCreatePacketStreamRequest
8433    {
8434        unsafe fn encode(
8435            self,
8436            encoder: &mut fidl::encoding::Encoder<
8437                '_,
8438                fidl::encoding::DefaultFuchsiaResourceDialect,
8439            >,
8440            offset: usize,
8441            mut depth: fidl::encoding::Depth,
8442        ) -> fidl::Result<()> {
8443            encoder.debug_check_bounds::<ControlCreatePacketStreamRequest>(offset);
8444            // Vector header
8445            let max_ordinal: u64 = self.max_ordinal_present();
8446            encoder.write_num(max_ordinal, offset);
8447            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8448            // Calling encoder.out_of_line_offset(0) is not allowed.
8449            if max_ordinal == 0 {
8450                return Ok(());
8451            }
8452            depth.increment()?;
8453            let envelope_size = 8;
8454            let bytes_len = max_ordinal as usize * envelope_size;
8455            #[allow(unused_variables)]
8456            let offset = encoder.out_of_line_offset(bytes_len);
8457            let mut _prev_end_offset: usize = 0;
8458            if 1 > max_ordinal {
8459                return Ok(());
8460            }
8461
8462            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8463            // are envelope_size bytes.
8464            let cur_offset: usize = (1 - 1) * envelope_size;
8465
8466            // Zero reserved fields.
8467            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8468
8469            // Safety:
8470            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8471            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8472            //   envelope_size bytes, there is always sufficient room.
8473            fidl::encoding::encode_in_envelope_optional::<
8474                u64,
8475                fidl::encoding::DefaultFuchsiaResourceDialect,
8476            >(
8477                self.element_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
8478                encoder,
8479                offset + cur_offset,
8480                depth,
8481            )?;
8482
8483            _prev_end_offset = cur_offset + envelope_size;
8484            if 2 > max_ordinal {
8485                return Ok(());
8486            }
8487
8488            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8489            // are envelope_size bytes.
8490            let cur_offset: usize = (2 - 1) * envelope_size;
8491
8492            // Zero reserved fields.
8493            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8494
8495            // Safety:
8496            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8497            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8498            //   envelope_size bytes, there is always sufficient room.
8499            fidl::encoding::encode_in_envelope_optional::<
8500                PacketStreamOptions,
8501                fidl::encoding::DefaultFuchsiaResourceDialect,
8502            >(
8503                self.options.as_mut().map(
8504                    <PacketStreamOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
8505                ),
8506                encoder,
8507                offset + cur_offset,
8508                depth,
8509            )?;
8510
8511            _prev_end_offset = cur_offset + envelope_size;
8512            if 3 > max_ordinal {
8513                return Ok(());
8514            }
8515
8516            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8517            // are envelope_size bytes.
8518            let cur_offset: usize = (3 - 1) * envelope_size;
8519
8520            // Zero reserved fields.
8521            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8522
8523            // Safety:
8524            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8525            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8526            //   envelope_size bytes, there is always sufficient room.
8527            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PacketStreamMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
8528            self.packet_stream_server.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PacketStreamMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
8529            encoder, offset + cur_offset, depth
8530        )?;
8531
8532            _prev_end_offset = cur_offset + envelope_size;
8533
8534            Ok(())
8535        }
8536    }
8537
8538    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8539        for ControlCreatePacketStreamRequest
8540    {
8541        #[inline(always)]
8542        fn new_empty() -> Self {
8543            Self::default()
8544        }
8545
8546        unsafe fn decode(
8547            &mut self,
8548            decoder: &mut fidl::encoding::Decoder<
8549                '_,
8550                fidl::encoding::DefaultFuchsiaResourceDialect,
8551            >,
8552            offset: usize,
8553            mut depth: fidl::encoding::Depth,
8554        ) -> fidl::Result<()> {
8555            decoder.debug_check_bounds::<Self>(offset);
8556            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8557                None => return Err(fidl::Error::NotNullable),
8558                Some(len) => len,
8559            };
8560            // Calling decoder.out_of_line_offset(0) is not allowed.
8561            if len == 0 {
8562                return Ok(());
8563            };
8564            depth.increment()?;
8565            let envelope_size = 8;
8566            let bytes_len = len * envelope_size;
8567            let offset = decoder.out_of_line_offset(bytes_len)?;
8568            // Decode the envelope for each type.
8569            let mut _next_ordinal_to_read = 0;
8570            let mut next_offset = offset;
8571            let end_offset = offset + bytes_len;
8572            _next_ordinal_to_read += 1;
8573            if next_offset >= end_offset {
8574                return Ok(());
8575            }
8576
8577            // Decode unknown envelopes for gaps in ordinals.
8578            while _next_ordinal_to_read < 1 {
8579                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8580                _next_ordinal_to_read += 1;
8581                next_offset += envelope_size;
8582            }
8583
8584            let next_out_of_line = decoder.next_out_of_line();
8585            let handles_before = decoder.remaining_handles();
8586            if let Some((inlined, num_bytes, num_handles)) =
8587                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8588            {
8589                let member_inline_size =
8590                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8591                if inlined != (member_inline_size <= 4) {
8592                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8593                }
8594                let inner_offset;
8595                let mut inner_depth = depth.clone();
8596                if inlined {
8597                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8598                    inner_offset = next_offset;
8599                } else {
8600                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8601                    inner_depth.increment()?;
8602                }
8603                let val_ref = self.element_id.get_or_insert_with(|| {
8604                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
8605                });
8606                fidl::decode!(
8607                    u64,
8608                    fidl::encoding::DefaultFuchsiaResourceDialect,
8609                    val_ref,
8610                    decoder,
8611                    inner_offset,
8612                    inner_depth
8613                )?;
8614                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8615                {
8616                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8617                }
8618                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8619                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8620                }
8621            }
8622
8623            next_offset += envelope_size;
8624            _next_ordinal_to_read += 1;
8625            if next_offset >= end_offset {
8626                return Ok(());
8627            }
8628
8629            // Decode unknown envelopes for gaps in ordinals.
8630            while _next_ordinal_to_read < 2 {
8631                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8632                _next_ordinal_to_read += 1;
8633                next_offset += envelope_size;
8634            }
8635
8636            let next_out_of_line = decoder.next_out_of_line();
8637            let handles_before = decoder.remaining_handles();
8638            if let Some((inlined, num_bytes, num_handles)) =
8639                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8640            {
8641                let member_inline_size =
8642                    <PacketStreamOptions as fidl::encoding::TypeMarker>::inline_size(
8643                        decoder.context,
8644                    );
8645                if inlined != (member_inline_size <= 4) {
8646                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8647                }
8648                let inner_offset;
8649                let mut inner_depth = depth.clone();
8650                if inlined {
8651                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8652                    inner_offset = next_offset;
8653                } else {
8654                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8655                    inner_depth.increment()?;
8656                }
8657                let val_ref = self.options.get_or_insert_with(|| {
8658                    fidl::new_empty!(
8659                        PacketStreamOptions,
8660                        fidl::encoding::DefaultFuchsiaResourceDialect
8661                    )
8662                });
8663                fidl::decode!(
8664                    PacketStreamOptions,
8665                    fidl::encoding::DefaultFuchsiaResourceDialect,
8666                    val_ref,
8667                    decoder,
8668                    inner_offset,
8669                    inner_depth
8670                )?;
8671                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8672                {
8673                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8674                }
8675                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8676                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8677                }
8678            }
8679
8680            next_offset += envelope_size;
8681            _next_ordinal_to_read += 1;
8682            if next_offset >= end_offset {
8683                return Ok(());
8684            }
8685
8686            // Decode unknown envelopes for gaps in ordinals.
8687            while _next_ordinal_to_read < 3 {
8688                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8689                _next_ordinal_to_read += 1;
8690                next_offset += envelope_size;
8691            }
8692
8693            let next_out_of_line = decoder.next_out_of_line();
8694            let handles_before = decoder.remaining_handles();
8695            if let Some((inlined, num_bytes, num_handles)) =
8696                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8697            {
8698                let member_inline_size = <fidl::encoding::Endpoint<
8699                    fidl::endpoints::ServerEnd<PacketStreamMarker>,
8700                > as fidl::encoding::TypeMarker>::inline_size(
8701                    decoder.context
8702                );
8703                if inlined != (member_inline_size <= 4) {
8704                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8705                }
8706                let inner_offset;
8707                let mut inner_depth = depth.clone();
8708                if inlined {
8709                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8710                    inner_offset = next_offset;
8711                } else {
8712                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8713                    inner_depth.increment()?;
8714                }
8715                let val_ref = self.packet_stream_server.get_or_insert_with(|| {
8716                    fidl::new_empty!(
8717                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PacketStreamMarker>>,
8718                        fidl::encoding::DefaultFuchsiaResourceDialect
8719                    )
8720                });
8721                fidl::decode!(
8722                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PacketStreamMarker>>,
8723                    fidl::encoding::DefaultFuchsiaResourceDialect,
8724                    val_ref,
8725                    decoder,
8726                    inner_offset,
8727                    inner_depth
8728                )?;
8729                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8730                {
8731                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8732                }
8733                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8734                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8735                }
8736            }
8737
8738            next_offset += envelope_size;
8739
8740            // Decode the remaining unknown envelopes.
8741            while next_offset < end_offset {
8742                _next_ordinal_to_read += 1;
8743                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8744                next_offset += envelope_size;
8745            }
8746
8747            Ok(())
8748        }
8749    }
8750
8751    impl ControlCreateRingBufferRequest {
8752        #[inline(always)]
8753        fn max_ordinal_present(&self) -> u64 {
8754            if let Some(_) = self.ring_buffer_server {
8755                return 3;
8756            }
8757            if let Some(_) = self.options {
8758                return 2;
8759            }
8760            if let Some(_) = self.element_id {
8761                return 1;
8762            }
8763            0
8764        }
8765    }
8766
8767    impl fidl::encoding::ResourceTypeMarker for ControlCreateRingBufferRequest {
8768        type Borrowed<'a> = &'a mut Self;
8769        fn take_or_borrow<'a>(
8770            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8771        ) -> Self::Borrowed<'a> {
8772            value
8773        }
8774    }
8775
8776    unsafe impl fidl::encoding::TypeMarker for ControlCreateRingBufferRequest {
8777        type Owned = Self;
8778
8779        #[inline(always)]
8780        fn inline_align(_context: fidl::encoding::Context) -> usize {
8781            8
8782        }
8783
8784        #[inline(always)]
8785        fn inline_size(_context: fidl::encoding::Context) -> usize {
8786            16
8787        }
8788    }
8789
8790    unsafe impl
8791        fidl::encoding::Encode<
8792            ControlCreateRingBufferRequest,
8793            fidl::encoding::DefaultFuchsiaResourceDialect,
8794        > for &mut ControlCreateRingBufferRequest
8795    {
8796        unsafe fn encode(
8797            self,
8798            encoder: &mut fidl::encoding::Encoder<
8799                '_,
8800                fidl::encoding::DefaultFuchsiaResourceDialect,
8801            >,
8802            offset: usize,
8803            mut depth: fidl::encoding::Depth,
8804        ) -> fidl::Result<()> {
8805            encoder.debug_check_bounds::<ControlCreateRingBufferRequest>(offset);
8806            // Vector header
8807            let max_ordinal: u64 = self.max_ordinal_present();
8808            encoder.write_num(max_ordinal, offset);
8809            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8810            // Calling encoder.out_of_line_offset(0) is not allowed.
8811            if max_ordinal == 0 {
8812                return Ok(());
8813            }
8814            depth.increment()?;
8815            let envelope_size = 8;
8816            let bytes_len = max_ordinal as usize * envelope_size;
8817            #[allow(unused_variables)]
8818            let offset = encoder.out_of_line_offset(bytes_len);
8819            let mut _prev_end_offset: usize = 0;
8820            if 1 > max_ordinal {
8821                return Ok(());
8822            }
8823
8824            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8825            // are envelope_size bytes.
8826            let cur_offset: usize = (1 - 1) * envelope_size;
8827
8828            // Zero reserved fields.
8829            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8830
8831            // Safety:
8832            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8833            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8834            //   envelope_size bytes, there is always sufficient room.
8835            fidl::encoding::encode_in_envelope_optional::<
8836                u64,
8837                fidl::encoding::DefaultFuchsiaResourceDialect,
8838            >(
8839                self.element_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
8840                encoder,
8841                offset + cur_offset,
8842                depth,
8843            )?;
8844
8845            _prev_end_offset = cur_offset + envelope_size;
8846            if 2 > max_ordinal {
8847                return Ok(());
8848            }
8849
8850            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8851            // are envelope_size bytes.
8852            let cur_offset: usize = (2 - 1) * envelope_size;
8853
8854            // Zero reserved fields.
8855            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8856
8857            // Safety:
8858            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8859            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8860            //   envelope_size bytes, there is always sufficient room.
8861            fidl::encoding::encode_in_envelope_optional::<
8862                RingBufferOptions,
8863                fidl::encoding::DefaultFuchsiaResourceDialect,
8864            >(
8865                self.options
8866                    .as_ref()
8867                    .map(<RingBufferOptions as fidl::encoding::ValueTypeMarker>::borrow),
8868                encoder,
8869                offset + cur_offset,
8870                depth,
8871            )?;
8872
8873            _prev_end_offset = cur_offset + envelope_size;
8874            if 3 > max_ordinal {
8875                return Ok(());
8876            }
8877
8878            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8879            // are envelope_size bytes.
8880            let cur_offset: usize = (3 - 1) * envelope_size;
8881
8882            // Zero reserved fields.
8883            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8884
8885            // Safety:
8886            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8887            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8888            //   envelope_size bytes, there is always sufficient room.
8889            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RingBufferMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
8890            self.ring_buffer_server.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RingBufferMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
8891            encoder, offset + cur_offset, depth
8892        )?;
8893
8894            _prev_end_offset = cur_offset + envelope_size;
8895
8896            Ok(())
8897        }
8898    }
8899
8900    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8901        for ControlCreateRingBufferRequest
8902    {
8903        #[inline(always)]
8904        fn new_empty() -> Self {
8905            Self::default()
8906        }
8907
8908        unsafe fn decode(
8909            &mut self,
8910            decoder: &mut fidl::encoding::Decoder<
8911                '_,
8912                fidl::encoding::DefaultFuchsiaResourceDialect,
8913            >,
8914            offset: usize,
8915            mut depth: fidl::encoding::Depth,
8916        ) -> fidl::Result<()> {
8917            decoder.debug_check_bounds::<Self>(offset);
8918            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8919                None => return Err(fidl::Error::NotNullable),
8920                Some(len) => len,
8921            };
8922            // Calling decoder.out_of_line_offset(0) is not allowed.
8923            if len == 0 {
8924                return Ok(());
8925            };
8926            depth.increment()?;
8927            let envelope_size = 8;
8928            let bytes_len = len * envelope_size;
8929            let offset = decoder.out_of_line_offset(bytes_len)?;
8930            // Decode the envelope for each type.
8931            let mut _next_ordinal_to_read = 0;
8932            let mut next_offset = offset;
8933            let end_offset = offset + bytes_len;
8934            _next_ordinal_to_read += 1;
8935            if next_offset >= end_offset {
8936                return Ok(());
8937            }
8938
8939            // Decode unknown envelopes for gaps in ordinals.
8940            while _next_ordinal_to_read < 1 {
8941                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8942                _next_ordinal_to_read += 1;
8943                next_offset += envelope_size;
8944            }
8945
8946            let next_out_of_line = decoder.next_out_of_line();
8947            let handles_before = decoder.remaining_handles();
8948            if let Some((inlined, num_bytes, num_handles)) =
8949                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8950            {
8951                let member_inline_size =
8952                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8953                if inlined != (member_inline_size <= 4) {
8954                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8955                }
8956                let inner_offset;
8957                let mut inner_depth = depth.clone();
8958                if inlined {
8959                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8960                    inner_offset = next_offset;
8961                } else {
8962                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8963                    inner_depth.increment()?;
8964                }
8965                let val_ref = self.element_id.get_or_insert_with(|| {
8966                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
8967                });
8968                fidl::decode!(
8969                    u64,
8970                    fidl::encoding::DefaultFuchsiaResourceDialect,
8971                    val_ref,
8972                    decoder,
8973                    inner_offset,
8974                    inner_depth
8975                )?;
8976                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8977                {
8978                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8979                }
8980                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8981                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8982                }
8983            }
8984
8985            next_offset += envelope_size;
8986            _next_ordinal_to_read += 1;
8987            if next_offset >= end_offset {
8988                return Ok(());
8989            }
8990
8991            // Decode unknown envelopes for gaps in ordinals.
8992            while _next_ordinal_to_read < 2 {
8993                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8994                _next_ordinal_to_read += 1;
8995                next_offset += envelope_size;
8996            }
8997
8998            let next_out_of_line = decoder.next_out_of_line();
8999            let handles_before = decoder.remaining_handles();
9000            if let Some((inlined, num_bytes, num_handles)) =
9001                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9002            {
9003                let member_inline_size =
9004                    <RingBufferOptions as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9005                if inlined != (member_inline_size <= 4) {
9006                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9007                }
9008                let inner_offset;
9009                let mut inner_depth = depth.clone();
9010                if inlined {
9011                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9012                    inner_offset = next_offset;
9013                } else {
9014                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9015                    inner_depth.increment()?;
9016                }
9017                let val_ref = self.options.get_or_insert_with(|| {
9018                    fidl::new_empty!(
9019                        RingBufferOptions,
9020                        fidl::encoding::DefaultFuchsiaResourceDialect
9021                    )
9022                });
9023                fidl::decode!(
9024                    RingBufferOptions,
9025                    fidl::encoding::DefaultFuchsiaResourceDialect,
9026                    val_ref,
9027                    decoder,
9028                    inner_offset,
9029                    inner_depth
9030                )?;
9031                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9032                {
9033                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9034                }
9035                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9036                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9037                }
9038            }
9039
9040            next_offset += envelope_size;
9041            _next_ordinal_to_read += 1;
9042            if next_offset >= end_offset {
9043                return Ok(());
9044            }
9045
9046            // Decode unknown envelopes for gaps in ordinals.
9047            while _next_ordinal_to_read < 3 {
9048                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9049                _next_ordinal_to_read += 1;
9050                next_offset += envelope_size;
9051            }
9052
9053            let next_out_of_line = decoder.next_out_of_line();
9054            let handles_before = decoder.remaining_handles();
9055            if let Some((inlined, num_bytes, num_handles)) =
9056                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9057            {
9058                let member_inline_size = <fidl::encoding::Endpoint<
9059                    fidl::endpoints::ServerEnd<RingBufferMarker>,
9060                > as fidl::encoding::TypeMarker>::inline_size(
9061                    decoder.context
9062                );
9063                if inlined != (member_inline_size <= 4) {
9064                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9065                }
9066                let inner_offset;
9067                let mut inner_depth = depth.clone();
9068                if inlined {
9069                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9070                    inner_offset = next_offset;
9071                } else {
9072                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9073                    inner_depth.increment()?;
9074                }
9075                let val_ref = self.ring_buffer_server.get_or_insert_with(|| {
9076                    fidl::new_empty!(
9077                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RingBufferMarker>>,
9078                        fidl::encoding::DefaultFuchsiaResourceDialect
9079                    )
9080                });
9081                fidl::decode!(
9082                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RingBufferMarker>>,
9083                    fidl::encoding::DefaultFuchsiaResourceDialect,
9084                    val_ref,
9085                    decoder,
9086                    inner_offset,
9087                    inner_depth
9088                )?;
9089                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9090                {
9091                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9092                }
9093                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9094                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9095                }
9096            }
9097
9098            next_offset += envelope_size;
9099
9100            // Decode the remaining unknown envelopes.
9101            while next_offset < end_offset {
9102                _next_ordinal_to_read += 1;
9103                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9104                next_offset += envelope_size;
9105            }
9106
9107            Ok(())
9108        }
9109    }
9110
9111    impl ControlCreatorCreateRequest {
9112        #[inline(always)]
9113        fn max_ordinal_present(&self) -> u64 {
9114            if let Some(_) = self.control_server {
9115                return 2;
9116            }
9117            if let Some(_) = self.token_id {
9118                return 1;
9119            }
9120            0
9121        }
9122    }
9123
9124    impl fidl::encoding::ResourceTypeMarker for ControlCreatorCreateRequest {
9125        type Borrowed<'a> = &'a mut Self;
9126        fn take_or_borrow<'a>(
9127            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9128        ) -> Self::Borrowed<'a> {
9129            value
9130        }
9131    }
9132
9133    unsafe impl fidl::encoding::TypeMarker for ControlCreatorCreateRequest {
9134        type Owned = Self;
9135
9136        #[inline(always)]
9137        fn inline_align(_context: fidl::encoding::Context) -> usize {
9138            8
9139        }
9140
9141        #[inline(always)]
9142        fn inline_size(_context: fidl::encoding::Context) -> usize {
9143            16
9144        }
9145    }
9146
9147    unsafe impl
9148        fidl::encoding::Encode<
9149            ControlCreatorCreateRequest,
9150            fidl::encoding::DefaultFuchsiaResourceDialect,
9151        > for &mut ControlCreatorCreateRequest
9152    {
9153        unsafe fn encode(
9154            self,
9155            encoder: &mut fidl::encoding::Encoder<
9156                '_,
9157                fidl::encoding::DefaultFuchsiaResourceDialect,
9158            >,
9159            offset: usize,
9160            mut depth: fidl::encoding::Depth,
9161        ) -> fidl::Result<()> {
9162            encoder.debug_check_bounds::<ControlCreatorCreateRequest>(offset);
9163            // Vector header
9164            let max_ordinal: u64 = self.max_ordinal_present();
9165            encoder.write_num(max_ordinal, offset);
9166            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9167            // Calling encoder.out_of_line_offset(0) is not allowed.
9168            if max_ordinal == 0 {
9169                return Ok(());
9170            }
9171            depth.increment()?;
9172            let envelope_size = 8;
9173            let bytes_len = max_ordinal as usize * envelope_size;
9174            #[allow(unused_variables)]
9175            let offset = encoder.out_of_line_offset(bytes_len);
9176            let mut _prev_end_offset: usize = 0;
9177            if 1 > max_ordinal {
9178                return Ok(());
9179            }
9180
9181            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9182            // are envelope_size bytes.
9183            let cur_offset: usize = (1 - 1) * envelope_size;
9184
9185            // Zero reserved fields.
9186            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9187
9188            // Safety:
9189            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9190            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9191            //   envelope_size bytes, there is always sufficient room.
9192            fidl::encoding::encode_in_envelope_optional::<
9193                u64,
9194                fidl::encoding::DefaultFuchsiaResourceDialect,
9195            >(
9196                self.token_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
9197                encoder,
9198                offset + cur_offset,
9199                depth,
9200            )?;
9201
9202            _prev_end_offset = cur_offset + envelope_size;
9203            if 2 > max_ordinal {
9204                return Ok(());
9205            }
9206
9207            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9208            // are envelope_size bytes.
9209            let cur_offset: usize = (2 - 1) * envelope_size;
9210
9211            // Zero reserved fields.
9212            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9213
9214            // Safety:
9215            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9216            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9217            //   envelope_size bytes, there is always sufficient room.
9218            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
9219            self.control_server.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
9220            encoder, offset + cur_offset, depth
9221        )?;
9222
9223            _prev_end_offset = cur_offset + envelope_size;
9224
9225            Ok(())
9226        }
9227    }
9228
9229    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9230        for ControlCreatorCreateRequest
9231    {
9232        #[inline(always)]
9233        fn new_empty() -> Self {
9234            Self::default()
9235        }
9236
9237        unsafe fn decode(
9238            &mut self,
9239            decoder: &mut fidl::encoding::Decoder<
9240                '_,
9241                fidl::encoding::DefaultFuchsiaResourceDialect,
9242            >,
9243            offset: usize,
9244            mut depth: fidl::encoding::Depth,
9245        ) -> fidl::Result<()> {
9246            decoder.debug_check_bounds::<Self>(offset);
9247            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9248                None => return Err(fidl::Error::NotNullable),
9249                Some(len) => len,
9250            };
9251            // Calling decoder.out_of_line_offset(0) is not allowed.
9252            if len == 0 {
9253                return Ok(());
9254            };
9255            depth.increment()?;
9256            let envelope_size = 8;
9257            let bytes_len = len * envelope_size;
9258            let offset = decoder.out_of_line_offset(bytes_len)?;
9259            // Decode the envelope for each type.
9260            let mut _next_ordinal_to_read = 0;
9261            let mut next_offset = offset;
9262            let end_offset = offset + bytes_len;
9263            _next_ordinal_to_read += 1;
9264            if next_offset >= end_offset {
9265                return Ok(());
9266            }
9267
9268            // Decode unknown envelopes for gaps in ordinals.
9269            while _next_ordinal_to_read < 1 {
9270                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9271                _next_ordinal_to_read += 1;
9272                next_offset += envelope_size;
9273            }
9274
9275            let next_out_of_line = decoder.next_out_of_line();
9276            let handles_before = decoder.remaining_handles();
9277            if let Some((inlined, num_bytes, num_handles)) =
9278                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9279            {
9280                let member_inline_size =
9281                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9282                if inlined != (member_inline_size <= 4) {
9283                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9284                }
9285                let inner_offset;
9286                let mut inner_depth = depth.clone();
9287                if inlined {
9288                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9289                    inner_offset = next_offset;
9290                } else {
9291                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9292                    inner_depth.increment()?;
9293                }
9294                let val_ref = self.token_id.get_or_insert_with(|| {
9295                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
9296                });
9297                fidl::decode!(
9298                    u64,
9299                    fidl::encoding::DefaultFuchsiaResourceDialect,
9300                    val_ref,
9301                    decoder,
9302                    inner_offset,
9303                    inner_depth
9304                )?;
9305                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9306                {
9307                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9308                }
9309                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9310                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9311                }
9312            }
9313
9314            next_offset += envelope_size;
9315            _next_ordinal_to_read += 1;
9316            if next_offset >= end_offset {
9317                return Ok(());
9318            }
9319
9320            // Decode unknown envelopes for gaps in ordinals.
9321            while _next_ordinal_to_read < 2 {
9322                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9323                _next_ordinal_to_read += 1;
9324                next_offset += envelope_size;
9325            }
9326
9327            let next_out_of_line = decoder.next_out_of_line();
9328            let handles_before = decoder.remaining_handles();
9329            if let Some((inlined, num_bytes, num_handles)) =
9330                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9331            {
9332                let member_inline_size = <fidl::encoding::Endpoint<
9333                    fidl::endpoints::ServerEnd<ControlMarker>,
9334                > as fidl::encoding::TypeMarker>::inline_size(
9335                    decoder.context
9336                );
9337                if inlined != (member_inline_size <= 4) {
9338                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9339                }
9340                let inner_offset;
9341                let mut inner_depth = depth.clone();
9342                if inlined {
9343                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9344                    inner_offset = next_offset;
9345                } else {
9346                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9347                    inner_depth.increment()?;
9348                }
9349                let val_ref = self.control_server.get_or_insert_with(|| {
9350                    fidl::new_empty!(
9351                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
9352                        fidl::encoding::DefaultFuchsiaResourceDialect
9353                    )
9354                });
9355                fidl::decode!(
9356                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ControlMarker>>,
9357                    fidl::encoding::DefaultFuchsiaResourceDialect,
9358                    val_ref,
9359                    decoder,
9360                    inner_offset,
9361                    inner_depth
9362                )?;
9363                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9364                {
9365                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9366                }
9367                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9368                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9369                }
9370            }
9371
9372            next_offset += envelope_size;
9373
9374            // Decode the remaining unknown envelopes.
9375            while next_offset < end_offset {
9376                _next_ordinal_to_read += 1;
9377                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9378                next_offset += envelope_size;
9379            }
9380
9381            Ok(())
9382        }
9383    }
9384
9385    impl ControlCreatePacketStreamResponse {
9386        #[inline(always)]
9387        fn max_ordinal_present(&self) -> u64 {
9388            if let Some(_) = self.properties {
9389                return 1;
9390            }
9391            0
9392        }
9393    }
9394
9395    impl fidl::encoding::ResourceTypeMarker for ControlCreatePacketStreamResponse {
9396        type Borrowed<'a> = &'a mut Self;
9397        fn take_or_borrow<'a>(
9398            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9399        ) -> Self::Borrowed<'a> {
9400            value
9401        }
9402    }
9403
9404    unsafe impl fidl::encoding::TypeMarker for ControlCreatePacketStreamResponse {
9405        type Owned = Self;
9406
9407        #[inline(always)]
9408        fn inline_align(_context: fidl::encoding::Context) -> usize {
9409            8
9410        }
9411
9412        #[inline(always)]
9413        fn inline_size(_context: fidl::encoding::Context) -> usize {
9414            16
9415        }
9416    }
9417
9418    unsafe impl
9419        fidl::encoding::Encode<
9420            ControlCreatePacketStreamResponse,
9421            fidl::encoding::DefaultFuchsiaResourceDialect,
9422        > for &mut ControlCreatePacketStreamResponse
9423    {
9424        unsafe fn encode(
9425            self,
9426            encoder: &mut fidl::encoding::Encoder<
9427                '_,
9428                fidl::encoding::DefaultFuchsiaResourceDialect,
9429            >,
9430            offset: usize,
9431            mut depth: fidl::encoding::Depth,
9432        ) -> fidl::Result<()> {
9433            encoder.debug_check_bounds::<ControlCreatePacketStreamResponse>(offset);
9434            // Vector header
9435            let max_ordinal: u64 = self.max_ordinal_present();
9436            encoder.write_num(max_ordinal, offset);
9437            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9438            // Calling encoder.out_of_line_offset(0) is not allowed.
9439            if max_ordinal == 0 {
9440                return Ok(());
9441            }
9442            depth.increment()?;
9443            let envelope_size = 8;
9444            let bytes_len = max_ordinal as usize * envelope_size;
9445            #[allow(unused_variables)]
9446            let offset = encoder.out_of_line_offset(bytes_len);
9447            let mut _prev_end_offset: usize = 0;
9448            if 1 > max_ordinal {
9449                return Ok(());
9450            }
9451
9452            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9453            // are envelope_size bytes.
9454            let cur_offset: usize = (1 - 1) * envelope_size;
9455
9456            // Zero reserved fields.
9457            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9458
9459            // Safety:
9460            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9461            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9462            //   envelope_size bytes, there is always sufficient room.
9463            fidl::encoding::encode_in_envelope_optional::<
9464                PacketStreamProperties,
9465                fidl::encoding::DefaultFuchsiaResourceDialect,
9466            >(
9467                self.properties.as_mut().map(
9468                    <PacketStreamProperties as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
9469                ),
9470                encoder,
9471                offset + cur_offset,
9472                depth,
9473            )?;
9474
9475            _prev_end_offset = cur_offset + envelope_size;
9476
9477            Ok(())
9478        }
9479    }
9480
9481    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9482        for ControlCreatePacketStreamResponse
9483    {
9484        #[inline(always)]
9485        fn new_empty() -> Self {
9486            Self::default()
9487        }
9488
9489        unsafe fn decode(
9490            &mut self,
9491            decoder: &mut fidl::encoding::Decoder<
9492                '_,
9493                fidl::encoding::DefaultFuchsiaResourceDialect,
9494            >,
9495            offset: usize,
9496            mut depth: fidl::encoding::Depth,
9497        ) -> fidl::Result<()> {
9498            decoder.debug_check_bounds::<Self>(offset);
9499            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9500                None => return Err(fidl::Error::NotNullable),
9501                Some(len) => len,
9502            };
9503            // Calling decoder.out_of_line_offset(0) is not allowed.
9504            if len == 0 {
9505                return Ok(());
9506            };
9507            depth.increment()?;
9508            let envelope_size = 8;
9509            let bytes_len = len * envelope_size;
9510            let offset = decoder.out_of_line_offset(bytes_len)?;
9511            // Decode the envelope for each type.
9512            let mut _next_ordinal_to_read = 0;
9513            let mut next_offset = offset;
9514            let end_offset = offset + bytes_len;
9515            _next_ordinal_to_read += 1;
9516            if next_offset >= end_offset {
9517                return Ok(());
9518            }
9519
9520            // Decode unknown envelopes for gaps in ordinals.
9521            while _next_ordinal_to_read < 1 {
9522                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9523                _next_ordinal_to_read += 1;
9524                next_offset += envelope_size;
9525            }
9526
9527            let next_out_of_line = decoder.next_out_of_line();
9528            let handles_before = decoder.remaining_handles();
9529            if let Some((inlined, num_bytes, num_handles)) =
9530                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9531            {
9532                let member_inline_size =
9533                    <PacketStreamProperties as fidl::encoding::TypeMarker>::inline_size(
9534                        decoder.context,
9535                    );
9536                if inlined != (member_inline_size <= 4) {
9537                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9538                }
9539                let inner_offset;
9540                let mut inner_depth = depth.clone();
9541                if inlined {
9542                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9543                    inner_offset = next_offset;
9544                } else {
9545                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9546                    inner_depth.increment()?;
9547                }
9548                let val_ref = self.properties.get_or_insert_with(|| {
9549                    fidl::new_empty!(
9550                        PacketStreamProperties,
9551                        fidl::encoding::DefaultFuchsiaResourceDialect
9552                    )
9553                });
9554                fidl::decode!(
9555                    PacketStreamProperties,
9556                    fidl::encoding::DefaultFuchsiaResourceDialect,
9557                    val_ref,
9558                    decoder,
9559                    inner_offset,
9560                    inner_depth
9561                )?;
9562                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9563                {
9564                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9565                }
9566                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9567                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9568                }
9569            }
9570
9571            next_offset += envelope_size;
9572
9573            // Decode the remaining unknown envelopes.
9574            while next_offset < end_offset {
9575                _next_ordinal_to_read += 1;
9576                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9577                next_offset += envelope_size;
9578            }
9579
9580            Ok(())
9581        }
9582    }
9583
9584    impl ControlCreateRingBufferResponse {
9585        #[inline(always)]
9586        fn max_ordinal_present(&self) -> u64 {
9587            if let Some(_) = self.ring_buffer {
9588                return 2;
9589            }
9590            if let Some(_) = self.properties {
9591                return 1;
9592            }
9593            0
9594        }
9595    }
9596
9597    impl fidl::encoding::ResourceTypeMarker for ControlCreateRingBufferResponse {
9598        type Borrowed<'a> = &'a mut Self;
9599        fn take_or_borrow<'a>(
9600            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9601        ) -> Self::Borrowed<'a> {
9602            value
9603        }
9604    }
9605
9606    unsafe impl fidl::encoding::TypeMarker for ControlCreateRingBufferResponse {
9607        type Owned = Self;
9608
9609        #[inline(always)]
9610        fn inline_align(_context: fidl::encoding::Context) -> usize {
9611            8
9612        }
9613
9614        #[inline(always)]
9615        fn inline_size(_context: fidl::encoding::Context) -> usize {
9616            16
9617        }
9618    }
9619
9620    unsafe impl
9621        fidl::encoding::Encode<
9622            ControlCreateRingBufferResponse,
9623            fidl::encoding::DefaultFuchsiaResourceDialect,
9624        > for &mut ControlCreateRingBufferResponse
9625    {
9626        unsafe fn encode(
9627            self,
9628            encoder: &mut fidl::encoding::Encoder<
9629                '_,
9630                fidl::encoding::DefaultFuchsiaResourceDialect,
9631            >,
9632            offset: usize,
9633            mut depth: fidl::encoding::Depth,
9634        ) -> fidl::Result<()> {
9635            encoder.debug_check_bounds::<ControlCreateRingBufferResponse>(offset);
9636            // Vector header
9637            let max_ordinal: u64 = self.max_ordinal_present();
9638            encoder.write_num(max_ordinal, offset);
9639            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9640            // Calling encoder.out_of_line_offset(0) is not allowed.
9641            if max_ordinal == 0 {
9642                return Ok(());
9643            }
9644            depth.increment()?;
9645            let envelope_size = 8;
9646            let bytes_len = max_ordinal as usize * envelope_size;
9647            #[allow(unused_variables)]
9648            let offset = encoder.out_of_line_offset(bytes_len);
9649            let mut _prev_end_offset: usize = 0;
9650            if 1 > max_ordinal {
9651                return Ok(());
9652            }
9653
9654            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9655            // are envelope_size bytes.
9656            let cur_offset: usize = (1 - 1) * envelope_size;
9657
9658            // Zero reserved fields.
9659            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9660
9661            // Safety:
9662            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9663            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9664            //   envelope_size bytes, there is always sufficient room.
9665            fidl::encoding::encode_in_envelope_optional::<
9666                RingBufferProperties,
9667                fidl::encoding::DefaultFuchsiaResourceDialect,
9668            >(
9669                self.properties
9670                    .as_ref()
9671                    .map(<RingBufferProperties as fidl::encoding::ValueTypeMarker>::borrow),
9672                encoder,
9673                offset + cur_offset,
9674                depth,
9675            )?;
9676
9677            _prev_end_offset = cur_offset + envelope_size;
9678            if 2 > max_ordinal {
9679                return Ok(());
9680            }
9681
9682            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9683            // are envelope_size bytes.
9684            let cur_offset: usize = (2 - 1) * envelope_size;
9685
9686            // Zero reserved fields.
9687            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9688
9689            // Safety:
9690            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9691            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9692            //   envelope_size bytes, there is always sufficient room.
9693            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_audio::RingBuffer, fidl::encoding::DefaultFuchsiaResourceDialect>(
9694            self.ring_buffer.as_mut().map(<fidl_fuchsia_audio::RingBuffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
9695            encoder, offset + cur_offset, depth
9696        )?;
9697
9698            _prev_end_offset = cur_offset + envelope_size;
9699
9700            Ok(())
9701        }
9702    }
9703
9704    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9705        for ControlCreateRingBufferResponse
9706    {
9707        #[inline(always)]
9708        fn new_empty() -> Self {
9709            Self::default()
9710        }
9711
9712        unsafe fn decode(
9713            &mut self,
9714            decoder: &mut fidl::encoding::Decoder<
9715                '_,
9716                fidl::encoding::DefaultFuchsiaResourceDialect,
9717            >,
9718            offset: usize,
9719            mut depth: fidl::encoding::Depth,
9720        ) -> fidl::Result<()> {
9721            decoder.debug_check_bounds::<Self>(offset);
9722            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9723                None => return Err(fidl::Error::NotNullable),
9724                Some(len) => len,
9725            };
9726            // Calling decoder.out_of_line_offset(0) is not allowed.
9727            if len == 0 {
9728                return Ok(());
9729            };
9730            depth.increment()?;
9731            let envelope_size = 8;
9732            let bytes_len = len * envelope_size;
9733            let offset = decoder.out_of_line_offset(bytes_len)?;
9734            // Decode the envelope for each type.
9735            let mut _next_ordinal_to_read = 0;
9736            let mut next_offset = offset;
9737            let end_offset = offset + bytes_len;
9738            _next_ordinal_to_read += 1;
9739            if next_offset >= end_offset {
9740                return Ok(());
9741            }
9742
9743            // Decode unknown envelopes for gaps in ordinals.
9744            while _next_ordinal_to_read < 1 {
9745                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9746                _next_ordinal_to_read += 1;
9747                next_offset += envelope_size;
9748            }
9749
9750            let next_out_of_line = decoder.next_out_of_line();
9751            let handles_before = decoder.remaining_handles();
9752            if let Some((inlined, num_bytes, num_handles)) =
9753                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9754            {
9755                let member_inline_size =
9756                    <RingBufferProperties as fidl::encoding::TypeMarker>::inline_size(
9757                        decoder.context,
9758                    );
9759                if inlined != (member_inline_size <= 4) {
9760                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9761                }
9762                let inner_offset;
9763                let mut inner_depth = depth.clone();
9764                if inlined {
9765                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9766                    inner_offset = next_offset;
9767                } else {
9768                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9769                    inner_depth.increment()?;
9770                }
9771                let val_ref = self.properties.get_or_insert_with(|| {
9772                    fidl::new_empty!(
9773                        RingBufferProperties,
9774                        fidl::encoding::DefaultFuchsiaResourceDialect
9775                    )
9776                });
9777                fidl::decode!(
9778                    RingBufferProperties,
9779                    fidl::encoding::DefaultFuchsiaResourceDialect,
9780                    val_ref,
9781                    decoder,
9782                    inner_offset,
9783                    inner_depth
9784                )?;
9785                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9786                {
9787                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9788                }
9789                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9790                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9791                }
9792            }
9793
9794            next_offset += envelope_size;
9795            _next_ordinal_to_read += 1;
9796            if next_offset >= end_offset {
9797                return Ok(());
9798            }
9799
9800            // Decode unknown envelopes for gaps in ordinals.
9801            while _next_ordinal_to_read < 2 {
9802                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9803                _next_ordinal_to_read += 1;
9804                next_offset += envelope_size;
9805            }
9806
9807            let next_out_of_line = decoder.next_out_of_line();
9808            let handles_before = decoder.remaining_handles();
9809            if let Some((inlined, num_bytes, num_handles)) =
9810                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9811            {
9812                let member_inline_size =
9813                    <fidl_fuchsia_audio::RingBuffer as fidl::encoding::TypeMarker>::inline_size(
9814                        decoder.context,
9815                    );
9816                if inlined != (member_inline_size <= 4) {
9817                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9818                }
9819                let inner_offset;
9820                let mut inner_depth = depth.clone();
9821                if inlined {
9822                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9823                    inner_offset = next_offset;
9824                } else {
9825                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9826                    inner_depth.increment()?;
9827                }
9828                let val_ref = self.ring_buffer.get_or_insert_with(|| {
9829                    fidl::new_empty!(
9830                        fidl_fuchsia_audio::RingBuffer,
9831                        fidl::encoding::DefaultFuchsiaResourceDialect
9832                    )
9833                });
9834                fidl::decode!(
9835                    fidl_fuchsia_audio::RingBuffer,
9836                    fidl::encoding::DefaultFuchsiaResourceDialect,
9837                    val_ref,
9838                    decoder,
9839                    inner_offset,
9840                    inner_depth
9841                )?;
9842                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9843                {
9844                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9845                }
9846                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9847                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9848                }
9849            }
9850
9851            next_offset += envelope_size;
9852
9853            // Decode the remaining unknown envelopes.
9854            while next_offset < end_offset {
9855                _next_ordinal_to_read += 1;
9856                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9857                next_offset += envelope_size;
9858            }
9859
9860            Ok(())
9861        }
9862    }
9863
9864    impl ObserverGetReferenceClockResponse {
9865        #[inline(always)]
9866        fn max_ordinal_present(&self) -> u64 {
9867            if let Some(_) = self.reference_clock {
9868                return 1;
9869            }
9870            0
9871        }
9872    }
9873
9874    impl fidl::encoding::ResourceTypeMarker for ObserverGetReferenceClockResponse {
9875        type Borrowed<'a> = &'a mut Self;
9876        fn take_or_borrow<'a>(
9877            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9878        ) -> Self::Borrowed<'a> {
9879            value
9880        }
9881    }
9882
9883    unsafe impl fidl::encoding::TypeMarker for ObserverGetReferenceClockResponse {
9884        type Owned = Self;
9885
9886        #[inline(always)]
9887        fn inline_align(_context: fidl::encoding::Context) -> usize {
9888            8
9889        }
9890
9891        #[inline(always)]
9892        fn inline_size(_context: fidl::encoding::Context) -> usize {
9893            16
9894        }
9895    }
9896
9897    unsafe impl
9898        fidl::encoding::Encode<
9899            ObserverGetReferenceClockResponse,
9900            fidl::encoding::DefaultFuchsiaResourceDialect,
9901        > for &mut ObserverGetReferenceClockResponse
9902    {
9903        unsafe fn encode(
9904            self,
9905            encoder: &mut fidl::encoding::Encoder<
9906                '_,
9907                fidl::encoding::DefaultFuchsiaResourceDialect,
9908            >,
9909            offset: usize,
9910            mut depth: fidl::encoding::Depth,
9911        ) -> fidl::Result<()> {
9912            encoder.debug_check_bounds::<ObserverGetReferenceClockResponse>(offset);
9913            // Vector header
9914            let max_ordinal: u64 = self.max_ordinal_present();
9915            encoder.write_num(max_ordinal, offset);
9916            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9917            // Calling encoder.out_of_line_offset(0) is not allowed.
9918            if max_ordinal == 0 {
9919                return Ok(());
9920            }
9921            depth.increment()?;
9922            let envelope_size = 8;
9923            let bytes_len = max_ordinal as usize * envelope_size;
9924            #[allow(unused_variables)]
9925            let offset = encoder.out_of_line_offset(bytes_len);
9926            let mut _prev_end_offset: usize = 0;
9927            if 1 > max_ordinal {
9928                return Ok(());
9929            }
9930
9931            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9932            // are envelope_size bytes.
9933            let cur_offset: usize = (1 - 1) * envelope_size;
9934
9935            // Zero reserved fields.
9936            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9937
9938            // Safety:
9939            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9940            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9941            //   envelope_size bytes, there is always sufficient room.
9942            fidl::encoding::encode_in_envelope_optional::<
9943                fidl::encoding::HandleType<
9944                    fidl::Clock,
9945                    { fidl::ObjectType::CLOCK.into_raw() },
9946                    2147483648,
9947                >,
9948                fidl::encoding::DefaultFuchsiaResourceDialect,
9949            >(
9950                self.reference_clock.as_mut().map(
9951                    <fidl::encoding::HandleType<
9952                        fidl::Clock,
9953                        { fidl::ObjectType::CLOCK.into_raw() },
9954                        2147483648,
9955                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
9956                ),
9957                encoder,
9958                offset + cur_offset,
9959                depth,
9960            )?;
9961
9962            _prev_end_offset = cur_offset + envelope_size;
9963
9964            Ok(())
9965        }
9966    }
9967
9968    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9969        for ObserverGetReferenceClockResponse
9970    {
9971        #[inline(always)]
9972        fn new_empty() -> Self {
9973            Self::default()
9974        }
9975
9976        unsafe fn decode(
9977            &mut self,
9978            decoder: &mut fidl::encoding::Decoder<
9979                '_,
9980                fidl::encoding::DefaultFuchsiaResourceDialect,
9981            >,
9982            offset: usize,
9983            mut depth: fidl::encoding::Depth,
9984        ) -> fidl::Result<()> {
9985            decoder.debug_check_bounds::<Self>(offset);
9986            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9987                None => return Err(fidl::Error::NotNullable),
9988                Some(len) => len,
9989            };
9990            // Calling decoder.out_of_line_offset(0) is not allowed.
9991            if len == 0 {
9992                return Ok(());
9993            };
9994            depth.increment()?;
9995            let envelope_size = 8;
9996            let bytes_len = len * envelope_size;
9997            let offset = decoder.out_of_line_offset(bytes_len)?;
9998            // Decode the envelope for each type.
9999            let mut _next_ordinal_to_read = 0;
10000            let mut next_offset = offset;
10001            let end_offset = offset + bytes_len;
10002            _next_ordinal_to_read += 1;
10003            if next_offset >= end_offset {
10004                return Ok(());
10005            }
10006
10007            // Decode unknown envelopes for gaps in ordinals.
10008            while _next_ordinal_to_read < 1 {
10009                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10010                _next_ordinal_to_read += 1;
10011                next_offset += envelope_size;
10012            }
10013
10014            let next_out_of_line = decoder.next_out_of_line();
10015            let handles_before = decoder.remaining_handles();
10016            if let Some((inlined, num_bytes, num_handles)) =
10017                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10018            {
10019                let member_inline_size = <fidl::encoding::HandleType<
10020                    fidl::Clock,
10021                    { fidl::ObjectType::CLOCK.into_raw() },
10022                    2147483648,
10023                > as fidl::encoding::TypeMarker>::inline_size(
10024                    decoder.context
10025                );
10026                if inlined != (member_inline_size <= 4) {
10027                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10028                }
10029                let inner_offset;
10030                let mut inner_depth = depth.clone();
10031                if inlined {
10032                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10033                    inner_offset = next_offset;
10034                } else {
10035                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10036                    inner_depth.increment()?;
10037                }
10038                let val_ref =
10039                self.reference_clock.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
10040                fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
10041                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10042                {
10043                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10044                }
10045                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10046                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10047                }
10048            }
10049
10050            next_offset += envelope_size;
10051
10052            // Decode the remaining unknown envelopes.
10053            while next_offset < end_offset {
10054                _next_ordinal_to_read += 1;
10055                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10056                next_offset += envelope_size;
10057            }
10058
10059            Ok(())
10060        }
10061    }
10062
10063    impl PacketStreamBuffers {
10064        #[inline(always)]
10065        fn max_ordinal_present(&self) -> u64 {
10066            if let Some(_) = self.vmo_infos {
10067                return 1;
10068            }
10069            0
10070        }
10071    }
10072
10073    impl fidl::encoding::ResourceTypeMarker for PacketStreamBuffers {
10074        type Borrowed<'a> = &'a mut Self;
10075        fn take_or_borrow<'a>(
10076            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10077        ) -> Self::Borrowed<'a> {
10078            value
10079        }
10080    }
10081
10082    unsafe impl fidl::encoding::TypeMarker for PacketStreamBuffers {
10083        type Owned = Self;
10084
10085        #[inline(always)]
10086        fn inline_align(_context: fidl::encoding::Context) -> usize {
10087            8
10088        }
10089
10090        #[inline(always)]
10091        fn inline_size(_context: fidl::encoding::Context) -> usize {
10092            16
10093        }
10094    }
10095
10096    unsafe impl
10097        fidl::encoding::Encode<PacketStreamBuffers, fidl::encoding::DefaultFuchsiaResourceDialect>
10098        for &mut PacketStreamBuffers
10099    {
10100        unsafe fn encode(
10101            self,
10102            encoder: &mut fidl::encoding::Encoder<
10103                '_,
10104                fidl::encoding::DefaultFuchsiaResourceDialect,
10105            >,
10106            offset: usize,
10107            mut depth: fidl::encoding::Depth,
10108        ) -> fidl::Result<()> {
10109            encoder.debug_check_bounds::<PacketStreamBuffers>(offset);
10110            // Vector header
10111            let max_ordinal: u64 = self.max_ordinal_present();
10112            encoder.write_num(max_ordinal, offset);
10113            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10114            // Calling encoder.out_of_line_offset(0) is not allowed.
10115            if max_ordinal == 0 {
10116                return Ok(());
10117            }
10118            depth.increment()?;
10119            let envelope_size = 8;
10120            let bytes_len = max_ordinal as usize * envelope_size;
10121            #[allow(unused_variables)]
10122            let offset = encoder.out_of_line_offset(bytes_len);
10123            let mut _prev_end_offset: usize = 0;
10124            if 1 > max_ordinal {
10125                return Ok(());
10126            }
10127
10128            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10129            // are envelope_size bytes.
10130            let cur_offset: usize = (1 - 1) * envelope_size;
10131
10132            // Zero reserved fields.
10133            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10134
10135            // Safety:
10136            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10137            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10138            //   envelope_size bytes, there is always sufficient room.
10139            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl_fuchsia_hardware_audio::VmoInfo, 256>, fidl::encoding::DefaultFuchsiaResourceDialect>(
10140            self.vmo_infos.as_mut().map(<fidl::encoding::Vector<fidl_fuchsia_hardware_audio::VmoInfo, 256> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
10141            encoder, offset + cur_offset, depth
10142        )?;
10143
10144            _prev_end_offset = cur_offset + envelope_size;
10145
10146            Ok(())
10147        }
10148    }
10149
10150    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10151        for PacketStreamBuffers
10152    {
10153        #[inline(always)]
10154        fn new_empty() -> Self {
10155            Self::default()
10156        }
10157
10158        unsafe fn decode(
10159            &mut self,
10160            decoder: &mut fidl::encoding::Decoder<
10161                '_,
10162                fidl::encoding::DefaultFuchsiaResourceDialect,
10163            >,
10164            offset: usize,
10165            mut depth: fidl::encoding::Depth,
10166        ) -> fidl::Result<()> {
10167            decoder.debug_check_bounds::<Self>(offset);
10168            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10169                None => return Err(fidl::Error::NotNullable),
10170                Some(len) => len,
10171            };
10172            // Calling decoder.out_of_line_offset(0) is not allowed.
10173            if len == 0 {
10174                return Ok(());
10175            };
10176            depth.increment()?;
10177            let envelope_size = 8;
10178            let bytes_len = len * envelope_size;
10179            let offset = decoder.out_of_line_offset(bytes_len)?;
10180            // Decode the envelope for each type.
10181            let mut _next_ordinal_to_read = 0;
10182            let mut next_offset = offset;
10183            let end_offset = offset + bytes_len;
10184            _next_ordinal_to_read += 1;
10185            if next_offset >= end_offset {
10186                return Ok(());
10187            }
10188
10189            // Decode unknown envelopes for gaps in ordinals.
10190            while _next_ordinal_to_read < 1 {
10191                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10192                _next_ordinal_to_read += 1;
10193                next_offset += envelope_size;
10194            }
10195
10196            let next_out_of_line = decoder.next_out_of_line();
10197            let handles_before = decoder.remaining_handles();
10198            if let Some((inlined, num_bytes, num_handles)) =
10199                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10200            {
10201                let member_inline_size = <fidl::encoding::Vector<
10202                    fidl_fuchsia_hardware_audio::VmoInfo,
10203                    256,
10204                > as fidl::encoding::TypeMarker>::inline_size(
10205                    decoder.context
10206                );
10207                if inlined != (member_inline_size <= 4) {
10208                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10209                }
10210                let inner_offset;
10211                let mut inner_depth = depth.clone();
10212                if inlined {
10213                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10214                    inner_offset = next_offset;
10215                } else {
10216                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10217                    inner_depth.increment()?;
10218                }
10219                let val_ref =
10220                self.vmo_infos.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_hardware_audio::VmoInfo, 256>, fidl::encoding::DefaultFuchsiaResourceDialect));
10221                fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_hardware_audio::VmoInfo, 256>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
10222                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10223                {
10224                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10225                }
10226                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10227                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10228                }
10229            }
10230
10231            next_offset += envelope_size;
10232
10233            // Decode the remaining unknown envelopes.
10234            while next_offset < end_offset {
10235                _next_ordinal_to_read += 1;
10236                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10237                next_offset += envelope_size;
10238            }
10239
10240            Ok(())
10241        }
10242    }
10243
10244    impl PacketStreamOptions {
10245        #[inline(always)]
10246        fn max_ordinal_present(&self) -> u64 {
10247            if let Some(_) = self.format {
10248                return 1;
10249            }
10250            0
10251        }
10252    }
10253
10254    impl fidl::encoding::ResourceTypeMarker for PacketStreamOptions {
10255        type Borrowed<'a> = &'a mut Self;
10256        fn take_or_borrow<'a>(
10257            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10258        ) -> Self::Borrowed<'a> {
10259            value
10260        }
10261    }
10262
10263    unsafe impl fidl::encoding::TypeMarker for PacketStreamOptions {
10264        type Owned = Self;
10265
10266        #[inline(always)]
10267        fn inline_align(_context: fidl::encoding::Context) -> usize {
10268            8
10269        }
10270
10271        #[inline(always)]
10272        fn inline_size(_context: fidl::encoding::Context) -> usize {
10273            16
10274        }
10275    }
10276
10277    unsafe impl
10278        fidl::encoding::Encode<PacketStreamOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
10279        for &mut PacketStreamOptions
10280    {
10281        unsafe fn encode(
10282            self,
10283            encoder: &mut fidl::encoding::Encoder<
10284                '_,
10285                fidl::encoding::DefaultFuchsiaResourceDialect,
10286            >,
10287            offset: usize,
10288            mut depth: fidl::encoding::Depth,
10289        ) -> fidl::Result<()> {
10290            encoder.debug_check_bounds::<PacketStreamOptions>(offset);
10291            // Vector header
10292            let max_ordinal: u64 = self.max_ordinal_present();
10293            encoder.write_num(max_ordinal, offset);
10294            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10295            // Calling encoder.out_of_line_offset(0) is not allowed.
10296            if max_ordinal == 0 {
10297                return Ok(());
10298            }
10299            depth.increment()?;
10300            let envelope_size = 8;
10301            let bytes_len = max_ordinal as usize * envelope_size;
10302            #[allow(unused_variables)]
10303            let offset = encoder.out_of_line_offset(bytes_len);
10304            let mut _prev_end_offset: usize = 0;
10305            if 1 > max_ordinal {
10306                return Ok(());
10307            }
10308
10309            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10310            // are envelope_size bytes.
10311            let cur_offset: usize = (1 - 1) * envelope_size;
10312
10313            // Zero reserved fields.
10314            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10315
10316            // Safety:
10317            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10318            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10319            //   envelope_size bytes, there is always sufficient room.
10320            fidl::encoding::encode_in_envelope_optional::<
10321                PacketStreamFormat,
10322                fidl::encoding::DefaultFuchsiaResourceDialect,
10323            >(
10324                self.format
10325                    .as_ref()
10326                    .map(<PacketStreamFormat as fidl::encoding::ValueTypeMarker>::borrow),
10327                encoder,
10328                offset + cur_offset,
10329                depth,
10330            )?;
10331
10332            _prev_end_offset = cur_offset + envelope_size;
10333
10334            Ok(())
10335        }
10336    }
10337
10338    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10339        for PacketStreamOptions
10340    {
10341        #[inline(always)]
10342        fn new_empty() -> Self {
10343            Self::default()
10344        }
10345
10346        unsafe fn decode(
10347            &mut self,
10348            decoder: &mut fidl::encoding::Decoder<
10349                '_,
10350                fidl::encoding::DefaultFuchsiaResourceDialect,
10351            >,
10352            offset: usize,
10353            mut depth: fidl::encoding::Depth,
10354        ) -> fidl::Result<()> {
10355            decoder.debug_check_bounds::<Self>(offset);
10356            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10357                None => return Err(fidl::Error::NotNullable),
10358                Some(len) => len,
10359            };
10360            // Calling decoder.out_of_line_offset(0) is not allowed.
10361            if len == 0 {
10362                return Ok(());
10363            };
10364            depth.increment()?;
10365            let envelope_size = 8;
10366            let bytes_len = len * envelope_size;
10367            let offset = decoder.out_of_line_offset(bytes_len)?;
10368            // Decode the envelope for each type.
10369            let mut _next_ordinal_to_read = 0;
10370            let mut next_offset = offset;
10371            let end_offset = offset + bytes_len;
10372            _next_ordinal_to_read += 1;
10373            if next_offset >= end_offset {
10374                return Ok(());
10375            }
10376
10377            // Decode unknown envelopes for gaps in ordinals.
10378            while _next_ordinal_to_read < 1 {
10379                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10380                _next_ordinal_to_read += 1;
10381                next_offset += envelope_size;
10382            }
10383
10384            let next_out_of_line = decoder.next_out_of_line();
10385            let handles_before = decoder.remaining_handles();
10386            if let Some((inlined, num_bytes, num_handles)) =
10387                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10388            {
10389                let member_inline_size =
10390                    <PacketStreamFormat as fidl::encoding::TypeMarker>::inline_size(
10391                        decoder.context,
10392                    );
10393                if inlined != (member_inline_size <= 4) {
10394                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10395                }
10396                let inner_offset;
10397                let mut inner_depth = depth.clone();
10398                if inlined {
10399                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10400                    inner_offset = next_offset;
10401                } else {
10402                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10403                    inner_depth.increment()?;
10404                }
10405                let val_ref = self.format.get_or_insert_with(|| {
10406                    fidl::new_empty!(
10407                        PacketStreamFormat,
10408                        fidl::encoding::DefaultFuchsiaResourceDialect
10409                    )
10410                });
10411                fidl::decode!(
10412                    PacketStreamFormat,
10413                    fidl::encoding::DefaultFuchsiaResourceDialect,
10414                    val_ref,
10415                    decoder,
10416                    inner_offset,
10417                    inner_depth
10418                )?;
10419                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10420                {
10421                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10422                }
10423                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10424                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10425                }
10426            }
10427
10428            next_offset += envelope_size;
10429
10430            // Decode the remaining unknown envelopes.
10431            while next_offset < end_offset {
10432                _next_ordinal_to_read += 1;
10433                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10434                next_offset += envelope_size;
10435            }
10436
10437            Ok(())
10438        }
10439    }
10440
10441    impl PacketStreamProperties {
10442        #[inline(always)]
10443        fn max_ordinal_present(&self) -> u64 {
10444            if let Some(_) = self.supported_buffer_types {
10445                return 4;
10446            }
10447            if let Some(_) = self.valid_bits_per_sample {
10448                return 3;
10449            }
10450            if let Some(_) = self.format {
10451                return 2;
10452            }
10453            if let Some(_) = self.data_sink {
10454                return 1;
10455            }
10456            0
10457        }
10458    }
10459
10460    impl fidl::encoding::ResourceTypeMarker for PacketStreamProperties {
10461        type Borrowed<'a> = &'a mut Self;
10462        fn take_or_borrow<'a>(
10463            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10464        ) -> Self::Borrowed<'a> {
10465            value
10466        }
10467    }
10468
10469    unsafe impl fidl::encoding::TypeMarker for PacketStreamProperties {
10470        type Owned = Self;
10471
10472        #[inline(always)]
10473        fn inline_align(_context: fidl::encoding::Context) -> usize {
10474            8
10475        }
10476
10477        #[inline(always)]
10478        fn inline_size(_context: fidl::encoding::Context) -> usize {
10479            16
10480        }
10481    }
10482
10483    unsafe impl
10484        fidl::encoding::Encode<
10485            PacketStreamProperties,
10486            fidl::encoding::DefaultFuchsiaResourceDialect,
10487        > for &mut PacketStreamProperties
10488    {
10489        unsafe fn encode(
10490            self,
10491            encoder: &mut fidl::encoding::Encoder<
10492                '_,
10493                fidl::encoding::DefaultFuchsiaResourceDialect,
10494            >,
10495            offset: usize,
10496            mut depth: fidl::encoding::Depth,
10497        ) -> fidl::Result<()> {
10498            encoder.debug_check_bounds::<PacketStreamProperties>(offset);
10499            // Vector header
10500            let max_ordinal: u64 = self.max_ordinal_present();
10501            encoder.write_num(max_ordinal, offset);
10502            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10503            // Calling encoder.out_of_line_offset(0) is not allowed.
10504            if max_ordinal == 0 {
10505                return Ok(());
10506            }
10507            depth.increment()?;
10508            let envelope_size = 8;
10509            let bytes_len = max_ordinal as usize * envelope_size;
10510            #[allow(unused_variables)]
10511            let offset = encoder.out_of_line_offset(bytes_len);
10512            let mut _prev_end_offset: usize = 0;
10513            if 1 > max_ordinal {
10514                return Ok(());
10515            }
10516
10517            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10518            // are envelope_size bytes.
10519            let cur_offset: usize = (1 - 1) * envelope_size;
10520
10521            // Zero reserved fields.
10522            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10523
10524            // Safety:
10525            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10526            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10527            //   envelope_size bytes, there is always sufficient room.
10528            fidl::encoding::encode_in_envelope_optional::<
10529                fidl::encoding::Endpoint<
10530                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::PacketStreamSinkMarker>,
10531                >,
10532                fidl::encoding::DefaultFuchsiaResourceDialect,
10533            >(
10534                self.data_sink.as_mut().map(
10535                    <fidl::encoding::Endpoint<
10536                        fidl::endpoints::ClientEnd<
10537                            fidl_fuchsia_hardware_audio::PacketStreamSinkMarker,
10538                        >,
10539                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
10540                ),
10541                encoder,
10542                offset + cur_offset,
10543                depth,
10544            )?;
10545
10546            _prev_end_offset = cur_offset + envelope_size;
10547            if 2 > max_ordinal {
10548                return Ok(());
10549            }
10550
10551            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10552            // are envelope_size bytes.
10553            let cur_offset: usize = (2 - 1) * envelope_size;
10554
10555            // Zero reserved fields.
10556            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10557
10558            // Safety:
10559            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10560            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10561            //   envelope_size bytes, there is always sufficient room.
10562            fidl::encoding::encode_in_envelope_optional::<
10563                PacketStreamFormat,
10564                fidl::encoding::DefaultFuchsiaResourceDialect,
10565            >(
10566                self.format
10567                    .as_ref()
10568                    .map(<PacketStreamFormat as fidl::encoding::ValueTypeMarker>::borrow),
10569                encoder,
10570                offset + cur_offset,
10571                depth,
10572            )?;
10573
10574            _prev_end_offset = cur_offset + envelope_size;
10575            if 3 > max_ordinal {
10576                return Ok(());
10577            }
10578
10579            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10580            // are envelope_size bytes.
10581            let cur_offset: usize = (3 - 1) * envelope_size;
10582
10583            // Zero reserved fields.
10584            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10585
10586            // Safety:
10587            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10588            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10589            //   envelope_size bytes, there is always sufficient room.
10590            fidl::encoding::encode_in_envelope_optional::<
10591                u8,
10592                fidl::encoding::DefaultFuchsiaResourceDialect,
10593            >(
10594                self.valid_bits_per_sample
10595                    .as_ref()
10596                    .map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
10597                encoder,
10598                offset + cur_offset,
10599                depth,
10600            )?;
10601
10602            _prev_end_offset = cur_offset + envelope_size;
10603            if 4 > max_ordinal {
10604                return Ok(());
10605            }
10606
10607            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10608            // are envelope_size bytes.
10609            let cur_offset: usize = (4 - 1) * envelope_size;
10610
10611            // Zero reserved fields.
10612            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10613
10614            // Safety:
10615            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10616            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10617            //   envelope_size bytes, there is always sufficient room.
10618            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_hardware_audio::BufferType, fidl::encoding::DefaultFuchsiaResourceDialect>(
10619            self.supported_buffer_types.as_ref().map(<fidl_fuchsia_hardware_audio::BufferType as fidl::encoding::ValueTypeMarker>::borrow),
10620            encoder, offset + cur_offset, depth
10621        )?;
10622
10623            _prev_end_offset = cur_offset + envelope_size;
10624
10625            Ok(())
10626        }
10627    }
10628
10629    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10630        for PacketStreamProperties
10631    {
10632        #[inline(always)]
10633        fn new_empty() -> Self {
10634            Self::default()
10635        }
10636
10637        unsafe fn decode(
10638            &mut self,
10639            decoder: &mut fidl::encoding::Decoder<
10640                '_,
10641                fidl::encoding::DefaultFuchsiaResourceDialect,
10642            >,
10643            offset: usize,
10644            mut depth: fidl::encoding::Depth,
10645        ) -> fidl::Result<()> {
10646            decoder.debug_check_bounds::<Self>(offset);
10647            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10648                None => return Err(fidl::Error::NotNullable),
10649                Some(len) => len,
10650            };
10651            // Calling decoder.out_of_line_offset(0) is not allowed.
10652            if len == 0 {
10653                return Ok(());
10654            };
10655            depth.increment()?;
10656            let envelope_size = 8;
10657            let bytes_len = len * envelope_size;
10658            let offset = decoder.out_of_line_offset(bytes_len)?;
10659            // Decode the envelope for each type.
10660            let mut _next_ordinal_to_read = 0;
10661            let mut next_offset = offset;
10662            let end_offset = offset + bytes_len;
10663            _next_ordinal_to_read += 1;
10664            if next_offset >= end_offset {
10665                return Ok(());
10666            }
10667
10668            // Decode unknown envelopes for gaps in ordinals.
10669            while _next_ordinal_to_read < 1 {
10670                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10671                _next_ordinal_to_read += 1;
10672                next_offset += envelope_size;
10673            }
10674
10675            let next_out_of_line = decoder.next_out_of_line();
10676            let handles_before = decoder.remaining_handles();
10677            if let Some((inlined, num_bytes, num_handles)) =
10678                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10679            {
10680                let member_inline_size = <fidl::encoding::Endpoint<
10681                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::PacketStreamSinkMarker>,
10682                > as fidl::encoding::TypeMarker>::inline_size(
10683                    decoder.context
10684                );
10685                if inlined != (member_inline_size <= 4) {
10686                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10687                }
10688                let inner_offset;
10689                let mut inner_depth = depth.clone();
10690                if inlined {
10691                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10692                    inner_offset = next_offset;
10693                } else {
10694                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10695                    inner_depth.increment()?;
10696                }
10697                let val_ref = self.data_sink.get_or_insert_with(|| {
10698                    fidl::new_empty!(
10699                        fidl::encoding::Endpoint<
10700                            fidl::endpoints::ClientEnd<
10701                                fidl_fuchsia_hardware_audio::PacketStreamSinkMarker,
10702                            >,
10703                        >,
10704                        fidl::encoding::DefaultFuchsiaResourceDialect
10705                    )
10706                });
10707                fidl::decode!(
10708                    fidl::encoding::Endpoint<
10709                        fidl::endpoints::ClientEnd<
10710                            fidl_fuchsia_hardware_audio::PacketStreamSinkMarker,
10711                        >,
10712                    >,
10713                    fidl::encoding::DefaultFuchsiaResourceDialect,
10714                    val_ref,
10715                    decoder,
10716                    inner_offset,
10717                    inner_depth
10718                )?;
10719                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10720                {
10721                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10722                }
10723                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10724                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10725                }
10726            }
10727
10728            next_offset += envelope_size;
10729            _next_ordinal_to_read += 1;
10730            if next_offset >= end_offset {
10731                return Ok(());
10732            }
10733
10734            // Decode unknown envelopes for gaps in ordinals.
10735            while _next_ordinal_to_read < 2 {
10736                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10737                _next_ordinal_to_read += 1;
10738                next_offset += envelope_size;
10739            }
10740
10741            let next_out_of_line = decoder.next_out_of_line();
10742            let handles_before = decoder.remaining_handles();
10743            if let Some((inlined, num_bytes, num_handles)) =
10744                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10745            {
10746                let member_inline_size =
10747                    <PacketStreamFormat as fidl::encoding::TypeMarker>::inline_size(
10748                        decoder.context,
10749                    );
10750                if inlined != (member_inline_size <= 4) {
10751                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10752                }
10753                let inner_offset;
10754                let mut inner_depth = depth.clone();
10755                if inlined {
10756                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10757                    inner_offset = next_offset;
10758                } else {
10759                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10760                    inner_depth.increment()?;
10761                }
10762                let val_ref = self.format.get_or_insert_with(|| {
10763                    fidl::new_empty!(
10764                        PacketStreamFormat,
10765                        fidl::encoding::DefaultFuchsiaResourceDialect
10766                    )
10767                });
10768                fidl::decode!(
10769                    PacketStreamFormat,
10770                    fidl::encoding::DefaultFuchsiaResourceDialect,
10771                    val_ref,
10772                    decoder,
10773                    inner_offset,
10774                    inner_depth
10775                )?;
10776                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10777                {
10778                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10779                }
10780                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10781                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10782                }
10783            }
10784
10785            next_offset += envelope_size;
10786            _next_ordinal_to_read += 1;
10787            if next_offset >= end_offset {
10788                return Ok(());
10789            }
10790
10791            // Decode unknown envelopes for gaps in ordinals.
10792            while _next_ordinal_to_read < 3 {
10793                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10794                _next_ordinal_to_read += 1;
10795                next_offset += envelope_size;
10796            }
10797
10798            let next_out_of_line = decoder.next_out_of_line();
10799            let handles_before = decoder.remaining_handles();
10800            if let Some((inlined, num_bytes, num_handles)) =
10801                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10802            {
10803                let member_inline_size =
10804                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10805                if inlined != (member_inline_size <= 4) {
10806                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10807                }
10808                let inner_offset;
10809                let mut inner_depth = depth.clone();
10810                if inlined {
10811                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10812                    inner_offset = next_offset;
10813                } else {
10814                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10815                    inner_depth.increment()?;
10816                }
10817                let val_ref = self.valid_bits_per_sample.get_or_insert_with(|| {
10818                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
10819                });
10820                fidl::decode!(
10821                    u8,
10822                    fidl::encoding::DefaultFuchsiaResourceDialect,
10823                    val_ref,
10824                    decoder,
10825                    inner_offset,
10826                    inner_depth
10827                )?;
10828                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10829                {
10830                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10831                }
10832                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10833                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10834                }
10835            }
10836
10837            next_offset += envelope_size;
10838            _next_ordinal_to_read += 1;
10839            if next_offset >= end_offset {
10840                return Ok(());
10841            }
10842
10843            // Decode unknown envelopes for gaps in ordinals.
10844            while _next_ordinal_to_read < 4 {
10845                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10846                _next_ordinal_to_read += 1;
10847                next_offset += envelope_size;
10848            }
10849
10850            let next_out_of_line = decoder.next_out_of_line();
10851            let handles_before = decoder.remaining_handles();
10852            if let Some((inlined, num_bytes, num_handles)) =
10853                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10854            {
10855                let member_inline_size = <fidl_fuchsia_hardware_audio::BufferType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10856                if inlined != (member_inline_size <= 4) {
10857                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10858                }
10859                let inner_offset;
10860                let mut inner_depth = depth.clone();
10861                if inlined {
10862                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10863                    inner_offset = next_offset;
10864                } else {
10865                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10866                    inner_depth.increment()?;
10867                }
10868                let val_ref = self.supported_buffer_types.get_or_insert_with(|| {
10869                    fidl::new_empty!(
10870                        fidl_fuchsia_hardware_audio::BufferType,
10871                        fidl::encoding::DefaultFuchsiaResourceDialect
10872                    )
10873                });
10874                fidl::decode!(
10875                    fidl_fuchsia_hardware_audio::BufferType,
10876                    fidl::encoding::DefaultFuchsiaResourceDialect,
10877                    val_ref,
10878                    decoder,
10879                    inner_offset,
10880                    inner_depth
10881                )?;
10882                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10883                {
10884                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10885                }
10886                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10887                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10888                }
10889            }
10890
10891            next_offset += envelope_size;
10892
10893            // Decode the remaining unknown envelopes.
10894            while next_offset < end_offset {
10895                _next_ordinal_to_read += 1;
10896                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10897                next_offset += envelope_size;
10898            }
10899
10900            Ok(())
10901        }
10902    }
10903
10904    impl PacketStreamSetBuffersRequest {
10905        #[inline(always)]
10906        fn max_ordinal_present(&self) -> u64 {
10907            if let Some(_) = self.vmo_info {
10908                return 1;
10909            }
10910            0
10911        }
10912    }
10913
10914    impl fidl::encoding::ResourceTypeMarker for PacketStreamSetBuffersRequest {
10915        type Borrowed<'a> = &'a mut Self;
10916        fn take_or_borrow<'a>(
10917            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10918        ) -> Self::Borrowed<'a> {
10919            value
10920        }
10921    }
10922
10923    unsafe impl fidl::encoding::TypeMarker for PacketStreamSetBuffersRequest {
10924        type Owned = Self;
10925
10926        #[inline(always)]
10927        fn inline_align(_context: fidl::encoding::Context) -> usize {
10928            8
10929        }
10930
10931        #[inline(always)]
10932        fn inline_size(_context: fidl::encoding::Context) -> usize {
10933            16
10934        }
10935    }
10936
10937    unsafe impl
10938        fidl::encoding::Encode<
10939            PacketStreamSetBuffersRequest,
10940            fidl::encoding::DefaultFuchsiaResourceDialect,
10941        > for &mut PacketStreamSetBuffersRequest
10942    {
10943        unsafe fn encode(
10944            self,
10945            encoder: &mut fidl::encoding::Encoder<
10946                '_,
10947                fidl::encoding::DefaultFuchsiaResourceDialect,
10948            >,
10949            offset: usize,
10950            mut depth: fidl::encoding::Depth,
10951        ) -> fidl::Result<()> {
10952            encoder.debug_check_bounds::<PacketStreamSetBuffersRequest>(offset);
10953            // Vector header
10954            let max_ordinal: u64 = self.max_ordinal_present();
10955            encoder.write_num(max_ordinal, offset);
10956            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10957            // Calling encoder.out_of_line_offset(0) is not allowed.
10958            if max_ordinal == 0 {
10959                return Ok(());
10960            }
10961            depth.increment()?;
10962            let envelope_size = 8;
10963            let bytes_len = max_ordinal as usize * envelope_size;
10964            #[allow(unused_variables)]
10965            let offset = encoder.out_of_line_offset(bytes_len);
10966            let mut _prev_end_offset: usize = 0;
10967            if 1 > max_ordinal {
10968                return Ok(());
10969            }
10970
10971            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10972            // are envelope_size bytes.
10973            let cur_offset: usize = (1 - 1) * envelope_size;
10974
10975            // Zero reserved fields.
10976            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10977
10978            // Safety:
10979            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10980            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10981            //   envelope_size bytes, there is always sufficient room.
10982            fidl::encoding::encode_in_envelope_optional::<PacketStreamSetupVmoInfo, fidl::encoding::DefaultFuchsiaResourceDialect>(
10983            self.vmo_info.as_mut().map(<PacketStreamSetupVmoInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
10984            encoder, offset + cur_offset, depth
10985        )?;
10986
10987            _prev_end_offset = cur_offset + envelope_size;
10988
10989            Ok(())
10990        }
10991    }
10992
10993    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10994        for PacketStreamSetBuffersRequest
10995    {
10996        #[inline(always)]
10997        fn new_empty() -> Self {
10998            Self::default()
10999        }
11000
11001        unsafe fn decode(
11002            &mut self,
11003            decoder: &mut fidl::encoding::Decoder<
11004                '_,
11005                fidl::encoding::DefaultFuchsiaResourceDialect,
11006            >,
11007            offset: usize,
11008            mut depth: fidl::encoding::Depth,
11009        ) -> fidl::Result<()> {
11010            decoder.debug_check_bounds::<Self>(offset);
11011            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11012                None => return Err(fidl::Error::NotNullable),
11013                Some(len) => len,
11014            };
11015            // Calling decoder.out_of_line_offset(0) is not allowed.
11016            if len == 0 {
11017                return Ok(());
11018            };
11019            depth.increment()?;
11020            let envelope_size = 8;
11021            let bytes_len = len * envelope_size;
11022            let offset = decoder.out_of_line_offset(bytes_len)?;
11023            // Decode the envelope for each type.
11024            let mut _next_ordinal_to_read = 0;
11025            let mut next_offset = offset;
11026            let end_offset = offset + bytes_len;
11027            _next_ordinal_to_read += 1;
11028            if next_offset >= end_offset {
11029                return Ok(());
11030            }
11031
11032            // Decode unknown envelopes for gaps in ordinals.
11033            while _next_ordinal_to_read < 1 {
11034                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11035                _next_ordinal_to_read += 1;
11036                next_offset += envelope_size;
11037            }
11038
11039            let next_out_of_line = decoder.next_out_of_line();
11040            let handles_before = decoder.remaining_handles();
11041            if let Some((inlined, num_bytes, num_handles)) =
11042                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11043            {
11044                let member_inline_size =
11045                    <PacketStreamSetupVmoInfo as fidl::encoding::TypeMarker>::inline_size(
11046                        decoder.context,
11047                    );
11048                if inlined != (member_inline_size <= 4) {
11049                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11050                }
11051                let inner_offset;
11052                let mut inner_depth = depth.clone();
11053                if inlined {
11054                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11055                    inner_offset = next_offset;
11056                } else {
11057                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11058                    inner_depth.increment()?;
11059                }
11060                let val_ref = self.vmo_info.get_or_insert_with(|| {
11061                    fidl::new_empty!(
11062                        PacketStreamSetupVmoInfo,
11063                        fidl::encoding::DefaultFuchsiaResourceDialect
11064                    )
11065                });
11066                fidl::decode!(
11067                    PacketStreamSetupVmoInfo,
11068                    fidl::encoding::DefaultFuchsiaResourceDialect,
11069                    val_ref,
11070                    decoder,
11071                    inner_offset,
11072                    inner_depth
11073                )?;
11074                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11075                {
11076                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11077                }
11078                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11079                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11080                }
11081            }
11082
11083            next_offset += envelope_size;
11084
11085            // Decode the remaining unknown envelopes.
11086            while next_offset < end_offset {
11087                _next_ordinal_to_read += 1;
11088                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11089                next_offset += envelope_size;
11090            }
11091
11092            Ok(())
11093        }
11094    }
11095
11096    impl PacketStreamSetBuffersResponse {
11097        #[inline(always)]
11098        fn max_ordinal_present(&self) -> u64 {
11099            if let Some(_) = self.packet_stream {
11100                return 1;
11101            }
11102            0
11103        }
11104    }
11105
11106    impl fidl::encoding::ResourceTypeMarker for PacketStreamSetBuffersResponse {
11107        type Borrowed<'a> = &'a mut Self;
11108        fn take_or_borrow<'a>(
11109            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11110        ) -> Self::Borrowed<'a> {
11111            value
11112        }
11113    }
11114
11115    unsafe impl fidl::encoding::TypeMarker for PacketStreamSetBuffersResponse {
11116        type Owned = Self;
11117
11118        #[inline(always)]
11119        fn inline_align(_context: fidl::encoding::Context) -> usize {
11120            8
11121        }
11122
11123        #[inline(always)]
11124        fn inline_size(_context: fidl::encoding::Context) -> usize {
11125            16
11126        }
11127    }
11128
11129    unsafe impl
11130        fidl::encoding::Encode<
11131            PacketStreamSetBuffersResponse,
11132            fidl::encoding::DefaultFuchsiaResourceDialect,
11133        > for &mut PacketStreamSetBuffersResponse
11134    {
11135        unsafe fn encode(
11136            self,
11137            encoder: &mut fidl::encoding::Encoder<
11138                '_,
11139                fidl::encoding::DefaultFuchsiaResourceDialect,
11140            >,
11141            offset: usize,
11142            mut depth: fidl::encoding::Depth,
11143        ) -> fidl::Result<()> {
11144            encoder.debug_check_bounds::<PacketStreamSetBuffersResponse>(offset);
11145            // Vector header
11146            let max_ordinal: u64 = self.max_ordinal_present();
11147            encoder.write_num(max_ordinal, offset);
11148            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11149            // Calling encoder.out_of_line_offset(0) is not allowed.
11150            if max_ordinal == 0 {
11151                return Ok(());
11152            }
11153            depth.increment()?;
11154            let envelope_size = 8;
11155            let bytes_len = max_ordinal as usize * envelope_size;
11156            #[allow(unused_variables)]
11157            let offset = encoder.out_of_line_offset(bytes_len);
11158            let mut _prev_end_offset: usize = 0;
11159            if 1 > max_ordinal {
11160                return Ok(());
11161            }
11162
11163            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11164            // are envelope_size bytes.
11165            let cur_offset: usize = (1 - 1) * envelope_size;
11166
11167            // Zero reserved fields.
11168            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11169
11170            // Safety:
11171            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11172            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11173            //   envelope_size bytes, there is always sufficient room.
11174            fidl::encoding::encode_in_envelope_optional::<
11175                PacketStreamBuffers,
11176                fidl::encoding::DefaultFuchsiaResourceDialect,
11177            >(
11178                self.packet_stream.as_mut().map(
11179                    <PacketStreamBuffers as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11180                ),
11181                encoder,
11182                offset + cur_offset,
11183                depth,
11184            )?;
11185
11186            _prev_end_offset = cur_offset + envelope_size;
11187
11188            Ok(())
11189        }
11190    }
11191
11192    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11193        for PacketStreamSetBuffersResponse
11194    {
11195        #[inline(always)]
11196        fn new_empty() -> Self {
11197            Self::default()
11198        }
11199
11200        unsafe fn decode(
11201            &mut self,
11202            decoder: &mut fidl::encoding::Decoder<
11203                '_,
11204                fidl::encoding::DefaultFuchsiaResourceDialect,
11205            >,
11206            offset: usize,
11207            mut depth: fidl::encoding::Depth,
11208        ) -> fidl::Result<()> {
11209            decoder.debug_check_bounds::<Self>(offset);
11210            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11211                None => return Err(fidl::Error::NotNullable),
11212                Some(len) => len,
11213            };
11214            // Calling decoder.out_of_line_offset(0) is not allowed.
11215            if len == 0 {
11216                return Ok(());
11217            };
11218            depth.increment()?;
11219            let envelope_size = 8;
11220            let bytes_len = len * envelope_size;
11221            let offset = decoder.out_of_line_offset(bytes_len)?;
11222            // Decode the envelope for each type.
11223            let mut _next_ordinal_to_read = 0;
11224            let mut next_offset = offset;
11225            let end_offset = offset + bytes_len;
11226            _next_ordinal_to_read += 1;
11227            if next_offset >= end_offset {
11228                return Ok(());
11229            }
11230
11231            // Decode unknown envelopes for gaps in ordinals.
11232            while _next_ordinal_to_read < 1 {
11233                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11234                _next_ordinal_to_read += 1;
11235                next_offset += envelope_size;
11236            }
11237
11238            let next_out_of_line = decoder.next_out_of_line();
11239            let handles_before = decoder.remaining_handles();
11240            if let Some((inlined, num_bytes, num_handles)) =
11241                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11242            {
11243                let member_inline_size =
11244                    <PacketStreamBuffers as fidl::encoding::TypeMarker>::inline_size(
11245                        decoder.context,
11246                    );
11247                if inlined != (member_inline_size <= 4) {
11248                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11249                }
11250                let inner_offset;
11251                let mut inner_depth = depth.clone();
11252                if inlined {
11253                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11254                    inner_offset = next_offset;
11255                } else {
11256                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11257                    inner_depth.increment()?;
11258                }
11259                let val_ref = self.packet_stream.get_or_insert_with(|| {
11260                    fidl::new_empty!(
11261                        PacketStreamBuffers,
11262                        fidl::encoding::DefaultFuchsiaResourceDialect
11263                    )
11264                });
11265                fidl::decode!(
11266                    PacketStreamBuffers,
11267                    fidl::encoding::DefaultFuchsiaResourceDialect,
11268                    val_ref,
11269                    decoder,
11270                    inner_offset,
11271                    inner_depth
11272                )?;
11273                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11274                {
11275                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11276                }
11277                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11278                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11279                }
11280            }
11281
11282            next_offset += envelope_size;
11283
11284            // Decode the remaining unknown envelopes.
11285            while next_offset < end_offset {
11286                _next_ordinal_to_read += 1;
11287                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11288                next_offset += envelope_size;
11289            }
11290
11291            Ok(())
11292        }
11293    }
11294
11295    impl ProviderAddDeviceRequest {
11296        #[inline(always)]
11297        fn max_ordinal_present(&self) -> u64 {
11298            if let Some(_) = self.driver_client {
11299                return 3;
11300            }
11301            if let Some(_) = self.device_type {
11302                return 2;
11303            }
11304            if let Some(_) = self.device_name {
11305                return 1;
11306            }
11307            0
11308        }
11309    }
11310
11311    impl fidl::encoding::ResourceTypeMarker for ProviderAddDeviceRequest {
11312        type Borrowed<'a> = &'a mut Self;
11313        fn take_or_borrow<'a>(
11314            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11315        ) -> Self::Borrowed<'a> {
11316            value
11317        }
11318    }
11319
11320    unsafe impl fidl::encoding::TypeMarker for ProviderAddDeviceRequest {
11321        type Owned = Self;
11322
11323        #[inline(always)]
11324        fn inline_align(_context: fidl::encoding::Context) -> usize {
11325            8
11326        }
11327
11328        #[inline(always)]
11329        fn inline_size(_context: fidl::encoding::Context) -> usize {
11330            16
11331        }
11332    }
11333
11334    unsafe impl
11335        fidl::encoding::Encode<
11336            ProviderAddDeviceRequest,
11337            fidl::encoding::DefaultFuchsiaResourceDialect,
11338        > for &mut ProviderAddDeviceRequest
11339    {
11340        unsafe fn encode(
11341            self,
11342            encoder: &mut fidl::encoding::Encoder<
11343                '_,
11344                fidl::encoding::DefaultFuchsiaResourceDialect,
11345            >,
11346            offset: usize,
11347            mut depth: fidl::encoding::Depth,
11348        ) -> fidl::Result<()> {
11349            encoder.debug_check_bounds::<ProviderAddDeviceRequest>(offset);
11350            // Vector header
11351            let max_ordinal: u64 = self.max_ordinal_present();
11352            encoder.write_num(max_ordinal, offset);
11353            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11354            // Calling encoder.out_of_line_offset(0) is not allowed.
11355            if max_ordinal == 0 {
11356                return Ok(());
11357            }
11358            depth.increment()?;
11359            let envelope_size = 8;
11360            let bytes_len = max_ordinal as usize * envelope_size;
11361            #[allow(unused_variables)]
11362            let offset = encoder.out_of_line_offset(bytes_len);
11363            let mut _prev_end_offset: usize = 0;
11364            if 1 > max_ordinal {
11365                return Ok(());
11366            }
11367
11368            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11369            // are envelope_size bytes.
11370            let cur_offset: usize = (1 - 1) * envelope_size;
11371
11372            // Zero reserved fields.
11373            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11374
11375            // Safety:
11376            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11377            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11378            //   envelope_size bytes, there is always sufficient room.
11379            fidl::encoding::encode_in_envelope_optional::<
11380                fidl::encoding::BoundedString<256>,
11381                fidl::encoding::DefaultFuchsiaResourceDialect,
11382            >(
11383                self.device_name.as_ref().map(
11384                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow,
11385                ),
11386                encoder,
11387                offset + cur_offset,
11388                depth,
11389            )?;
11390
11391            _prev_end_offset = cur_offset + envelope_size;
11392            if 2 > max_ordinal {
11393                return Ok(());
11394            }
11395
11396            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11397            // are envelope_size bytes.
11398            let cur_offset: usize = (2 - 1) * envelope_size;
11399
11400            // Zero reserved fields.
11401            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11402
11403            // Safety:
11404            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11405            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11406            //   envelope_size bytes, there is always sufficient room.
11407            fidl::encoding::encode_in_envelope_optional::<
11408                DeviceType,
11409                fidl::encoding::DefaultFuchsiaResourceDialect,
11410            >(
11411                self.device_type
11412                    .as_ref()
11413                    .map(<DeviceType as fidl::encoding::ValueTypeMarker>::borrow),
11414                encoder,
11415                offset + cur_offset,
11416                depth,
11417            )?;
11418
11419            _prev_end_offset = cur_offset + envelope_size;
11420            if 3 > max_ordinal {
11421                return Ok(());
11422            }
11423
11424            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11425            // are envelope_size bytes.
11426            let cur_offset: usize = (3 - 1) * envelope_size;
11427
11428            // Zero reserved fields.
11429            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11430
11431            // Safety:
11432            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11433            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11434            //   envelope_size bytes, there is always sufficient room.
11435            fidl::encoding::encode_in_envelope_optional::<
11436                DriverClient,
11437                fidl::encoding::DefaultFuchsiaResourceDialect,
11438            >(
11439                self.driver_client
11440                    .as_mut()
11441                    .map(<DriverClient as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11442                encoder,
11443                offset + cur_offset,
11444                depth,
11445            )?;
11446
11447            _prev_end_offset = cur_offset + envelope_size;
11448
11449            Ok(())
11450        }
11451    }
11452
11453    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11454        for ProviderAddDeviceRequest
11455    {
11456        #[inline(always)]
11457        fn new_empty() -> Self {
11458            Self::default()
11459        }
11460
11461        unsafe fn decode(
11462            &mut self,
11463            decoder: &mut fidl::encoding::Decoder<
11464                '_,
11465                fidl::encoding::DefaultFuchsiaResourceDialect,
11466            >,
11467            offset: usize,
11468            mut depth: fidl::encoding::Depth,
11469        ) -> fidl::Result<()> {
11470            decoder.debug_check_bounds::<Self>(offset);
11471            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11472                None => return Err(fidl::Error::NotNullable),
11473                Some(len) => len,
11474            };
11475            // Calling decoder.out_of_line_offset(0) is not allowed.
11476            if len == 0 {
11477                return Ok(());
11478            };
11479            depth.increment()?;
11480            let envelope_size = 8;
11481            let bytes_len = len * envelope_size;
11482            let offset = decoder.out_of_line_offset(bytes_len)?;
11483            // Decode the envelope for each type.
11484            let mut _next_ordinal_to_read = 0;
11485            let mut next_offset = offset;
11486            let end_offset = offset + bytes_len;
11487            _next_ordinal_to_read += 1;
11488            if next_offset >= end_offset {
11489                return Ok(());
11490            }
11491
11492            // Decode unknown envelopes for gaps in ordinals.
11493            while _next_ordinal_to_read < 1 {
11494                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11495                _next_ordinal_to_read += 1;
11496                next_offset += envelope_size;
11497            }
11498
11499            let next_out_of_line = decoder.next_out_of_line();
11500            let handles_before = decoder.remaining_handles();
11501            if let Some((inlined, num_bytes, num_handles)) =
11502                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11503            {
11504                let member_inline_size =
11505                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
11506                        decoder.context,
11507                    );
11508                if inlined != (member_inline_size <= 4) {
11509                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11510                }
11511                let inner_offset;
11512                let mut inner_depth = depth.clone();
11513                if inlined {
11514                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11515                    inner_offset = next_offset;
11516                } else {
11517                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11518                    inner_depth.increment()?;
11519                }
11520                let val_ref = self.device_name.get_or_insert_with(|| {
11521                    fidl::new_empty!(
11522                        fidl::encoding::BoundedString<256>,
11523                        fidl::encoding::DefaultFuchsiaResourceDialect
11524                    )
11525                });
11526                fidl::decode!(
11527                    fidl::encoding::BoundedString<256>,
11528                    fidl::encoding::DefaultFuchsiaResourceDialect,
11529                    val_ref,
11530                    decoder,
11531                    inner_offset,
11532                    inner_depth
11533                )?;
11534                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11535                {
11536                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11537                }
11538                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11539                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11540                }
11541            }
11542
11543            next_offset += envelope_size;
11544            _next_ordinal_to_read += 1;
11545            if next_offset >= end_offset {
11546                return Ok(());
11547            }
11548
11549            // Decode unknown envelopes for gaps in ordinals.
11550            while _next_ordinal_to_read < 2 {
11551                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11552                _next_ordinal_to_read += 1;
11553                next_offset += envelope_size;
11554            }
11555
11556            let next_out_of_line = decoder.next_out_of_line();
11557            let handles_before = decoder.remaining_handles();
11558            if let Some((inlined, num_bytes, num_handles)) =
11559                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11560            {
11561                let member_inline_size =
11562                    <DeviceType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11563                if inlined != (member_inline_size <= 4) {
11564                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11565                }
11566                let inner_offset;
11567                let mut inner_depth = depth.clone();
11568                if inlined {
11569                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11570                    inner_offset = next_offset;
11571                } else {
11572                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11573                    inner_depth.increment()?;
11574                }
11575                let val_ref = self.device_type.get_or_insert_with(|| {
11576                    fidl::new_empty!(DeviceType, fidl::encoding::DefaultFuchsiaResourceDialect)
11577                });
11578                fidl::decode!(
11579                    DeviceType,
11580                    fidl::encoding::DefaultFuchsiaResourceDialect,
11581                    val_ref,
11582                    decoder,
11583                    inner_offset,
11584                    inner_depth
11585                )?;
11586                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11587                {
11588                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11589                }
11590                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11591                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11592                }
11593            }
11594
11595            next_offset += envelope_size;
11596            _next_ordinal_to_read += 1;
11597            if next_offset >= end_offset {
11598                return Ok(());
11599            }
11600
11601            // Decode unknown envelopes for gaps in ordinals.
11602            while _next_ordinal_to_read < 3 {
11603                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11604                _next_ordinal_to_read += 1;
11605                next_offset += envelope_size;
11606            }
11607
11608            let next_out_of_line = decoder.next_out_of_line();
11609            let handles_before = decoder.remaining_handles();
11610            if let Some((inlined, num_bytes, num_handles)) =
11611                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11612            {
11613                let member_inline_size =
11614                    <DriverClient as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11615                if inlined != (member_inline_size <= 4) {
11616                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11617                }
11618                let inner_offset;
11619                let mut inner_depth = depth.clone();
11620                if inlined {
11621                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11622                    inner_offset = next_offset;
11623                } else {
11624                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11625                    inner_depth.increment()?;
11626                }
11627                let val_ref = self.driver_client.get_or_insert_with(|| {
11628                    fidl::new_empty!(DriverClient, fidl::encoding::DefaultFuchsiaResourceDialect)
11629                });
11630                fidl::decode!(
11631                    DriverClient,
11632                    fidl::encoding::DefaultFuchsiaResourceDialect,
11633                    val_ref,
11634                    decoder,
11635                    inner_offset,
11636                    inner_depth
11637                )?;
11638                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11639                {
11640                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11641                }
11642                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11643                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11644                }
11645            }
11646
11647            next_offset += envelope_size;
11648
11649            // Decode the remaining unknown envelopes.
11650            while next_offset < end_offset {
11651                _next_ordinal_to_read += 1;
11652                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11653                next_offset += envelope_size;
11654            }
11655
11656            Ok(())
11657        }
11658    }
11659
11660    impl RegistryCreateObserverRequest {
11661        #[inline(always)]
11662        fn max_ordinal_present(&self) -> u64 {
11663            if let Some(_) = self.observer_server {
11664                return 2;
11665            }
11666            if let Some(_) = self.token_id {
11667                return 1;
11668            }
11669            0
11670        }
11671    }
11672
11673    impl fidl::encoding::ResourceTypeMarker for RegistryCreateObserverRequest {
11674        type Borrowed<'a> = &'a mut Self;
11675        fn take_or_borrow<'a>(
11676            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11677        ) -> Self::Borrowed<'a> {
11678            value
11679        }
11680    }
11681
11682    unsafe impl fidl::encoding::TypeMarker for RegistryCreateObserverRequest {
11683        type Owned = Self;
11684
11685        #[inline(always)]
11686        fn inline_align(_context: fidl::encoding::Context) -> usize {
11687            8
11688        }
11689
11690        #[inline(always)]
11691        fn inline_size(_context: fidl::encoding::Context) -> usize {
11692            16
11693        }
11694    }
11695
11696    unsafe impl
11697        fidl::encoding::Encode<
11698            RegistryCreateObserverRequest,
11699            fidl::encoding::DefaultFuchsiaResourceDialect,
11700        > for &mut RegistryCreateObserverRequest
11701    {
11702        unsafe fn encode(
11703            self,
11704            encoder: &mut fidl::encoding::Encoder<
11705                '_,
11706                fidl::encoding::DefaultFuchsiaResourceDialect,
11707            >,
11708            offset: usize,
11709            mut depth: fidl::encoding::Depth,
11710        ) -> fidl::Result<()> {
11711            encoder.debug_check_bounds::<RegistryCreateObserverRequest>(offset);
11712            // Vector header
11713            let max_ordinal: u64 = self.max_ordinal_present();
11714            encoder.write_num(max_ordinal, offset);
11715            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11716            // Calling encoder.out_of_line_offset(0) is not allowed.
11717            if max_ordinal == 0 {
11718                return Ok(());
11719            }
11720            depth.increment()?;
11721            let envelope_size = 8;
11722            let bytes_len = max_ordinal as usize * envelope_size;
11723            #[allow(unused_variables)]
11724            let offset = encoder.out_of_line_offset(bytes_len);
11725            let mut _prev_end_offset: usize = 0;
11726            if 1 > max_ordinal {
11727                return Ok(());
11728            }
11729
11730            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11731            // are envelope_size bytes.
11732            let cur_offset: usize = (1 - 1) * envelope_size;
11733
11734            // Zero reserved fields.
11735            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11736
11737            // Safety:
11738            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11739            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11740            //   envelope_size bytes, there is always sufficient room.
11741            fidl::encoding::encode_in_envelope_optional::<
11742                u64,
11743                fidl::encoding::DefaultFuchsiaResourceDialect,
11744            >(
11745                self.token_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11746                encoder,
11747                offset + cur_offset,
11748                depth,
11749            )?;
11750
11751            _prev_end_offset = cur_offset + envelope_size;
11752            if 2 > max_ordinal {
11753                return Ok(());
11754            }
11755
11756            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11757            // are envelope_size bytes.
11758            let cur_offset: usize = (2 - 1) * envelope_size;
11759
11760            // Zero reserved fields.
11761            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11762
11763            // Safety:
11764            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11765            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11766            //   envelope_size bytes, there is always sufficient room.
11767            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ObserverMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
11768            self.observer_server.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ObserverMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11769            encoder, offset + cur_offset, depth
11770        )?;
11771
11772            _prev_end_offset = cur_offset + envelope_size;
11773
11774            Ok(())
11775        }
11776    }
11777
11778    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11779        for RegistryCreateObserverRequest
11780    {
11781        #[inline(always)]
11782        fn new_empty() -> Self {
11783            Self::default()
11784        }
11785
11786        unsafe fn decode(
11787            &mut self,
11788            decoder: &mut fidl::encoding::Decoder<
11789                '_,
11790                fidl::encoding::DefaultFuchsiaResourceDialect,
11791            >,
11792            offset: usize,
11793            mut depth: fidl::encoding::Depth,
11794        ) -> fidl::Result<()> {
11795            decoder.debug_check_bounds::<Self>(offset);
11796            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11797                None => return Err(fidl::Error::NotNullable),
11798                Some(len) => len,
11799            };
11800            // Calling decoder.out_of_line_offset(0) is not allowed.
11801            if len == 0 {
11802                return Ok(());
11803            };
11804            depth.increment()?;
11805            let envelope_size = 8;
11806            let bytes_len = len * envelope_size;
11807            let offset = decoder.out_of_line_offset(bytes_len)?;
11808            // Decode the envelope for each type.
11809            let mut _next_ordinal_to_read = 0;
11810            let mut next_offset = offset;
11811            let end_offset = offset + bytes_len;
11812            _next_ordinal_to_read += 1;
11813            if next_offset >= end_offset {
11814                return Ok(());
11815            }
11816
11817            // Decode unknown envelopes for gaps in ordinals.
11818            while _next_ordinal_to_read < 1 {
11819                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11820                _next_ordinal_to_read += 1;
11821                next_offset += envelope_size;
11822            }
11823
11824            let next_out_of_line = decoder.next_out_of_line();
11825            let handles_before = decoder.remaining_handles();
11826            if let Some((inlined, num_bytes, num_handles)) =
11827                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11828            {
11829                let member_inline_size =
11830                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11831                if inlined != (member_inline_size <= 4) {
11832                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11833                }
11834                let inner_offset;
11835                let mut inner_depth = depth.clone();
11836                if inlined {
11837                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11838                    inner_offset = next_offset;
11839                } else {
11840                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11841                    inner_depth.increment()?;
11842                }
11843                let val_ref = self.token_id.get_or_insert_with(|| {
11844                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
11845                });
11846                fidl::decode!(
11847                    u64,
11848                    fidl::encoding::DefaultFuchsiaResourceDialect,
11849                    val_ref,
11850                    decoder,
11851                    inner_offset,
11852                    inner_depth
11853                )?;
11854                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11855                {
11856                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11857                }
11858                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11859                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11860                }
11861            }
11862
11863            next_offset += envelope_size;
11864            _next_ordinal_to_read += 1;
11865            if next_offset >= end_offset {
11866                return Ok(());
11867            }
11868
11869            // Decode unknown envelopes for gaps in ordinals.
11870            while _next_ordinal_to_read < 2 {
11871                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11872                _next_ordinal_to_read += 1;
11873                next_offset += envelope_size;
11874            }
11875
11876            let next_out_of_line = decoder.next_out_of_line();
11877            let handles_before = decoder.remaining_handles();
11878            if let Some((inlined, num_bytes, num_handles)) =
11879                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11880            {
11881                let member_inline_size = <fidl::encoding::Endpoint<
11882                    fidl::endpoints::ServerEnd<ObserverMarker>,
11883                > as fidl::encoding::TypeMarker>::inline_size(
11884                    decoder.context
11885                );
11886                if inlined != (member_inline_size <= 4) {
11887                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11888                }
11889                let inner_offset;
11890                let mut inner_depth = depth.clone();
11891                if inlined {
11892                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11893                    inner_offset = next_offset;
11894                } else {
11895                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11896                    inner_depth.increment()?;
11897                }
11898                let val_ref = self.observer_server.get_or_insert_with(|| {
11899                    fidl::new_empty!(
11900                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ObserverMarker>>,
11901                        fidl::encoding::DefaultFuchsiaResourceDialect
11902                    )
11903                });
11904                fidl::decode!(
11905                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ObserverMarker>>,
11906                    fidl::encoding::DefaultFuchsiaResourceDialect,
11907                    val_ref,
11908                    decoder,
11909                    inner_offset,
11910                    inner_depth
11911                )?;
11912                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11913                {
11914                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11915                }
11916                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11917                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11918                }
11919            }
11920
11921            next_offset += envelope_size;
11922
11923            // Decode the remaining unknown envelopes.
11924            while next_offset < end_offset {
11925                _next_ordinal_to_read += 1;
11926                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11927                next_offset += envelope_size;
11928            }
11929
11930            Ok(())
11931        }
11932    }
11933
11934    impl fidl::encoding::ResourceTypeMarker for DriverClient {
11935        type Borrowed<'a> = &'a mut Self;
11936        fn take_or_borrow<'a>(
11937            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11938        ) -> Self::Borrowed<'a> {
11939            value
11940        }
11941    }
11942
11943    unsafe impl fidl::encoding::TypeMarker for DriverClient {
11944        type Owned = Self;
11945
11946        #[inline(always)]
11947        fn inline_align(_context: fidl::encoding::Context) -> usize {
11948            8
11949        }
11950
11951        #[inline(always)]
11952        fn inline_size(_context: fidl::encoding::Context) -> usize {
11953            16
11954        }
11955    }
11956
11957    unsafe impl fidl::encoding::Encode<DriverClient, fidl::encoding::DefaultFuchsiaResourceDialect>
11958        for &mut DriverClient
11959    {
11960        #[inline]
11961        unsafe fn encode(
11962            self,
11963            encoder: &mut fidl::encoding::Encoder<
11964                '_,
11965                fidl::encoding::DefaultFuchsiaResourceDialect,
11966            >,
11967            offset: usize,
11968            _depth: fidl::encoding::Depth,
11969        ) -> fidl::Result<()> {
11970            encoder.debug_check_bounds::<DriverClient>(offset);
11971            encoder.write_num::<u64>(self.ordinal(), offset);
11972            match self {
11973                DriverClient::Codec(ref mut val) => fidl::encoding::encode_in_envelope::<
11974                    fidl::encoding::Endpoint<
11975                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CodecMarker>,
11976                    >,
11977                    fidl::encoding::DefaultFuchsiaResourceDialect,
11978                >(
11979                    <fidl::encoding::Endpoint<
11980                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CodecMarker>,
11981                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11982                        val
11983                    ),
11984                    encoder,
11985                    offset + 8,
11986                    _depth,
11987                ),
11988                DriverClient::Composite(ref mut val) => fidl::encoding::encode_in_envelope::<
11989                    fidl::encoding::Endpoint<
11990                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CompositeMarker>,
11991                    >,
11992                    fidl::encoding::DefaultFuchsiaResourceDialect,
11993                >(
11994                    <fidl::encoding::Endpoint<
11995                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CompositeMarker>,
11996                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11997                        val
11998                    ),
11999                    encoder,
12000                    offset + 8,
12001                    _depth,
12002                ),
12003                DriverClient::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
12004            }
12005        }
12006    }
12007
12008    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for DriverClient {
12009        #[inline(always)]
12010        fn new_empty() -> Self {
12011            Self::__SourceBreaking { unknown_ordinal: 0 }
12012        }
12013
12014        #[inline]
12015        unsafe fn decode(
12016            &mut self,
12017            decoder: &mut fidl::encoding::Decoder<
12018                '_,
12019                fidl::encoding::DefaultFuchsiaResourceDialect,
12020            >,
12021            offset: usize,
12022            mut depth: fidl::encoding::Depth,
12023        ) -> fidl::Result<()> {
12024            decoder.debug_check_bounds::<Self>(offset);
12025            #[allow(unused_variables)]
12026            let next_out_of_line = decoder.next_out_of_line();
12027            let handles_before = decoder.remaining_handles();
12028            let (ordinal, inlined, num_bytes, num_handles) =
12029                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
12030
12031            let member_inline_size = match ordinal {
12032                1 => <fidl::encoding::Endpoint<
12033                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CodecMarker>,
12034                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
12035                2 => <fidl::encoding::Endpoint<
12036                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::CompositeMarker>,
12037                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
12038                0 => return Err(fidl::Error::UnknownUnionTag),
12039                _ => num_bytes as usize,
12040            };
12041
12042            if inlined != (member_inline_size <= 4) {
12043                return Err(fidl::Error::InvalidInlineBitInEnvelope);
12044            }
12045            let _inner_offset;
12046            if inlined {
12047                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
12048                _inner_offset = offset + 8;
12049            } else {
12050                depth.increment()?;
12051                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12052            }
12053            match ordinal {
12054                1 => {
12055                    #[allow(irrefutable_let_patterns)]
12056                    if let DriverClient::Codec(_) = self {
12057                        // Do nothing, read the value into the object
12058                    } else {
12059                        // Initialize `self` to the right variant
12060                        *self = DriverClient::Codec(fidl::new_empty!(
12061                            fidl::encoding::Endpoint<
12062                                fidl::endpoints::ClientEnd<
12063                                    fidl_fuchsia_hardware_audio::CodecMarker,
12064                                >,
12065                            >,
12066                            fidl::encoding::DefaultFuchsiaResourceDialect
12067                        ));
12068                    }
12069                    #[allow(irrefutable_let_patterns)]
12070                    if let DriverClient::Codec(ref mut val) = self {
12071                        fidl::decode!(
12072                            fidl::encoding::Endpoint<
12073                                fidl::endpoints::ClientEnd<
12074                                    fidl_fuchsia_hardware_audio::CodecMarker,
12075                                >,
12076                            >,
12077                            fidl::encoding::DefaultFuchsiaResourceDialect,
12078                            val,
12079                            decoder,
12080                            _inner_offset,
12081                            depth
12082                        )?;
12083                    } else {
12084                        unreachable!()
12085                    }
12086                }
12087                2 => {
12088                    #[allow(irrefutable_let_patterns)]
12089                    if let DriverClient::Composite(_) = self {
12090                        // Do nothing, read the value into the object
12091                    } else {
12092                        // Initialize `self` to the right variant
12093                        *self = DriverClient::Composite(fidl::new_empty!(
12094                            fidl::encoding::Endpoint<
12095                                fidl::endpoints::ClientEnd<
12096                                    fidl_fuchsia_hardware_audio::CompositeMarker,
12097                                >,
12098                            >,
12099                            fidl::encoding::DefaultFuchsiaResourceDialect
12100                        ));
12101                    }
12102                    #[allow(irrefutable_let_patterns)]
12103                    if let DriverClient::Composite(ref mut val) = self {
12104                        fidl::decode!(
12105                            fidl::encoding::Endpoint<
12106                                fidl::endpoints::ClientEnd<
12107                                    fidl_fuchsia_hardware_audio::CompositeMarker,
12108                                >,
12109                            >,
12110                            fidl::encoding::DefaultFuchsiaResourceDialect,
12111                            val,
12112                            decoder,
12113                            _inner_offset,
12114                            depth
12115                        )?;
12116                    } else {
12117                        unreachable!()
12118                    }
12119                }
12120                #[allow(deprecated)]
12121                ordinal => {
12122                    for _ in 0..num_handles {
12123                        decoder.drop_next_handle()?;
12124                    }
12125                    *self = DriverClient::__SourceBreaking { unknown_ordinal: ordinal };
12126                }
12127            }
12128            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
12129                return Err(fidl::Error::InvalidNumBytesInEnvelope);
12130            }
12131            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12132                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12133            }
12134            Ok(())
12135        }
12136    }
12137
12138    impl fidl::encoding::ResourceTypeMarker for PacketStreamSetupVmoInfo {
12139        type Borrowed<'a> = &'a mut Self;
12140        fn take_or_borrow<'a>(
12141            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12142        ) -> Self::Borrowed<'a> {
12143            value
12144        }
12145    }
12146
12147    unsafe impl fidl::encoding::TypeMarker for PacketStreamSetupVmoInfo {
12148        type Owned = Self;
12149
12150        #[inline(always)]
12151        fn inline_align(_context: fidl::encoding::Context) -> usize {
12152            8
12153        }
12154
12155        #[inline(always)]
12156        fn inline_size(_context: fidl::encoding::Context) -> usize {
12157            16
12158        }
12159    }
12160
12161    unsafe impl
12162        fidl::encoding::Encode<
12163            PacketStreamSetupVmoInfo,
12164            fidl::encoding::DefaultFuchsiaResourceDialect,
12165        > for &mut PacketStreamSetupVmoInfo
12166    {
12167        #[inline]
12168        unsafe fn encode(
12169            self,
12170            encoder: &mut fidl::encoding::Encoder<
12171                '_,
12172                fidl::encoding::DefaultFuchsiaResourceDialect,
12173            >,
12174            offset: usize,
12175            _depth: fidl::encoding::Depth,
12176        ) -> fidl::Result<()> {
12177            encoder.debug_check_bounds::<PacketStreamSetupVmoInfo>(offset);
12178            encoder.write_num::<u64>(self.ordinal(), offset);
12179            match self {
12180            PacketStreamSetupVmoInfo::AllocateInfo(ref val) => {
12181                fidl::encoding::encode_in_envelope::<fidl_fuchsia_hardware_audio::AllocateVmosConfig, fidl::encoding::DefaultFuchsiaResourceDialect>(
12182                    <fidl_fuchsia_hardware_audio::AllocateVmosConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
12183                    encoder, offset + 8, _depth
12184                )
12185            }
12186            PacketStreamSetupVmoInfo::RegisterInfo(ref mut val) => {
12187                fidl::encoding::encode_in_envelope::<fidl_fuchsia_hardware_audio::RegisterVmosConfig, fidl::encoding::DefaultFuchsiaResourceDialect>(
12188                    <fidl_fuchsia_hardware_audio::RegisterVmosConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
12189                    encoder, offset + 8, _depth
12190                )
12191            }
12192            PacketStreamSetupVmoInfo::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
12193        }
12194        }
12195    }
12196
12197    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12198        for PacketStreamSetupVmoInfo
12199    {
12200        #[inline(always)]
12201        fn new_empty() -> Self {
12202            Self::__SourceBreaking { unknown_ordinal: 0 }
12203        }
12204
12205        #[inline]
12206        unsafe fn decode(
12207            &mut self,
12208            decoder: &mut fidl::encoding::Decoder<
12209                '_,
12210                fidl::encoding::DefaultFuchsiaResourceDialect,
12211            >,
12212            offset: usize,
12213            mut depth: fidl::encoding::Depth,
12214        ) -> fidl::Result<()> {
12215            decoder.debug_check_bounds::<Self>(offset);
12216            #[allow(unused_variables)]
12217            let next_out_of_line = decoder.next_out_of_line();
12218            let handles_before = decoder.remaining_handles();
12219            let (ordinal, inlined, num_bytes, num_handles) =
12220                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
12221
12222            let member_inline_size = match ordinal {
12223            1 => <fidl_fuchsia_hardware_audio::AllocateVmosConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context),
12224            2 => <fidl_fuchsia_hardware_audio::RegisterVmosConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context),
12225            0 => return Err(fidl::Error::UnknownUnionTag),
12226            _ => num_bytes as usize,
12227        };
12228
12229            if inlined != (member_inline_size <= 4) {
12230                return Err(fidl::Error::InvalidInlineBitInEnvelope);
12231            }
12232            let _inner_offset;
12233            if inlined {
12234                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
12235                _inner_offset = offset + 8;
12236            } else {
12237                depth.increment()?;
12238                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12239            }
12240            match ordinal {
12241                1 => {
12242                    #[allow(irrefutable_let_patterns)]
12243                    if let PacketStreamSetupVmoInfo::AllocateInfo(_) = self {
12244                        // Do nothing, read the value into the object
12245                    } else {
12246                        // Initialize `self` to the right variant
12247                        *self = PacketStreamSetupVmoInfo::AllocateInfo(fidl::new_empty!(
12248                            fidl_fuchsia_hardware_audio::AllocateVmosConfig,
12249                            fidl::encoding::DefaultFuchsiaResourceDialect
12250                        ));
12251                    }
12252                    #[allow(irrefutable_let_patterns)]
12253                    if let PacketStreamSetupVmoInfo::AllocateInfo(ref mut val) = self {
12254                        fidl::decode!(
12255                            fidl_fuchsia_hardware_audio::AllocateVmosConfig,
12256                            fidl::encoding::DefaultFuchsiaResourceDialect,
12257                            val,
12258                            decoder,
12259                            _inner_offset,
12260                            depth
12261                        )?;
12262                    } else {
12263                        unreachable!()
12264                    }
12265                }
12266                2 => {
12267                    #[allow(irrefutable_let_patterns)]
12268                    if let PacketStreamSetupVmoInfo::RegisterInfo(_) = self {
12269                        // Do nothing, read the value into the object
12270                    } else {
12271                        // Initialize `self` to the right variant
12272                        *self = PacketStreamSetupVmoInfo::RegisterInfo(fidl::new_empty!(
12273                            fidl_fuchsia_hardware_audio::RegisterVmosConfig,
12274                            fidl::encoding::DefaultFuchsiaResourceDialect
12275                        ));
12276                    }
12277                    #[allow(irrefutable_let_patterns)]
12278                    if let PacketStreamSetupVmoInfo::RegisterInfo(ref mut val) = self {
12279                        fidl::decode!(
12280                            fidl_fuchsia_hardware_audio::RegisterVmosConfig,
12281                            fidl::encoding::DefaultFuchsiaResourceDialect,
12282                            val,
12283                            decoder,
12284                            _inner_offset,
12285                            depth
12286                        )?;
12287                    } else {
12288                        unreachable!()
12289                    }
12290                }
12291                #[allow(deprecated)]
12292                ordinal => {
12293                    for _ in 0..num_handles {
12294                        decoder.drop_next_handle()?;
12295                    }
12296                    *self = PacketStreamSetupVmoInfo::__SourceBreaking { unknown_ordinal: ordinal };
12297                }
12298            }
12299            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
12300                return Err(fidl::Error::InvalidNumBytesInEnvelope);
12301            }
12302            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12303                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12304            }
12305            Ok(())
12306        }
12307    }
12308}