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