Skip to main content

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