Skip to main content

fdomain_fuchsia_media/
fdomain_fuchsia_media.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_media__common::*;
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
14pub struct AudioCapturerBindGainControlRequest {
15    pub gain_control_request:
16        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
17}
18
19impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
20    for AudioCapturerBindGainControlRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct AudioCapturerGetReferenceClockResponse {
26    pub reference_clock: fdomain_client::Clock,
27}
28
29impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
30    for AudioCapturerGetReferenceClockResponse
31{
32}
33
34#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct AudioCapturerSetReferenceClockRequest {
36    pub reference_clock: Option<fdomain_client::Clock>,
37}
38
39impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
40    for AudioCapturerSetReferenceClockRequest
41{
42}
43
44#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
45pub struct AudioConsumerBindVolumeControlRequest {
46    pub volume_control_request:
47        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
48}
49
50impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
51    for AudioConsumerBindVolumeControlRequest
52{
53}
54
55#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
56pub struct AudioConsumerCreateStreamSinkRequest {
57    pub buffers: Vec<fdomain_client::Vmo>,
58    pub stream_type: AudioStreamType,
59    pub compression: Option<Box<Compression>>,
60    pub stream_sink_request: fdomain_client::fidl::ServerEnd<StreamSinkMarker>,
61}
62
63impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
64    for AudioConsumerCreateStreamSinkRequest
65{
66}
67
68#[derive(Debug, PartialEq)]
69pub struct AudioCoreBindUsageVolumeControl2Request {
70    pub usage: Usage2,
71    pub volume_control:
72        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
73}
74
75impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
76    for AudioCoreBindUsageVolumeControl2Request
77{
78}
79
80#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
81pub struct AudioCoreBindUsageVolumeControlRequest {
82    pub usage: Usage,
83    pub volume_control:
84        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
85}
86
87impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
88    for AudioCoreBindUsageVolumeControlRequest
89{
90}
91
92#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
93pub struct AudioCoreCreateAudioCapturerRequest {
94    pub loopback: bool,
95    pub audio_in_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
96}
97
98impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
99    for AudioCoreCreateAudioCapturerRequest
100{
101}
102
103#[derive(Debug, PartialEq)]
104pub struct AudioCoreCreateAudioCapturerWithConfigurationRequest {
105    pub stream_type: AudioStreamType,
106    pub configuration: AudioCapturerConfiguration,
107    pub audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
108}
109
110impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
111    for AudioCoreCreateAudioCapturerWithConfigurationRequest
112{
113}
114
115#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
116pub struct AudioCoreCreateAudioRendererRequest {
117    pub audio_out_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
118}
119
120impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
121    for AudioCoreCreateAudioRendererRequest
122{
123}
124
125#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
126pub struct AudioCreateAudioCapturerRequest {
127    pub audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
128    pub loopback: bool,
129}
130
131impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
132    for AudioCreateAudioCapturerRequest
133{
134}
135
136#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
137pub struct AudioCreateAudioRendererRequest {
138    pub audio_renderer_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
139}
140
141impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
142    for AudioCreateAudioRendererRequest
143{
144}
145
146#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
147pub struct AudioDeviceEnumeratorAddDeviceByChannelRequest {
148    pub device_name: String,
149    pub is_input: bool,
150    pub channel:
151        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_hardware_audio::StreamConfigMarker>,
152}
153
154impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
155    for AudioDeviceEnumeratorAddDeviceByChannelRequest
156{
157}
158
159#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
160pub struct AudioRendererBindGainControlRequest {
161    pub gain_control_request:
162        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
163}
164
165impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
166    for AudioRendererBindGainControlRequest
167{
168}
169
170#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
171pub struct AudioRendererGetReferenceClockResponse {
172    pub reference_clock: fdomain_client::Clock,
173}
174
175impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
176    for AudioRendererGetReferenceClockResponse
177{
178}
179
180#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
181pub struct AudioRendererSetReferenceClockRequest {
182    pub reference_clock: Option<fdomain_client::Clock>,
183}
184
185impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
186    for AudioRendererSetReferenceClockRequest
187{
188}
189
190#[derive(Debug, PartialEq, PartialOrd)]
191pub struct ProfileProviderRegisterHandlerWithCapacityRequest {
192    pub thread_handle: fdomain_client::Thread,
193    pub name: String,
194    pub period: i64,
195    pub capacity: f32,
196}
197
198impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
199    for ProfileProviderRegisterHandlerWithCapacityRequest
200{
201}
202
203#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
204pub struct ProfileProviderRegisterMemoryRangeRequest {
205    pub vmar_handle: fdomain_client::Vmar,
206    pub name: String,
207}
208
209impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
210    for ProfileProviderRegisterMemoryRangeRequest
211{
212}
213
214#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
215pub struct ProfileProviderUnregisterHandlerRequest {
216    pub thread_handle: fdomain_client::Thread,
217    pub name: String,
218}
219
220impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
221    for ProfileProviderUnregisterHandlerRequest
222{
223}
224
225#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
226pub struct ProfileProviderUnregisterMemoryRangeRequest {
227    pub vmar_handle: fdomain_client::Vmar,
228}
229
230impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
231    for ProfileProviderUnregisterMemoryRangeRequest
232{
233}
234
235#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
236pub struct SessionAudioConsumerFactoryCreateAudioConsumerRequest {
237    pub session_id: u64,
238    pub audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
239}
240
241impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
242    for SessionAudioConsumerFactoryCreateAudioConsumerRequest
243{
244}
245
246#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
247pub struct StreamBufferSetAddPayloadBufferRequest {
248    pub id: u32,
249    pub payload_buffer: fdomain_client::Vmo,
250}
251
252impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
253    for StreamBufferSetAddPayloadBufferRequest
254{
255}
256
257#[derive(Debug, PartialEq)]
258pub struct StreamProcessorSetInputBufferPartialSettingsRequest {
259    pub input_settings: StreamBufferPartialSettings,
260}
261
262impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
263    for StreamProcessorSetInputBufferPartialSettingsRequest
264{
265}
266
267#[derive(Debug, PartialEq)]
268pub struct StreamProcessorSetOutputBufferPartialSettingsRequest {
269    pub output_settings: StreamBufferPartialSettings,
270}
271
272impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
273    for StreamProcessorSetOutputBufferPartialSettingsRequest
274{
275}
276
277#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
278pub struct Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
279    pub usage: AudioRenderUsage2,
280    pub audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
281}
282
283impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
284    for Usage2AudioConsumerFactoryCreateAudioConsumerRequest
285{
286}
287
288#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
289pub struct UsageAudioConsumerFactoryCreateAudioConsumerRequest {
290    pub usage: AudioRenderUsage,
291    pub audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
292}
293
294impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
295    for UsageAudioConsumerFactoryCreateAudioConsumerRequest
296{
297}
298
299#[derive(Debug, PartialEq)]
300pub struct UsageGainReporterRegisterListener2Request {
301    pub device_unique_id: String,
302    pub usage: Usage2,
303    pub usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
304}
305
306impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
307    for UsageGainReporterRegisterListener2Request
308{
309}
310
311#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
312pub struct UsageGainReporterRegisterListenerRequest {
313    pub device_unique_id: String,
314    pub usage: Usage,
315    pub usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
316}
317
318impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
319    for UsageGainReporterRegisterListenerRequest
320{
321}
322
323#[derive(Debug, PartialEq)]
324pub struct UsageReporterWatch2Request {
325    pub usage: Usage2,
326    pub usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>,
327}
328
329impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for UsageReporterWatch2Request {}
330
331#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
332pub struct UsageReporterWatchRequest {
333    pub usage: Usage,
334    pub usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcherMarker>,
335}
336
337impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for UsageReporterWatchRequest {}
338
339#[derive(Debug, Default, PartialEq)]
340pub struct StreamBufferPartialSettings {
341    /// The containing message starts a new buffer_lifetime_ordinal.
342    ///
343    /// There is a separate buffer_lifetime_ordinal for input vs. output.
344    ///
345    /// Re-use of the same value is not allowed.  Values must be odd.  Values
346    /// must only increase (increasing by more than 2 is permitted).
347    ///
348    /// A buffer_lifetime_ordinal lifetime starts at SetInputBufferSettings() or
349    /// SetOutputBufferSettings(), and ends at the earlier of
350    /// CloseCurrentStream() with release_input_buffers/release_output_buffers
351    /// set or SetOutputBufferSettings() with new buffer_lifetime_ordinal in the
352    /// case of mid-stream output config change.
353    pub buffer_lifetime_ordinal: Option<u64>,
354    /// This value indicates which version of constraints the client is/was aware
355    /// of so far.
356    ///
357    /// For input, this must always be 0 because constraints don't change for
358    /// input (settings can change, but there's no settings vs current
359    /// constraints synchronization issue on input).
360    ///
361    /// For output, this allows the server to know when the client is
362    /// sufficiently caught up before the server will generate any more output.
363    ///
364    /// When there is no active stream, a client is permitted to re-configure
365    /// buffers again using the same buffer_constraints_version_ordinal.
366    pub buffer_constraints_version_ordinal: Option<u64>,
367    pub single_buffer_mode: Option<bool>,
368    pub packet_count_for_server: Option<u32>,
369    pub packet_count_for_client: Option<u32>,
370    pub sysmem_token: Option<
371        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_sysmem::BufferCollectionTokenMarker>,
372    >,
373    /// The client end of a BufferCollectionToken channel, which the
374    /// StreamProcessor will use to deliver constraints to sysmem and learn of
375    /// buffers allocated by sysmem.
376    ///
377    /// The client guarantees that the token is already known to sysmem (via
378    /// BufferCollectionToken.Sync(), BufferCollection.Sync(), or
379    /// BufferCollectionEvents.OnDuplicatedTokensKnownByServer()).
380    pub sysmem2_token: Option<
381        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker>,
382    >,
383    #[doc(hidden)]
384    pub __source_breaking: fidl::marker::SourceBreaking,
385}
386
387impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
388    for StreamBufferPartialSettings
389{
390}
391
392#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
393pub struct ActivityReporterMarker;
394
395impl fdomain_client::fidl::ProtocolMarker for ActivityReporterMarker {
396    type Proxy = ActivityReporterProxy;
397    type RequestStream = ActivityReporterRequestStream;
398
399    const DEBUG_NAME: &'static str = "fuchsia.media.ActivityReporter";
400}
401impl fdomain_client::fidl::DiscoverableProtocolMarker for ActivityReporterMarker {}
402
403pub trait ActivityReporterProxyInterface: Send + Sync {
404    type WatchRenderActivityResponseFut: std::future::Future<Output = Result<Vec<AudioRenderUsage>, fidl::Error>>
405        + Send;
406    fn r#watch_render_activity(&self) -> Self::WatchRenderActivityResponseFut;
407    type WatchRenderActivity2ResponseFut: std::future::Future<Output = Result<Vec<AudioRenderUsage2>, fidl::Error>>
408        + Send;
409    fn r#watch_render_activity2(&self) -> Self::WatchRenderActivity2ResponseFut;
410    type WatchCaptureActivityResponseFut: std::future::Future<Output = Result<Vec<AudioCaptureUsage>, fidl::Error>>
411        + Send;
412    fn r#watch_capture_activity(&self) -> Self::WatchCaptureActivityResponseFut;
413    type WatchCaptureActivity2ResponseFut: std::future::Future<Output = Result<Vec<AudioCaptureUsage2>, fidl::Error>>
414        + Send;
415    fn r#watch_capture_activity2(&self) -> Self::WatchCaptureActivity2ResponseFut;
416}
417
418#[derive(Debug, Clone)]
419pub struct ActivityReporterProxy {
420    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
421}
422
423impl fdomain_client::fidl::Proxy for ActivityReporterProxy {
424    type Protocol = ActivityReporterMarker;
425
426    fn from_channel(inner: fdomain_client::Channel) -> Self {
427        Self::new(inner)
428    }
429
430    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
431        self.client.into_channel().map_err(|client| Self { client })
432    }
433
434    fn as_channel(&self) -> &fdomain_client::Channel {
435        self.client.as_channel()
436    }
437}
438
439impl ActivityReporterProxy {
440    /// Create a new Proxy for fuchsia.media/ActivityReporter.
441    pub fn new(channel: fdomain_client::Channel) -> Self {
442        let protocol_name =
443            <ActivityReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
444        Self { client: fidl::client::Client::new(channel, protocol_name) }
445    }
446
447    /// Get a Stream of events from the remote end of the protocol.
448    ///
449    /// # Panics
450    ///
451    /// Panics if the event stream was already taken.
452    pub fn take_event_stream(&self) -> ActivityReporterEventStream {
453        ActivityReporterEventStream { event_receiver: self.client.take_event_receiver() }
454    }
455
456    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
457    /// It returns immediately the first time that it is called.
458    pub fn r#watch_render_activity(
459        &self,
460    ) -> fidl::client::QueryResponseFut<
461        Vec<AudioRenderUsage>,
462        fdomain_client::fidl::FDomainResourceDialect,
463    > {
464        ActivityReporterProxyInterface::r#watch_render_activity(self)
465    }
466
467    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
468    /// It returns immediately the first time that it is called.
469    pub fn r#watch_render_activity2(
470        &self,
471    ) -> fidl::client::QueryResponseFut<
472        Vec<AudioRenderUsage2>,
473        fdomain_client::fidl::FDomainResourceDialect,
474    > {
475        ActivityReporterProxyInterface::r#watch_render_activity2(self)
476    }
477
478    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
479    /// It returns immediately the first time that it is called.
480    pub fn r#watch_capture_activity(
481        &self,
482    ) -> fidl::client::QueryResponseFut<
483        Vec<AudioCaptureUsage>,
484        fdomain_client::fidl::FDomainResourceDialect,
485    > {
486        ActivityReporterProxyInterface::r#watch_capture_activity(self)
487    }
488
489    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
490    /// It returns immediately the first time that it is called.
491    pub fn r#watch_capture_activity2(
492        &self,
493    ) -> fidl::client::QueryResponseFut<
494        Vec<AudioCaptureUsage2>,
495        fdomain_client::fidl::FDomainResourceDialect,
496    > {
497        ActivityReporterProxyInterface::r#watch_capture_activity2(self)
498    }
499}
500
501impl ActivityReporterProxyInterface for ActivityReporterProxy {
502    type WatchRenderActivityResponseFut = fidl::client::QueryResponseFut<
503        Vec<AudioRenderUsage>,
504        fdomain_client::fidl::FDomainResourceDialect,
505    >;
506    fn r#watch_render_activity(&self) -> Self::WatchRenderActivityResponseFut {
507        fn _decode(
508            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
509        ) -> Result<Vec<AudioRenderUsage>, fidl::Error> {
510            let _response = fidl::client::decode_transaction_body::<
511                ActivityReporterWatchRenderActivityResponse,
512                fdomain_client::fidl::FDomainResourceDialect,
513                0x2974e9f5880b2f1f,
514            >(_buf?)?;
515            Ok(_response.active_usages)
516        }
517        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioRenderUsage>>(
518            (),
519            0x2974e9f5880b2f1f,
520            fidl::encoding::DynamicFlags::empty(),
521            _decode,
522        )
523    }
524
525    type WatchRenderActivity2ResponseFut = fidl::client::QueryResponseFut<
526        Vec<AudioRenderUsage2>,
527        fdomain_client::fidl::FDomainResourceDialect,
528    >;
529    fn r#watch_render_activity2(&self) -> Self::WatchRenderActivity2ResponseFut {
530        fn _decode(
531            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
532        ) -> Result<Vec<AudioRenderUsage2>, fidl::Error> {
533            let _response = fidl::client::decode_transaction_body::<
534                fidl::encoding::FlexibleType<ActivityReporterWatchRenderActivity2Response>,
535                fdomain_client::fidl::FDomainResourceDialect,
536                0x484236fc11b363e6,
537            >(_buf?)?
538            .into_result_fdomain::<ActivityReporterMarker>("watch_render_activity2")?;
539            Ok(_response.active_usages)
540        }
541        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioRenderUsage2>>(
542            (),
543            0x484236fc11b363e6,
544            fidl::encoding::DynamicFlags::FLEXIBLE,
545            _decode,
546        )
547    }
548
549    type WatchCaptureActivityResponseFut = fidl::client::QueryResponseFut<
550        Vec<AudioCaptureUsage>,
551        fdomain_client::fidl::FDomainResourceDialect,
552    >;
553    fn r#watch_capture_activity(&self) -> Self::WatchCaptureActivityResponseFut {
554        fn _decode(
555            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
556        ) -> Result<Vec<AudioCaptureUsage>, fidl::Error> {
557            let _response = fidl::client::decode_transaction_body::<
558                ActivityReporterWatchCaptureActivityResponse,
559                fdomain_client::fidl::FDomainResourceDialect,
560                0x70e7038e9658e128,
561            >(_buf?)?;
562            Ok(_response.active_usages)
563        }
564        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioCaptureUsage>>(
565            (),
566            0x70e7038e9658e128,
567            fidl::encoding::DynamicFlags::empty(),
568            _decode,
569        )
570    }
571
572    type WatchCaptureActivity2ResponseFut = fidl::client::QueryResponseFut<
573        Vec<AudioCaptureUsage2>,
574        fdomain_client::fidl::FDomainResourceDialect,
575    >;
576    fn r#watch_capture_activity2(&self) -> Self::WatchCaptureActivity2ResponseFut {
577        fn _decode(
578            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
579        ) -> Result<Vec<AudioCaptureUsage2>, fidl::Error> {
580            let _response = fidl::client::decode_transaction_body::<
581                fidl::encoding::FlexibleType<ActivityReporterWatchCaptureActivity2Response>,
582                fdomain_client::fidl::FDomainResourceDialect,
583                0x3d137e0364f9d550,
584            >(_buf?)?
585            .into_result_fdomain::<ActivityReporterMarker>("watch_capture_activity2")?;
586            Ok(_response.active_usages)
587        }
588        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioCaptureUsage2>>(
589            (),
590            0x3d137e0364f9d550,
591            fidl::encoding::DynamicFlags::FLEXIBLE,
592            _decode,
593        )
594    }
595}
596
597pub struct ActivityReporterEventStream {
598    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
599}
600
601impl std::marker::Unpin for ActivityReporterEventStream {}
602
603impl futures::stream::FusedStream for ActivityReporterEventStream {
604    fn is_terminated(&self) -> bool {
605        self.event_receiver.is_terminated()
606    }
607}
608
609impl futures::Stream for ActivityReporterEventStream {
610    type Item = Result<ActivityReporterEvent, fidl::Error>;
611
612    fn poll_next(
613        mut self: std::pin::Pin<&mut Self>,
614        cx: &mut std::task::Context<'_>,
615    ) -> std::task::Poll<Option<Self::Item>> {
616        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
617            &mut self.event_receiver,
618            cx
619        )?) {
620            Some(buf) => std::task::Poll::Ready(Some(ActivityReporterEvent::decode(buf))),
621            None => std::task::Poll::Ready(None),
622        }
623    }
624}
625
626#[derive(Debug)]
627pub enum ActivityReporterEvent {
628    #[non_exhaustive]
629    _UnknownEvent {
630        /// Ordinal of the event that was sent.
631        ordinal: u64,
632    },
633}
634
635impl ActivityReporterEvent {
636    /// Decodes a message buffer as a [`ActivityReporterEvent`].
637    fn decode(
638        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
639    ) -> Result<ActivityReporterEvent, fidl::Error> {
640        let (bytes, _handles) = buf.split_mut();
641        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
642        debug_assert_eq!(tx_header.tx_id, 0);
643        match tx_header.ordinal {
644            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
645                Ok(ActivityReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
646            }
647            _ => Err(fidl::Error::UnknownOrdinal {
648                ordinal: tx_header.ordinal,
649                protocol_name:
650                    <ActivityReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
651            }),
652        }
653    }
654}
655
656/// A Stream of incoming requests for fuchsia.media/ActivityReporter.
657pub struct ActivityReporterRequestStream {
658    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
659    is_terminated: bool,
660}
661
662impl std::marker::Unpin for ActivityReporterRequestStream {}
663
664impl futures::stream::FusedStream for ActivityReporterRequestStream {
665    fn is_terminated(&self) -> bool {
666        self.is_terminated
667    }
668}
669
670impl fdomain_client::fidl::RequestStream for ActivityReporterRequestStream {
671    type Protocol = ActivityReporterMarker;
672    type ControlHandle = ActivityReporterControlHandle;
673
674    fn from_channel(channel: fdomain_client::Channel) -> Self {
675        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
676    }
677
678    fn control_handle(&self) -> Self::ControlHandle {
679        ActivityReporterControlHandle { inner: self.inner.clone() }
680    }
681
682    fn into_inner(
683        self,
684    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
685    {
686        (self.inner, self.is_terminated)
687    }
688
689    fn from_inner(
690        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
691        is_terminated: bool,
692    ) -> Self {
693        Self { inner, is_terminated }
694    }
695}
696
697impl futures::Stream for ActivityReporterRequestStream {
698    type Item = Result<ActivityReporterRequest, fidl::Error>;
699
700    fn poll_next(
701        mut self: std::pin::Pin<&mut Self>,
702        cx: &mut std::task::Context<'_>,
703    ) -> std::task::Poll<Option<Self::Item>> {
704        let this = &mut *self;
705        if this.inner.check_shutdown(cx) {
706            this.is_terminated = true;
707            return std::task::Poll::Ready(None);
708        }
709        if this.is_terminated {
710            panic!("polled ActivityReporterRequestStream after completion");
711        }
712        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
713            |bytes, handles| {
714                match this.inner.channel().read_etc(cx, bytes, handles) {
715                    std::task::Poll::Ready(Ok(())) => {}
716                    std::task::Poll::Pending => return std::task::Poll::Pending,
717                    std::task::Poll::Ready(Err(None)) => {
718                        this.is_terminated = true;
719                        return std::task::Poll::Ready(None);
720                    }
721                    std::task::Poll::Ready(Err(Some(e))) => {
722                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
723                            e.into(),
724                        ))));
725                    }
726                }
727
728                // A message has been received from the channel
729                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
730
731                std::task::Poll::Ready(Some(match header.ordinal {
732                0x2974e9f5880b2f1f => {
733                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
734                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
735                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
736                    let control_handle = ActivityReporterControlHandle {
737                        inner: this.inner.clone(),
738                    };
739                    Ok(ActivityReporterRequest::WatchRenderActivity {
740                        responder: ActivityReporterWatchRenderActivityResponder {
741                            control_handle: std::mem::ManuallyDrop::new(control_handle),
742                            tx_id: header.tx_id,
743                        },
744                    })
745                }
746                0x484236fc11b363e6 => {
747                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
748                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
749                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
750                    let control_handle = ActivityReporterControlHandle {
751                        inner: this.inner.clone(),
752                    };
753                    Ok(ActivityReporterRequest::WatchRenderActivity2 {
754                        responder: ActivityReporterWatchRenderActivity2Responder {
755                            control_handle: std::mem::ManuallyDrop::new(control_handle),
756                            tx_id: header.tx_id,
757                        },
758                    })
759                }
760                0x70e7038e9658e128 => {
761                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
762                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
763                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
764                    let control_handle = ActivityReporterControlHandle {
765                        inner: this.inner.clone(),
766                    };
767                    Ok(ActivityReporterRequest::WatchCaptureActivity {
768                        responder: ActivityReporterWatchCaptureActivityResponder {
769                            control_handle: std::mem::ManuallyDrop::new(control_handle),
770                            tx_id: header.tx_id,
771                        },
772                    })
773                }
774                0x3d137e0364f9d550 => {
775                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
776                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
777                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
778                    let control_handle = ActivityReporterControlHandle {
779                        inner: this.inner.clone(),
780                    };
781                    Ok(ActivityReporterRequest::WatchCaptureActivity2 {
782                        responder: ActivityReporterWatchCaptureActivity2Responder {
783                            control_handle: std::mem::ManuallyDrop::new(control_handle),
784                            tx_id: header.tx_id,
785                        },
786                    })
787                }
788                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
789                    Ok(ActivityReporterRequest::_UnknownMethod {
790                        ordinal: header.ordinal,
791                        control_handle: ActivityReporterControlHandle { inner: this.inner.clone() },
792                        method_type: fidl::MethodType::OneWay,
793                    })
794                }
795                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
796                    this.inner.send_framework_err(
797                        fidl::encoding::FrameworkErr::UnknownMethod,
798                        header.tx_id,
799                        header.ordinal,
800                        header.dynamic_flags(),
801                        (bytes, handles),
802                    )?;
803                    Ok(ActivityReporterRequest::_UnknownMethod {
804                        ordinal: header.ordinal,
805                        control_handle: ActivityReporterControlHandle { inner: this.inner.clone() },
806                        method_type: fidl::MethodType::TwoWay,
807                    })
808                }
809                _ => Err(fidl::Error::UnknownOrdinal {
810                    ordinal: header.ordinal,
811                    protocol_name: <ActivityReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
812                }),
813            }))
814            },
815        )
816    }
817}
818
819/// A protocol for monitoring the usage activity of the AudioRenderers and AudioCapturers.
820#[derive(Debug)]
821pub enum ActivityReporterRequest {
822    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
823    /// It returns immediately the first time that it is called.
824    WatchRenderActivity { responder: ActivityReporterWatchRenderActivityResponder },
825    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
826    /// It returns immediately the first time that it is called.
827    WatchRenderActivity2 { responder: ActivityReporterWatchRenderActivity2Responder },
828    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
829    /// It returns immediately the first time that it is called.
830    WatchCaptureActivity { responder: ActivityReporterWatchCaptureActivityResponder },
831    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
832    /// It returns immediately the first time that it is called.
833    WatchCaptureActivity2 { responder: ActivityReporterWatchCaptureActivity2Responder },
834    /// An interaction was received which does not match any known method.
835    #[non_exhaustive]
836    _UnknownMethod {
837        /// Ordinal of the method that was called.
838        ordinal: u64,
839        control_handle: ActivityReporterControlHandle,
840        method_type: fidl::MethodType,
841    },
842}
843
844impl ActivityReporterRequest {
845    #[allow(irrefutable_let_patterns)]
846    pub fn into_watch_render_activity(
847        self,
848    ) -> Option<(ActivityReporterWatchRenderActivityResponder)> {
849        if let ActivityReporterRequest::WatchRenderActivity { responder } = self {
850            Some((responder))
851        } else {
852            None
853        }
854    }
855
856    #[allow(irrefutable_let_patterns)]
857    pub fn into_watch_render_activity2(
858        self,
859    ) -> Option<(ActivityReporterWatchRenderActivity2Responder)> {
860        if let ActivityReporterRequest::WatchRenderActivity2 { responder } = self {
861            Some((responder))
862        } else {
863            None
864        }
865    }
866
867    #[allow(irrefutable_let_patterns)]
868    pub fn into_watch_capture_activity(
869        self,
870    ) -> Option<(ActivityReporterWatchCaptureActivityResponder)> {
871        if let ActivityReporterRequest::WatchCaptureActivity { responder } = self {
872            Some((responder))
873        } else {
874            None
875        }
876    }
877
878    #[allow(irrefutable_let_patterns)]
879    pub fn into_watch_capture_activity2(
880        self,
881    ) -> Option<(ActivityReporterWatchCaptureActivity2Responder)> {
882        if let ActivityReporterRequest::WatchCaptureActivity2 { responder } = self {
883            Some((responder))
884        } else {
885            None
886        }
887    }
888
889    /// Name of the method defined in FIDL
890    pub fn method_name(&self) -> &'static str {
891        match *self {
892            ActivityReporterRequest::WatchRenderActivity { .. } => "watch_render_activity",
893            ActivityReporterRequest::WatchRenderActivity2 { .. } => "watch_render_activity2",
894            ActivityReporterRequest::WatchCaptureActivity { .. } => "watch_capture_activity",
895            ActivityReporterRequest::WatchCaptureActivity2 { .. } => "watch_capture_activity2",
896            ActivityReporterRequest::_UnknownMethod {
897                method_type: fidl::MethodType::OneWay,
898                ..
899            } => "unknown one-way method",
900            ActivityReporterRequest::_UnknownMethod {
901                method_type: fidl::MethodType::TwoWay,
902                ..
903            } => "unknown two-way method",
904        }
905    }
906}
907
908#[derive(Debug, Clone)]
909pub struct ActivityReporterControlHandle {
910    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
911}
912
913impl fdomain_client::fidl::ControlHandle for ActivityReporterControlHandle {
914    fn shutdown(&self) {
915        self.inner.shutdown()
916    }
917
918    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
919        self.inner.shutdown_with_epitaph(status)
920    }
921
922    fn is_closed(&self) -> bool {
923        self.inner.channel().is_closed()
924    }
925    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
926        self.inner.channel().on_closed()
927    }
928}
929
930impl ActivityReporterControlHandle {}
931
932#[must_use = "FIDL methods require a response to be sent"]
933#[derive(Debug)]
934pub struct ActivityReporterWatchRenderActivityResponder {
935    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
936    tx_id: u32,
937}
938
939/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
940/// if the responder is dropped without sending a response, so that the client
941/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
942impl std::ops::Drop for ActivityReporterWatchRenderActivityResponder {
943    fn drop(&mut self) {
944        self.control_handle.shutdown();
945        // Safety: drops once, never accessed again
946        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
947    }
948}
949
950impl fdomain_client::fidl::Responder for ActivityReporterWatchRenderActivityResponder {
951    type ControlHandle = ActivityReporterControlHandle;
952
953    fn control_handle(&self) -> &ActivityReporterControlHandle {
954        &self.control_handle
955    }
956
957    fn drop_without_shutdown(mut self) {
958        // Safety: drops once, never accessed again due to mem::forget
959        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
960        // Prevent Drop from running (which would shut down the channel)
961        std::mem::forget(self);
962    }
963}
964
965impl ActivityReporterWatchRenderActivityResponder {
966    /// Sends a response to the FIDL transaction.
967    ///
968    /// Sets the channel to shutdown if an error occurs.
969    pub fn send(self, mut active_usages: &[AudioRenderUsage]) -> Result<(), fidl::Error> {
970        let _result = self.send_raw(active_usages);
971        if _result.is_err() {
972            self.control_handle.shutdown();
973        }
974        self.drop_without_shutdown();
975        _result
976    }
977
978    /// Similar to "send" but does not shutdown the channel if an error occurs.
979    pub fn send_no_shutdown_on_err(
980        self,
981        mut active_usages: &[AudioRenderUsage],
982    ) -> Result<(), fidl::Error> {
983        let _result = self.send_raw(active_usages);
984        self.drop_without_shutdown();
985        _result
986    }
987
988    fn send_raw(&self, mut active_usages: &[AudioRenderUsage]) -> Result<(), fidl::Error> {
989        self.control_handle.inner.send::<ActivityReporterWatchRenderActivityResponse>(
990            (active_usages,),
991            self.tx_id,
992            0x2974e9f5880b2f1f,
993            fidl::encoding::DynamicFlags::empty(),
994        )
995    }
996}
997
998#[must_use = "FIDL methods require a response to be sent"]
999#[derive(Debug)]
1000pub struct ActivityReporterWatchRenderActivity2Responder {
1001    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1002    tx_id: u32,
1003}
1004
1005/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1006/// if the responder is dropped without sending a response, so that the client
1007/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1008impl std::ops::Drop for ActivityReporterWatchRenderActivity2Responder {
1009    fn drop(&mut self) {
1010        self.control_handle.shutdown();
1011        // Safety: drops once, never accessed again
1012        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1013    }
1014}
1015
1016impl fdomain_client::fidl::Responder for ActivityReporterWatchRenderActivity2Responder {
1017    type ControlHandle = ActivityReporterControlHandle;
1018
1019    fn control_handle(&self) -> &ActivityReporterControlHandle {
1020        &self.control_handle
1021    }
1022
1023    fn drop_without_shutdown(mut self) {
1024        // Safety: drops once, never accessed again due to mem::forget
1025        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1026        // Prevent Drop from running (which would shut down the channel)
1027        std::mem::forget(self);
1028    }
1029}
1030
1031impl ActivityReporterWatchRenderActivity2Responder {
1032    /// Sends a response to the FIDL transaction.
1033    ///
1034    /// Sets the channel to shutdown if an error occurs.
1035    pub fn send(self, mut active_usages: &[AudioRenderUsage2]) -> Result<(), fidl::Error> {
1036        let _result = self.send_raw(active_usages);
1037        if _result.is_err() {
1038            self.control_handle.shutdown();
1039        }
1040        self.drop_without_shutdown();
1041        _result
1042    }
1043
1044    /// Similar to "send" but does not shutdown the channel if an error occurs.
1045    pub fn send_no_shutdown_on_err(
1046        self,
1047        mut active_usages: &[AudioRenderUsage2],
1048    ) -> Result<(), fidl::Error> {
1049        let _result = self.send_raw(active_usages);
1050        self.drop_without_shutdown();
1051        _result
1052    }
1053
1054    fn send_raw(&self, mut active_usages: &[AudioRenderUsage2]) -> Result<(), fidl::Error> {
1055        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1056            ActivityReporterWatchRenderActivity2Response,
1057        >>(
1058            fidl::encoding::Flexible::new((active_usages,)),
1059            self.tx_id,
1060            0x484236fc11b363e6,
1061            fidl::encoding::DynamicFlags::FLEXIBLE,
1062        )
1063    }
1064}
1065
1066#[must_use = "FIDL methods require a response to be sent"]
1067#[derive(Debug)]
1068pub struct ActivityReporterWatchCaptureActivityResponder {
1069    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1070    tx_id: u32,
1071}
1072
1073/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1074/// if the responder is dropped without sending a response, so that the client
1075/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1076impl std::ops::Drop for ActivityReporterWatchCaptureActivityResponder {
1077    fn drop(&mut self) {
1078        self.control_handle.shutdown();
1079        // Safety: drops once, never accessed again
1080        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1081    }
1082}
1083
1084impl fdomain_client::fidl::Responder for ActivityReporterWatchCaptureActivityResponder {
1085    type ControlHandle = ActivityReporterControlHandle;
1086
1087    fn control_handle(&self) -> &ActivityReporterControlHandle {
1088        &self.control_handle
1089    }
1090
1091    fn drop_without_shutdown(mut self) {
1092        // Safety: drops once, never accessed again due to mem::forget
1093        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1094        // Prevent Drop from running (which would shut down the channel)
1095        std::mem::forget(self);
1096    }
1097}
1098
1099impl ActivityReporterWatchCaptureActivityResponder {
1100    /// Sends a response to the FIDL transaction.
1101    ///
1102    /// Sets the channel to shutdown if an error occurs.
1103    pub fn send(self, mut active_usages: &[AudioCaptureUsage]) -> Result<(), fidl::Error> {
1104        let _result = self.send_raw(active_usages);
1105        if _result.is_err() {
1106            self.control_handle.shutdown();
1107        }
1108        self.drop_without_shutdown();
1109        _result
1110    }
1111
1112    /// Similar to "send" but does not shutdown the channel if an error occurs.
1113    pub fn send_no_shutdown_on_err(
1114        self,
1115        mut active_usages: &[AudioCaptureUsage],
1116    ) -> Result<(), fidl::Error> {
1117        let _result = self.send_raw(active_usages);
1118        self.drop_without_shutdown();
1119        _result
1120    }
1121
1122    fn send_raw(&self, mut active_usages: &[AudioCaptureUsage]) -> Result<(), fidl::Error> {
1123        self.control_handle.inner.send::<ActivityReporterWatchCaptureActivityResponse>(
1124            (active_usages,),
1125            self.tx_id,
1126            0x70e7038e9658e128,
1127            fidl::encoding::DynamicFlags::empty(),
1128        )
1129    }
1130}
1131
1132#[must_use = "FIDL methods require a response to be sent"]
1133#[derive(Debug)]
1134pub struct ActivityReporterWatchCaptureActivity2Responder {
1135    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1136    tx_id: u32,
1137}
1138
1139/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1140/// if the responder is dropped without sending a response, so that the client
1141/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1142impl std::ops::Drop for ActivityReporterWatchCaptureActivity2Responder {
1143    fn drop(&mut self) {
1144        self.control_handle.shutdown();
1145        // Safety: drops once, never accessed again
1146        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1147    }
1148}
1149
1150impl fdomain_client::fidl::Responder for ActivityReporterWatchCaptureActivity2Responder {
1151    type ControlHandle = ActivityReporterControlHandle;
1152
1153    fn control_handle(&self) -> &ActivityReporterControlHandle {
1154        &self.control_handle
1155    }
1156
1157    fn drop_without_shutdown(mut self) {
1158        // Safety: drops once, never accessed again due to mem::forget
1159        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1160        // Prevent Drop from running (which would shut down the channel)
1161        std::mem::forget(self);
1162    }
1163}
1164
1165impl ActivityReporterWatchCaptureActivity2Responder {
1166    /// Sends a response to the FIDL transaction.
1167    ///
1168    /// Sets the channel to shutdown if an error occurs.
1169    pub fn send(self, mut active_usages: &[AudioCaptureUsage2]) -> Result<(), fidl::Error> {
1170        let _result = self.send_raw(active_usages);
1171        if _result.is_err() {
1172            self.control_handle.shutdown();
1173        }
1174        self.drop_without_shutdown();
1175        _result
1176    }
1177
1178    /// Similar to "send" but does not shutdown the channel if an error occurs.
1179    pub fn send_no_shutdown_on_err(
1180        self,
1181        mut active_usages: &[AudioCaptureUsage2],
1182    ) -> Result<(), fidl::Error> {
1183        let _result = self.send_raw(active_usages);
1184        self.drop_without_shutdown();
1185        _result
1186    }
1187
1188    fn send_raw(&self, mut active_usages: &[AudioCaptureUsage2]) -> Result<(), fidl::Error> {
1189        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1190            ActivityReporterWatchCaptureActivity2Response,
1191        >>(
1192            fidl::encoding::Flexible::new((active_usages,)),
1193            self.tx_id,
1194            0x3d137e0364f9d550,
1195            fidl::encoding::DynamicFlags::FLEXIBLE,
1196        )
1197    }
1198}
1199
1200#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1201pub struct AudioMarker;
1202
1203impl fdomain_client::fidl::ProtocolMarker for AudioMarker {
1204    type Proxy = AudioProxy;
1205    type RequestStream = AudioRequestStream;
1206
1207    const DEBUG_NAME: &'static str = "fuchsia.media.Audio";
1208}
1209impl fdomain_client::fidl::DiscoverableProtocolMarker for AudioMarker {}
1210
1211pub trait AudioProxyInterface: Send + Sync {
1212    fn r#create_audio_renderer(
1213        &self,
1214        audio_renderer_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
1215    ) -> Result<(), fidl::Error>;
1216    fn r#create_audio_capturer(
1217        &self,
1218        audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
1219        loopback: bool,
1220    ) -> Result<(), fidl::Error>;
1221}
1222
1223#[derive(Debug, Clone)]
1224pub struct AudioProxy {
1225    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
1226}
1227
1228impl fdomain_client::fidl::Proxy for AudioProxy {
1229    type Protocol = AudioMarker;
1230
1231    fn from_channel(inner: fdomain_client::Channel) -> Self {
1232        Self::new(inner)
1233    }
1234
1235    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
1236        self.client.into_channel().map_err(|client| Self { client })
1237    }
1238
1239    fn as_channel(&self) -> &fdomain_client::Channel {
1240        self.client.as_channel()
1241    }
1242}
1243
1244impl AudioProxy {
1245    /// Create a new Proxy for fuchsia.media/Audio.
1246    pub fn new(channel: fdomain_client::Channel) -> Self {
1247        let protocol_name = <AudioMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
1248        Self { client: fidl::client::Client::new(channel, protocol_name) }
1249    }
1250
1251    /// Get a Stream of events from the remote end of the protocol.
1252    ///
1253    /// # Panics
1254    ///
1255    /// Panics if the event stream was already taken.
1256    pub fn take_event_stream(&self) -> AudioEventStream {
1257        AudioEventStream { event_receiver: self.client.take_event_receiver() }
1258    }
1259
1260    pub fn r#create_audio_renderer(
1261        &self,
1262        mut audio_renderer_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
1263    ) -> Result<(), fidl::Error> {
1264        AudioProxyInterface::r#create_audio_renderer(self, audio_renderer_request)
1265    }
1266
1267    /// Creates an AudioCapturer which either captures from the current default
1268    /// audio input device, or loops-back from the current default audio output
1269    /// device based on value passed for the loopback flag.
1270    pub fn r#create_audio_capturer(
1271        &self,
1272        mut audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
1273        mut loopback: bool,
1274    ) -> Result<(), fidl::Error> {
1275        AudioProxyInterface::r#create_audio_capturer(self, audio_capturer_request, loopback)
1276    }
1277}
1278
1279impl AudioProxyInterface for AudioProxy {
1280    fn r#create_audio_renderer(
1281        &self,
1282        mut audio_renderer_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
1283    ) -> Result<(), fidl::Error> {
1284        self.client.send::<AudioCreateAudioRendererRequest>(
1285            (audio_renderer_request,),
1286            0x572f413566fd58f1,
1287            fidl::encoding::DynamicFlags::empty(),
1288        )
1289    }
1290
1291    fn r#create_audio_capturer(
1292        &self,
1293        mut audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
1294        mut loopback: bool,
1295    ) -> Result<(), fidl::Error> {
1296        self.client.send::<AudioCreateAudioCapturerRequest>(
1297            (audio_capturer_request, loopback),
1298            0x44660fc63a6202f,
1299            fidl::encoding::DynamicFlags::empty(),
1300        )
1301    }
1302}
1303
1304pub struct AudioEventStream {
1305    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
1306}
1307
1308impl std::marker::Unpin for AudioEventStream {}
1309
1310impl futures::stream::FusedStream for AudioEventStream {
1311    fn is_terminated(&self) -> bool {
1312        self.event_receiver.is_terminated()
1313    }
1314}
1315
1316impl futures::Stream for AudioEventStream {
1317    type Item = Result<AudioEvent, fidl::Error>;
1318
1319    fn poll_next(
1320        mut self: std::pin::Pin<&mut Self>,
1321        cx: &mut std::task::Context<'_>,
1322    ) -> std::task::Poll<Option<Self::Item>> {
1323        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1324            &mut self.event_receiver,
1325            cx
1326        )?) {
1327            Some(buf) => std::task::Poll::Ready(Some(AudioEvent::decode(buf))),
1328            None => std::task::Poll::Ready(None),
1329        }
1330    }
1331}
1332
1333#[derive(Debug)]
1334pub enum AudioEvent {}
1335
1336impl AudioEvent {
1337    /// Decodes a message buffer as a [`AudioEvent`].
1338    fn decode(
1339        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1340    ) -> Result<AudioEvent, fidl::Error> {
1341        let (bytes, _handles) = buf.split_mut();
1342        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1343        debug_assert_eq!(tx_header.tx_id, 0);
1344        match tx_header.ordinal {
1345            _ => Err(fidl::Error::UnknownOrdinal {
1346                ordinal: tx_header.ordinal,
1347                protocol_name: <AudioMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1348            }),
1349        }
1350    }
1351}
1352
1353/// A Stream of incoming requests for fuchsia.media/Audio.
1354pub struct AudioRequestStream {
1355    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1356    is_terminated: bool,
1357}
1358
1359impl std::marker::Unpin for AudioRequestStream {}
1360
1361impl futures::stream::FusedStream for AudioRequestStream {
1362    fn is_terminated(&self) -> bool {
1363        self.is_terminated
1364    }
1365}
1366
1367impl fdomain_client::fidl::RequestStream for AudioRequestStream {
1368    type Protocol = AudioMarker;
1369    type ControlHandle = AudioControlHandle;
1370
1371    fn from_channel(channel: fdomain_client::Channel) -> Self {
1372        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1373    }
1374
1375    fn control_handle(&self) -> Self::ControlHandle {
1376        AudioControlHandle { inner: self.inner.clone() }
1377    }
1378
1379    fn into_inner(
1380        self,
1381    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
1382    {
1383        (self.inner, self.is_terminated)
1384    }
1385
1386    fn from_inner(
1387        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1388        is_terminated: bool,
1389    ) -> Self {
1390        Self { inner, is_terminated }
1391    }
1392}
1393
1394impl futures::Stream for AudioRequestStream {
1395    type Item = Result<AudioRequest, fidl::Error>;
1396
1397    fn poll_next(
1398        mut self: std::pin::Pin<&mut Self>,
1399        cx: &mut std::task::Context<'_>,
1400    ) -> std::task::Poll<Option<Self::Item>> {
1401        let this = &mut *self;
1402        if this.inner.check_shutdown(cx) {
1403            this.is_terminated = true;
1404            return std::task::Poll::Ready(None);
1405        }
1406        if this.is_terminated {
1407            panic!("polled AudioRequestStream after completion");
1408        }
1409        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
1410            |bytes, handles| {
1411                match this.inner.channel().read_etc(cx, bytes, handles) {
1412                    std::task::Poll::Ready(Ok(())) => {}
1413                    std::task::Poll::Pending => return std::task::Poll::Pending,
1414                    std::task::Poll::Ready(Err(None)) => {
1415                        this.is_terminated = true;
1416                        return std::task::Poll::Ready(None);
1417                    }
1418                    std::task::Poll::Ready(Err(Some(e))) => {
1419                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1420                            e.into(),
1421                        ))));
1422                    }
1423                }
1424
1425                // A message has been received from the channel
1426                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1427
1428                std::task::Poll::Ready(Some(match header.ordinal {
1429                    0x572f413566fd58f1 => {
1430                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1431                        let mut req = fidl::new_empty!(
1432                            AudioCreateAudioRendererRequest,
1433                            fdomain_client::fidl::FDomainResourceDialect
1434                        );
1435                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCreateAudioRendererRequest>(&header, _body_bytes, handles, &mut req)?;
1436                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
1437                        Ok(AudioRequest::CreateAudioRenderer {
1438                            audio_renderer_request: req.audio_renderer_request,
1439
1440                            control_handle,
1441                        })
1442                    }
1443                    0x44660fc63a6202f => {
1444                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1445                        let mut req = fidl::new_empty!(
1446                            AudioCreateAudioCapturerRequest,
1447                            fdomain_client::fidl::FDomainResourceDialect
1448                        );
1449                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCreateAudioCapturerRequest>(&header, _body_bytes, handles, &mut req)?;
1450                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
1451                        Ok(AudioRequest::CreateAudioCapturer {
1452                            audio_capturer_request: req.audio_capturer_request,
1453                            loopback: req.loopback,
1454
1455                            control_handle,
1456                        })
1457                    }
1458                    _ => Err(fidl::Error::UnknownOrdinal {
1459                        ordinal: header.ordinal,
1460                        protocol_name:
1461                            <AudioMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1462                    }),
1463                }))
1464            },
1465        )
1466    }
1467}
1468
1469#[derive(Debug)]
1470pub enum AudioRequest {
1471    CreateAudioRenderer {
1472        audio_renderer_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
1473        control_handle: AudioControlHandle,
1474    },
1475    /// Creates an AudioCapturer which either captures from the current default
1476    /// audio input device, or loops-back from the current default audio output
1477    /// device based on value passed for the loopback flag.
1478    CreateAudioCapturer {
1479        audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
1480        loopback: bool,
1481        control_handle: AudioControlHandle,
1482    },
1483}
1484
1485impl AudioRequest {
1486    #[allow(irrefutable_let_patterns)]
1487    pub fn into_create_audio_renderer(
1488        self,
1489    ) -> Option<(fdomain_client::fidl::ServerEnd<AudioRendererMarker>, AudioControlHandle)> {
1490        if let AudioRequest::CreateAudioRenderer { audio_renderer_request, control_handle } = self {
1491            Some((audio_renderer_request, control_handle))
1492        } else {
1493            None
1494        }
1495    }
1496
1497    #[allow(irrefutable_let_patterns)]
1498    pub fn into_create_audio_capturer(
1499        self,
1500    ) -> Option<(fdomain_client::fidl::ServerEnd<AudioCapturerMarker>, bool, AudioControlHandle)>
1501    {
1502        if let AudioRequest::CreateAudioCapturer {
1503            audio_capturer_request,
1504            loopback,
1505            control_handle,
1506        } = self
1507        {
1508            Some((audio_capturer_request, loopback, control_handle))
1509        } else {
1510            None
1511        }
1512    }
1513
1514    /// Name of the method defined in FIDL
1515    pub fn method_name(&self) -> &'static str {
1516        match *self {
1517            AudioRequest::CreateAudioRenderer { .. } => "create_audio_renderer",
1518            AudioRequest::CreateAudioCapturer { .. } => "create_audio_capturer",
1519        }
1520    }
1521}
1522
1523#[derive(Debug, Clone)]
1524pub struct AudioControlHandle {
1525    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1526}
1527
1528impl fdomain_client::fidl::ControlHandle for AudioControlHandle {
1529    fn shutdown(&self) {
1530        self.inner.shutdown()
1531    }
1532
1533    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1534        self.inner.shutdown_with_epitaph(status)
1535    }
1536
1537    fn is_closed(&self) -> bool {
1538        self.inner.channel().is_closed()
1539    }
1540    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1541        self.inner.channel().on_closed()
1542    }
1543}
1544
1545impl AudioControlHandle {}
1546
1547#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1548pub struct AudioCapturerMarker;
1549
1550impl fdomain_client::fidl::ProtocolMarker for AudioCapturerMarker {
1551    type Proxy = AudioCapturerProxy;
1552    type RequestStream = AudioCapturerRequestStream;
1553
1554    const DEBUG_NAME: &'static str = "fuchsia.media.AudioCapturer";
1555}
1556impl fdomain_client::fidl::DiscoverableProtocolMarker for AudioCapturerMarker {}
1557
1558pub trait AudioCapturerProxyInterface: Send + Sync {
1559    fn r#add_payload_buffer(
1560        &self,
1561        id: u32,
1562        payload_buffer: fdomain_client::Vmo,
1563    ) -> Result<(), fidl::Error>;
1564    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
1565    fn r#release_packet(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
1566    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1567    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
1568    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
1569    fn r#set_pcm_stream_type(&self, stream_type: &AudioStreamType) -> Result<(), fidl::Error>;
1570    type CaptureAtResponseFut: std::future::Future<Output = Result<StreamPacket, fidl::Error>>
1571        + Send;
1572    fn r#capture_at(
1573        &self,
1574        payload_buffer_id: u32,
1575        payload_offset: u32,
1576        frames: u32,
1577    ) -> Self::CaptureAtResponseFut;
1578    fn r#start_async_capture(&self, frames_per_packet: u32) -> Result<(), fidl::Error>;
1579    type StopAsyncCaptureResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1580    fn r#stop_async_capture(&self) -> Self::StopAsyncCaptureResponseFut;
1581    fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error>;
1582    fn r#bind_gain_control(
1583        &self,
1584        gain_control_request: fdomain_client::fidl::ServerEnd<
1585            fdomain_fuchsia_media_audio::GainControlMarker,
1586        >,
1587    ) -> Result<(), fidl::Error>;
1588    type GetReferenceClockResponseFut: std::future::Future<Output = Result<fdomain_client::Clock, fidl::Error>>
1589        + Send;
1590    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
1591    fn r#set_reference_clock(
1592        &self,
1593        reference_clock: Option<fdomain_client::Clock>,
1594    ) -> Result<(), fidl::Error>;
1595    fn r#set_usage(&self, usage: AudioCaptureUsage) -> Result<(), fidl::Error>;
1596    fn r#set_usage2(&self, usage: AudioCaptureUsage2) -> Result<(), fidl::Error>;
1597    type GetStreamTypeResponseFut: std::future::Future<Output = Result<StreamType, fidl::Error>>
1598        + Send;
1599    fn r#get_stream_type(&self) -> Self::GetStreamTypeResponseFut;
1600}
1601
1602#[derive(Debug, Clone)]
1603pub struct AudioCapturerProxy {
1604    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
1605}
1606
1607impl fdomain_client::fidl::Proxy for AudioCapturerProxy {
1608    type Protocol = AudioCapturerMarker;
1609
1610    fn from_channel(inner: fdomain_client::Channel) -> Self {
1611        Self::new(inner)
1612    }
1613
1614    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
1615        self.client.into_channel().map_err(|client| Self { client })
1616    }
1617
1618    fn as_channel(&self) -> &fdomain_client::Channel {
1619        self.client.as_channel()
1620    }
1621}
1622
1623impl AudioCapturerProxy {
1624    /// Create a new Proxy for fuchsia.media/AudioCapturer.
1625    pub fn new(channel: fdomain_client::Channel) -> Self {
1626        let protocol_name =
1627            <AudioCapturerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
1628        Self { client: fidl::client::Client::new(channel, protocol_name) }
1629    }
1630
1631    /// Get a Stream of events from the remote end of the protocol.
1632    ///
1633    /// # Panics
1634    ///
1635    /// Panics if the event stream was already taken.
1636    pub fn take_event_stream(&self) -> AudioCapturerEventStream {
1637        AudioCapturerEventStream { event_receiver: self.client.take_event_receiver() }
1638    }
1639
1640    /// Adds a payload buffer to the current buffer set associated with the
1641    /// connection. A `StreamPacket` struct reference a payload buffer in the
1642    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
1643    ///
1644    /// A buffer with ID `id` must not be in the current set when this method is
1645    /// invoked, otherwise the service will close the connection.
1646    pub fn r#add_payload_buffer(
1647        &self,
1648        mut id: u32,
1649        mut payload_buffer: fdomain_client::Vmo,
1650    ) -> Result<(), fidl::Error> {
1651        AudioCapturerProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
1652    }
1653
1654    /// Removes a payload buffer from the current buffer set associated with the
1655    /// connection.
1656    ///
1657    /// A buffer with ID `id` must exist in the current set when this method is
1658    /// invoked, otherwise the service will will close the connection.
1659    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
1660        AudioCapturerProxyInterface::r#remove_payload_buffer(self, id)
1661    }
1662
1663    /// Releases payload memory associated with a packet previously delivered
1664    /// via `OnPacketProduced`.
1665    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
1666        AudioCapturerProxyInterface::r#release_packet(self, packet)
1667    }
1668
1669    pub fn r#discard_all_packets(
1670        &self,
1671    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
1672        AudioCapturerProxyInterface::r#discard_all_packets(self)
1673    }
1674
1675    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
1676        AudioCapturerProxyInterface::r#discard_all_packets_no_reply(self)
1677    }
1678
1679    /// Sets the stream type of the stream to be delivered. Causes the source
1680    /// material to be reformatted/resampled if needed in order to produce the
1681    /// requested stream type. Must be called before the payload buffer is
1682    /// established.
1683    pub fn r#set_pcm_stream_type(
1684        &self,
1685        mut stream_type: &AudioStreamType,
1686    ) -> Result<(), fidl::Error> {
1687        AudioCapturerProxyInterface::r#set_pcm_stream_type(self, stream_type)
1688    }
1689
1690    /// Explicitly specifies a region of the shared payload buffer for the audio
1691    /// input to capture into.
1692    pub fn r#capture_at(
1693        &self,
1694        mut payload_buffer_id: u32,
1695        mut payload_offset: u32,
1696        mut frames: u32,
1697    ) -> fidl::client::QueryResponseFut<StreamPacket, fdomain_client::fidl::FDomainResourceDialect>
1698    {
1699        AudioCapturerProxyInterface::r#capture_at(self, payload_buffer_id, payload_offset, frames)
1700    }
1701
1702    /// Places the AudioCapturer into 'async' capture mode and begin to produce
1703    /// packets of exactly 'frames_per_packet' number of frames each. The
1704    /// OnPacketProduced event (of StreamSink) will be used to inform the client
1705    /// of produced packets.
1706    pub fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
1707        AudioCapturerProxyInterface::r#start_async_capture(self, frames_per_packet)
1708    }
1709
1710    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
1711    /// that may be used by the client if explicit synchronization is needed.
1712    pub fn r#stop_async_capture(
1713        &self,
1714    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
1715        AudioCapturerProxyInterface::r#stop_async_capture(self)
1716    }
1717
1718    pub fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
1719        AudioCapturerProxyInterface::r#stop_async_capture_no_reply(self)
1720    }
1721
1722    /// Binds to the gain control for this AudioCapturer.
1723    pub fn r#bind_gain_control(
1724        &self,
1725        mut gain_control_request: fdomain_client::fidl::ServerEnd<
1726            fdomain_fuchsia_media_audio::GainControlMarker,
1727        >,
1728    ) -> Result<(), fidl::Error> {
1729        AudioCapturerProxyInterface::r#bind_gain_control(self, gain_control_request)
1730    }
1731
1732    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
1733    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
1734    pub fn r#get_reference_clock(
1735        &self,
1736    ) -> fidl::client::QueryResponseFut<
1737        fdomain_client::Clock,
1738        fdomain_client::fidl::FDomainResourceDialect,
1739    > {
1740        AudioCapturerProxyInterface::r#get_reference_clock(self)
1741    }
1742
1743    /// Sets the reference clock that controls this capturer's playback rate. If the input
1744    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
1745    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
1746    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
1747    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
1748    ///
1749    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
1750    /// added. It also cannot be called a second time (even before capture).
1751    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
1752    /// diverge at some later time, they should create a clone of the monotonic clock, set
1753    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
1754    pub fn r#set_reference_clock(
1755        &self,
1756        mut reference_clock: Option<fdomain_client::Clock>,
1757    ) -> Result<(), fidl::Error> {
1758        AudioCapturerProxyInterface::r#set_reference_clock(self, reference_clock)
1759    }
1760
1761    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
1762    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
1763    pub fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
1764        AudioCapturerProxyInterface::r#set_usage(self, usage)
1765    }
1766
1767    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
1768    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
1769    pub fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
1770        AudioCapturerProxyInterface::r#set_usage2(self, usage)
1771    }
1772
1773    /// Gets the currently configured stream type. Note: for an AudioCapturer
1774    /// which was just created and has not yet had its stream type explicitly
1775    /// set, this will retrieve the stream type -- at the time the AudioCapturer
1776    /// was created -- of the source (input or looped-back output) to which the
1777    /// AudioCapturer is bound. Even if this matches the client's desired format,
1778    /// `SetPcmStreamType` must still be called.
1779    pub fn r#get_stream_type(
1780        &self,
1781    ) -> fidl::client::QueryResponseFut<StreamType, fdomain_client::fidl::FDomainResourceDialect>
1782    {
1783        AudioCapturerProxyInterface::r#get_stream_type(self)
1784    }
1785}
1786
1787impl AudioCapturerProxyInterface for AudioCapturerProxy {
1788    fn r#add_payload_buffer(
1789        &self,
1790        mut id: u32,
1791        mut payload_buffer: fdomain_client::Vmo,
1792    ) -> Result<(), fidl::Error> {
1793        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
1794            (id, payload_buffer),
1795            0x3b3a37fc34fe5b56,
1796            fidl::encoding::DynamicFlags::empty(),
1797        )
1798    }
1799
1800    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
1801        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
1802            (id,),
1803            0x5d1e4f74c3658262,
1804            fidl::encoding::DynamicFlags::empty(),
1805        )
1806    }
1807
1808    fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
1809        self.client.send::<StreamSourceReleasePacketRequest>(
1810            (packet,),
1811            0x7a7b57f0f7d9e4bb,
1812            fidl::encoding::DynamicFlags::empty(),
1813        )
1814    }
1815
1816    type DiscardAllPacketsResponseFut =
1817        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
1818    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
1819        fn _decode(
1820            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1821        ) -> Result<(), fidl::Error> {
1822            let _response = fidl::client::decode_transaction_body::<
1823                fidl::encoding::EmptyPayload,
1824                fdomain_client::fidl::FDomainResourceDialect,
1825                0x27afd605e97b09d2,
1826            >(_buf?)?;
1827            Ok(_response)
1828        }
1829        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1830            (),
1831            0x27afd605e97b09d2,
1832            fidl::encoding::DynamicFlags::empty(),
1833            _decode,
1834        )
1835    }
1836
1837    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
1838        self.client.send::<fidl::encoding::EmptyPayload>(
1839            (),
1840            0x35f9d721e905b831,
1841            fidl::encoding::DynamicFlags::empty(),
1842        )
1843    }
1844
1845    fn r#set_pcm_stream_type(&self, mut stream_type: &AudioStreamType) -> Result<(), fidl::Error> {
1846        self.client.send::<AudioCapturerSetPcmStreamTypeRequest>(
1847            (stream_type,),
1848            0x1531ea9ea2c852cd,
1849            fidl::encoding::DynamicFlags::empty(),
1850        )
1851    }
1852
1853    type CaptureAtResponseFut =
1854        fidl::client::QueryResponseFut<StreamPacket, fdomain_client::fidl::FDomainResourceDialect>;
1855    fn r#capture_at(
1856        &self,
1857        mut payload_buffer_id: u32,
1858        mut payload_offset: u32,
1859        mut frames: u32,
1860    ) -> Self::CaptureAtResponseFut {
1861        fn _decode(
1862            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1863        ) -> Result<StreamPacket, fidl::Error> {
1864            let _response = fidl::client::decode_transaction_body::<
1865                AudioCapturerCaptureAtResponse,
1866                fdomain_client::fidl::FDomainResourceDialect,
1867                0x784e25df72cea780,
1868            >(_buf?)?;
1869            Ok(_response.captured_packet)
1870        }
1871        self.client.send_query_and_decode::<AudioCapturerCaptureAtRequest, StreamPacket>(
1872            (payload_buffer_id, payload_offset, frames),
1873            0x784e25df72cea780,
1874            fidl::encoding::DynamicFlags::empty(),
1875            _decode,
1876        )
1877    }
1878
1879    fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
1880        self.client.send::<AudioCapturerStartAsyncCaptureRequest>(
1881            (frames_per_packet,),
1882            0x7768adbb1ccfd7a6,
1883            fidl::encoding::DynamicFlags::empty(),
1884        )
1885    }
1886
1887    type StopAsyncCaptureResponseFut =
1888        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
1889    fn r#stop_async_capture(&self) -> Self::StopAsyncCaptureResponseFut {
1890        fn _decode(
1891            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1892        ) -> Result<(), fidl::Error> {
1893            let _response = fidl::client::decode_transaction_body::<
1894                fidl::encoding::EmptyPayload,
1895                fdomain_client::fidl::FDomainResourceDialect,
1896                0x5bfc8790a8cef8cb,
1897            >(_buf?)?;
1898            Ok(_response)
1899        }
1900        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1901            (),
1902            0x5bfc8790a8cef8cb,
1903            fidl::encoding::DynamicFlags::empty(),
1904            _decode,
1905        )
1906    }
1907
1908    fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
1909        self.client.send::<fidl::encoding::EmptyPayload>(
1910            (),
1911            0x33223cb2962c95e3,
1912            fidl::encoding::DynamicFlags::empty(),
1913        )
1914    }
1915
1916    fn r#bind_gain_control(
1917        &self,
1918        mut gain_control_request: fdomain_client::fidl::ServerEnd<
1919            fdomain_fuchsia_media_audio::GainControlMarker,
1920        >,
1921    ) -> Result<(), fidl::Error> {
1922        self.client.send::<AudioCapturerBindGainControlRequest>(
1923            (gain_control_request,),
1924            0x658a6a17ddb3a8e0,
1925            fidl::encoding::DynamicFlags::empty(),
1926        )
1927    }
1928
1929    type GetReferenceClockResponseFut = fidl::client::QueryResponseFut<
1930        fdomain_client::Clock,
1931        fdomain_client::fidl::FDomainResourceDialect,
1932    >;
1933    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
1934        fn _decode(
1935            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1936        ) -> Result<fdomain_client::Clock, fidl::Error> {
1937            let _response = fidl::client::decode_transaction_body::<
1938                AudioCapturerGetReferenceClockResponse,
1939                fdomain_client::fidl::FDomainResourceDialect,
1940                0x50d037aa5a4b4d71,
1941            >(_buf?)?;
1942            Ok(_response.reference_clock)
1943        }
1944        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fdomain_client::Clock>(
1945            (),
1946            0x50d037aa5a4b4d71,
1947            fidl::encoding::DynamicFlags::empty(),
1948            _decode,
1949        )
1950    }
1951
1952    fn r#set_reference_clock(
1953        &self,
1954        mut reference_clock: Option<fdomain_client::Clock>,
1955    ) -> Result<(), fidl::Error> {
1956        self.client.send::<AudioCapturerSetReferenceClockRequest>(
1957            (reference_clock,),
1958            0x732b2c496d521bcf,
1959            fidl::encoding::DynamicFlags::empty(),
1960        )
1961    }
1962
1963    fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
1964        self.client.send::<AudioCapturerSetUsageRequest>(
1965            (usage,),
1966            0x42a16f392bd21b25,
1967            fidl::encoding::DynamicFlags::empty(),
1968        )
1969    }
1970
1971    fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
1972        self.client.send::<AudioCapturerSetUsage2Request>(
1973            (usage,),
1974            0x7a73e251b8d2382b,
1975            fidl::encoding::DynamicFlags::FLEXIBLE,
1976        )
1977    }
1978
1979    type GetStreamTypeResponseFut =
1980        fidl::client::QueryResponseFut<StreamType, fdomain_client::fidl::FDomainResourceDialect>;
1981    fn r#get_stream_type(&self) -> Self::GetStreamTypeResponseFut {
1982        fn _decode(
1983            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1984        ) -> Result<StreamType, fidl::Error> {
1985            let _response = fidl::client::decode_transaction_body::<
1986                AudioCapturerGetStreamTypeResponse,
1987                fdomain_client::fidl::FDomainResourceDialect,
1988                0x5dcaaa670b433088,
1989            >(_buf?)?;
1990            Ok(_response.stream_type)
1991        }
1992        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, StreamType>(
1993            (),
1994            0x5dcaaa670b433088,
1995            fidl::encoding::DynamicFlags::empty(),
1996            _decode,
1997        )
1998    }
1999}
2000
2001pub struct AudioCapturerEventStream {
2002    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
2003}
2004
2005impl std::marker::Unpin for AudioCapturerEventStream {}
2006
2007impl futures::stream::FusedStream for AudioCapturerEventStream {
2008    fn is_terminated(&self) -> bool {
2009        self.event_receiver.is_terminated()
2010    }
2011}
2012
2013impl futures::Stream for AudioCapturerEventStream {
2014    type Item = Result<AudioCapturerEvent, fidl::Error>;
2015
2016    fn poll_next(
2017        mut self: std::pin::Pin<&mut Self>,
2018        cx: &mut std::task::Context<'_>,
2019    ) -> std::task::Poll<Option<Self::Item>> {
2020        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2021            &mut self.event_receiver,
2022            cx
2023        )?) {
2024            Some(buf) => std::task::Poll::Ready(Some(AudioCapturerEvent::decode(buf))),
2025            None => std::task::Poll::Ready(None),
2026        }
2027    }
2028}
2029
2030#[derive(Debug)]
2031pub enum AudioCapturerEvent {
2032    OnPacketProduced {
2033        packet: StreamPacket,
2034    },
2035    OnEndOfStream {},
2036    #[non_exhaustive]
2037    _UnknownEvent {
2038        /// Ordinal of the event that was sent.
2039        ordinal: u64,
2040    },
2041}
2042
2043impl AudioCapturerEvent {
2044    #[allow(irrefutable_let_patterns)]
2045    pub fn into_on_packet_produced(self) -> Option<StreamPacket> {
2046        if let AudioCapturerEvent::OnPacketProduced { packet } = self {
2047            Some((packet))
2048        } else {
2049            None
2050        }
2051    }
2052    #[allow(irrefutable_let_patterns)]
2053    pub fn into_on_end_of_stream(self) -> Option<()> {
2054        if let AudioCapturerEvent::OnEndOfStream {} = self { Some(()) } else { None }
2055    }
2056
2057    /// Decodes a message buffer as a [`AudioCapturerEvent`].
2058    fn decode(
2059        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2060    ) -> Result<AudioCapturerEvent, fidl::Error> {
2061        let (bytes, _handles) = buf.split_mut();
2062        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2063        debug_assert_eq!(tx_header.tx_id, 0);
2064        match tx_header.ordinal {
2065            0x6bbe69746a3c8bd9 => {
2066                let mut out = fidl::new_empty!(
2067                    StreamSourceOnPacketProducedRequest,
2068                    fdomain_client::fidl::FDomainResourceDialect
2069                );
2070                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2071                Ok((AudioCapturerEvent::OnPacketProduced { packet: out.packet }))
2072            }
2073            0x550e69b41d03e2c2 => {
2074                let mut out = fidl::new_empty!(
2075                    fidl::encoding::EmptyPayload,
2076                    fdomain_client::fidl::FDomainResourceDialect
2077                );
2078                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
2079                Ok((AudioCapturerEvent::OnEndOfStream {}))
2080            }
2081            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2082                Ok(AudioCapturerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2083            }
2084            _ => Err(fidl::Error::UnknownOrdinal {
2085                ordinal: tx_header.ordinal,
2086                protocol_name:
2087                    <AudioCapturerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2088            }),
2089        }
2090    }
2091}
2092
2093/// A Stream of incoming requests for fuchsia.media/AudioCapturer.
2094pub struct AudioCapturerRequestStream {
2095    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2096    is_terminated: bool,
2097}
2098
2099impl std::marker::Unpin for AudioCapturerRequestStream {}
2100
2101impl futures::stream::FusedStream for AudioCapturerRequestStream {
2102    fn is_terminated(&self) -> bool {
2103        self.is_terminated
2104    }
2105}
2106
2107impl fdomain_client::fidl::RequestStream for AudioCapturerRequestStream {
2108    type Protocol = AudioCapturerMarker;
2109    type ControlHandle = AudioCapturerControlHandle;
2110
2111    fn from_channel(channel: fdomain_client::Channel) -> Self {
2112        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2113    }
2114
2115    fn control_handle(&self) -> Self::ControlHandle {
2116        AudioCapturerControlHandle { inner: self.inner.clone() }
2117    }
2118
2119    fn into_inner(
2120        self,
2121    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
2122    {
2123        (self.inner, self.is_terminated)
2124    }
2125
2126    fn from_inner(
2127        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2128        is_terminated: bool,
2129    ) -> Self {
2130        Self { inner, is_terminated }
2131    }
2132}
2133
2134impl futures::Stream for AudioCapturerRequestStream {
2135    type Item = Result<AudioCapturerRequest, fidl::Error>;
2136
2137    fn poll_next(
2138        mut self: std::pin::Pin<&mut Self>,
2139        cx: &mut std::task::Context<'_>,
2140    ) -> std::task::Poll<Option<Self::Item>> {
2141        let this = &mut *self;
2142        if this.inner.check_shutdown(cx) {
2143            this.is_terminated = true;
2144            return std::task::Poll::Ready(None);
2145        }
2146        if this.is_terminated {
2147            panic!("polled AudioCapturerRequestStream after completion");
2148        }
2149        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
2150            |bytes, handles| {
2151                match this.inner.channel().read_etc(cx, bytes, handles) {
2152                    std::task::Poll::Ready(Ok(())) => {}
2153                    std::task::Poll::Pending => return std::task::Poll::Pending,
2154                    std::task::Poll::Ready(Err(None)) => {
2155                        this.is_terminated = true;
2156                        return std::task::Poll::Ready(None);
2157                    }
2158                    std::task::Poll::Ready(Err(Some(e))) => {
2159                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2160                            e.into(),
2161                        ))));
2162                    }
2163                }
2164
2165                // A message has been received from the channel
2166                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2167
2168                std::task::Poll::Ready(Some(match header.ordinal {
2169                0x3b3a37fc34fe5b56 => {
2170                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2171                    let mut req = fidl::new_empty!(StreamBufferSetAddPayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
2172                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
2173                    let control_handle = AudioCapturerControlHandle {
2174                        inner: this.inner.clone(),
2175                    };
2176                    Ok(AudioCapturerRequest::AddPayloadBuffer {id: req.id,
2177payload_buffer: req.payload_buffer,
2178
2179                        control_handle,
2180                    })
2181                }
2182                0x5d1e4f74c3658262 => {
2183                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2184                    let mut req = fidl::new_empty!(StreamBufferSetRemovePayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
2185                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
2186                    let control_handle = AudioCapturerControlHandle {
2187                        inner: this.inner.clone(),
2188                    };
2189                    Ok(AudioCapturerRequest::RemovePayloadBuffer {id: req.id,
2190
2191                        control_handle,
2192                    })
2193                }
2194                0x7a7b57f0f7d9e4bb => {
2195                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2196                    let mut req = fidl::new_empty!(StreamSourceReleasePacketRequest, fdomain_client::fidl::FDomainResourceDialect);
2197                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
2198                    let control_handle = AudioCapturerControlHandle {
2199                        inner: this.inner.clone(),
2200                    };
2201                    Ok(AudioCapturerRequest::ReleasePacket {packet: req.packet,
2202
2203                        control_handle,
2204                    })
2205                }
2206                0x27afd605e97b09d2 => {
2207                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2208                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2209                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2210                    let control_handle = AudioCapturerControlHandle {
2211                        inner: this.inner.clone(),
2212                    };
2213                    Ok(AudioCapturerRequest::DiscardAllPackets {
2214                        responder: AudioCapturerDiscardAllPacketsResponder {
2215                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2216                            tx_id: header.tx_id,
2217                        },
2218                    })
2219                }
2220                0x35f9d721e905b831 => {
2221                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2222                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2223                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2224                    let control_handle = AudioCapturerControlHandle {
2225                        inner: this.inner.clone(),
2226                    };
2227                    Ok(AudioCapturerRequest::DiscardAllPacketsNoReply {
2228                        control_handle,
2229                    })
2230                }
2231                0x1531ea9ea2c852cd => {
2232                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2233                    let mut req = fidl::new_empty!(AudioCapturerSetPcmStreamTypeRequest, fdomain_client::fidl::FDomainResourceDialect);
2234                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerSetPcmStreamTypeRequest>(&header, _body_bytes, handles, &mut req)?;
2235                    let control_handle = AudioCapturerControlHandle {
2236                        inner: this.inner.clone(),
2237                    };
2238                    Ok(AudioCapturerRequest::SetPcmStreamType {stream_type: req.stream_type,
2239
2240                        control_handle,
2241                    })
2242                }
2243                0x784e25df72cea780 => {
2244                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2245                    let mut req = fidl::new_empty!(AudioCapturerCaptureAtRequest, fdomain_client::fidl::FDomainResourceDialect);
2246                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerCaptureAtRequest>(&header, _body_bytes, handles, &mut req)?;
2247                    let control_handle = AudioCapturerControlHandle {
2248                        inner: this.inner.clone(),
2249                    };
2250                    Ok(AudioCapturerRequest::CaptureAt {payload_buffer_id: req.payload_buffer_id,
2251payload_offset: req.payload_offset,
2252frames: req.frames,
2253
2254                        responder: AudioCapturerCaptureAtResponder {
2255                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2256                            tx_id: header.tx_id,
2257                        },
2258                    })
2259                }
2260                0x7768adbb1ccfd7a6 => {
2261                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2262                    let mut req = fidl::new_empty!(AudioCapturerStartAsyncCaptureRequest, fdomain_client::fidl::FDomainResourceDialect);
2263                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerStartAsyncCaptureRequest>(&header, _body_bytes, handles, &mut req)?;
2264                    let control_handle = AudioCapturerControlHandle {
2265                        inner: this.inner.clone(),
2266                    };
2267                    Ok(AudioCapturerRequest::StartAsyncCapture {frames_per_packet: req.frames_per_packet,
2268
2269                        control_handle,
2270                    })
2271                }
2272                0x5bfc8790a8cef8cb => {
2273                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2274                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2275                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2276                    let control_handle = AudioCapturerControlHandle {
2277                        inner: this.inner.clone(),
2278                    };
2279                    Ok(AudioCapturerRequest::StopAsyncCapture {
2280                        responder: AudioCapturerStopAsyncCaptureResponder {
2281                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2282                            tx_id: header.tx_id,
2283                        },
2284                    })
2285                }
2286                0x33223cb2962c95e3 => {
2287                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2288                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2289                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2290                    let control_handle = AudioCapturerControlHandle {
2291                        inner: this.inner.clone(),
2292                    };
2293                    Ok(AudioCapturerRequest::StopAsyncCaptureNoReply {
2294                        control_handle,
2295                    })
2296                }
2297                0x658a6a17ddb3a8e0 => {
2298                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2299                    let mut req = fidl::new_empty!(AudioCapturerBindGainControlRequest, fdomain_client::fidl::FDomainResourceDialect);
2300                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerBindGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
2301                    let control_handle = AudioCapturerControlHandle {
2302                        inner: this.inner.clone(),
2303                    };
2304                    Ok(AudioCapturerRequest::BindGainControl {gain_control_request: req.gain_control_request,
2305
2306                        control_handle,
2307                    })
2308                }
2309                0x50d037aa5a4b4d71 => {
2310                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2311                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2312                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2313                    let control_handle = AudioCapturerControlHandle {
2314                        inner: this.inner.clone(),
2315                    };
2316                    Ok(AudioCapturerRequest::GetReferenceClock {
2317                        responder: AudioCapturerGetReferenceClockResponder {
2318                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2319                            tx_id: header.tx_id,
2320                        },
2321                    })
2322                }
2323                0x732b2c496d521bcf => {
2324                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2325                    let mut req = fidl::new_empty!(AudioCapturerSetReferenceClockRequest, fdomain_client::fidl::FDomainResourceDialect);
2326                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerSetReferenceClockRequest>(&header, _body_bytes, handles, &mut req)?;
2327                    let control_handle = AudioCapturerControlHandle {
2328                        inner: this.inner.clone(),
2329                    };
2330                    Ok(AudioCapturerRequest::SetReferenceClock {reference_clock: req.reference_clock,
2331
2332                        control_handle,
2333                    })
2334                }
2335                0x42a16f392bd21b25 => {
2336                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2337                    let mut req = fidl::new_empty!(AudioCapturerSetUsageRequest, fdomain_client::fidl::FDomainResourceDialect);
2338                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerSetUsageRequest>(&header, _body_bytes, handles, &mut req)?;
2339                    let control_handle = AudioCapturerControlHandle {
2340                        inner: this.inner.clone(),
2341                    };
2342                    Ok(AudioCapturerRequest::SetUsage {usage: req.usage,
2343
2344                        control_handle,
2345                    })
2346                }
2347                0x7a73e251b8d2382b => {
2348                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2349                    let mut req = fidl::new_empty!(AudioCapturerSetUsage2Request, fdomain_client::fidl::FDomainResourceDialect);
2350                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerSetUsage2Request>(&header, _body_bytes, handles, &mut req)?;
2351                    let control_handle = AudioCapturerControlHandle {
2352                        inner: this.inner.clone(),
2353                    };
2354                    Ok(AudioCapturerRequest::SetUsage2 {usage: req.usage,
2355
2356                        control_handle,
2357                    })
2358                }
2359                0x5dcaaa670b433088 => {
2360                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2361                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2362                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2363                    let control_handle = AudioCapturerControlHandle {
2364                        inner: this.inner.clone(),
2365                    };
2366                    Ok(AudioCapturerRequest::GetStreamType {
2367                        responder: AudioCapturerGetStreamTypeResponder {
2368                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2369                            tx_id: header.tx_id,
2370                        },
2371                    })
2372                }
2373                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2374                    Ok(AudioCapturerRequest::_UnknownMethod {
2375                        ordinal: header.ordinal,
2376                        control_handle: AudioCapturerControlHandle { inner: this.inner.clone() },
2377                        method_type: fidl::MethodType::OneWay,
2378                    })
2379                }
2380                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2381                    this.inner.send_framework_err(
2382                        fidl::encoding::FrameworkErr::UnknownMethod,
2383                        header.tx_id,
2384                        header.ordinal,
2385                        header.dynamic_flags(),
2386                        (bytes, handles),
2387                    )?;
2388                    Ok(AudioCapturerRequest::_UnknownMethod {
2389                        ordinal: header.ordinal,
2390                        control_handle: AudioCapturerControlHandle { inner: this.inner.clone() },
2391                        method_type: fidl::MethodType::TwoWay,
2392                    })
2393                }
2394                _ => Err(fidl::Error::UnknownOrdinal {
2395                    ordinal: header.ordinal,
2396                    protocol_name: <AudioCapturerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2397                }),
2398            }))
2399            },
2400        )
2401    }
2402}
2403
2404/// AudioCapturer
2405///
2406/// An AudioCapturer is an interface returned from an fuchsia.media.Audio's
2407/// CreateAudioCapturer method, which may be used by clients to capture audio
2408/// from either the current default audio input device, or the current default
2409/// audio output device depending on the flags passed during creation.
2410///
2411/// **Format support**
2412///
2413/// See (Get|Set)StreamType below. By default, the captured stream type will be
2414/// initially determined by the currently configured stream type of the source
2415/// that the AudioCapturer was bound to at creation time. Users may either fetch
2416/// this type using GetStreamType, or they may choose to have the media
2417/// resampled or converted to a type of their choosing by calling SetStreamType.
2418/// Note: the stream type may only be set while the system is not running,
2419/// meaning that there are no pending capture regions (specified using CaptureAt)
2420/// and that the system is not currently running in 'async' capture mode.
2421///
2422/// **Buffers and memory management**
2423///
2424/// Audio data is captured into a shared memory buffer (a VMO) supplied by the
2425/// user to the AudioCapturer during the AddPayloadBuffer call. Please note the
2426/// following requirements related to the management of the payload buffer.
2427///
2428/// + The payload buffer must be supplied before any capture operation may
2429///   start. Any attempt to start capture (via either CaptureAt or
2430///   StartAsyncCapture) before a payload buffer has been established is an
2431///   error.
2432/// + The payload buffer may not be changed while there are any capture
2433///   operations pending.
2434/// + The stream type may not be changed after the payload buffer has been set.
2435/// + The payload buffer must be an integral number of audio frame sizes (in
2436///   bytes)
2437/// + When running in 'async' mode (see below), the payload buffer must be at
2438///   least as large as twice the frames_per_packet size specified during
2439///   StartAsyncCapture.
2440/// + The handle to the payload buffer supplied by the user must be readable,
2441///   writable, mappable and transferable.
2442/// + Users should always treat the payload buffer as read-only.
2443///
2444/// **Synchronous vs. Asynchronous capture mode**
2445///
2446/// The AudioCapturer interface can be used in one of two mutually exclusive
2447/// modes: Synchronous and Asynchronous. A description of each mode and their
2448/// tradeoffs is given below.
2449///
2450/// **Synchronous mode**
2451///
2452/// By default, AudioCapturer instances are running in 'sync' mode. They will
2453/// only capture data when a user supplies at least one region to capture into
2454/// using the CaptureAt method. Regions supplied in this way will be filled in
2455/// the order that they are received and returned to the client as StreamPackets
2456/// via the return value of the CaptureAt method. If an AudioCapturer instance
2457/// has data to capture, but no place to put it (because there are no more
2458/// pending regions to fill), the next payload generated will indicate that their
2459/// has been an overflow by setting the Discontinuity flag on the next produced
2460/// StreamPacket. Synchronous mode may not be used in conjunction with
2461/// Asynchronous mode. It is an error to attempt to call StartAsyncCapture while
2462/// the system still regions supplied by CaptureAt waiting to be filled.
2463///
2464/// If a user has supplied regions to be filled by the AudioCapturer instance in
2465/// the past, but wishes to reclaim those regions, they may do so using the
2466/// DiscardAllPackets method. Calling the DiscardAllPackets method will cause
2467/// all pending regions to be returned, but with `NO_TIMESTAMP` as their
2468/// StreamPacket's PTS. See "Timing and Overflows", below, for a discussion of
2469/// timestamps and discontinuity flags. After a DiscardAllPackets operation,
2470/// an OnEndOfStream event will be produced. While an AudioCapturer will never
2471/// overwrite any region of the payload buffer after a completed region is
2472/// returned, it may overwrite the unfilled portions of a partially filled
2473/// buffer which has been returned as a result of a DiscardAllPackets operation.
2474///
2475/// **Asynchronous mode**
2476///
2477/// While running in 'async' mode, clients do not need to explicitly supply
2478/// shared buffer regions to be filled by the AudioCapturer instance. Instead, a
2479/// client enters into 'async' mode by calling StartAsyncCapture and supplying a
2480/// callback interface and the number of frames to capture per-callback. Once
2481/// running in async mode, the AudioCapturer instance will identify which
2482/// payload buffer regions to capture into, capture the specified number of
2483/// frames, then deliver those frames as StreamPackets using the OnPacketCapture
2484/// FIDL event. Users may stop capturing and return the AudioCapturer instance to
2485/// 'sync' mode using the StopAsyncCapture method.
2486///
2487/// It is considered an error to attempt any of the following operations.
2488///
2489/// + To attempt to enter 'async' capture mode when no payload buffer has been
2490///   established.
2491/// + To specify a number of frames to capture per payload which does not permit
2492///   at least two contiguous capture payloads to exist in the established
2493///   shared payload buffer simultaneously.
2494/// + To send a region to capture into using the CaptureAt method while the
2495///   AudioCapturer instance is running in 'async' mode.
2496/// + To attempt to call DiscardAllPackets while the AudioCapturer instance is
2497///   running in 'async' mode.
2498/// + To attempt to re-start 'async' mode capturing without having first
2499///   stopped.
2500/// + To attempt any operation except for SetGain while in the process of
2501///   stopping.
2502///
2503/// **Synchronizing with a StopAsyncCapture operation**
2504///
2505/// Stopping asynchronous capture mode and returning to synchronous capture mode
2506/// is an operation which takes time. Aside from SetGain, users may not call any
2507/// other methods on the AudioCapturer interface after calling StopAsyncCapture
2508/// (including calling StopAsyncCapture again) until after the stop operation has
2509/// completed. Because of this, it is important for users to be able to
2510/// synchronize with the stop operation. Two mechanisms are provided for doing
2511/// so.
2512///
2513/// The first is to use StopAsyncCapture (not the NoReply variant). When the user's
2514/// callback has been called, they can be certain that stop operation is complete
2515/// and that the AudioCapturer instance has returned to synchronous operation
2516/// mode.
2517///
2518/// The second way to determine that a stop operation has completed is to use the
2519/// flags on the packets which get delivered via the user-supplied
2520/// AudioCapturerCallback interface after calling StopAsyncCapture. When
2521/// asked to stop, any partially filled packet will be returned to the user, and
2522/// the final packet returned will always have the end-of-stream flag (kFlagsEos)
2523/// set on it to indicate that this is the final frame in the sequence. If
2524/// there is no partially filled packet to return, the AudioCapturer will
2525/// synthesize an empty packet with no timestamp, and offset/length set to zero,
2526/// in order to deliver a packet with the end-of-stream flag set on it. Once
2527/// users have seen the end-of-stream flag after calling stop, the AudioCapturer
2528/// has finished the stop operation and returned to synchronous operating mode.
2529///
2530/// **Timing and Overflows**
2531///
2532/// All media packets produced by an AudioCapturer instance will have their PTS
2533/// field filled out with the capture time of the audio expressed as a timestamp
2534/// given by the reference clock timeline. Note: this timestamp is actually a
2535/// capture timestamp, not a presentation timestamp (it is more of a CTS than a
2536/// PTS) and is meant to represent the underlying system's best estimate of the
2537/// capture time of the first frame of audio, including all outboard and hardware
2538/// introduced buffering delay. As a result, all timestamps produced by an
2539/// AudioCapturer should be expected to be in the past relative to 'now' on the
2540/// stream's reference clock timeline.
2541///
2542/// The one exception to the "everything has an explicit timestamp" rule is when
2543/// discarding submitted regions while operating in synchronous mode. Discarded
2544/// packets have no data in them, but FIDL demands that all pending
2545/// method-return-value callbacks be executed. Because of this, the regions will
2546/// be returned to the user, but their timestamps will be set to
2547/// `NO_TIMESTAMP`, and their payload sizes will be set to zero. Any
2548/// partially filled payload will have a valid timestamp, but a payload size
2549/// smaller than originally requested. The final discarded payload (if there
2550/// were any to discard) will be followed by an OnEndOfStream event.
2551///
2552/// Two StreamPackets delivered by an AudioCapturer instance are 'continuous' if
2553/// the first frame of audio contained in the second packet was captured exactly
2554/// one nominal frame time after the final frame of audio in the first packet.
2555/// If this relationship does not hold, the second StreamPacket will have the
2556/// `STREAM_PACKET_FLAG_DISCONTINUITY` bit set in its `flags` field.
2557///
2558/// Even though explicit timestamps are provided on every StreamPacket produced,
2559/// users who have very precise timing requirements are encouraged to always
2560/// reason about time by counting frames delivered since the last discontinuity,
2561/// rather than simply using the raw capture timestamps. This is because the
2562/// explicit timestamps written on continuous packets may have a small amount of
2563/// rounding error based on whether or not the units of the capture timeline
2564/// reference clock are divisible by the chosen audio frame rate.
2565///
2566/// Users should always expect the first StreamPacket produced by an
2567/// AudioCapturer to have the discontinuous flag set on it (as there is no
2568/// previous packet to be continuous with). Similarly, the first StreamPacket
2569/// after a DiscardAllPackets or a Stop/Start cycle will always be
2570/// discontinuous. After that, there are only two reasons that a StreamPacket
2571/// will ever be discontinuous:
2572///
2573/// 1. The user is operating in synchronous mode and does not supply regions to
2574///    be filled quickly enough. If the next continuous frame of data has not
2575///    been captured by the time it needs to be purged from the source buffers,
2576///    an overflow has occurred and the AudioCapturer will flag the next captured
2577///    region as discontinuous.
2578/// 2. The user is operating in asynchronous mode and some internal error
2579///    prevents the AudioCapturer instance from capturing the next frame of audio
2580///    in a continuous fashion. This might be high system load or a hardware
2581///    error, but in general it is something which should never normally happen.
2582///    In practice, however, if it does, the next produced packet will be flagged
2583///    as being discontinuous.
2584///
2585/// **Synchronous vs. Asynchronous Trade-offs**
2586///
2587/// The choice of operating in synchronous vs. asynchronous mode is up to the
2588/// user, and depending on the user's requirements, there are some advantages and
2589/// disadvantages to each choice.
2590///
2591/// Synchronous mode requires only a single Zircon channel under the hood and can
2592/// achieve some small savings because of this. In addition, the user has
2593/// complete control over the buffer management. Users specify exactly where
2594/// audio will be captured to and in what order. Because of this, if users do
2595/// not need to always be capturing, it is simple to stop and restart the capture
2596/// later (just by ceasing to supply packets, then resuming later on). Payloads
2597/// do not need to be uniform in size either, clients may specify payloads of
2598/// whatever granularity is appropriate.
2599///
2600/// The primary downside of operating in synchronous mode is that two messages
2601/// will need to be sent for every packet to be captured. One to inform the
2602/// AudioCapturer of the instance to capture into, and one to inform the user
2603/// that the packet has been captured. This may end up increasing overhead and
2604/// potentially complicating client designs.
2605///
2606/// Asynchronous mode has the advantage requiring only 1/2 of the messages,
2607/// however, when operating in 'async' mode, AudioCapturer instances have no way
2608/// of knowing if a user is processing the StreamPackets being sent in a timely
2609/// fashion, and no way of automatically detecting an overflow condition. Users
2610/// of 'async' mode should be careful to use a buffer large enough to ensure that
2611/// they will be able to process their data before an AudioCapturer will be
2612/// forced to overwrite it.
2613#[derive(Debug)]
2614pub enum AudioCapturerRequest {
2615    /// Adds a payload buffer to the current buffer set associated with the
2616    /// connection. A `StreamPacket` struct reference a payload buffer in the
2617    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
2618    ///
2619    /// A buffer with ID `id` must not be in the current set when this method is
2620    /// invoked, otherwise the service will close the connection.
2621    AddPayloadBuffer {
2622        id: u32,
2623        payload_buffer: fdomain_client::Vmo,
2624        control_handle: AudioCapturerControlHandle,
2625    },
2626    /// Removes a payload buffer from the current buffer set associated with the
2627    /// connection.
2628    ///
2629    /// A buffer with ID `id` must exist in the current set when this method is
2630    /// invoked, otherwise the service will will close the connection.
2631    RemovePayloadBuffer {
2632        id: u32,
2633        control_handle: AudioCapturerControlHandle,
2634    },
2635    /// Releases payload memory associated with a packet previously delivered
2636    /// via `OnPacketProduced`.
2637    ReleasePacket {
2638        packet: StreamPacket,
2639        control_handle: AudioCapturerControlHandle,
2640    },
2641    DiscardAllPackets {
2642        responder: AudioCapturerDiscardAllPacketsResponder,
2643    },
2644    DiscardAllPacketsNoReply {
2645        control_handle: AudioCapturerControlHandle,
2646    },
2647    /// Sets the stream type of the stream to be delivered. Causes the source
2648    /// material to be reformatted/resampled if needed in order to produce the
2649    /// requested stream type. Must be called before the payload buffer is
2650    /// established.
2651    SetPcmStreamType {
2652        stream_type: AudioStreamType,
2653        control_handle: AudioCapturerControlHandle,
2654    },
2655    /// Explicitly specifies a region of the shared payload buffer for the audio
2656    /// input to capture into.
2657    CaptureAt {
2658        payload_buffer_id: u32,
2659        payload_offset: u32,
2660        frames: u32,
2661        responder: AudioCapturerCaptureAtResponder,
2662    },
2663    /// Places the AudioCapturer into 'async' capture mode and begin to produce
2664    /// packets of exactly 'frames_per_packet' number of frames each. The
2665    /// OnPacketProduced event (of StreamSink) will be used to inform the client
2666    /// of produced packets.
2667    StartAsyncCapture {
2668        frames_per_packet: u32,
2669        control_handle: AudioCapturerControlHandle,
2670    },
2671    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
2672    /// that may be used by the client if explicit synchronization is needed.
2673    StopAsyncCapture {
2674        responder: AudioCapturerStopAsyncCaptureResponder,
2675    },
2676    StopAsyncCaptureNoReply {
2677        control_handle: AudioCapturerControlHandle,
2678    },
2679    /// Binds to the gain control for this AudioCapturer.
2680    BindGainControl {
2681        gain_control_request:
2682            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
2683        control_handle: AudioCapturerControlHandle,
2684    },
2685    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
2686    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
2687    GetReferenceClock {
2688        responder: AudioCapturerGetReferenceClockResponder,
2689    },
2690    /// Sets the reference clock that controls this capturer's playback rate. If the input
2691    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
2692    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
2693    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
2694    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
2695    ///
2696    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
2697    /// added. It also cannot be called a second time (even before capture).
2698    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
2699    /// diverge at some later time, they should create a clone of the monotonic clock, set
2700    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
2701    SetReferenceClock {
2702        reference_clock: Option<fdomain_client::Clock>,
2703        control_handle: AudioCapturerControlHandle,
2704    },
2705    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
2706    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
2707    SetUsage {
2708        usage: AudioCaptureUsage,
2709        control_handle: AudioCapturerControlHandle,
2710    },
2711    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
2712    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
2713    SetUsage2 {
2714        usage: AudioCaptureUsage2,
2715        control_handle: AudioCapturerControlHandle,
2716    },
2717    /// Gets the currently configured stream type. Note: for an AudioCapturer
2718    /// which was just created and has not yet had its stream type explicitly
2719    /// set, this will retrieve the stream type -- at the time the AudioCapturer
2720    /// was created -- of the source (input or looped-back output) to which the
2721    /// AudioCapturer is bound. Even if this matches the client's desired format,
2722    /// `SetPcmStreamType` must still be called.
2723    GetStreamType {
2724        responder: AudioCapturerGetStreamTypeResponder,
2725    },
2726    /// An interaction was received which does not match any known method.
2727    #[non_exhaustive]
2728    _UnknownMethod {
2729        /// Ordinal of the method that was called.
2730        ordinal: u64,
2731        control_handle: AudioCapturerControlHandle,
2732        method_type: fidl::MethodType,
2733    },
2734}
2735
2736impl AudioCapturerRequest {
2737    #[allow(irrefutable_let_patterns)]
2738    pub fn into_add_payload_buffer(
2739        self,
2740    ) -> Option<(u32, fdomain_client::Vmo, AudioCapturerControlHandle)> {
2741        if let AudioCapturerRequest::AddPayloadBuffer { id, payload_buffer, control_handle } = self
2742        {
2743            Some((id, payload_buffer, control_handle))
2744        } else {
2745            None
2746        }
2747    }
2748
2749    #[allow(irrefutable_let_patterns)]
2750    pub fn into_remove_payload_buffer(self) -> Option<(u32, AudioCapturerControlHandle)> {
2751        if let AudioCapturerRequest::RemovePayloadBuffer { id, control_handle } = self {
2752            Some((id, control_handle))
2753        } else {
2754            None
2755        }
2756    }
2757
2758    #[allow(irrefutable_let_patterns)]
2759    pub fn into_release_packet(self) -> Option<(StreamPacket, AudioCapturerControlHandle)> {
2760        if let AudioCapturerRequest::ReleasePacket { packet, control_handle } = self {
2761            Some((packet, control_handle))
2762        } else {
2763            None
2764        }
2765    }
2766
2767    #[allow(irrefutable_let_patterns)]
2768    pub fn into_discard_all_packets(self) -> Option<(AudioCapturerDiscardAllPacketsResponder)> {
2769        if let AudioCapturerRequest::DiscardAllPackets { responder } = self {
2770            Some((responder))
2771        } else {
2772            None
2773        }
2774    }
2775
2776    #[allow(irrefutable_let_patterns)]
2777    pub fn into_discard_all_packets_no_reply(self) -> Option<(AudioCapturerControlHandle)> {
2778        if let AudioCapturerRequest::DiscardAllPacketsNoReply { control_handle } = self {
2779            Some((control_handle))
2780        } else {
2781            None
2782        }
2783    }
2784
2785    #[allow(irrefutable_let_patterns)]
2786    pub fn into_set_pcm_stream_type(self) -> Option<(AudioStreamType, AudioCapturerControlHandle)> {
2787        if let AudioCapturerRequest::SetPcmStreamType { stream_type, control_handle } = self {
2788            Some((stream_type, control_handle))
2789        } else {
2790            None
2791        }
2792    }
2793
2794    #[allow(irrefutable_let_patterns)]
2795    pub fn into_capture_at(self) -> Option<(u32, u32, u32, AudioCapturerCaptureAtResponder)> {
2796        if let AudioCapturerRequest::CaptureAt {
2797            payload_buffer_id,
2798            payload_offset,
2799            frames,
2800            responder,
2801        } = self
2802        {
2803            Some((payload_buffer_id, payload_offset, frames, responder))
2804        } else {
2805            None
2806        }
2807    }
2808
2809    #[allow(irrefutable_let_patterns)]
2810    pub fn into_start_async_capture(self) -> Option<(u32, AudioCapturerControlHandle)> {
2811        if let AudioCapturerRequest::StartAsyncCapture { frames_per_packet, control_handle } = self
2812        {
2813            Some((frames_per_packet, control_handle))
2814        } else {
2815            None
2816        }
2817    }
2818
2819    #[allow(irrefutable_let_patterns)]
2820    pub fn into_stop_async_capture(self) -> Option<(AudioCapturerStopAsyncCaptureResponder)> {
2821        if let AudioCapturerRequest::StopAsyncCapture { responder } = self {
2822            Some((responder))
2823        } else {
2824            None
2825        }
2826    }
2827
2828    #[allow(irrefutable_let_patterns)]
2829    pub fn into_stop_async_capture_no_reply(self) -> Option<(AudioCapturerControlHandle)> {
2830        if let AudioCapturerRequest::StopAsyncCaptureNoReply { control_handle } = self {
2831            Some((control_handle))
2832        } else {
2833            None
2834        }
2835    }
2836
2837    #[allow(irrefutable_let_patterns)]
2838    pub fn into_bind_gain_control(
2839        self,
2840    ) -> Option<(
2841        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
2842        AudioCapturerControlHandle,
2843    )> {
2844        if let AudioCapturerRequest::BindGainControl { gain_control_request, control_handle } = self
2845        {
2846            Some((gain_control_request, control_handle))
2847        } else {
2848            None
2849        }
2850    }
2851
2852    #[allow(irrefutable_let_patterns)]
2853    pub fn into_get_reference_clock(self) -> Option<(AudioCapturerGetReferenceClockResponder)> {
2854        if let AudioCapturerRequest::GetReferenceClock { responder } = self {
2855            Some((responder))
2856        } else {
2857            None
2858        }
2859    }
2860
2861    #[allow(irrefutable_let_patterns)]
2862    pub fn into_set_reference_clock(
2863        self,
2864    ) -> Option<(Option<fdomain_client::Clock>, AudioCapturerControlHandle)> {
2865        if let AudioCapturerRequest::SetReferenceClock { reference_clock, control_handle } = self {
2866            Some((reference_clock, control_handle))
2867        } else {
2868            None
2869        }
2870    }
2871
2872    #[allow(irrefutable_let_patterns)]
2873    pub fn into_set_usage(self) -> Option<(AudioCaptureUsage, AudioCapturerControlHandle)> {
2874        if let AudioCapturerRequest::SetUsage { usage, control_handle } = self {
2875            Some((usage, control_handle))
2876        } else {
2877            None
2878        }
2879    }
2880
2881    #[allow(irrefutable_let_patterns)]
2882    pub fn into_set_usage2(self) -> Option<(AudioCaptureUsage2, AudioCapturerControlHandle)> {
2883        if let AudioCapturerRequest::SetUsage2 { usage, control_handle } = self {
2884            Some((usage, control_handle))
2885        } else {
2886            None
2887        }
2888    }
2889
2890    #[allow(irrefutable_let_patterns)]
2891    pub fn into_get_stream_type(self) -> Option<(AudioCapturerGetStreamTypeResponder)> {
2892        if let AudioCapturerRequest::GetStreamType { responder } = self {
2893            Some((responder))
2894        } else {
2895            None
2896        }
2897    }
2898
2899    /// Name of the method defined in FIDL
2900    pub fn method_name(&self) -> &'static str {
2901        match *self {
2902            AudioCapturerRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
2903            AudioCapturerRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
2904            AudioCapturerRequest::ReleasePacket { .. } => "release_packet",
2905            AudioCapturerRequest::DiscardAllPackets { .. } => "discard_all_packets",
2906            AudioCapturerRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
2907            AudioCapturerRequest::SetPcmStreamType { .. } => "set_pcm_stream_type",
2908            AudioCapturerRequest::CaptureAt { .. } => "capture_at",
2909            AudioCapturerRequest::StartAsyncCapture { .. } => "start_async_capture",
2910            AudioCapturerRequest::StopAsyncCapture { .. } => "stop_async_capture",
2911            AudioCapturerRequest::StopAsyncCaptureNoReply { .. } => "stop_async_capture_no_reply",
2912            AudioCapturerRequest::BindGainControl { .. } => "bind_gain_control",
2913            AudioCapturerRequest::GetReferenceClock { .. } => "get_reference_clock",
2914            AudioCapturerRequest::SetReferenceClock { .. } => "set_reference_clock",
2915            AudioCapturerRequest::SetUsage { .. } => "set_usage",
2916            AudioCapturerRequest::SetUsage2 { .. } => "set_usage2",
2917            AudioCapturerRequest::GetStreamType { .. } => "get_stream_type",
2918            AudioCapturerRequest::_UnknownMethod {
2919                method_type: fidl::MethodType::OneWay, ..
2920            } => "unknown one-way method",
2921            AudioCapturerRequest::_UnknownMethod {
2922                method_type: fidl::MethodType::TwoWay, ..
2923            } => "unknown two-way method",
2924        }
2925    }
2926}
2927
2928#[derive(Debug, Clone)]
2929pub struct AudioCapturerControlHandle {
2930    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2931}
2932
2933impl fdomain_client::fidl::ControlHandle for AudioCapturerControlHandle {
2934    fn shutdown(&self) {
2935        self.inner.shutdown()
2936    }
2937
2938    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2939        self.inner.shutdown_with_epitaph(status)
2940    }
2941
2942    fn is_closed(&self) -> bool {
2943        self.inner.channel().is_closed()
2944    }
2945    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
2946        self.inner.channel().on_closed()
2947    }
2948}
2949
2950impl AudioCapturerControlHandle {
2951    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
2952        self.inner.send::<StreamSourceOnPacketProducedRequest>(
2953            (packet,),
2954            0,
2955            0x6bbe69746a3c8bd9,
2956            fidl::encoding::DynamicFlags::empty(),
2957        )
2958    }
2959
2960    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
2961        self.inner.send::<fidl::encoding::EmptyPayload>(
2962            (),
2963            0,
2964            0x550e69b41d03e2c2,
2965            fidl::encoding::DynamicFlags::empty(),
2966        )
2967    }
2968}
2969
2970#[must_use = "FIDL methods require a response to be sent"]
2971#[derive(Debug)]
2972pub struct AudioCapturerDiscardAllPacketsResponder {
2973    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
2974    tx_id: u32,
2975}
2976
2977/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
2978/// if the responder is dropped without sending a response, so that the client
2979/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2980impl std::ops::Drop for AudioCapturerDiscardAllPacketsResponder {
2981    fn drop(&mut self) {
2982        self.control_handle.shutdown();
2983        // Safety: drops once, never accessed again
2984        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2985    }
2986}
2987
2988impl fdomain_client::fidl::Responder for AudioCapturerDiscardAllPacketsResponder {
2989    type ControlHandle = AudioCapturerControlHandle;
2990
2991    fn control_handle(&self) -> &AudioCapturerControlHandle {
2992        &self.control_handle
2993    }
2994
2995    fn drop_without_shutdown(mut self) {
2996        // Safety: drops once, never accessed again due to mem::forget
2997        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2998        // Prevent Drop from running (which would shut down the channel)
2999        std::mem::forget(self);
3000    }
3001}
3002
3003impl AudioCapturerDiscardAllPacketsResponder {
3004    /// Sends a response to the FIDL transaction.
3005    ///
3006    /// Sets the channel to shutdown if an error occurs.
3007    pub fn send(self) -> Result<(), fidl::Error> {
3008        let _result = self.send_raw();
3009        if _result.is_err() {
3010            self.control_handle.shutdown();
3011        }
3012        self.drop_without_shutdown();
3013        _result
3014    }
3015
3016    /// Similar to "send" but does not shutdown the channel if an error occurs.
3017    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3018        let _result = self.send_raw();
3019        self.drop_without_shutdown();
3020        _result
3021    }
3022
3023    fn send_raw(&self) -> Result<(), fidl::Error> {
3024        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3025            (),
3026            self.tx_id,
3027            0x27afd605e97b09d2,
3028            fidl::encoding::DynamicFlags::empty(),
3029        )
3030    }
3031}
3032
3033#[must_use = "FIDL methods require a response to be sent"]
3034#[derive(Debug)]
3035pub struct AudioCapturerCaptureAtResponder {
3036    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3037    tx_id: u32,
3038}
3039
3040/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3041/// if the responder is dropped without sending a response, so that the client
3042/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3043impl std::ops::Drop for AudioCapturerCaptureAtResponder {
3044    fn drop(&mut self) {
3045        self.control_handle.shutdown();
3046        // Safety: drops once, never accessed again
3047        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3048    }
3049}
3050
3051impl fdomain_client::fidl::Responder for AudioCapturerCaptureAtResponder {
3052    type ControlHandle = AudioCapturerControlHandle;
3053
3054    fn control_handle(&self) -> &AudioCapturerControlHandle {
3055        &self.control_handle
3056    }
3057
3058    fn drop_without_shutdown(mut self) {
3059        // Safety: drops once, never accessed again due to mem::forget
3060        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3061        // Prevent Drop from running (which would shut down the channel)
3062        std::mem::forget(self);
3063    }
3064}
3065
3066impl AudioCapturerCaptureAtResponder {
3067    /// Sends a response to the FIDL transaction.
3068    ///
3069    /// Sets the channel to shutdown if an error occurs.
3070    pub fn send(self, mut captured_packet: &StreamPacket) -> Result<(), fidl::Error> {
3071        let _result = self.send_raw(captured_packet);
3072        if _result.is_err() {
3073            self.control_handle.shutdown();
3074        }
3075        self.drop_without_shutdown();
3076        _result
3077    }
3078
3079    /// Similar to "send" but does not shutdown the channel if an error occurs.
3080    pub fn send_no_shutdown_on_err(
3081        self,
3082        mut captured_packet: &StreamPacket,
3083    ) -> Result<(), fidl::Error> {
3084        let _result = self.send_raw(captured_packet);
3085        self.drop_without_shutdown();
3086        _result
3087    }
3088
3089    fn send_raw(&self, mut captured_packet: &StreamPacket) -> Result<(), fidl::Error> {
3090        self.control_handle.inner.send::<AudioCapturerCaptureAtResponse>(
3091            (captured_packet,),
3092            self.tx_id,
3093            0x784e25df72cea780,
3094            fidl::encoding::DynamicFlags::empty(),
3095        )
3096    }
3097}
3098
3099#[must_use = "FIDL methods require a response to be sent"]
3100#[derive(Debug)]
3101pub struct AudioCapturerStopAsyncCaptureResponder {
3102    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3103    tx_id: u32,
3104}
3105
3106/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3107/// if the responder is dropped without sending a response, so that the client
3108/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3109impl std::ops::Drop for AudioCapturerStopAsyncCaptureResponder {
3110    fn drop(&mut self) {
3111        self.control_handle.shutdown();
3112        // Safety: drops once, never accessed again
3113        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3114    }
3115}
3116
3117impl fdomain_client::fidl::Responder for AudioCapturerStopAsyncCaptureResponder {
3118    type ControlHandle = AudioCapturerControlHandle;
3119
3120    fn control_handle(&self) -> &AudioCapturerControlHandle {
3121        &self.control_handle
3122    }
3123
3124    fn drop_without_shutdown(mut self) {
3125        // Safety: drops once, never accessed again due to mem::forget
3126        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3127        // Prevent Drop from running (which would shut down the channel)
3128        std::mem::forget(self);
3129    }
3130}
3131
3132impl AudioCapturerStopAsyncCaptureResponder {
3133    /// Sends a response to the FIDL transaction.
3134    ///
3135    /// Sets the channel to shutdown if an error occurs.
3136    pub fn send(self) -> Result<(), fidl::Error> {
3137        let _result = self.send_raw();
3138        if _result.is_err() {
3139            self.control_handle.shutdown();
3140        }
3141        self.drop_without_shutdown();
3142        _result
3143    }
3144
3145    /// Similar to "send" but does not shutdown the channel if an error occurs.
3146    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3147        let _result = self.send_raw();
3148        self.drop_without_shutdown();
3149        _result
3150    }
3151
3152    fn send_raw(&self) -> Result<(), fidl::Error> {
3153        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3154            (),
3155            self.tx_id,
3156            0x5bfc8790a8cef8cb,
3157            fidl::encoding::DynamicFlags::empty(),
3158        )
3159    }
3160}
3161
3162#[must_use = "FIDL methods require a response to be sent"]
3163#[derive(Debug)]
3164pub struct AudioCapturerGetReferenceClockResponder {
3165    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3166    tx_id: u32,
3167}
3168
3169/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3170/// if the responder is dropped without sending a response, so that the client
3171/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3172impl std::ops::Drop for AudioCapturerGetReferenceClockResponder {
3173    fn drop(&mut self) {
3174        self.control_handle.shutdown();
3175        // Safety: drops once, never accessed again
3176        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3177    }
3178}
3179
3180impl fdomain_client::fidl::Responder for AudioCapturerGetReferenceClockResponder {
3181    type ControlHandle = AudioCapturerControlHandle;
3182
3183    fn control_handle(&self) -> &AudioCapturerControlHandle {
3184        &self.control_handle
3185    }
3186
3187    fn drop_without_shutdown(mut self) {
3188        // Safety: drops once, never accessed again due to mem::forget
3189        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3190        // Prevent Drop from running (which would shut down the channel)
3191        std::mem::forget(self);
3192    }
3193}
3194
3195impl AudioCapturerGetReferenceClockResponder {
3196    /// Sends a response to the FIDL transaction.
3197    ///
3198    /// Sets the channel to shutdown if an error occurs.
3199    pub fn send(self, mut reference_clock: fdomain_client::Clock) -> Result<(), fidl::Error> {
3200        let _result = self.send_raw(reference_clock);
3201        if _result.is_err() {
3202            self.control_handle.shutdown();
3203        }
3204        self.drop_without_shutdown();
3205        _result
3206    }
3207
3208    /// Similar to "send" but does not shutdown the channel if an error occurs.
3209    pub fn send_no_shutdown_on_err(
3210        self,
3211        mut reference_clock: fdomain_client::Clock,
3212    ) -> Result<(), fidl::Error> {
3213        let _result = self.send_raw(reference_clock);
3214        self.drop_without_shutdown();
3215        _result
3216    }
3217
3218    fn send_raw(&self, mut reference_clock: fdomain_client::Clock) -> Result<(), fidl::Error> {
3219        self.control_handle.inner.send::<AudioCapturerGetReferenceClockResponse>(
3220            (reference_clock,),
3221            self.tx_id,
3222            0x50d037aa5a4b4d71,
3223            fidl::encoding::DynamicFlags::empty(),
3224        )
3225    }
3226}
3227
3228#[must_use = "FIDL methods require a response to be sent"]
3229#[derive(Debug)]
3230pub struct AudioCapturerGetStreamTypeResponder {
3231    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3232    tx_id: u32,
3233}
3234
3235/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3236/// if the responder is dropped without sending a response, so that the client
3237/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3238impl std::ops::Drop for AudioCapturerGetStreamTypeResponder {
3239    fn drop(&mut self) {
3240        self.control_handle.shutdown();
3241        // Safety: drops once, never accessed again
3242        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3243    }
3244}
3245
3246impl fdomain_client::fidl::Responder for AudioCapturerGetStreamTypeResponder {
3247    type ControlHandle = AudioCapturerControlHandle;
3248
3249    fn control_handle(&self) -> &AudioCapturerControlHandle {
3250        &self.control_handle
3251    }
3252
3253    fn drop_without_shutdown(mut self) {
3254        // Safety: drops once, never accessed again due to mem::forget
3255        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3256        // Prevent Drop from running (which would shut down the channel)
3257        std::mem::forget(self);
3258    }
3259}
3260
3261impl AudioCapturerGetStreamTypeResponder {
3262    /// Sends a response to the FIDL transaction.
3263    ///
3264    /// Sets the channel to shutdown if an error occurs.
3265    pub fn send(self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3266        let _result = self.send_raw(stream_type);
3267        if _result.is_err() {
3268            self.control_handle.shutdown();
3269        }
3270        self.drop_without_shutdown();
3271        _result
3272    }
3273
3274    /// Similar to "send" but does not shutdown the channel if an error occurs.
3275    pub fn send_no_shutdown_on_err(self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3276        let _result = self.send_raw(stream_type);
3277        self.drop_without_shutdown();
3278        _result
3279    }
3280
3281    fn send_raw(&self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3282        self.control_handle.inner.send::<AudioCapturerGetStreamTypeResponse>(
3283            (stream_type,),
3284            self.tx_id,
3285            0x5dcaaa670b433088,
3286            fidl::encoding::DynamicFlags::empty(),
3287        )
3288    }
3289}
3290
3291#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3292pub struct AudioConsumerMarker;
3293
3294impl fdomain_client::fidl::ProtocolMarker for AudioConsumerMarker {
3295    type Proxy = AudioConsumerProxy;
3296    type RequestStream = AudioConsumerRequestStream;
3297
3298    const DEBUG_NAME: &'static str = "(anonymous) AudioConsumer";
3299}
3300
3301pub trait AudioConsumerProxyInterface: Send + Sync {
3302    fn r#create_stream_sink(
3303        &self,
3304        buffers: Vec<fdomain_client::Vmo>,
3305        stream_type: &AudioStreamType,
3306        compression: Option<&Compression>,
3307        stream_sink_request: fdomain_client::fidl::ServerEnd<StreamSinkMarker>,
3308    ) -> Result<(), fidl::Error>;
3309    fn r#start(
3310        &self,
3311        flags: AudioConsumerStartFlags,
3312        reference_time: i64,
3313        media_time: i64,
3314    ) -> Result<(), fidl::Error>;
3315    fn r#stop(&self) -> Result<(), fidl::Error>;
3316    fn r#set_rate(&self, rate: f32) -> Result<(), fidl::Error>;
3317    fn r#bind_volume_control(
3318        &self,
3319        volume_control_request: fdomain_client::fidl::ServerEnd<
3320            fdomain_fuchsia_media_audio::VolumeControlMarker,
3321        >,
3322    ) -> Result<(), fidl::Error>;
3323    type WatchStatusResponseFut: std::future::Future<Output = Result<AudioConsumerStatus, fidl::Error>>
3324        + Send;
3325    fn r#watch_status(&self) -> Self::WatchStatusResponseFut;
3326}
3327
3328#[derive(Debug, Clone)]
3329pub struct AudioConsumerProxy {
3330    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
3331}
3332
3333impl fdomain_client::fidl::Proxy for AudioConsumerProxy {
3334    type Protocol = AudioConsumerMarker;
3335
3336    fn from_channel(inner: fdomain_client::Channel) -> Self {
3337        Self::new(inner)
3338    }
3339
3340    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
3341        self.client.into_channel().map_err(|client| Self { client })
3342    }
3343
3344    fn as_channel(&self) -> &fdomain_client::Channel {
3345        self.client.as_channel()
3346    }
3347}
3348
3349impl AudioConsumerProxy {
3350    /// Create a new Proxy for fuchsia.media/AudioConsumer.
3351    pub fn new(channel: fdomain_client::Channel) -> Self {
3352        let protocol_name =
3353            <AudioConsumerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
3354        Self { client: fidl::client::Client::new(channel, protocol_name) }
3355    }
3356
3357    /// Get a Stream of events from the remote end of the protocol.
3358    ///
3359    /// # Panics
3360    ///
3361    /// Panics if the event stream was already taken.
3362    pub fn take_event_stream(&self) -> AudioConsumerEventStream {
3363        AudioConsumerEventStream { event_receiver: self.client.take_event_receiver() }
3364    }
3365
3366    /// Creates a `StreamSink` for the consumer with the indicated properties.
3367    ///
3368    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
3369    /// sequentially rather than concurrently. The first stream sink that's created using this
3370    /// method is used as the sole source of packets incoming to the logical consumer until that
3371    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
3372    /// the second stream sink is used, and so on.
3373    ///
3374    /// If an unsupported compression type is supplied, the
3375    /// `stream_sink_request` request will be closed with an epitaph value of
3376    /// `ZX_ERR_INVALID_ARGS`.
3377    pub fn r#create_stream_sink(
3378        &self,
3379        mut buffers: Vec<fdomain_client::Vmo>,
3380        mut stream_type: &AudioStreamType,
3381        mut compression: Option<&Compression>,
3382        mut stream_sink_request: fdomain_client::fidl::ServerEnd<StreamSinkMarker>,
3383    ) -> Result<(), fidl::Error> {
3384        AudioConsumerProxyInterface::r#create_stream_sink(
3385            self,
3386            buffers,
3387            stream_type,
3388            compression,
3389            stream_sink_request,
3390        )
3391    }
3392
3393    /// Starts rendering as indicated by `flags`.
3394    ///
3395    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
3396    /// Typically, this is the timestamp of the first packet that will be
3397    /// rendered. If packets will be supplied with no timestamps, this value
3398    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
3399    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
3400    ///     1. When starting for the first time, the default media time is the
3401    ///        timestamp on the first packet sent to the stream sink.
3402    ///     2. When resuming after stop, the default media time is the media
3403    ///        time at which the stream stopped.
3404    ///
3405    /// `reference_time` is the monotonic system time at which rendering should
3406    /// be started. For supply-driven sources, this must be the time at which
3407    /// the first packet was (or will be) sent plus a lead time, which must be
3408    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
3409    /// sources, the client must ensure that the lead time requirement is met at
3410    /// the start time.  Passing the default value of 0 for `reference_time`
3411    /// causes the consumer to choose a start time based on the availability of
3412    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
3413    /// specified.
3414    ///
3415    /// The actual start time will be reflected in the updated status.
3416    pub fn r#start(
3417        &self,
3418        mut flags: AudioConsumerStartFlags,
3419        mut reference_time: i64,
3420        mut media_time: i64,
3421    ) -> Result<(), fidl::Error> {
3422        AudioConsumerProxyInterface::r#start(self, flags, reference_time, media_time)
3423    }
3424
3425    /// Stops rendering as soon as possible after this method is called. The actual stop time will
3426    /// be reflected in the updated status.
3427    pub fn r#stop(&self) -> Result<(), fidl::Error> {
3428        AudioConsumerProxyInterface::r#stop(self)
3429    }
3430
3431    /// Requests to change the playback rate of the renderer. 1.0 means normal
3432    /// playback. Negative rates are not supported. The new rate will be
3433    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
3434    pub fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
3435        AudioConsumerProxyInterface::r#set_rate(self, rate)
3436    }
3437
3438    /// Binds to this `AudioConsumer` volume control for control and notifications.
3439    pub fn r#bind_volume_control(
3440        &self,
3441        mut volume_control_request: fdomain_client::fidl::ServerEnd<
3442            fdomain_fuchsia_media_audio::VolumeControlMarker,
3443        >,
3444    ) -> Result<(), fidl::Error> {
3445        AudioConsumerProxyInterface::r#bind_volume_control(self, volume_control_request)
3446    }
3447
3448    /// Gets the current status of the consumer using the long get pattern. The consumer responds
3449    /// to this method when the status changes - initially with respect to the initial status value
3450    /// and thereafter with respect to the previously-reported status value.
3451    pub fn r#watch_status(
3452        &self,
3453    ) -> fidl::client::QueryResponseFut<
3454        AudioConsumerStatus,
3455        fdomain_client::fidl::FDomainResourceDialect,
3456    > {
3457        AudioConsumerProxyInterface::r#watch_status(self)
3458    }
3459}
3460
3461impl AudioConsumerProxyInterface for AudioConsumerProxy {
3462    fn r#create_stream_sink(
3463        &self,
3464        mut buffers: Vec<fdomain_client::Vmo>,
3465        mut stream_type: &AudioStreamType,
3466        mut compression: Option<&Compression>,
3467        mut stream_sink_request: fdomain_client::fidl::ServerEnd<StreamSinkMarker>,
3468    ) -> Result<(), fidl::Error> {
3469        self.client.send::<AudioConsumerCreateStreamSinkRequest>(
3470            (buffers.as_mut(), stream_type, compression, stream_sink_request),
3471            0x525b3b97fdf7d884,
3472            fidl::encoding::DynamicFlags::empty(),
3473        )
3474    }
3475
3476    fn r#start(
3477        &self,
3478        mut flags: AudioConsumerStartFlags,
3479        mut reference_time: i64,
3480        mut media_time: i64,
3481    ) -> Result<(), fidl::Error> {
3482        self.client.send::<AudioConsumerStartRequest>(
3483            (flags, reference_time, media_time),
3484            0x4fdbd44b3f2a3a3c,
3485            fidl::encoding::DynamicFlags::empty(),
3486        )
3487    }
3488
3489    fn r#stop(&self) -> Result<(), fidl::Error> {
3490        self.client.send::<fidl::encoding::EmptyPayload>(
3491            (),
3492            0x3d46c3741686c40d,
3493            fidl::encoding::DynamicFlags::empty(),
3494        )
3495    }
3496
3497    fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
3498        self.client.send::<AudioConsumerSetRateRequest>(
3499            (rate,),
3500            0x45342b73968bfafe,
3501            fidl::encoding::DynamicFlags::empty(),
3502        )
3503    }
3504
3505    fn r#bind_volume_control(
3506        &self,
3507        mut volume_control_request: fdomain_client::fidl::ServerEnd<
3508            fdomain_fuchsia_media_audio::VolumeControlMarker,
3509        >,
3510    ) -> Result<(), fidl::Error> {
3511        self.client.send::<AudioConsumerBindVolumeControlRequest>(
3512            (volume_control_request,),
3513            0x6f1b01fd887f5748,
3514            fidl::encoding::DynamicFlags::empty(),
3515        )
3516    }
3517
3518    type WatchStatusResponseFut = fidl::client::QueryResponseFut<
3519        AudioConsumerStatus,
3520        fdomain_client::fidl::FDomainResourceDialect,
3521    >;
3522    fn r#watch_status(&self) -> Self::WatchStatusResponseFut {
3523        fn _decode(
3524            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3525        ) -> Result<AudioConsumerStatus, fidl::Error> {
3526            let _response = fidl::client::decode_transaction_body::<
3527                AudioConsumerWatchStatusResponse,
3528                fdomain_client::fidl::FDomainResourceDialect,
3529                0x35cf702c721e2cc6,
3530            >(_buf?)?;
3531            Ok(_response.status)
3532        }
3533        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, AudioConsumerStatus>(
3534            (),
3535            0x35cf702c721e2cc6,
3536            fidl::encoding::DynamicFlags::empty(),
3537            _decode,
3538        )
3539    }
3540}
3541
3542pub struct AudioConsumerEventStream {
3543    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
3544}
3545
3546impl std::marker::Unpin for AudioConsumerEventStream {}
3547
3548impl futures::stream::FusedStream for AudioConsumerEventStream {
3549    fn is_terminated(&self) -> bool {
3550        self.event_receiver.is_terminated()
3551    }
3552}
3553
3554impl futures::Stream for AudioConsumerEventStream {
3555    type Item = Result<AudioConsumerEvent, fidl::Error>;
3556
3557    fn poll_next(
3558        mut self: std::pin::Pin<&mut Self>,
3559        cx: &mut std::task::Context<'_>,
3560    ) -> std::task::Poll<Option<Self::Item>> {
3561        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3562            &mut self.event_receiver,
3563            cx
3564        )?) {
3565            Some(buf) => std::task::Poll::Ready(Some(AudioConsumerEvent::decode(buf))),
3566            None => std::task::Poll::Ready(None),
3567        }
3568    }
3569}
3570
3571#[derive(Debug)]
3572pub enum AudioConsumerEvent {
3573    OnEndOfStream {},
3574}
3575
3576impl AudioConsumerEvent {
3577    #[allow(irrefutable_let_patterns)]
3578    pub fn into_on_end_of_stream(self) -> Option<()> {
3579        if let AudioConsumerEvent::OnEndOfStream {} = self { Some(()) } else { None }
3580    }
3581
3582    /// Decodes a message buffer as a [`AudioConsumerEvent`].
3583    fn decode(
3584        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3585    ) -> Result<AudioConsumerEvent, fidl::Error> {
3586        let (bytes, _handles) = buf.split_mut();
3587        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3588        debug_assert_eq!(tx_header.tx_id, 0);
3589        match tx_header.ordinal {
3590            0x53a64e6d0e8f8a20 => {
3591                let mut out = fidl::new_empty!(
3592                    fidl::encoding::EmptyPayload,
3593                    fdomain_client::fidl::FDomainResourceDialect
3594                );
3595                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
3596                Ok((AudioConsumerEvent::OnEndOfStream {}))
3597            }
3598            _ => Err(fidl::Error::UnknownOrdinal {
3599                ordinal: tx_header.ordinal,
3600                protocol_name:
3601                    <AudioConsumerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
3602            }),
3603        }
3604    }
3605}
3606
3607/// A Stream of incoming requests for fuchsia.media/AudioConsumer.
3608pub struct AudioConsumerRequestStream {
3609    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3610    is_terminated: bool,
3611}
3612
3613impl std::marker::Unpin for AudioConsumerRequestStream {}
3614
3615impl futures::stream::FusedStream for AudioConsumerRequestStream {
3616    fn is_terminated(&self) -> bool {
3617        self.is_terminated
3618    }
3619}
3620
3621impl fdomain_client::fidl::RequestStream for AudioConsumerRequestStream {
3622    type Protocol = AudioConsumerMarker;
3623    type ControlHandle = AudioConsumerControlHandle;
3624
3625    fn from_channel(channel: fdomain_client::Channel) -> Self {
3626        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3627    }
3628
3629    fn control_handle(&self) -> Self::ControlHandle {
3630        AudioConsumerControlHandle { inner: self.inner.clone() }
3631    }
3632
3633    fn into_inner(
3634        self,
3635    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
3636    {
3637        (self.inner, self.is_terminated)
3638    }
3639
3640    fn from_inner(
3641        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3642        is_terminated: bool,
3643    ) -> Self {
3644        Self { inner, is_terminated }
3645    }
3646}
3647
3648impl futures::Stream for AudioConsumerRequestStream {
3649    type Item = Result<AudioConsumerRequest, fidl::Error>;
3650
3651    fn poll_next(
3652        mut self: std::pin::Pin<&mut Self>,
3653        cx: &mut std::task::Context<'_>,
3654    ) -> std::task::Poll<Option<Self::Item>> {
3655        let this = &mut *self;
3656        if this.inner.check_shutdown(cx) {
3657            this.is_terminated = true;
3658            return std::task::Poll::Ready(None);
3659        }
3660        if this.is_terminated {
3661            panic!("polled AudioConsumerRequestStream after completion");
3662        }
3663        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
3664            |bytes, handles| {
3665                match this.inner.channel().read_etc(cx, bytes, handles) {
3666                    std::task::Poll::Ready(Ok(())) => {}
3667                    std::task::Poll::Pending => return std::task::Poll::Pending,
3668                    std::task::Poll::Ready(Err(None)) => {
3669                        this.is_terminated = true;
3670                        return std::task::Poll::Ready(None);
3671                    }
3672                    std::task::Poll::Ready(Err(Some(e))) => {
3673                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3674                            e.into(),
3675                        ))));
3676                    }
3677                }
3678
3679                // A message has been received from the channel
3680                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3681
3682                std::task::Poll::Ready(Some(match header.ordinal {
3683                0x525b3b97fdf7d884 => {
3684                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3685                    let mut req = fidl::new_empty!(AudioConsumerCreateStreamSinkRequest, fdomain_client::fidl::FDomainResourceDialect);
3686                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioConsumerCreateStreamSinkRequest>(&header, _body_bytes, handles, &mut req)?;
3687                    let control_handle = AudioConsumerControlHandle {
3688                        inner: this.inner.clone(),
3689                    };
3690                    Ok(AudioConsumerRequest::CreateStreamSink {buffers: req.buffers,
3691stream_type: req.stream_type,
3692compression: req.compression,
3693stream_sink_request: req.stream_sink_request,
3694
3695                        control_handle,
3696                    })
3697                }
3698                0x4fdbd44b3f2a3a3c => {
3699                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3700                    let mut req = fidl::new_empty!(AudioConsumerStartRequest, fdomain_client::fidl::FDomainResourceDialect);
3701                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioConsumerStartRequest>(&header, _body_bytes, handles, &mut req)?;
3702                    let control_handle = AudioConsumerControlHandle {
3703                        inner: this.inner.clone(),
3704                    };
3705                    Ok(AudioConsumerRequest::Start {flags: req.flags,
3706reference_time: req.reference_time,
3707media_time: req.media_time,
3708
3709                        control_handle,
3710                    })
3711                }
3712                0x3d46c3741686c40d => {
3713                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3714                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
3715                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3716                    let control_handle = AudioConsumerControlHandle {
3717                        inner: this.inner.clone(),
3718                    };
3719                    Ok(AudioConsumerRequest::Stop {
3720                        control_handle,
3721                    })
3722                }
3723                0x45342b73968bfafe => {
3724                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3725                    let mut req = fidl::new_empty!(AudioConsumerSetRateRequest, fdomain_client::fidl::FDomainResourceDialect);
3726                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioConsumerSetRateRequest>(&header, _body_bytes, handles, &mut req)?;
3727                    let control_handle = AudioConsumerControlHandle {
3728                        inner: this.inner.clone(),
3729                    };
3730                    Ok(AudioConsumerRequest::SetRate {rate: req.rate,
3731
3732                        control_handle,
3733                    })
3734                }
3735                0x6f1b01fd887f5748 => {
3736                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3737                    let mut req = fidl::new_empty!(AudioConsumerBindVolumeControlRequest, fdomain_client::fidl::FDomainResourceDialect);
3738                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioConsumerBindVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
3739                    let control_handle = AudioConsumerControlHandle {
3740                        inner: this.inner.clone(),
3741                    };
3742                    Ok(AudioConsumerRequest::BindVolumeControl {volume_control_request: req.volume_control_request,
3743
3744                        control_handle,
3745                    })
3746                }
3747                0x35cf702c721e2cc6 => {
3748                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3749                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
3750                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3751                    let control_handle = AudioConsumerControlHandle {
3752                        inner: this.inner.clone(),
3753                    };
3754                    Ok(AudioConsumerRequest::WatchStatus {
3755                        responder: AudioConsumerWatchStatusResponder {
3756                            control_handle: std::mem::ManuallyDrop::new(control_handle),
3757                            tx_id: header.tx_id,
3758                        },
3759                    })
3760                }
3761                _ => Err(fidl::Error::UnknownOrdinal {
3762                    ordinal: header.ordinal,
3763                    protocol_name: <AudioConsumerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
3764                }),
3765            }))
3766            },
3767        )
3768    }
3769}
3770
3771/// Interface for playing and controlling audio.
3772#[derive(Debug)]
3773pub enum AudioConsumerRequest {
3774    /// Creates a `StreamSink` for the consumer with the indicated properties.
3775    ///
3776    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
3777    /// sequentially rather than concurrently. The first stream sink that's created using this
3778    /// method is used as the sole source of packets incoming to the logical consumer until that
3779    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
3780    /// the second stream sink is used, and so on.
3781    ///
3782    /// If an unsupported compression type is supplied, the
3783    /// `stream_sink_request` request will be closed with an epitaph value of
3784    /// `ZX_ERR_INVALID_ARGS`.
3785    CreateStreamSink {
3786        buffers: Vec<fdomain_client::Vmo>,
3787        stream_type: AudioStreamType,
3788        compression: Option<Box<Compression>>,
3789        stream_sink_request: fdomain_client::fidl::ServerEnd<StreamSinkMarker>,
3790        control_handle: AudioConsumerControlHandle,
3791    },
3792    /// Starts rendering as indicated by `flags`.
3793    ///
3794    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
3795    /// Typically, this is the timestamp of the first packet that will be
3796    /// rendered. If packets will be supplied with no timestamps, this value
3797    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
3798    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
3799    ///     1. When starting for the first time, the default media time is the
3800    ///        timestamp on the first packet sent to the stream sink.
3801    ///     2. When resuming after stop, the default media time is the media
3802    ///        time at which the stream stopped.
3803    ///
3804    /// `reference_time` is the monotonic system time at which rendering should
3805    /// be started. For supply-driven sources, this must be the time at which
3806    /// the first packet was (or will be) sent plus a lead time, which must be
3807    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
3808    /// sources, the client must ensure that the lead time requirement is met at
3809    /// the start time.  Passing the default value of 0 for `reference_time`
3810    /// causes the consumer to choose a start time based on the availability of
3811    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
3812    /// specified.
3813    ///
3814    /// The actual start time will be reflected in the updated status.
3815    Start {
3816        flags: AudioConsumerStartFlags,
3817        reference_time: i64,
3818        media_time: i64,
3819        control_handle: AudioConsumerControlHandle,
3820    },
3821    /// Stops rendering as soon as possible after this method is called. The actual stop time will
3822    /// be reflected in the updated status.
3823    Stop { control_handle: AudioConsumerControlHandle },
3824    /// Requests to change the playback rate of the renderer. 1.0 means normal
3825    /// playback. Negative rates are not supported. The new rate will be
3826    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
3827    SetRate { rate: f32, control_handle: AudioConsumerControlHandle },
3828    /// Binds to this `AudioConsumer` volume control for control and notifications.
3829    BindVolumeControl {
3830        volume_control_request:
3831            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
3832        control_handle: AudioConsumerControlHandle,
3833    },
3834    /// Gets the current status of the consumer using the long get pattern. The consumer responds
3835    /// to this method when the status changes - initially with respect to the initial status value
3836    /// and thereafter with respect to the previously-reported status value.
3837    WatchStatus { responder: AudioConsumerWatchStatusResponder },
3838}
3839
3840impl AudioConsumerRequest {
3841    #[allow(irrefutable_let_patterns)]
3842    pub fn into_create_stream_sink(
3843        self,
3844    ) -> Option<(
3845        Vec<fdomain_client::Vmo>,
3846        AudioStreamType,
3847        Option<Box<Compression>>,
3848        fdomain_client::fidl::ServerEnd<StreamSinkMarker>,
3849        AudioConsumerControlHandle,
3850    )> {
3851        if let AudioConsumerRequest::CreateStreamSink {
3852            buffers,
3853            stream_type,
3854            compression,
3855            stream_sink_request,
3856            control_handle,
3857        } = self
3858        {
3859            Some((buffers, stream_type, compression, stream_sink_request, control_handle))
3860        } else {
3861            None
3862        }
3863    }
3864
3865    #[allow(irrefutable_let_patterns)]
3866    pub fn into_start(
3867        self,
3868    ) -> Option<(AudioConsumerStartFlags, i64, i64, AudioConsumerControlHandle)> {
3869        if let AudioConsumerRequest::Start { flags, reference_time, media_time, control_handle } =
3870            self
3871        {
3872            Some((flags, reference_time, media_time, control_handle))
3873        } else {
3874            None
3875        }
3876    }
3877
3878    #[allow(irrefutable_let_patterns)]
3879    pub fn into_stop(self) -> Option<(AudioConsumerControlHandle)> {
3880        if let AudioConsumerRequest::Stop { control_handle } = self {
3881            Some((control_handle))
3882        } else {
3883            None
3884        }
3885    }
3886
3887    #[allow(irrefutable_let_patterns)]
3888    pub fn into_set_rate(self) -> Option<(f32, AudioConsumerControlHandle)> {
3889        if let AudioConsumerRequest::SetRate { rate, control_handle } = self {
3890            Some((rate, control_handle))
3891        } else {
3892            None
3893        }
3894    }
3895
3896    #[allow(irrefutable_let_patterns)]
3897    pub fn into_bind_volume_control(
3898        self,
3899    ) -> Option<(
3900        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
3901        AudioConsumerControlHandle,
3902    )> {
3903        if let AudioConsumerRequest::BindVolumeControl { volume_control_request, control_handle } =
3904            self
3905        {
3906            Some((volume_control_request, control_handle))
3907        } else {
3908            None
3909        }
3910    }
3911
3912    #[allow(irrefutable_let_patterns)]
3913    pub fn into_watch_status(self) -> Option<(AudioConsumerWatchStatusResponder)> {
3914        if let AudioConsumerRequest::WatchStatus { responder } = self {
3915            Some((responder))
3916        } else {
3917            None
3918        }
3919    }
3920
3921    /// Name of the method defined in FIDL
3922    pub fn method_name(&self) -> &'static str {
3923        match *self {
3924            AudioConsumerRequest::CreateStreamSink { .. } => "create_stream_sink",
3925            AudioConsumerRequest::Start { .. } => "start",
3926            AudioConsumerRequest::Stop { .. } => "stop",
3927            AudioConsumerRequest::SetRate { .. } => "set_rate",
3928            AudioConsumerRequest::BindVolumeControl { .. } => "bind_volume_control",
3929            AudioConsumerRequest::WatchStatus { .. } => "watch_status",
3930        }
3931    }
3932}
3933
3934#[derive(Debug, Clone)]
3935pub struct AudioConsumerControlHandle {
3936    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3937}
3938
3939impl fdomain_client::fidl::ControlHandle for AudioConsumerControlHandle {
3940    fn shutdown(&self) {
3941        self.inner.shutdown()
3942    }
3943
3944    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3945        self.inner.shutdown_with_epitaph(status)
3946    }
3947
3948    fn is_closed(&self) -> bool {
3949        self.inner.channel().is_closed()
3950    }
3951    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
3952        self.inner.channel().on_closed()
3953    }
3954}
3955
3956impl AudioConsumerControlHandle {
3957    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
3958        self.inner.send::<fidl::encoding::EmptyPayload>(
3959            (),
3960            0,
3961            0x53a64e6d0e8f8a20,
3962            fidl::encoding::DynamicFlags::empty(),
3963        )
3964    }
3965}
3966
3967#[must_use = "FIDL methods require a response to be sent"]
3968#[derive(Debug)]
3969pub struct AudioConsumerWatchStatusResponder {
3970    control_handle: std::mem::ManuallyDrop<AudioConsumerControlHandle>,
3971    tx_id: u32,
3972}
3973
3974/// Set the the channel to be shutdown (see [`AudioConsumerControlHandle::shutdown`])
3975/// if the responder is dropped without sending a response, so that the client
3976/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3977impl std::ops::Drop for AudioConsumerWatchStatusResponder {
3978    fn drop(&mut self) {
3979        self.control_handle.shutdown();
3980        // Safety: drops once, never accessed again
3981        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3982    }
3983}
3984
3985impl fdomain_client::fidl::Responder for AudioConsumerWatchStatusResponder {
3986    type ControlHandle = AudioConsumerControlHandle;
3987
3988    fn control_handle(&self) -> &AudioConsumerControlHandle {
3989        &self.control_handle
3990    }
3991
3992    fn drop_without_shutdown(mut self) {
3993        // Safety: drops once, never accessed again due to mem::forget
3994        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3995        // Prevent Drop from running (which would shut down the channel)
3996        std::mem::forget(self);
3997    }
3998}
3999
4000impl AudioConsumerWatchStatusResponder {
4001    /// Sends a response to the FIDL transaction.
4002    ///
4003    /// Sets the channel to shutdown if an error occurs.
4004    pub fn send(self, mut status: &AudioConsumerStatus) -> Result<(), fidl::Error> {
4005        let _result = self.send_raw(status);
4006        if _result.is_err() {
4007            self.control_handle.shutdown();
4008        }
4009        self.drop_without_shutdown();
4010        _result
4011    }
4012
4013    /// Similar to "send" but does not shutdown the channel if an error occurs.
4014    pub fn send_no_shutdown_on_err(
4015        self,
4016        mut status: &AudioConsumerStatus,
4017    ) -> Result<(), fidl::Error> {
4018        let _result = self.send_raw(status);
4019        self.drop_without_shutdown();
4020        _result
4021    }
4022
4023    fn send_raw(&self, mut status: &AudioConsumerStatus) -> Result<(), fidl::Error> {
4024        self.control_handle.inner.send::<AudioConsumerWatchStatusResponse>(
4025            (status,),
4026            self.tx_id,
4027            0x35cf702c721e2cc6,
4028            fidl::encoding::DynamicFlags::empty(),
4029        )
4030    }
4031}
4032
4033#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4034pub struct AudioCoreMarker;
4035
4036impl fdomain_client::fidl::ProtocolMarker for AudioCoreMarker {
4037    type Proxy = AudioCoreProxy;
4038    type RequestStream = AudioCoreRequestStream;
4039
4040    const DEBUG_NAME: &'static str = "fuchsia.media.AudioCore";
4041}
4042impl fdomain_client::fidl::DiscoverableProtocolMarker for AudioCoreMarker {}
4043
4044pub trait AudioCoreProxyInterface: Send + Sync {
4045    fn r#create_audio_renderer(
4046        &self,
4047        audio_out_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
4048    ) -> Result<(), fidl::Error>;
4049    fn r#create_audio_capturer_with_configuration(
4050        &self,
4051        stream_type: &AudioStreamType,
4052        configuration: &AudioCapturerConfiguration,
4053        audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
4054    ) -> Result<(), fidl::Error>;
4055    fn r#create_audio_capturer(
4056        &self,
4057        loopback: bool,
4058        audio_in_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
4059    ) -> Result<(), fidl::Error>;
4060    fn r#set_render_usage_gain(
4061        &self,
4062        usage: AudioRenderUsage,
4063        gain_db: f32,
4064    ) -> Result<(), fidl::Error>;
4065    fn r#set_render_usage_gain2(
4066        &self,
4067        usage: AudioRenderUsage2,
4068        gain_db: f32,
4069    ) -> Result<(), fidl::Error>;
4070    fn r#set_capture_usage_gain(
4071        &self,
4072        usage: AudioCaptureUsage,
4073        gain_db: f32,
4074    ) -> Result<(), fidl::Error>;
4075    fn r#set_capture_usage_gain2(
4076        &self,
4077        usage: AudioCaptureUsage2,
4078        gain_db: f32,
4079    ) -> Result<(), fidl::Error>;
4080    fn r#bind_usage_volume_control(
4081        &self,
4082        usage: &Usage,
4083        volume_control: fdomain_client::fidl::ServerEnd<
4084            fdomain_fuchsia_media_audio::VolumeControlMarker,
4085        >,
4086    ) -> Result<(), fidl::Error>;
4087    fn r#bind_usage_volume_control2(
4088        &self,
4089        usage: &Usage2,
4090        volume_control: fdomain_client::fidl::ServerEnd<
4091            fdomain_fuchsia_media_audio::VolumeControlMarker,
4092        >,
4093    ) -> Result<(), fidl::Error>;
4094    type GetVolumeFromDbResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4095    fn r#get_volume_from_db(&self, usage: &Usage, gain_db: f32)
4096    -> Self::GetVolumeFromDbResponseFut;
4097    type GetVolumeFromDb2ResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4098    fn r#get_volume_from_db2(
4099        &self,
4100        usage: &Usage2,
4101        gain_db: f32,
4102    ) -> Self::GetVolumeFromDb2ResponseFut;
4103    type GetDbFromVolumeResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4104    fn r#get_db_from_volume(&self, usage: &Usage, volume: f32) -> Self::GetDbFromVolumeResponseFut;
4105    type GetDbFromVolume2ResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4106    fn r#get_db_from_volume2(
4107        &self,
4108        usage: &Usage2,
4109        volume: f32,
4110    ) -> Self::GetDbFromVolume2ResponseFut;
4111    fn r#set_interaction(
4112        &self,
4113        active: &Usage,
4114        affected: &Usage,
4115        behavior: Behavior,
4116    ) -> Result<(), fidl::Error>;
4117    fn r#set_interaction2(
4118        &self,
4119        active: &Usage2,
4120        affected: &Usage2,
4121        behavior: Behavior,
4122    ) -> Result<(), fidl::Error>;
4123    fn r#reset_interactions(&self) -> Result<(), fidl::Error>;
4124    fn r#load_defaults(&self) -> Result<(), fidl::Error>;
4125}
4126
4127#[derive(Debug, Clone)]
4128pub struct AudioCoreProxy {
4129    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
4130}
4131
4132impl fdomain_client::fidl::Proxy for AudioCoreProxy {
4133    type Protocol = AudioCoreMarker;
4134
4135    fn from_channel(inner: fdomain_client::Channel) -> Self {
4136        Self::new(inner)
4137    }
4138
4139    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
4140        self.client.into_channel().map_err(|client| Self { client })
4141    }
4142
4143    fn as_channel(&self) -> &fdomain_client::Channel {
4144        self.client.as_channel()
4145    }
4146}
4147
4148impl AudioCoreProxy {
4149    /// Create a new Proxy for fuchsia.media/AudioCore.
4150    pub fn new(channel: fdomain_client::Channel) -> Self {
4151        let protocol_name = <AudioCoreMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
4152        Self { client: fidl::client::Client::new(channel, protocol_name) }
4153    }
4154
4155    /// Get a Stream of events from the remote end of the protocol.
4156    ///
4157    /// # Panics
4158    ///
4159    /// Panics if the event stream was already taken.
4160    pub fn take_event_stream(&self) -> AudioCoreEventStream {
4161        AudioCoreEventStream { event_receiver: self.client.take_event_receiver() }
4162    }
4163
4164    /// Creates an AudioRenderer which outputs audio to the default device.
4165    pub fn r#create_audio_renderer(
4166        &self,
4167        mut audio_out_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
4168    ) -> Result<(), fidl::Error> {
4169        AudioCoreProxyInterface::r#create_audio_renderer(self, audio_out_request)
4170    }
4171
4172    /// Creates an AudioCapturer according to the given requirements.
4173    ///
4174    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
4175    /// It causes the source material to be reformatted/resampled if needed
4176    /// in order to produce the requested stream type.
4177    ///
4178    /// `usage` is used by Fuchsia to make decisions about user experience.
4179    /// See `AudioCaptureUsage` for more details.
4180    ///
4181    /// `configuration` must be initialized to a variant, or no capturer
4182    /// can be created.
4183    pub fn r#create_audio_capturer_with_configuration(
4184        &self,
4185        mut stream_type: &AudioStreamType,
4186        mut configuration: &AudioCapturerConfiguration,
4187        mut audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
4188    ) -> Result<(), fidl::Error> {
4189        AudioCoreProxyInterface::r#create_audio_capturer_with_configuration(
4190            self,
4191            stream_type,
4192            configuration,
4193            audio_capturer_request,
4194        )
4195    }
4196
4197    /// Creates an AudioCapturer which either captures from the current default
4198    /// audio input device, or loops-back from the current default audio output
4199    /// device based on value passed for the loopback flag.
4200    pub fn r#create_audio_capturer(
4201        &self,
4202        mut loopback: bool,
4203        mut audio_in_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
4204    ) -> Result<(), fidl::Error> {
4205        AudioCoreProxyInterface::r#create_audio_capturer(self, loopback, audio_in_request)
4206    }
4207
4208    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
4209    pub fn r#set_render_usage_gain(
4210        &self,
4211        mut usage: AudioRenderUsage,
4212        mut gain_db: f32,
4213    ) -> Result<(), fidl::Error> {
4214        AudioCoreProxyInterface::r#set_render_usage_gain(self, usage, gain_db)
4215    }
4216
4217    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
4218    pub fn r#set_render_usage_gain2(
4219        &self,
4220        mut usage: AudioRenderUsage2,
4221        mut gain_db: f32,
4222    ) -> Result<(), fidl::Error> {
4223        AudioCoreProxyInterface::r#set_render_usage_gain2(self, usage, gain_db)
4224    }
4225
4226    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
4227    pub fn r#set_capture_usage_gain(
4228        &self,
4229        mut usage: AudioCaptureUsage,
4230        mut gain_db: f32,
4231    ) -> Result<(), fidl::Error> {
4232        AudioCoreProxyInterface::r#set_capture_usage_gain(self, usage, gain_db)
4233    }
4234
4235    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
4236    pub fn r#set_capture_usage_gain2(
4237        &self,
4238        mut usage: AudioCaptureUsage2,
4239        mut gain_db: f32,
4240    ) -> Result<(), fidl::Error> {
4241        AudioCoreProxyInterface::r#set_capture_usage_gain2(self, usage, gain_db)
4242    }
4243
4244    /// Binds to a volume control protocol for the given usage.
4245    pub fn r#bind_usage_volume_control(
4246        &self,
4247        mut usage: &Usage,
4248        mut volume_control: fdomain_client::fidl::ServerEnd<
4249            fdomain_fuchsia_media_audio::VolumeControlMarker,
4250        >,
4251    ) -> Result<(), fidl::Error> {
4252        AudioCoreProxyInterface::r#bind_usage_volume_control(self, usage, volume_control)
4253    }
4254
4255    /// Binds to a volume control protocol for the given usage.
4256    pub fn r#bind_usage_volume_control2(
4257        &self,
4258        mut usage: &Usage2,
4259        mut volume_control: fdomain_client::fidl::ServerEnd<
4260            fdomain_fuchsia_media_audio::VolumeControlMarker,
4261        >,
4262    ) -> Result<(), fidl::Error> {
4263        AudioCoreProxyInterface::r#bind_usage_volume_control2(self, usage, volume_control)
4264    }
4265
4266    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
4267    /// `usage`. This is the same mapping as used by the VolumeControl from
4268    /// `BindUsageVolumeControl`.
4269    pub fn r#get_volume_from_db(
4270        &self,
4271        mut usage: &Usage,
4272        mut gain_db: f32,
4273    ) -> fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect> {
4274        AudioCoreProxyInterface::r#get_volume_from_db(self, usage, gain_db)
4275    }
4276
4277    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
4278    /// `usage`. This is the same mapping as used by the VolumeControl from
4279    /// `BindUsageVolumeControl`.
4280    pub fn r#get_volume_from_db2(
4281        &self,
4282        mut usage: &Usage2,
4283        mut gain_db: f32,
4284    ) -> fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect> {
4285        AudioCoreProxyInterface::r#get_volume_from_db2(self, usage, gain_db)
4286    }
4287
4288    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
4289    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
4290    pub fn r#get_db_from_volume(
4291        &self,
4292        mut usage: &Usage,
4293        mut volume: f32,
4294    ) -> fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect> {
4295        AudioCoreProxyInterface::r#get_db_from_volume(self, usage, volume)
4296    }
4297
4298    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
4299    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
4300    pub fn r#get_db_from_volume2(
4301        &self,
4302        mut usage: &Usage2,
4303        mut volume: f32,
4304    ) -> fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect> {
4305        AudioCoreProxyInterface::r#get_db_from_volume2(self, usage, volume)
4306    }
4307
4308    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
4309    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
4310    /// the Behavior specified will be applied to the streams of Usage `affected`.
4311    pub fn r#set_interaction(
4312        &self,
4313        mut active: &Usage,
4314        mut affected: &Usage,
4315        mut behavior: Behavior,
4316    ) -> Result<(), fidl::Error> {
4317        AudioCoreProxyInterface::r#set_interaction(self, active, affected, behavior)
4318    }
4319
4320    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
4321    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
4322    /// the Behavior specified will be applied to the streams of Usage `affected`.
4323    pub fn r#set_interaction2(
4324        &self,
4325        mut active: &Usage2,
4326        mut affected: &Usage2,
4327        mut behavior: Behavior,
4328    ) -> Result<(), fidl::Error> {
4329        AudioCoreProxyInterface::r#set_interaction2(self, active, affected, behavior)
4330    }
4331
4332    /// Re-initializes the set of rules that are currently governing the interaction of streams in
4333    /// audio_core. The default behavior is 'NONE'.
4334    pub fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
4335        AudioCoreProxyInterface::r#reset_interactions(self)
4336    }
4337
4338    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
4339    /// does not provide a config.
4340    pub fn r#load_defaults(&self) -> Result<(), fidl::Error> {
4341        AudioCoreProxyInterface::r#load_defaults(self)
4342    }
4343}
4344
4345impl AudioCoreProxyInterface for AudioCoreProxy {
4346    fn r#create_audio_renderer(
4347        &self,
4348        mut audio_out_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
4349    ) -> Result<(), fidl::Error> {
4350        self.client.send::<AudioCoreCreateAudioRendererRequest>(
4351            (audio_out_request,),
4352            0x2ac9beba47f83435,
4353            fidl::encoding::DynamicFlags::empty(),
4354        )
4355    }
4356
4357    fn r#create_audio_capturer_with_configuration(
4358        &self,
4359        mut stream_type: &AudioStreamType,
4360        mut configuration: &AudioCapturerConfiguration,
4361        mut audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
4362    ) -> Result<(), fidl::Error> {
4363        self.client.send::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(
4364            (stream_type, configuration, audio_capturer_request),
4365            0x459de383b0d76d97,
4366            fidl::encoding::DynamicFlags::empty(),
4367        )
4368    }
4369
4370    fn r#create_audio_capturer(
4371        &self,
4372        mut loopback: bool,
4373        mut audio_in_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
4374    ) -> Result<(), fidl::Error> {
4375        self.client.send::<AudioCoreCreateAudioCapturerRequest>(
4376            (loopback, audio_in_request),
4377            0x787db169df99aed0,
4378            fidl::encoding::DynamicFlags::empty(),
4379        )
4380    }
4381
4382    fn r#set_render_usage_gain(
4383        &self,
4384        mut usage: AudioRenderUsage,
4385        mut gain_db: f32,
4386    ) -> Result<(), fidl::Error> {
4387        self.client.send::<AudioCoreSetRenderUsageGainRequest>(
4388            (usage, gain_db),
4389            0x48097f45f6e2b8e7,
4390            fidl::encoding::DynamicFlags::empty(),
4391        )
4392    }
4393
4394    fn r#set_render_usage_gain2(
4395        &self,
4396        mut usage: AudioRenderUsage2,
4397        mut gain_db: f32,
4398    ) -> Result<(), fidl::Error> {
4399        self.client.send::<AudioCoreSetRenderUsageGain2Request>(
4400            (usage, gain_db),
4401            0x779b1531dc9e64f4,
4402            fidl::encoding::DynamicFlags::FLEXIBLE,
4403        )
4404    }
4405
4406    fn r#set_capture_usage_gain(
4407        &self,
4408        mut usage: AudioCaptureUsage,
4409        mut gain_db: f32,
4410    ) -> Result<(), fidl::Error> {
4411        self.client.send::<AudioCoreSetCaptureUsageGainRequest>(
4412            (usage, gain_db),
4413            0x457d29217d4ea248,
4414            fidl::encoding::DynamicFlags::empty(),
4415        )
4416    }
4417
4418    fn r#set_capture_usage_gain2(
4419        &self,
4420        mut usage: AudioCaptureUsage2,
4421        mut gain_db: f32,
4422    ) -> Result<(), fidl::Error> {
4423        self.client.send::<AudioCoreSetCaptureUsageGain2Request>(
4424            (usage, gain_db),
4425            0x15065ee308f44af0,
4426            fidl::encoding::DynamicFlags::FLEXIBLE,
4427        )
4428    }
4429
4430    fn r#bind_usage_volume_control(
4431        &self,
4432        mut usage: &Usage,
4433        mut volume_control: fdomain_client::fidl::ServerEnd<
4434            fdomain_fuchsia_media_audio::VolumeControlMarker,
4435        >,
4436    ) -> Result<(), fidl::Error> {
4437        self.client.send::<AudioCoreBindUsageVolumeControlRequest>(
4438            (usage, volume_control),
4439            0x7225be116aadc137,
4440            fidl::encoding::DynamicFlags::empty(),
4441        )
4442    }
4443
4444    fn r#bind_usage_volume_control2(
4445        &self,
4446        mut usage: &Usage2,
4447        mut volume_control: fdomain_client::fidl::ServerEnd<
4448            fdomain_fuchsia_media_audio::VolumeControlMarker,
4449        >,
4450    ) -> Result<(), fidl::Error> {
4451        self.client.send::<AudioCoreBindUsageVolumeControl2Request>(
4452            (usage, volume_control),
4453            0x729dff93019d055,
4454            fidl::encoding::DynamicFlags::FLEXIBLE,
4455        )
4456    }
4457
4458    type GetVolumeFromDbResponseFut =
4459        fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect>;
4460    fn r#get_volume_from_db(
4461        &self,
4462        mut usage: &Usage,
4463        mut gain_db: f32,
4464    ) -> Self::GetVolumeFromDbResponseFut {
4465        fn _decode(
4466            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4467        ) -> Result<f32, fidl::Error> {
4468            let _response = fidl::client::decode_transaction_body::<
4469                AudioCoreGetVolumeFromDbResponse,
4470                fdomain_client::fidl::FDomainResourceDialect,
4471                0x50e3ca45509770bf,
4472            >(_buf?)?;
4473            Ok(_response.volume)
4474        }
4475        self.client.send_query_and_decode::<AudioCoreGetVolumeFromDbRequest, f32>(
4476            (usage, gain_db),
4477            0x50e3ca45509770bf,
4478            fidl::encoding::DynamicFlags::empty(),
4479            _decode,
4480        )
4481    }
4482
4483    type GetVolumeFromDb2ResponseFut =
4484        fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect>;
4485    fn r#get_volume_from_db2(
4486        &self,
4487        mut usage: &Usage2,
4488        mut gain_db: f32,
4489    ) -> Self::GetVolumeFromDb2ResponseFut {
4490        fn _decode(
4491            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4492        ) -> Result<f32, fidl::Error> {
4493            let _response = fidl::client::decode_transaction_body::<
4494                fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>,
4495                fdomain_client::fidl::FDomainResourceDialect,
4496                0x165c811091ef99da,
4497            >(_buf?)?
4498            .into_result_fdomain::<AudioCoreMarker>("get_volume_from_db2")?;
4499            Ok(_response.volume)
4500        }
4501        self.client.send_query_and_decode::<AudioCoreGetVolumeFromDb2Request, f32>(
4502            (usage, gain_db),
4503            0x165c811091ef99da,
4504            fidl::encoding::DynamicFlags::FLEXIBLE,
4505            _decode,
4506        )
4507    }
4508
4509    type GetDbFromVolumeResponseFut =
4510        fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect>;
4511    fn r#get_db_from_volume(
4512        &self,
4513        mut usage: &Usage,
4514        mut volume: f32,
4515    ) -> Self::GetDbFromVolumeResponseFut {
4516        fn _decode(
4517            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4518        ) -> Result<f32, fidl::Error> {
4519            let _response = fidl::client::decode_transaction_body::<
4520                AudioCoreGetDbFromVolumeResponse,
4521                fdomain_client::fidl::FDomainResourceDialect,
4522                0x3e8eec27dd5a8bda,
4523            >(_buf?)?;
4524            Ok(_response.gain_db)
4525        }
4526        self.client.send_query_and_decode::<AudioCoreGetDbFromVolumeRequest, f32>(
4527            (usage, volume),
4528            0x3e8eec27dd5a8bda,
4529            fidl::encoding::DynamicFlags::empty(),
4530            _decode,
4531        )
4532    }
4533
4534    type GetDbFromVolume2ResponseFut =
4535        fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect>;
4536    fn r#get_db_from_volume2(
4537        &self,
4538        mut usage: &Usage2,
4539        mut volume: f32,
4540    ) -> Self::GetDbFromVolume2ResponseFut {
4541        fn _decode(
4542            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4543        ) -> Result<f32, fidl::Error> {
4544            let _response = fidl::client::decode_transaction_body::<
4545                fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>,
4546                fdomain_client::fidl::FDomainResourceDialect,
4547                0x5f421a8ebf265bf3,
4548            >(_buf?)?
4549            .into_result_fdomain::<AudioCoreMarker>("get_db_from_volume2")?;
4550            Ok(_response.gain_db)
4551        }
4552        self.client.send_query_and_decode::<AudioCoreGetDbFromVolume2Request, f32>(
4553            (usage, volume),
4554            0x5f421a8ebf265bf3,
4555            fidl::encoding::DynamicFlags::FLEXIBLE,
4556            _decode,
4557        )
4558    }
4559
4560    fn r#set_interaction(
4561        &self,
4562        mut active: &Usage,
4563        mut affected: &Usage,
4564        mut behavior: Behavior,
4565    ) -> Result<(), fidl::Error> {
4566        self.client.send::<AudioCoreSetInteractionRequest>(
4567            (active, affected, behavior),
4568            0x7bfed14345ece7b7,
4569            fidl::encoding::DynamicFlags::empty(),
4570        )
4571    }
4572
4573    fn r#set_interaction2(
4574        &self,
4575        mut active: &Usage2,
4576        mut affected: &Usage2,
4577        mut behavior: Behavior,
4578    ) -> Result<(), fidl::Error> {
4579        self.client.send::<AudioCoreSetInteraction2Request>(
4580            (active, affected, behavior),
4581            0x7226c7c6e6edc62f,
4582            fidl::encoding::DynamicFlags::FLEXIBLE,
4583        )
4584    }
4585
4586    fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
4587        self.client.send::<fidl::encoding::EmptyPayload>(
4588            (),
4589            0x65bd94d9d0a28b5e,
4590            fidl::encoding::DynamicFlags::empty(),
4591        )
4592    }
4593
4594    fn r#load_defaults(&self) -> Result<(), fidl::Error> {
4595        self.client.send::<fidl::encoding::EmptyPayload>(
4596            (),
4597            0x54a0bebca85f6b31,
4598            fidl::encoding::DynamicFlags::empty(),
4599        )
4600    }
4601}
4602
4603pub struct AudioCoreEventStream {
4604    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
4605}
4606
4607impl std::marker::Unpin for AudioCoreEventStream {}
4608
4609impl futures::stream::FusedStream for AudioCoreEventStream {
4610    fn is_terminated(&self) -> bool {
4611        self.event_receiver.is_terminated()
4612    }
4613}
4614
4615impl futures::Stream for AudioCoreEventStream {
4616    type Item = Result<AudioCoreEvent, fidl::Error>;
4617
4618    fn poll_next(
4619        mut self: std::pin::Pin<&mut Self>,
4620        cx: &mut std::task::Context<'_>,
4621    ) -> std::task::Poll<Option<Self::Item>> {
4622        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4623            &mut self.event_receiver,
4624            cx
4625        )?) {
4626            Some(buf) => std::task::Poll::Ready(Some(AudioCoreEvent::decode(buf))),
4627            None => std::task::Poll::Ready(None),
4628        }
4629    }
4630}
4631
4632#[derive(Debug)]
4633pub enum AudioCoreEvent {
4634    #[non_exhaustive]
4635    _UnknownEvent {
4636        /// Ordinal of the event that was sent.
4637        ordinal: u64,
4638    },
4639}
4640
4641impl AudioCoreEvent {
4642    /// Decodes a message buffer as a [`AudioCoreEvent`].
4643    fn decode(
4644        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4645    ) -> Result<AudioCoreEvent, fidl::Error> {
4646        let (bytes, _handles) = buf.split_mut();
4647        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4648        debug_assert_eq!(tx_header.tx_id, 0);
4649        match tx_header.ordinal {
4650            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4651                Ok(AudioCoreEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4652            }
4653            _ => Err(fidl::Error::UnknownOrdinal {
4654                ordinal: tx_header.ordinal,
4655                protocol_name:
4656                    <AudioCoreMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
4657            }),
4658        }
4659    }
4660}
4661
4662/// A Stream of incoming requests for fuchsia.media/AudioCore.
4663pub struct AudioCoreRequestStream {
4664    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4665    is_terminated: bool,
4666}
4667
4668impl std::marker::Unpin for AudioCoreRequestStream {}
4669
4670impl futures::stream::FusedStream for AudioCoreRequestStream {
4671    fn is_terminated(&self) -> bool {
4672        self.is_terminated
4673    }
4674}
4675
4676impl fdomain_client::fidl::RequestStream for AudioCoreRequestStream {
4677    type Protocol = AudioCoreMarker;
4678    type ControlHandle = AudioCoreControlHandle;
4679
4680    fn from_channel(channel: fdomain_client::Channel) -> Self {
4681        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4682    }
4683
4684    fn control_handle(&self) -> Self::ControlHandle {
4685        AudioCoreControlHandle { inner: self.inner.clone() }
4686    }
4687
4688    fn into_inner(
4689        self,
4690    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
4691    {
4692        (self.inner, self.is_terminated)
4693    }
4694
4695    fn from_inner(
4696        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4697        is_terminated: bool,
4698    ) -> Self {
4699        Self { inner, is_terminated }
4700    }
4701}
4702
4703impl futures::Stream for AudioCoreRequestStream {
4704    type Item = Result<AudioCoreRequest, fidl::Error>;
4705
4706    fn poll_next(
4707        mut self: std::pin::Pin<&mut Self>,
4708        cx: &mut std::task::Context<'_>,
4709    ) -> std::task::Poll<Option<Self::Item>> {
4710        let this = &mut *self;
4711        if this.inner.check_shutdown(cx) {
4712            this.is_terminated = true;
4713            return std::task::Poll::Ready(None);
4714        }
4715        if this.is_terminated {
4716            panic!("polled AudioCoreRequestStream after completion");
4717        }
4718        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
4719            |bytes, handles| {
4720                match this.inner.channel().read_etc(cx, bytes, handles) {
4721                    std::task::Poll::Ready(Ok(())) => {}
4722                    std::task::Poll::Pending => return std::task::Poll::Pending,
4723                    std::task::Poll::Ready(Err(None)) => {
4724                        this.is_terminated = true;
4725                        return std::task::Poll::Ready(None);
4726                    }
4727                    std::task::Poll::Ready(Err(Some(e))) => {
4728                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4729                            e.into(),
4730                        ))));
4731                    }
4732                }
4733
4734                // A message has been received from the channel
4735                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4736
4737                std::task::Poll::Ready(Some(match header.ordinal {
4738                    0x2ac9beba47f83435 => {
4739                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4740                        let mut req = fidl::new_empty!(
4741                            AudioCoreCreateAudioRendererRequest,
4742                            fdomain_client::fidl::FDomainResourceDialect
4743                        );
4744                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreCreateAudioRendererRequest>(&header, _body_bytes, handles, &mut req)?;
4745                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
4746                        Ok(AudioCoreRequest::CreateAudioRenderer {
4747                            audio_out_request: req.audio_out_request,
4748
4749                            control_handle,
4750                        })
4751                    }
4752                    0x459de383b0d76d97 => {
4753                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4754                        let mut req = fidl::new_empty!(
4755                            AudioCoreCreateAudioCapturerWithConfigurationRequest,
4756                            fdomain_client::fidl::FDomainResourceDialect
4757                        );
4758                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(&header, _body_bytes, handles, &mut req)?;
4759                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
4760                        Ok(AudioCoreRequest::CreateAudioCapturerWithConfiguration {
4761                            stream_type: req.stream_type,
4762                            configuration: req.configuration,
4763                            audio_capturer_request: req.audio_capturer_request,
4764
4765                            control_handle,
4766                        })
4767                    }
4768                    0x787db169df99aed0 => {
4769                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4770                        let mut req = fidl::new_empty!(
4771                            AudioCoreCreateAudioCapturerRequest,
4772                            fdomain_client::fidl::FDomainResourceDialect
4773                        );
4774                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreCreateAudioCapturerRequest>(&header, _body_bytes, handles, &mut req)?;
4775                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
4776                        Ok(AudioCoreRequest::CreateAudioCapturer {
4777                            loopback: req.loopback,
4778                            audio_in_request: req.audio_in_request,
4779
4780                            control_handle,
4781                        })
4782                    }
4783                    0x48097f45f6e2b8e7 => {
4784                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4785                        let mut req = fidl::new_empty!(
4786                            AudioCoreSetRenderUsageGainRequest,
4787                            fdomain_client::fidl::FDomainResourceDialect
4788                        );
4789                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreSetRenderUsageGainRequest>(&header, _body_bytes, handles, &mut req)?;
4790                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
4791                        Ok(AudioCoreRequest::SetRenderUsageGain {
4792                            usage: req.usage,
4793                            gain_db: req.gain_db,
4794
4795                            control_handle,
4796                        })
4797                    }
4798                    0x779b1531dc9e64f4 => {
4799                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4800                        let mut req = fidl::new_empty!(
4801                            AudioCoreSetRenderUsageGain2Request,
4802                            fdomain_client::fidl::FDomainResourceDialect
4803                        );
4804                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreSetRenderUsageGain2Request>(&header, _body_bytes, handles, &mut req)?;
4805                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
4806                        Ok(AudioCoreRequest::SetRenderUsageGain2 {
4807                            usage: req.usage,
4808                            gain_db: req.gain_db,
4809
4810                            control_handle,
4811                        })
4812                    }
4813                    0x457d29217d4ea248 => {
4814                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4815                        let mut req = fidl::new_empty!(
4816                            AudioCoreSetCaptureUsageGainRequest,
4817                            fdomain_client::fidl::FDomainResourceDialect
4818                        );
4819                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreSetCaptureUsageGainRequest>(&header, _body_bytes, handles, &mut req)?;
4820                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
4821                        Ok(AudioCoreRequest::SetCaptureUsageGain {
4822                            usage: req.usage,
4823                            gain_db: req.gain_db,
4824
4825                            control_handle,
4826                        })
4827                    }
4828                    0x15065ee308f44af0 => {
4829                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4830                        let mut req = fidl::new_empty!(
4831                            AudioCoreSetCaptureUsageGain2Request,
4832                            fdomain_client::fidl::FDomainResourceDialect
4833                        );
4834                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreSetCaptureUsageGain2Request>(&header, _body_bytes, handles, &mut req)?;
4835                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
4836                        Ok(AudioCoreRequest::SetCaptureUsageGain2 {
4837                            usage: req.usage,
4838                            gain_db: req.gain_db,
4839
4840                            control_handle,
4841                        })
4842                    }
4843                    0x7225be116aadc137 => {
4844                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4845                        let mut req = fidl::new_empty!(
4846                            AudioCoreBindUsageVolumeControlRequest,
4847                            fdomain_client::fidl::FDomainResourceDialect
4848                        );
4849                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreBindUsageVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
4850                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
4851                        Ok(AudioCoreRequest::BindUsageVolumeControl {
4852                            usage: req.usage,
4853                            volume_control: req.volume_control,
4854
4855                            control_handle,
4856                        })
4857                    }
4858                    0x729dff93019d055 => {
4859                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4860                        let mut req = fidl::new_empty!(
4861                            AudioCoreBindUsageVolumeControl2Request,
4862                            fdomain_client::fidl::FDomainResourceDialect
4863                        );
4864                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreBindUsageVolumeControl2Request>(&header, _body_bytes, handles, &mut req)?;
4865                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
4866                        Ok(AudioCoreRequest::BindUsageVolumeControl2 {
4867                            usage: req.usage,
4868                            volume_control: req.volume_control,
4869
4870                            control_handle,
4871                        })
4872                    }
4873                    0x50e3ca45509770bf => {
4874                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4875                        let mut req = fidl::new_empty!(
4876                            AudioCoreGetVolumeFromDbRequest,
4877                            fdomain_client::fidl::FDomainResourceDialect
4878                        );
4879                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreGetVolumeFromDbRequest>(&header, _body_bytes, handles, &mut req)?;
4880                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
4881                        Ok(AudioCoreRequest::GetVolumeFromDb {
4882                            usage: req.usage,
4883                            gain_db: req.gain_db,
4884
4885                            responder: AudioCoreGetVolumeFromDbResponder {
4886                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4887                                tx_id: header.tx_id,
4888                            },
4889                        })
4890                    }
4891                    0x165c811091ef99da => {
4892                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4893                        let mut req = fidl::new_empty!(
4894                            AudioCoreGetVolumeFromDb2Request,
4895                            fdomain_client::fidl::FDomainResourceDialect
4896                        );
4897                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreGetVolumeFromDb2Request>(&header, _body_bytes, handles, &mut req)?;
4898                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
4899                        Ok(AudioCoreRequest::GetVolumeFromDb2 {
4900                            usage: req.usage,
4901                            gain_db: req.gain_db,
4902
4903                            responder: AudioCoreGetVolumeFromDb2Responder {
4904                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4905                                tx_id: header.tx_id,
4906                            },
4907                        })
4908                    }
4909                    0x3e8eec27dd5a8bda => {
4910                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4911                        let mut req = fidl::new_empty!(
4912                            AudioCoreGetDbFromVolumeRequest,
4913                            fdomain_client::fidl::FDomainResourceDialect
4914                        );
4915                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreGetDbFromVolumeRequest>(&header, _body_bytes, handles, &mut req)?;
4916                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
4917                        Ok(AudioCoreRequest::GetDbFromVolume {
4918                            usage: req.usage,
4919                            volume: req.volume,
4920
4921                            responder: AudioCoreGetDbFromVolumeResponder {
4922                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4923                                tx_id: header.tx_id,
4924                            },
4925                        })
4926                    }
4927                    0x5f421a8ebf265bf3 => {
4928                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4929                        let mut req = fidl::new_empty!(
4930                            AudioCoreGetDbFromVolume2Request,
4931                            fdomain_client::fidl::FDomainResourceDialect
4932                        );
4933                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreGetDbFromVolume2Request>(&header, _body_bytes, handles, &mut req)?;
4934                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
4935                        Ok(AudioCoreRequest::GetDbFromVolume2 {
4936                            usage: req.usage,
4937                            volume: req.volume,
4938
4939                            responder: AudioCoreGetDbFromVolume2Responder {
4940                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4941                                tx_id: header.tx_id,
4942                            },
4943                        })
4944                    }
4945                    0x7bfed14345ece7b7 => {
4946                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4947                        let mut req = fidl::new_empty!(
4948                            AudioCoreSetInteractionRequest,
4949                            fdomain_client::fidl::FDomainResourceDialect
4950                        );
4951                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreSetInteractionRequest>(&header, _body_bytes, handles, &mut req)?;
4952                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
4953                        Ok(AudioCoreRequest::SetInteraction {
4954                            active: req.active,
4955                            affected: req.affected,
4956                            behavior: req.behavior,
4957
4958                            control_handle,
4959                        })
4960                    }
4961                    0x7226c7c6e6edc62f => {
4962                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4963                        let mut req = fidl::new_empty!(
4964                            AudioCoreSetInteraction2Request,
4965                            fdomain_client::fidl::FDomainResourceDialect
4966                        );
4967                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreSetInteraction2Request>(&header, _body_bytes, handles, &mut req)?;
4968                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
4969                        Ok(AudioCoreRequest::SetInteraction2 {
4970                            active: req.active,
4971                            affected: req.affected,
4972                            behavior: req.behavior,
4973
4974                            control_handle,
4975                        })
4976                    }
4977                    0x65bd94d9d0a28b5e => {
4978                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4979                        let mut req = fidl::new_empty!(
4980                            fidl::encoding::EmptyPayload,
4981                            fdomain_client::fidl::FDomainResourceDialect
4982                        );
4983                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4984                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
4985                        Ok(AudioCoreRequest::ResetInteractions { control_handle })
4986                    }
4987                    0x54a0bebca85f6b31 => {
4988                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4989                        let mut req = fidl::new_empty!(
4990                            fidl::encoding::EmptyPayload,
4991                            fdomain_client::fidl::FDomainResourceDialect
4992                        );
4993                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4994                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
4995                        Ok(AudioCoreRequest::LoadDefaults { control_handle })
4996                    }
4997                    _ if header.tx_id == 0
4998                        && header
4999                            .dynamic_flags()
5000                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5001                    {
5002                        Ok(AudioCoreRequest::_UnknownMethod {
5003                            ordinal: header.ordinal,
5004                            control_handle: AudioCoreControlHandle { inner: this.inner.clone() },
5005                            method_type: fidl::MethodType::OneWay,
5006                        })
5007                    }
5008                    _ if header
5009                        .dynamic_flags()
5010                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5011                    {
5012                        this.inner.send_framework_err(
5013                            fidl::encoding::FrameworkErr::UnknownMethod,
5014                            header.tx_id,
5015                            header.ordinal,
5016                            header.dynamic_flags(),
5017                            (bytes, handles),
5018                        )?;
5019                        Ok(AudioCoreRequest::_UnknownMethod {
5020                            ordinal: header.ordinal,
5021                            control_handle: AudioCoreControlHandle { inner: this.inner.clone() },
5022                            method_type: fidl::MethodType::TwoWay,
5023                        })
5024                    }
5025                    _ => Err(fidl::Error::UnknownOrdinal {
5026                        ordinal: header.ordinal,
5027                        protocol_name:
5028                            <AudioCoreMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
5029                    }),
5030                }))
5031            },
5032        )
5033    }
5034}
5035
5036#[derive(Debug)]
5037pub enum AudioCoreRequest {
5038    /// Creates an AudioRenderer which outputs audio to the default device.
5039    CreateAudioRenderer {
5040        audio_out_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
5041        control_handle: AudioCoreControlHandle,
5042    },
5043    /// Creates an AudioCapturer according to the given requirements.
5044    ///
5045    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
5046    /// It causes the source material to be reformatted/resampled if needed
5047    /// in order to produce the requested stream type.
5048    ///
5049    /// `usage` is used by Fuchsia to make decisions about user experience.
5050    /// See `AudioCaptureUsage` for more details.
5051    ///
5052    /// `configuration` must be initialized to a variant, or no capturer
5053    /// can be created.
5054    CreateAudioCapturerWithConfiguration {
5055        stream_type: AudioStreamType,
5056        configuration: AudioCapturerConfiguration,
5057        audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
5058        control_handle: AudioCoreControlHandle,
5059    },
5060    /// Creates an AudioCapturer which either captures from the current default
5061    /// audio input device, or loops-back from the current default audio output
5062    /// device based on value passed for the loopback flag.
5063    CreateAudioCapturer {
5064        loopback: bool,
5065        audio_in_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
5066        control_handle: AudioCoreControlHandle,
5067    },
5068    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5069    SetRenderUsageGain {
5070        usage: AudioRenderUsage,
5071        gain_db: f32,
5072        control_handle: AudioCoreControlHandle,
5073    },
5074    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5075    SetRenderUsageGain2 {
5076        usage: AudioRenderUsage2,
5077        gain_db: f32,
5078        control_handle: AudioCoreControlHandle,
5079    },
5080    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5081    SetCaptureUsageGain {
5082        usage: AudioCaptureUsage,
5083        gain_db: f32,
5084        control_handle: AudioCoreControlHandle,
5085    },
5086    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5087    SetCaptureUsageGain2 {
5088        usage: AudioCaptureUsage2,
5089        gain_db: f32,
5090        control_handle: AudioCoreControlHandle,
5091    },
5092    /// Binds to a volume control protocol for the given usage.
5093    BindUsageVolumeControl {
5094        usage: Usage,
5095        volume_control:
5096            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
5097        control_handle: AudioCoreControlHandle,
5098    },
5099    /// Binds to a volume control protocol for the given usage.
5100    BindUsageVolumeControl2 {
5101        usage: Usage2,
5102        volume_control:
5103            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
5104        control_handle: AudioCoreControlHandle,
5105    },
5106    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5107    /// `usage`. This is the same mapping as used by the VolumeControl from
5108    /// `BindUsageVolumeControl`.
5109    GetVolumeFromDb { usage: Usage, gain_db: f32, responder: AudioCoreGetVolumeFromDbResponder },
5110    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5111    /// `usage`. This is the same mapping as used by the VolumeControl from
5112    /// `BindUsageVolumeControl`.
5113    GetVolumeFromDb2 { usage: Usage2, gain_db: f32, responder: AudioCoreGetVolumeFromDb2Responder },
5114    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5115    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5116    GetDbFromVolume { usage: Usage, volume: f32, responder: AudioCoreGetDbFromVolumeResponder },
5117    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5118    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5119    GetDbFromVolume2 { usage: Usage2, volume: f32, responder: AudioCoreGetDbFromVolume2Responder },
5120    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5121    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5122    /// the Behavior specified will be applied to the streams of Usage `affected`.
5123    SetInteraction {
5124        active: Usage,
5125        affected: Usage,
5126        behavior: Behavior,
5127        control_handle: AudioCoreControlHandle,
5128    },
5129    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5130    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5131    /// the Behavior specified will be applied to the streams of Usage `affected`.
5132    SetInteraction2 {
5133        active: Usage2,
5134        affected: Usage2,
5135        behavior: Behavior,
5136        control_handle: AudioCoreControlHandle,
5137    },
5138    /// Re-initializes the set of rules that are currently governing the interaction of streams in
5139    /// audio_core. The default behavior is 'NONE'.
5140    ResetInteractions { control_handle: AudioCoreControlHandle },
5141    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
5142    /// does not provide a config.
5143    LoadDefaults { control_handle: AudioCoreControlHandle },
5144    /// An interaction was received which does not match any known method.
5145    #[non_exhaustive]
5146    _UnknownMethod {
5147        /// Ordinal of the method that was called.
5148        ordinal: u64,
5149        control_handle: AudioCoreControlHandle,
5150        method_type: fidl::MethodType,
5151    },
5152}
5153
5154impl AudioCoreRequest {
5155    #[allow(irrefutable_let_patterns)]
5156    pub fn into_create_audio_renderer(
5157        self,
5158    ) -> Option<(fdomain_client::fidl::ServerEnd<AudioRendererMarker>, AudioCoreControlHandle)>
5159    {
5160        if let AudioCoreRequest::CreateAudioRenderer { audio_out_request, control_handle } = self {
5161            Some((audio_out_request, control_handle))
5162        } else {
5163            None
5164        }
5165    }
5166
5167    #[allow(irrefutable_let_patterns)]
5168    pub fn into_create_audio_capturer_with_configuration(
5169        self,
5170    ) -> Option<(
5171        AudioStreamType,
5172        AudioCapturerConfiguration,
5173        fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
5174        AudioCoreControlHandle,
5175    )> {
5176        if let AudioCoreRequest::CreateAudioCapturerWithConfiguration {
5177            stream_type,
5178            configuration,
5179            audio_capturer_request,
5180            control_handle,
5181        } = self
5182        {
5183            Some((stream_type, configuration, audio_capturer_request, control_handle))
5184        } else {
5185            None
5186        }
5187    }
5188
5189    #[allow(irrefutable_let_patterns)]
5190    pub fn into_create_audio_capturer(
5191        self,
5192    ) -> Option<(bool, fdomain_client::fidl::ServerEnd<AudioCapturerMarker>, AudioCoreControlHandle)>
5193    {
5194        if let AudioCoreRequest::CreateAudioCapturer {
5195            loopback,
5196            audio_in_request,
5197            control_handle,
5198        } = self
5199        {
5200            Some((loopback, audio_in_request, control_handle))
5201        } else {
5202            None
5203        }
5204    }
5205
5206    #[allow(irrefutable_let_patterns)]
5207    pub fn into_set_render_usage_gain(
5208        self,
5209    ) -> Option<(AudioRenderUsage, f32, AudioCoreControlHandle)> {
5210        if let AudioCoreRequest::SetRenderUsageGain { usage, gain_db, control_handle } = self {
5211            Some((usage, gain_db, control_handle))
5212        } else {
5213            None
5214        }
5215    }
5216
5217    #[allow(irrefutable_let_patterns)]
5218    pub fn into_set_render_usage_gain2(
5219        self,
5220    ) -> Option<(AudioRenderUsage2, f32, AudioCoreControlHandle)> {
5221        if let AudioCoreRequest::SetRenderUsageGain2 { usage, gain_db, control_handle } = self {
5222            Some((usage, gain_db, control_handle))
5223        } else {
5224            None
5225        }
5226    }
5227
5228    #[allow(irrefutable_let_patterns)]
5229    pub fn into_set_capture_usage_gain(
5230        self,
5231    ) -> Option<(AudioCaptureUsage, f32, AudioCoreControlHandle)> {
5232        if let AudioCoreRequest::SetCaptureUsageGain { usage, gain_db, control_handle } = self {
5233            Some((usage, gain_db, control_handle))
5234        } else {
5235            None
5236        }
5237    }
5238
5239    #[allow(irrefutable_let_patterns)]
5240    pub fn into_set_capture_usage_gain2(
5241        self,
5242    ) -> Option<(AudioCaptureUsage2, f32, AudioCoreControlHandle)> {
5243        if let AudioCoreRequest::SetCaptureUsageGain2 { usage, gain_db, control_handle } = self {
5244            Some((usage, gain_db, control_handle))
5245        } else {
5246            None
5247        }
5248    }
5249
5250    #[allow(irrefutable_let_patterns)]
5251    pub fn into_bind_usage_volume_control(
5252        self,
5253    ) -> Option<(
5254        Usage,
5255        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
5256        AudioCoreControlHandle,
5257    )> {
5258        if let AudioCoreRequest::BindUsageVolumeControl { usage, volume_control, control_handle } =
5259            self
5260        {
5261            Some((usage, volume_control, control_handle))
5262        } else {
5263            None
5264        }
5265    }
5266
5267    #[allow(irrefutable_let_patterns)]
5268    pub fn into_bind_usage_volume_control2(
5269        self,
5270    ) -> Option<(
5271        Usage2,
5272        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
5273        AudioCoreControlHandle,
5274    )> {
5275        if let AudioCoreRequest::BindUsageVolumeControl2 { usage, volume_control, control_handle } =
5276            self
5277        {
5278            Some((usage, volume_control, control_handle))
5279        } else {
5280            None
5281        }
5282    }
5283
5284    #[allow(irrefutable_let_patterns)]
5285    pub fn into_get_volume_from_db(
5286        self,
5287    ) -> Option<(Usage, f32, AudioCoreGetVolumeFromDbResponder)> {
5288        if let AudioCoreRequest::GetVolumeFromDb { usage, gain_db, responder } = self {
5289            Some((usage, gain_db, responder))
5290        } else {
5291            None
5292        }
5293    }
5294
5295    #[allow(irrefutable_let_patterns)]
5296    pub fn into_get_volume_from_db2(
5297        self,
5298    ) -> Option<(Usage2, f32, AudioCoreGetVolumeFromDb2Responder)> {
5299        if let AudioCoreRequest::GetVolumeFromDb2 { usage, gain_db, responder } = self {
5300            Some((usage, gain_db, responder))
5301        } else {
5302            None
5303        }
5304    }
5305
5306    #[allow(irrefutable_let_patterns)]
5307    pub fn into_get_db_from_volume(
5308        self,
5309    ) -> Option<(Usage, f32, AudioCoreGetDbFromVolumeResponder)> {
5310        if let AudioCoreRequest::GetDbFromVolume { usage, volume, responder } = self {
5311            Some((usage, volume, responder))
5312        } else {
5313            None
5314        }
5315    }
5316
5317    #[allow(irrefutable_let_patterns)]
5318    pub fn into_get_db_from_volume2(
5319        self,
5320    ) -> Option<(Usage2, f32, AudioCoreGetDbFromVolume2Responder)> {
5321        if let AudioCoreRequest::GetDbFromVolume2 { usage, volume, responder } = self {
5322            Some((usage, volume, responder))
5323        } else {
5324            None
5325        }
5326    }
5327
5328    #[allow(irrefutable_let_patterns)]
5329    pub fn into_set_interaction(self) -> Option<(Usage, Usage, Behavior, AudioCoreControlHandle)> {
5330        if let AudioCoreRequest::SetInteraction { active, affected, behavior, control_handle } =
5331            self
5332        {
5333            Some((active, affected, behavior, control_handle))
5334        } else {
5335            None
5336        }
5337    }
5338
5339    #[allow(irrefutable_let_patterns)]
5340    pub fn into_set_interaction2(
5341        self,
5342    ) -> Option<(Usage2, Usage2, Behavior, AudioCoreControlHandle)> {
5343        if let AudioCoreRequest::SetInteraction2 { active, affected, behavior, control_handle } =
5344            self
5345        {
5346            Some((active, affected, behavior, control_handle))
5347        } else {
5348            None
5349        }
5350    }
5351
5352    #[allow(irrefutable_let_patterns)]
5353    pub fn into_reset_interactions(self) -> Option<(AudioCoreControlHandle)> {
5354        if let AudioCoreRequest::ResetInteractions { control_handle } = self {
5355            Some((control_handle))
5356        } else {
5357            None
5358        }
5359    }
5360
5361    #[allow(irrefutable_let_patterns)]
5362    pub fn into_load_defaults(self) -> Option<(AudioCoreControlHandle)> {
5363        if let AudioCoreRequest::LoadDefaults { control_handle } = self {
5364            Some((control_handle))
5365        } else {
5366            None
5367        }
5368    }
5369
5370    /// Name of the method defined in FIDL
5371    pub fn method_name(&self) -> &'static str {
5372        match *self {
5373            AudioCoreRequest::CreateAudioRenderer { .. } => "create_audio_renderer",
5374            AudioCoreRequest::CreateAudioCapturerWithConfiguration { .. } => {
5375                "create_audio_capturer_with_configuration"
5376            }
5377            AudioCoreRequest::CreateAudioCapturer { .. } => "create_audio_capturer",
5378            AudioCoreRequest::SetRenderUsageGain { .. } => "set_render_usage_gain",
5379            AudioCoreRequest::SetRenderUsageGain2 { .. } => "set_render_usage_gain2",
5380            AudioCoreRequest::SetCaptureUsageGain { .. } => "set_capture_usage_gain",
5381            AudioCoreRequest::SetCaptureUsageGain2 { .. } => "set_capture_usage_gain2",
5382            AudioCoreRequest::BindUsageVolumeControl { .. } => "bind_usage_volume_control",
5383            AudioCoreRequest::BindUsageVolumeControl2 { .. } => "bind_usage_volume_control2",
5384            AudioCoreRequest::GetVolumeFromDb { .. } => "get_volume_from_db",
5385            AudioCoreRequest::GetVolumeFromDb2 { .. } => "get_volume_from_db2",
5386            AudioCoreRequest::GetDbFromVolume { .. } => "get_db_from_volume",
5387            AudioCoreRequest::GetDbFromVolume2 { .. } => "get_db_from_volume2",
5388            AudioCoreRequest::SetInteraction { .. } => "set_interaction",
5389            AudioCoreRequest::SetInteraction2 { .. } => "set_interaction2",
5390            AudioCoreRequest::ResetInteractions { .. } => "reset_interactions",
5391            AudioCoreRequest::LoadDefaults { .. } => "load_defaults",
5392            AudioCoreRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
5393                "unknown one-way method"
5394            }
5395            AudioCoreRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
5396                "unknown two-way method"
5397            }
5398        }
5399    }
5400}
5401
5402#[derive(Debug, Clone)]
5403pub struct AudioCoreControlHandle {
5404    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
5405}
5406
5407impl fdomain_client::fidl::ControlHandle for AudioCoreControlHandle {
5408    fn shutdown(&self) {
5409        self.inner.shutdown()
5410    }
5411
5412    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5413        self.inner.shutdown_with_epitaph(status)
5414    }
5415
5416    fn is_closed(&self) -> bool {
5417        self.inner.channel().is_closed()
5418    }
5419    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
5420        self.inner.channel().on_closed()
5421    }
5422}
5423
5424impl AudioCoreControlHandle {}
5425
5426#[must_use = "FIDL methods require a response to be sent"]
5427#[derive(Debug)]
5428pub struct AudioCoreGetVolumeFromDbResponder {
5429    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
5430    tx_id: u32,
5431}
5432
5433/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
5434/// if the responder is dropped without sending a response, so that the client
5435/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5436impl std::ops::Drop for AudioCoreGetVolumeFromDbResponder {
5437    fn drop(&mut self) {
5438        self.control_handle.shutdown();
5439        // Safety: drops once, never accessed again
5440        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5441    }
5442}
5443
5444impl fdomain_client::fidl::Responder for AudioCoreGetVolumeFromDbResponder {
5445    type ControlHandle = AudioCoreControlHandle;
5446
5447    fn control_handle(&self) -> &AudioCoreControlHandle {
5448        &self.control_handle
5449    }
5450
5451    fn drop_without_shutdown(mut self) {
5452        // Safety: drops once, never accessed again due to mem::forget
5453        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5454        // Prevent Drop from running (which would shut down the channel)
5455        std::mem::forget(self);
5456    }
5457}
5458
5459impl AudioCoreGetVolumeFromDbResponder {
5460    /// Sends a response to the FIDL transaction.
5461    ///
5462    /// Sets the channel to shutdown if an error occurs.
5463    pub fn send(self, mut volume: f32) -> Result<(), fidl::Error> {
5464        let _result = self.send_raw(volume);
5465        if _result.is_err() {
5466            self.control_handle.shutdown();
5467        }
5468        self.drop_without_shutdown();
5469        _result
5470    }
5471
5472    /// Similar to "send" but does not shutdown the channel if an error occurs.
5473    pub fn send_no_shutdown_on_err(self, mut volume: f32) -> Result<(), fidl::Error> {
5474        let _result = self.send_raw(volume);
5475        self.drop_without_shutdown();
5476        _result
5477    }
5478
5479    fn send_raw(&self, mut volume: f32) -> Result<(), fidl::Error> {
5480        self.control_handle.inner.send::<AudioCoreGetVolumeFromDbResponse>(
5481            (volume,),
5482            self.tx_id,
5483            0x50e3ca45509770bf,
5484            fidl::encoding::DynamicFlags::empty(),
5485        )
5486    }
5487}
5488
5489#[must_use = "FIDL methods require a response to be sent"]
5490#[derive(Debug)]
5491pub struct AudioCoreGetVolumeFromDb2Responder {
5492    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
5493    tx_id: u32,
5494}
5495
5496/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
5497/// if the responder is dropped without sending a response, so that the client
5498/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5499impl std::ops::Drop for AudioCoreGetVolumeFromDb2Responder {
5500    fn drop(&mut self) {
5501        self.control_handle.shutdown();
5502        // Safety: drops once, never accessed again
5503        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5504    }
5505}
5506
5507impl fdomain_client::fidl::Responder for AudioCoreGetVolumeFromDb2Responder {
5508    type ControlHandle = AudioCoreControlHandle;
5509
5510    fn control_handle(&self) -> &AudioCoreControlHandle {
5511        &self.control_handle
5512    }
5513
5514    fn drop_without_shutdown(mut self) {
5515        // Safety: drops once, never accessed again due to mem::forget
5516        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5517        // Prevent Drop from running (which would shut down the channel)
5518        std::mem::forget(self);
5519    }
5520}
5521
5522impl AudioCoreGetVolumeFromDb2Responder {
5523    /// Sends a response to the FIDL transaction.
5524    ///
5525    /// Sets the channel to shutdown if an error occurs.
5526    pub fn send(self, mut volume: f32) -> Result<(), fidl::Error> {
5527        let _result = self.send_raw(volume);
5528        if _result.is_err() {
5529            self.control_handle.shutdown();
5530        }
5531        self.drop_without_shutdown();
5532        _result
5533    }
5534
5535    /// Similar to "send" but does not shutdown the channel if an error occurs.
5536    pub fn send_no_shutdown_on_err(self, mut volume: f32) -> Result<(), fidl::Error> {
5537        let _result = self.send_raw(volume);
5538        self.drop_without_shutdown();
5539        _result
5540    }
5541
5542    fn send_raw(&self, mut volume: f32) -> Result<(), fidl::Error> {
5543        self.control_handle
5544            .inner
5545            .send::<fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>>(
5546                fidl::encoding::Flexible::new((volume,)),
5547                self.tx_id,
5548                0x165c811091ef99da,
5549                fidl::encoding::DynamicFlags::FLEXIBLE,
5550            )
5551    }
5552}
5553
5554#[must_use = "FIDL methods require a response to be sent"]
5555#[derive(Debug)]
5556pub struct AudioCoreGetDbFromVolumeResponder {
5557    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
5558    tx_id: u32,
5559}
5560
5561/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
5562/// if the responder is dropped without sending a response, so that the client
5563/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5564impl std::ops::Drop for AudioCoreGetDbFromVolumeResponder {
5565    fn drop(&mut self) {
5566        self.control_handle.shutdown();
5567        // Safety: drops once, never accessed again
5568        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5569    }
5570}
5571
5572impl fdomain_client::fidl::Responder for AudioCoreGetDbFromVolumeResponder {
5573    type ControlHandle = AudioCoreControlHandle;
5574
5575    fn control_handle(&self) -> &AudioCoreControlHandle {
5576        &self.control_handle
5577    }
5578
5579    fn drop_without_shutdown(mut self) {
5580        // Safety: drops once, never accessed again due to mem::forget
5581        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5582        // Prevent Drop from running (which would shut down the channel)
5583        std::mem::forget(self);
5584    }
5585}
5586
5587impl AudioCoreGetDbFromVolumeResponder {
5588    /// Sends a response to the FIDL transaction.
5589    ///
5590    /// Sets the channel to shutdown if an error occurs.
5591    pub fn send(self, mut gain_db: f32) -> Result<(), fidl::Error> {
5592        let _result = self.send_raw(gain_db);
5593        if _result.is_err() {
5594            self.control_handle.shutdown();
5595        }
5596        self.drop_without_shutdown();
5597        _result
5598    }
5599
5600    /// Similar to "send" but does not shutdown the channel if an error occurs.
5601    pub fn send_no_shutdown_on_err(self, mut gain_db: f32) -> Result<(), fidl::Error> {
5602        let _result = self.send_raw(gain_db);
5603        self.drop_without_shutdown();
5604        _result
5605    }
5606
5607    fn send_raw(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
5608        self.control_handle.inner.send::<AudioCoreGetDbFromVolumeResponse>(
5609            (gain_db,),
5610            self.tx_id,
5611            0x3e8eec27dd5a8bda,
5612            fidl::encoding::DynamicFlags::empty(),
5613        )
5614    }
5615}
5616
5617#[must_use = "FIDL methods require a response to be sent"]
5618#[derive(Debug)]
5619pub struct AudioCoreGetDbFromVolume2Responder {
5620    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
5621    tx_id: u32,
5622}
5623
5624/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
5625/// if the responder is dropped without sending a response, so that the client
5626/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5627impl std::ops::Drop for AudioCoreGetDbFromVolume2Responder {
5628    fn drop(&mut self) {
5629        self.control_handle.shutdown();
5630        // Safety: drops once, never accessed again
5631        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5632    }
5633}
5634
5635impl fdomain_client::fidl::Responder for AudioCoreGetDbFromVolume2Responder {
5636    type ControlHandle = AudioCoreControlHandle;
5637
5638    fn control_handle(&self) -> &AudioCoreControlHandle {
5639        &self.control_handle
5640    }
5641
5642    fn drop_without_shutdown(mut self) {
5643        // Safety: drops once, never accessed again due to mem::forget
5644        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5645        // Prevent Drop from running (which would shut down the channel)
5646        std::mem::forget(self);
5647    }
5648}
5649
5650impl AudioCoreGetDbFromVolume2Responder {
5651    /// Sends a response to the FIDL transaction.
5652    ///
5653    /// Sets the channel to shutdown if an error occurs.
5654    pub fn send(self, mut gain_db: f32) -> Result<(), fidl::Error> {
5655        let _result = self.send_raw(gain_db);
5656        if _result.is_err() {
5657            self.control_handle.shutdown();
5658        }
5659        self.drop_without_shutdown();
5660        _result
5661    }
5662
5663    /// Similar to "send" but does not shutdown the channel if an error occurs.
5664    pub fn send_no_shutdown_on_err(self, mut gain_db: f32) -> Result<(), fidl::Error> {
5665        let _result = self.send_raw(gain_db);
5666        self.drop_without_shutdown();
5667        _result
5668    }
5669
5670    fn send_raw(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
5671        self.control_handle
5672            .inner
5673            .send::<fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>>(
5674                fidl::encoding::Flexible::new((gain_db,)),
5675                self.tx_id,
5676                0x5f421a8ebf265bf3,
5677                fidl::encoding::DynamicFlags::FLEXIBLE,
5678            )
5679    }
5680}
5681
5682#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5683pub struct AudioDeviceEnumeratorMarker;
5684
5685impl fdomain_client::fidl::ProtocolMarker for AudioDeviceEnumeratorMarker {
5686    type Proxy = AudioDeviceEnumeratorProxy;
5687    type RequestStream = AudioDeviceEnumeratorRequestStream;
5688
5689    const DEBUG_NAME: &'static str = "fuchsia.media.AudioDeviceEnumerator";
5690}
5691impl fdomain_client::fidl::DiscoverableProtocolMarker for AudioDeviceEnumeratorMarker {}
5692
5693pub trait AudioDeviceEnumeratorProxyInterface: Send + Sync {
5694    type GetDevicesResponseFut: std::future::Future<Output = Result<Vec<AudioDeviceInfo>, fidl::Error>>
5695        + Send;
5696    fn r#get_devices(&self) -> Self::GetDevicesResponseFut;
5697    type GetDeviceGainResponseFut: std::future::Future<Output = Result<(u64, AudioGainInfo), fidl::Error>>
5698        + Send;
5699    fn r#get_device_gain(&self, device_token: u64) -> Self::GetDeviceGainResponseFut;
5700    fn r#set_device_gain(
5701        &self,
5702        device_token: u64,
5703        gain_info: &AudioGainInfo,
5704        valid_flags: AudioGainValidFlags,
5705    ) -> Result<(), fidl::Error>;
5706    fn r#add_device_by_channel(
5707        &self,
5708        device_name: &str,
5709        is_input: bool,
5710        channel: fdomain_client::fidl::ClientEnd<
5711            fdomain_fuchsia_hardware_audio::StreamConfigMarker,
5712        >,
5713    ) -> Result<(), fidl::Error>;
5714}
5715
5716#[derive(Debug, Clone)]
5717pub struct AudioDeviceEnumeratorProxy {
5718    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
5719}
5720
5721impl fdomain_client::fidl::Proxy for AudioDeviceEnumeratorProxy {
5722    type Protocol = AudioDeviceEnumeratorMarker;
5723
5724    fn from_channel(inner: fdomain_client::Channel) -> Self {
5725        Self::new(inner)
5726    }
5727
5728    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
5729        self.client.into_channel().map_err(|client| Self { client })
5730    }
5731
5732    fn as_channel(&self) -> &fdomain_client::Channel {
5733        self.client.as_channel()
5734    }
5735}
5736
5737impl AudioDeviceEnumeratorProxy {
5738    /// Create a new Proxy for fuchsia.media/AudioDeviceEnumerator.
5739    pub fn new(channel: fdomain_client::Channel) -> Self {
5740        let protocol_name =
5741            <AudioDeviceEnumeratorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
5742        Self { client: fidl::client::Client::new(channel, protocol_name) }
5743    }
5744
5745    /// Get a Stream of events from the remote end of the protocol.
5746    ///
5747    /// # Panics
5748    ///
5749    /// Panics if the event stream was already taken.
5750    pub fn take_event_stream(&self) -> AudioDeviceEnumeratorEventStream {
5751        AudioDeviceEnumeratorEventStream { event_receiver: self.client.take_event_receiver() }
5752    }
5753
5754    /// Obtain the list of currently active audio devices.
5755    pub fn r#get_devices(
5756        &self,
5757    ) -> fidl::client::QueryResponseFut<
5758        Vec<AudioDeviceInfo>,
5759        fdomain_client::fidl::FDomainResourceDialect,
5760    > {
5761        AudioDeviceEnumeratorProxyInterface::r#get_devices(self)
5762    }
5763
5764    /// Gain/Mute/AGC control
5765    ///
5766    /// Note that each of these operations requires a device_token in order to
5767    /// target the proper input/output.
5768    ///
5769    /// The Get command returns the device_token of the device whose gain is
5770    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
5771    /// device_token was invalid or the device had been removed from the system
5772    /// before the Get command could be processed.
5773    ///
5774    /// Set commands which are given an invalid device token are ignored and
5775    /// have no effect on the system. In addition, users do not need to control
5776    /// all of the gain settings for an audio device with each call. Only the
5777    /// settings with a corresponding flag set in the set_flags parameter will
5778    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
5779    /// a SetDeviceGain call to care only about the mute setting in the
5780    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
5781    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
5782    /// status to be changed simultaneously.
5783    pub fn r#get_device_gain(
5784        &self,
5785        mut device_token: u64,
5786    ) -> fidl::client::QueryResponseFut<
5787        (u64, AudioGainInfo),
5788        fdomain_client::fidl::FDomainResourceDialect,
5789    > {
5790        AudioDeviceEnumeratorProxyInterface::r#get_device_gain(self, device_token)
5791    }
5792
5793    pub fn r#set_device_gain(
5794        &self,
5795        mut device_token: u64,
5796        mut gain_info: &AudioGainInfo,
5797        mut valid_flags: AudioGainValidFlags,
5798    ) -> Result<(), fidl::Error> {
5799        AudioDeviceEnumeratorProxyInterface::r#set_device_gain(
5800            self,
5801            device_token,
5802            gain_info,
5803            valid_flags,
5804        )
5805    }
5806
5807    /// # Deprecation
5808    ///
5809    /// StreamConfig is not supported anymore, instead use an
5810    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
5811    /// , see
5812    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
5813    pub fn r#add_device_by_channel(
5814        &self,
5815        mut device_name: &str,
5816        mut is_input: bool,
5817        mut channel: fdomain_client::fidl::ClientEnd<
5818            fdomain_fuchsia_hardware_audio::StreamConfigMarker,
5819        >,
5820    ) -> Result<(), fidl::Error> {
5821        AudioDeviceEnumeratorProxyInterface::r#add_device_by_channel(
5822            self,
5823            device_name,
5824            is_input,
5825            channel,
5826        )
5827    }
5828}
5829
5830impl AudioDeviceEnumeratorProxyInterface for AudioDeviceEnumeratorProxy {
5831    type GetDevicesResponseFut = fidl::client::QueryResponseFut<
5832        Vec<AudioDeviceInfo>,
5833        fdomain_client::fidl::FDomainResourceDialect,
5834    >;
5835    fn r#get_devices(&self) -> Self::GetDevicesResponseFut {
5836        fn _decode(
5837            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5838        ) -> Result<Vec<AudioDeviceInfo>, fidl::Error> {
5839            let _response = fidl::client::decode_transaction_body::<
5840                AudioDeviceEnumeratorGetDevicesResponse,
5841                fdomain_client::fidl::FDomainResourceDialect,
5842                0x4ce1aa218aeb12a6,
5843            >(_buf?)?;
5844            Ok(_response.devices)
5845        }
5846        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioDeviceInfo>>(
5847            (),
5848            0x4ce1aa218aeb12a6,
5849            fidl::encoding::DynamicFlags::empty(),
5850            _decode,
5851        )
5852    }
5853
5854    type GetDeviceGainResponseFut = fidl::client::QueryResponseFut<
5855        (u64, AudioGainInfo),
5856        fdomain_client::fidl::FDomainResourceDialect,
5857    >;
5858    fn r#get_device_gain(&self, mut device_token: u64) -> Self::GetDeviceGainResponseFut {
5859        fn _decode(
5860            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5861        ) -> Result<(u64, AudioGainInfo), fidl::Error> {
5862            let _response = fidl::client::decode_transaction_body::<
5863                AudioDeviceEnumeratorGetDeviceGainResponse,
5864                fdomain_client::fidl::FDomainResourceDialect,
5865                0x25dd4723403c414b,
5866            >(_buf?)?;
5867            Ok((_response.device_token, _response.gain_info))
5868        }
5869        self.client.send_query_and_decode::<
5870            AudioDeviceEnumeratorGetDeviceGainRequest,
5871            (u64, AudioGainInfo),
5872        >(
5873            (device_token,),
5874            0x25dd4723403c414b,
5875            fidl::encoding::DynamicFlags::empty(),
5876            _decode,
5877        )
5878    }
5879
5880    fn r#set_device_gain(
5881        &self,
5882        mut device_token: u64,
5883        mut gain_info: &AudioGainInfo,
5884        mut valid_flags: AudioGainValidFlags,
5885    ) -> Result<(), fidl::Error> {
5886        self.client.send::<AudioDeviceEnumeratorSetDeviceGainRequest>(
5887            (device_token, gain_info, valid_flags),
5888            0x5bdabc8ebe83591,
5889            fidl::encoding::DynamicFlags::empty(),
5890        )
5891    }
5892
5893    fn r#add_device_by_channel(
5894        &self,
5895        mut device_name: &str,
5896        mut is_input: bool,
5897        mut channel: fdomain_client::fidl::ClientEnd<
5898            fdomain_fuchsia_hardware_audio::StreamConfigMarker,
5899        >,
5900    ) -> Result<(), fidl::Error> {
5901        self.client.send::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(
5902            (device_name, is_input, channel),
5903            0x72cdbada4d70ed67,
5904            fidl::encoding::DynamicFlags::empty(),
5905        )
5906    }
5907}
5908
5909pub struct AudioDeviceEnumeratorEventStream {
5910    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
5911}
5912
5913impl std::marker::Unpin for AudioDeviceEnumeratorEventStream {}
5914
5915impl futures::stream::FusedStream for AudioDeviceEnumeratorEventStream {
5916    fn is_terminated(&self) -> bool {
5917        self.event_receiver.is_terminated()
5918    }
5919}
5920
5921impl futures::Stream for AudioDeviceEnumeratorEventStream {
5922    type Item = Result<AudioDeviceEnumeratorEvent, fidl::Error>;
5923
5924    fn poll_next(
5925        mut self: std::pin::Pin<&mut Self>,
5926        cx: &mut std::task::Context<'_>,
5927    ) -> std::task::Poll<Option<Self::Item>> {
5928        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5929            &mut self.event_receiver,
5930            cx
5931        )?) {
5932            Some(buf) => std::task::Poll::Ready(Some(AudioDeviceEnumeratorEvent::decode(buf))),
5933            None => std::task::Poll::Ready(None),
5934        }
5935    }
5936}
5937
5938#[derive(Debug)]
5939pub enum AudioDeviceEnumeratorEvent {
5940    OnDeviceAdded { device: AudioDeviceInfo },
5941    OnDeviceRemoved { device_token: u64 },
5942    OnDeviceGainChanged { device_token: u64, gain_info: AudioGainInfo },
5943    OnDefaultDeviceChanged { old_default_token: u64, new_default_token: u64 },
5944}
5945
5946impl AudioDeviceEnumeratorEvent {
5947    #[allow(irrefutable_let_patterns)]
5948    pub fn into_on_device_added(self) -> Option<AudioDeviceInfo> {
5949        if let AudioDeviceEnumeratorEvent::OnDeviceAdded { device } = self {
5950            Some((device))
5951        } else {
5952            None
5953        }
5954    }
5955    #[allow(irrefutable_let_patterns)]
5956    pub fn into_on_device_removed(self) -> Option<u64> {
5957        if let AudioDeviceEnumeratorEvent::OnDeviceRemoved { device_token } = self {
5958            Some((device_token))
5959        } else {
5960            None
5961        }
5962    }
5963    #[allow(irrefutable_let_patterns)]
5964    pub fn into_on_device_gain_changed(self) -> Option<(u64, AudioGainInfo)> {
5965        if let AudioDeviceEnumeratorEvent::OnDeviceGainChanged { device_token, gain_info } = self {
5966            Some((device_token, gain_info))
5967        } else {
5968            None
5969        }
5970    }
5971    #[allow(irrefutable_let_patterns)]
5972    pub fn into_on_default_device_changed(self) -> Option<(u64, u64)> {
5973        if let AudioDeviceEnumeratorEvent::OnDefaultDeviceChanged {
5974            old_default_token,
5975            new_default_token,
5976        } = self
5977        {
5978            Some((old_default_token, new_default_token))
5979        } else {
5980            None
5981        }
5982    }
5983
5984    /// Decodes a message buffer as a [`AudioDeviceEnumeratorEvent`].
5985    fn decode(
5986        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5987    ) -> Result<AudioDeviceEnumeratorEvent, fidl::Error> {
5988        let (bytes, _handles) = buf.split_mut();
5989        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5990        debug_assert_eq!(tx_header.tx_id, 0);
5991        match tx_header.ordinal {
5992            0xe0fbe40057c4b44 => {
5993                let mut out = fidl::new_empty!(AudioDeviceEnumeratorOnDeviceAddedRequest, fdomain_client::fidl::FDomainResourceDialect);
5994                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceAddedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
5995                Ok((
5996                    AudioDeviceEnumeratorEvent::OnDeviceAdded {device: out.device,
5997
5998                    }
5999                ))
6000            }
6001            0x6f3b7574463d9ff8 => {
6002                let mut out = fidl::new_empty!(AudioDeviceEnumeratorOnDeviceRemovedRequest, fdomain_client::fidl::FDomainResourceDialect);
6003                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceRemovedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6004                Ok((
6005                    AudioDeviceEnumeratorEvent::OnDeviceRemoved {device_token: out.device_token,
6006
6007                    }
6008                ))
6009            }
6010            0x14aefcbbb076b0e9 => {
6011                let mut out = fidl::new_empty!(AudioDeviceEnumeratorOnDeviceGainChangedRequest, fdomain_client::fidl::FDomainResourceDialect);
6012                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceGainChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6013                Ok((
6014                    AudioDeviceEnumeratorEvent::OnDeviceGainChanged {device_token: out.device_token,
6015gain_info: out.gain_info,
6016
6017                    }
6018                ))
6019            }
6020            0x16357b42d4c16e11 => {
6021                let mut out = fidl::new_empty!(AudioDeviceEnumeratorOnDefaultDeviceChangedRequest, fdomain_client::fidl::FDomainResourceDialect);
6022                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDefaultDeviceChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6023                Ok((
6024                    AudioDeviceEnumeratorEvent::OnDefaultDeviceChanged {old_default_token: out.old_default_token,
6025new_default_token: out.new_default_token,
6026
6027                    }
6028                ))
6029            }
6030            _ => Err(fidl::Error::UnknownOrdinal {
6031                ordinal: tx_header.ordinal,
6032                protocol_name: <AudioDeviceEnumeratorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
6033            })
6034        }
6035    }
6036}
6037
6038/// A Stream of incoming requests for fuchsia.media/AudioDeviceEnumerator.
6039pub struct AudioDeviceEnumeratorRequestStream {
6040    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
6041    is_terminated: bool,
6042}
6043
6044impl std::marker::Unpin for AudioDeviceEnumeratorRequestStream {}
6045
6046impl futures::stream::FusedStream for AudioDeviceEnumeratorRequestStream {
6047    fn is_terminated(&self) -> bool {
6048        self.is_terminated
6049    }
6050}
6051
6052impl fdomain_client::fidl::RequestStream for AudioDeviceEnumeratorRequestStream {
6053    type Protocol = AudioDeviceEnumeratorMarker;
6054    type ControlHandle = AudioDeviceEnumeratorControlHandle;
6055
6056    fn from_channel(channel: fdomain_client::Channel) -> Self {
6057        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6058    }
6059
6060    fn control_handle(&self) -> Self::ControlHandle {
6061        AudioDeviceEnumeratorControlHandle { inner: self.inner.clone() }
6062    }
6063
6064    fn into_inner(
6065        self,
6066    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
6067    {
6068        (self.inner, self.is_terminated)
6069    }
6070
6071    fn from_inner(
6072        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
6073        is_terminated: bool,
6074    ) -> Self {
6075        Self { inner, is_terminated }
6076    }
6077}
6078
6079impl futures::Stream for AudioDeviceEnumeratorRequestStream {
6080    type Item = Result<AudioDeviceEnumeratorRequest, fidl::Error>;
6081
6082    fn poll_next(
6083        mut self: std::pin::Pin<&mut Self>,
6084        cx: &mut std::task::Context<'_>,
6085    ) -> std::task::Poll<Option<Self::Item>> {
6086        let this = &mut *self;
6087        if this.inner.check_shutdown(cx) {
6088            this.is_terminated = true;
6089            return std::task::Poll::Ready(None);
6090        }
6091        if this.is_terminated {
6092            panic!("polled AudioDeviceEnumeratorRequestStream after completion");
6093        }
6094        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
6095            |bytes, handles| {
6096                match this.inner.channel().read_etc(cx, bytes, handles) {
6097                    std::task::Poll::Ready(Ok(())) => {}
6098                    std::task::Poll::Pending => return std::task::Poll::Pending,
6099                    std::task::Poll::Ready(Err(None)) => {
6100                        this.is_terminated = true;
6101                        return std::task::Poll::Ready(None);
6102                    }
6103                    std::task::Poll::Ready(Err(Some(e))) => {
6104                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6105                            e.into(),
6106                        ))));
6107                    }
6108                }
6109
6110                // A message has been received from the channel
6111                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6112
6113                std::task::Poll::Ready(Some(match header.ordinal {
6114                0x4ce1aa218aeb12a6 => {
6115                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6116                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
6117                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6118                    let control_handle = AudioDeviceEnumeratorControlHandle {
6119                        inner: this.inner.clone(),
6120                    };
6121                    Ok(AudioDeviceEnumeratorRequest::GetDevices {
6122                        responder: AudioDeviceEnumeratorGetDevicesResponder {
6123                            control_handle: std::mem::ManuallyDrop::new(control_handle),
6124                            tx_id: header.tx_id,
6125                        },
6126                    })
6127                }
6128                0x25dd4723403c414b => {
6129                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6130                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorGetDeviceGainRequest, fdomain_client::fidl::FDomainResourceDialect);
6131                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorGetDeviceGainRequest>(&header, _body_bytes, handles, &mut req)?;
6132                    let control_handle = AudioDeviceEnumeratorControlHandle {
6133                        inner: this.inner.clone(),
6134                    };
6135                    Ok(AudioDeviceEnumeratorRequest::GetDeviceGain {device_token: req.device_token,
6136
6137                        responder: AudioDeviceEnumeratorGetDeviceGainResponder {
6138                            control_handle: std::mem::ManuallyDrop::new(control_handle),
6139                            tx_id: header.tx_id,
6140                        },
6141                    })
6142                }
6143                0x5bdabc8ebe83591 => {
6144                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6145                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorSetDeviceGainRequest, fdomain_client::fidl::FDomainResourceDialect);
6146                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorSetDeviceGainRequest>(&header, _body_bytes, handles, &mut req)?;
6147                    let control_handle = AudioDeviceEnumeratorControlHandle {
6148                        inner: this.inner.clone(),
6149                    };
6150                    Ok(AudioDeviceEnumeratorRequest::SetDeviceGain {device_token: req.device_token,
6151gain_info: req.gain_info,
6152valid_flags: req.valid_flags,
6153
6154                        control_handle,
6155                    })
6156                }
6157                0x72cdbada4d70ed67 => {
6158                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6159                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorAddDeviceByChannelRequest, fdomain_client::fidl::FDomainResourceDialect);
6160                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(&header, _body_bytes, handles, &mut req)?;
6161                    let control_handle = AudioDeviceEnumeratorControlHandle {
6162                        inner: this.inner.clone(),
6163                    };
6164                    Ok(AudioDeviceEnumeratorRequest::AddDeviceByChannel {device_name: req.device_name,
6165is_input: req.is_input,
6166channel: req.channel,
6167
6168                        control_handle,
6169                    })
6170                }
6171                _ => Err(fidl::Error::UnknownOrdinal {
6172                    ordinal: header.ordinal,
6173                    protocol_name: <AudioDeviceEnumeratorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
6174                }),
6175            }))
6176            },
6177        )
6178    }
6179}
6180
6181#[derive(Debug)]
6182pub enum AudioDeviceEnumeratorRequest {
6183    /// Obtain the list of currently active audio devices.
6184    GetDevices { responder: AudioDeviceEnumeratorGetDevicesResponder },
6185    /// Gain/Mute/AGC control
6186    ///
6187    /// Note that each of these operations requires a device_token in order to
6188    /// target the proper input/output.
6189    ///
6190    /// The Get command returns the device_token of the device whose gain is
6191    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
6192    /// device_token was invalid or the device had been removed from the system
6193    /// before the Get command could be processed.
6194    ///
6195    /// Set commands which are given an invalid device token are ignored and
6196    /// have no effect on the system. In addition, users do not need to control
6197    /// all of the gain settings for an audio device with each call. Only the
6198    /// settings with a corresponding flag set in the set_flags parameter will
6199    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
6200    /// a SetDeviceGain call to care only about the mute setting in the
6201    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
6202    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
6203    /// status to be changed simultaneously.
6204    GetDeviceGain { device_token: u64, responder: AudioDeviceEnumeratorGetDeviceGainResponder },
6205    SetDeviceGain {
6206        device_token: u64,
6207        gain_info: AudioGainInfo,
6208        valid_flags: AudioGainValidFlags,
6209        control_handle: AudioDeviceEnumeratorControlHandle,
6210    },
6211    /// # Deprecation
6212    ///
6213    /// StreamConfig is not supported anymore, instead use an
6214    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
6215    /// , see
6216    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
6217    AddDeviceByChannel {
6218        device_name: String,
6219        is_input: bool,
6220        channel:
6221            fdomain_client::fidl::ClientEnd<fdomain_fuchsia_hardware_audio::StreamConfigMarker>,
6222        control_handle: AudioDeviceEnumeratorControlHandle,
6223    },
6224}
6225
6226impl AudioDeviceEnumeratorRequest {
6227    #[allow(irrefutable_let_patterns)]
6228    pub fn into_get_devices(self) -> Option<(AudioDeviceEnumeratorGetDevicesResponder)> {
6229        if let AudioDeviceEnumeratorRequest::GetDevices { responder } = self {
6230            Some((responder))
6231        } else {
6232            None
6233        }
6234    }
6235
6236    #[allow(irrefutable_let_patterns)]
6237    pub fn into_get_device_gain(
6238        self,
6239    ) -> Option<(u64, AudioDeviceEnumeratorGetDeviceGainResponder)> {
6240        if let AudioDeviceEnumeratorRequest::GetDeviceGain { device_token, responder } = self {
6241            Some((device_token, responder))
6242        } else {
6243            None
6244        }
6245    }
6246
6247    #[allow(irrefutable_let_patterns)]
6248    pub fn into_set_device_gain(
6249        self,
6250    ) -> Option<(u64, AudioGainInfo, AudioGainValidFlags, AudioDeviceEnumeratorControlHandle)> {
6251        if let AudioDeviceEnumeratorRequest::SetDeviceGain {
6252            device_token,
6253            gain_info,
6254            valid_flags,
6255            control_handle,
6256        } = self
6257        {
6258            Some((device_token, gain_info, valid_flags, control_handle))
6259        } else {
6260            None
6261        }
6262    }
6263
6264    #[allow(irrefutable_let_patterns)]
6265    pub fn into_add_device_by_channel(
6266        self,
6267    ) -> Option<(
6268        String,
6269        bool,
6270        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_hardware_audio::StreamConfigMarker>,
6271        AudioDeviceEnumeratorControlHandle,
6272    )> {
6273        if let AudioDeviceEnumeratorRequest::AddDeviceByChannel {
6274            device_name,
6275            is_input,
6276            channel,
6277            control_handle,
6278        } = self
6279        {
6280            Some((device_name, is_input, channel, control_handle))
6281        } else {
6282            None
6283        }
6284    }
6285
6286    /// Name of the method defined in FIDL
6287    pub fn method_name(&self) -> &'static str {
6288        match *self {
6289            AudioDeviceEnumeratorRequest::GetDevices { .. } => "get_devices",
6290            AudioDeviceEnumeratorRequest::GetDeviceGain { .. } => "get_device_gain",
6291            AudioDeviceEnumeratorRequest::SetDeviceGain { .. } => "set_device_gain",
6292            AudioDeviceEnumeratorRequest::AddDeviceByChannel { .. } => "add_device_by_channel",
6293        }
6294    }
6295}
6296
6297#[derive(Debug, Clone)]
6298pub struct AudioDeviceEnumeratorControlHandle {
6299    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
6300}
6301
6302impl fdomain_client::fidl::ControlHandle for AudioDeviceEnumeratorControlHandle {
6303    fn shutdown(&self) {
6304        self.inner.shutdown()
6305    }
6306
6307    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6308        self.inner.shutdown_with_epitaph(status)
6309    }
6310
6311    fn is_closed(&self) -> bool {
6312        self.inner.channel().is_closed()
6313    }
6314    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
6315        self.inner.channel().on_closed()
6316    }
6317}
6318
6319impl AudioDeviceEnumeratorControlHandle {
6320    pub fn send_on_device_added(&self, mut device: &AudioDeviceInfo) -> Result<(), fidl::Error> {
6321        self.inner.send::<AudioDeviceEnumeratorOnDeviceAddedRequest>(
6322            (device,),
6323            0,
6324            0xe0fbe40057c4b44,
6325            fidl::encoding::DynamicFlags::empty(),
6326        )
6327    }
6328
6329    pub fn send_on_device_removed(&self, mut device_token: u64) -> Result<(), fidl::Error> {
6330        self.inner.send::<AudioDeviceEnumeratorOnDeviceRemovedRequest>(
6331            (device_token,),
6332            0,
6333            0x6f3b7574463d9ff8,
6334            fidl::encoding::DynamicFlags::empty(),
6335        )
6336    }
6337
6338    pub fn send_on_device_gain_changed(
6339        &self,
6340        mut device_token: u64,
6341        mut gain_info: &AudioGainInfo,
6342    ) -> Result<(), fidl::Error> {
6343        self.inner.send::<AudioDeviceEnumeratorOnDeviceGainChangedRequest>(
6344            (device_token, gain_info),
6345            0,
6346            0x14aefcbbb076b0e9,
6347            fidl::encoding::DynamicFlags::empty(),
6348        )
6349    }
6350
6351    pub fn send_on_default_device_changed(
6352        &self,
6353        mut old_default_token: u64,
6354        mut new_default_token: u64,
6355    ) -> Result<(), fidl::Error> {
6356        self.inner.send::<AudioDeviceEnumeratorOnDefaultDeviceChangedRequest>(
6357            (old_default_token, new_default_token),
6358            0,
6359            0x16357b42d4c16e11,
6360            fidl::encoding::DynamicFlags::empty(),
6361        )
6362    }
6363}
6364
6365#[must_use = "FIDL methods require a response to be sent"]
6366#[derive(Debug)]
6367pub struct AudioDeviceEnumeratorGetDevicesResponder {
6368    control_handle: std::mem::ManuallyDrop<AudioDeviceEnumeratorControlHandle>,
6369    tx_id: u32,
6370}
6371
6372/// Set the the channel to be shutdown (see [`AudioDeviceEnumeratorControlHandle::shutdown`])
6373/// if the responder is dropped without sending a response, so that the client
6374/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6375impl std::ops::Drop for AudioDeviceEnumeratorGetDevicesResponder {
6376    fn drop(&mut self) {
6377        self.control_handle.shutdown();
6378        // Safety: drops once, never accessed again
6379        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6380    }
6381}
6382
6383impl fdomain_client::fidl::Responder for AudioDeviceEnumeratorGetDevicesResponder {
6384    type ControlHandle = AudioDeviceEnumeratorControlHandle;
6385
6386    fn control_handle(&self) -> &AudioDeviceEnumeratorControlHandle {
6387        &self.control_handle
6388    }
6389
6390    fn drop_without_shutdown(mut self) {
6391        // Safety: drops once, never accessed again due to mem::forget
6392        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6393        // Prevent Drop from running (which would shut down the channel)
6394        std::mem::forget(self);
6395    }
6396}
6397
6398impl AudioDeviceEnumeratorGetDevicesResponder {
6399    /// Sends a response to the FIDL transaction.
6400    ///
6401    /// Sets the channel to shutdown if an error occurs.
6402    pub fn send(self, mut devices: &[AudioDeviceInfo]) -> Result<(), fidl::Error> {
6403        let _result = self.send_raw(devices);
6404        if _result.is_err() {
6405            self.control_handle.shutdown();
6406        }
6407        self.drop_without_shutdown();
6408        _result
6409    }
6410
6411    /// Similar to "send" but does not shutdown the channel if an error occurs.
6412    pub fn send_no_shutdown_on_err(
6413        self,
6414        mut devices: &[AudioDeviceInfo],
6415    ) -> Result<(), fidl::Error> {
6416        let _result = self.send_raw(devices);
6417        self.drop_without_shutdown();
6418        _result
6419    }
6420
6421    fn send_raw(&self, mut devices: &[AudioDeviceInfo]) -> Result<(), fidl::Error> {
6422        self.control_handle.inner.send::<AudioDeviceEnumeratorGetDevicesResponse>(
6423            (devices,),
6424            self.tx_id,
6425            0x4ce1aa218aeb12a6,
6426            fidl::encoding::DynamicFlags::empty(),
6427        )
6428    }
6429}
6430
6431#[must_use = "FIDL methods require a response to be sent"]
6432#[derive(Debug)]
6433pub struct AudioDeviceEnumeratorGetDeviceGainResponder {
6434    control_handle: std::mem::ManuallyDrop<AudioDeviceEnumeratorControlHandle>,
6435    tx_id: u32,
6436}
6437
6438/// Set the the channel to be shutdown (see [`AudioDeviceEnumeratorControlHandle::shutdown`])
6439/// if the responder is dropped without sending a response, so that the client
6440/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6441impl std::ops::Drop for AudioDeviceEnumeratorGetDeviceGainResponder {
6442    fn drop(&mut self) {
6443        self.control_handle.shutdown();
6444        // Safety: drops once, never accessed again
6445        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6446    }
6447}
6448
6449impl fdomain_client::fidl::Responder for AudioDeviceEnumeratorGetDeviceGainResponder {
6450    type ControlHandle = AudioDeviceEnumeratorControlHandle;
6451
6452    fn control_handle(&self) -> &AudioDeviceEnumeratorControlHandle {
6453        &self.control_handle
6454    }
6455
6456    fn drop_without_shutdown(mut self) {
6457        // Safety: drops once, never accessed again due to mem::forget
6458        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6459        // Prevent Drop from running (which would shut down the channel)
6460        std::mem::forget(self);
6461    }
6462}
6463
6464impl AudioDeviceEnumeratorGetDeviceGainResponder {
6465    /// Sends a response to the FIDL transaction.
6466    ///
6467    /// Sets the channel to shutdown if an error occurs.
6468    pub fn send(
6469        self,
6470        mut device_token: u64,
6471        mut gain_info: &AudioGainInfo,
6472    ) -> Result<(), fidl::Error> {
6473        let _result = self.send_raw(device_token, gain_info);
6474        if _result.is_err() {
6475            self.control_handle.shutdown();
6476        }
6477        self.drop_without_shutdown();
6478        _result
6479    }
6480
6481    /// Similar to "send" but does not shutdown the channel if an error occurs.
6482    pub fn send_no_shutdown_on_err(
6483        self,
6484        mut device_token: u64,
6485        mut gain_info: &AudioGainInfo,
6486    ) -> Result<(), fidl::Error> {
6487        let _result = self.send_raw(device_token, gain_info);
6488        self.drop_without_shutdown();
6489        _result
6490    }
6491
6492    fn send_raw(
6493        &self,
6494        mut device_token: u64,
6495        mut gain_info: &AudioGainInfo,
6496    ) -> Result<(), fidl::Error> {
6497        self.control_handle.inner.send::<AudioDeviceEnumeratorGetDeviceGainResponse>(
6498            (device_token, gain_info),
6499            self.tx_id,
6500            0x25dd4723403c414b,
6501            fidl::encoding::DynamicFlags::empty(),
6502        )
6503    }
6504}
6505
6506#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6507pub struct AudioRendererMarker;
6508
6509impl fdomain_client::fidl::ProtocolMarker for AudioRendererMarker {
6510    type Proxy = AudioRendererProxy;
6511    type RequestStream = AudioRendererRequestStream;
6512
6513    const DEBUG_NAME: &'static str = "fuchsia.media.AudioRenderer";
6514}
6515impl fdomain_client::fidl::DiscoverableProtocolMarker for AudioRendererMarker {}
6516
6517pub trait AudioRendererProxyInterface: Send + Sync {
6518    fn r#add_payload_buffer(
6519        &self,
6520        id: u32,
6521        payload_buffer: fdomain_client::Vmo,
6522    ) -> Result<(), fidl::Error>;
6523    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
6524    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6525    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
6526    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
6527    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
6528    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6529    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
6530    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
6531    fn r#bind_gain_control(
6532        &self,
6533        gain_control_request: fdomain_client::fidl::ServerEnd<
6534            fdomain_fuchsia_media_audio::GainControlMarker,
6535        >,
6536    ) -> Result<(), fidl::Error>;
6537    fn r#set_pts_units(
6538        &self,
6539        tick_per_second_numerator: u32,
6540        tick_per_second_denominator: u32,
6541    ) -> Result<(), fidl::Error>;
6542    fn r#set_pts_continuity_threshold(&self, threshold_seconds: f32) -> Result<(), fidl::Error>;
6543    type GetReferenceClockResponseFut: std::future::Future<Output = Result<fdomain_client::Clock, fidl::Error>>
6544        + Send;
6545    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
6546    fn r#set_reference_clock(
6547        &self,
6548        reference_clock: Option<fdomain_client::Clock>,
6549    ) -> Result<(), fidl::Error>;
6550    fn r#set_usage(&self, usage: AudioRenderUsage) -> Result<(), fidl::Error>;
6551    fn r#set_usage2(&self, usage2: AudioRenderUsage2) -> Result<(), fidl::Error>;
6552    fn r#set_pcm_stream_type(&self, type_: &AudioStreamType) -> Result<(), fidl::Error>;
6553    fn r#enable_min_lead_time_events(&self, enabled: bool) -> Result<(), fidl::Error>;
6554    type GetMinLeadTimeResponseFut: std::future::Future<Output = Result<i64, fidl::Error>> + Send;
6555    fn r#get_min_lead_time(&self) -> Self::GetMinLeadTimeResponseFut;
6556    type PlayResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>> + Send;
6557    fn r#play(&self, reference_time: i64, media_time: i64) -> Self::PlayResponseFut;
6558    fn r#play_no_reply(&self, reference_time: i64, media_time: i64) -> Result<(), fidl::Error>;
6559    type PauseResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>> + Send;
6560    fn r#pause(&self) -> Self::PauseResponseFut;
6561    fn r#pause_no_reply(&self) -> Result<(), fidl::Error>;
6562}
6563
6564#[derive(Debug, Clone)]
6565pub struct AudioRendererProxy {
6566    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
6567}
6568
6569impl fdomain_client::fidl::Proxy for AudioRendererProxy {
6570    type Protocol = AudioRendererMarker;
6571
6572    fn from_channel(inner: fdomain_client::Channel) -> Self {
6573        Self::new(inner)
6574    }
6575
6576    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
6577        self.client.into_channel().map_err(|client| Self { client })
6578    }
6579
6580    fn as_channel(&self) -> &fdomain_client::Channel {
6581        self.client.as_channel()
6582    }
6583}
6584
6585impl AudioRendererProxy {
6586    /// Create a new Proxy for fuchsia.media/AudioRenderer.
6587    pub fn new(channel: fdomain_client::Channel) -> Self {
6588        let protocol_name =
6589            <AudioRendererMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
6590        Self { client: fidl::client::Client::new(channel, protocol_name) }
6591    }
6592
6593    /// Get a Stream of events from the remote end of the protocol.
6594    ///
6595    /// # Panics
6596    ///
6597    /// Panics if the event stream was already taken.
6598    pub fn take_event_stream(&self) -> AudioRendererEventStream {
6599        AudioRendererEventStream { event_receiver: self.client.take_event_receiver() }
6600    }
6601
6602    /// Adds a payload buffer to the current buffer set associated with the
6603    /// connection. A `StreamPacket` struct reference a payload buffer in the
6604    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
6605    ///
6606    /// A buffer with ID `id` must not be in the current set when this method is
6607    /// invoked, otherwise the service will close the connection.
6608    pub fn r#add_payload_buffer(
6609        &self,
6610        mut id: u32,
6611        mut payload_buffer: fdomain_client::Vmo,
6612    ) -> Result<(), fidl::Error> {
6613        AudioRendererProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
6614    }
6615
6616    /// Removes a payload buffer from the current buffer set associated with the
6617    /// connection.
6618    ///
6619    /// A buffer with ID `id` must exist in the current set when this method is
6620    /// invoked, otherwise the service will will close the connection.
6621    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
6622        AudioRendererProxyInterface::r#remove_payload_buffer(self, id)
6623    }
6624
6625    /// Sends a packet to the service. The response is sent when the service is
6626    /// done with the associated payload memory.
6627    ///
6628    /// `packet` must be valid for the current buffer set, otherwise the service
6629    /// will close the connection.
6630    pub fn r#send_packet(
6631        &self,
6632        mut packet: &StreamPacket,
6633    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
6634        AudioRendererProxyInterface::r#send_packet(self, packet)
6635    }
6636
6637    /// Sends a packet to the service. This interface doesn't define how the
6638    /// client knows when the sink is done with the associated payload memory.
6639    /// The inheriting interface must define that.
6640    ///
6641    /// `packet` must be valid for the current buffer set, otherwise the service
6642    /// will close the connection.
6643    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
6644        AudioRendererProxyInterface::r#send_packet_no_reply(self, packet)
6645    }
6646
6647    /// Indicates the stream has ended. The precise semantics of this method are
6648    /// determined by the inheriting interface.
6649    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
6650        AudioRendererProxyInterface::r#end_of_stream(self)
6651    }
6652
6653    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
6654    /// and not yet released. The response is sent after all packets have been
6655    /// released.
6656    pub fn r#discard_all_packets(
6657        &self,
6658    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
6659        AudioRendererProxyInterface::r#discard_all_packets(self)
6660    }
6661
6662    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
6663    /// and not yet released.
6664    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
6665        AudioRendererProxyInterface::r#discard_all_packets_no_reply(self)
6666    }
6667
6668    /// Binds to the gain control for this AudioRenderer.
6669    pub fn r#bind_gain_control(
6670        &self,
6671        mut gain_control_request: fdomain_client::fidl::ServerEnd<
6672            fdomain_fuchsia_media_audio::GainControlMarker,
6673        >,
6674    ) -> Result<(), fidl::Error> {
6675        AudioRendererProxyInterface::r#bind_gain_control(self, gain_control_request)
6676    }
6677
6678    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
6679    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
6680    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
6681    pub fn r#set_pts_units(
6682        &self,
6683        mut tick_per_second_numerator: u32,
6684        mut tick_per_second_denominator: u32,
6685    ) -> Result<(), fidl::Error> {
6686        AudioRendererProxyInterface::r#set_pts_units(
6687            self,
6688            tick_per_second_numerator,
6689            tick_per_second_denominator,
6690        )
6691    }
6692
6693    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
6694    /// and expected PTS (determined using interpolation). Beyond this threshold,
6695    /// a stream is no longer considered 'continuous' by the renderer.
6696    ///
6697    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
6698    /// Most users should not need to change this value from its default.
6699    ///
6700    /// Example:
6701    /// A user is playing back 48KHz audio from a container, which also contains
6702    /// video and needs to be synchronized with the audio. The timestamps are
6703    /// provided explicitly per packet by the container, and expressed in mSec
6704    /// units. This means that a single tick of the media timeline (1 mSec)
6705    /// represents exactly 48 frames of audio. The application in this scenario
6706    /// delivers packets of audio to the AudioRenderer, each with exactly 470
6707    /// frames of audio, and each with an explicit timestamp set to the best
6708    /// possible representation of the presentation time (given this media
6709    /// clock's resolution). So, starting from zero, the timestamps would be..
6710    ///
6711    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
6712    ///
6713    /// In this example, attempting to use the presentation time to compute the
6714    /// starting frame number of the audio in the packet would be wrong the
6715    /// majority of the time. The first timestamp is correct (by definition), but
6716    /// it will be 24 packets before the timestamps and frame numbers come back
6717    /// into alignment (the 24th packet would start with the 11280th audio frame
6718    /// and have a PTS of exactly 235).
6719    ///
6720    /// One way to fix this situation is to set the PTS continuity threshold
6721    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
6722    /// the number of frames contained within a single tick of the media clock,
6723    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
6724    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
6725    /// explicitly provided PTS would be considered to be a continuation of the
6726    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
6727    /// would work well.
6728    ///
6729    /// Other possible uses:
6730    /// Users who are scheduling audio explicitly, relative to a clock which has
6731    /// not been configured as the reference clock, can use this value to control
6732    /// the maximum acceptable synchronization error before a discontinuity is
6733    /// introduced. E.g., if a user is scheduling audio based on a recovered
6734    /// common media clock, and has not published that clock as the reference
6735    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
6736    /// can accumulate before the AudioRenderer deliberately inserts a
6737    /// presentation discontinuity to account for the error.
6738    ///
6739    /// Users whose need to deal with a container where their timestamps may be
6740    /// even less correct than +/- 1/2 of a PTS tick may set this value to
6741    /// something larger. This should be the maximum level of inaccuracy present
6742    /// in the container timestamps, if known. Failing that, it could be set to
6743    /// the maximum tolerable level of drift error before absolute timestamps are
6744    /// explicitly obeyed. Finally, a user could set this number to a very large
6745    /// value (86400.0 seconds, for example) to effectively cause *all*
6746    /// timestamps to be ignored after the first, thus treating all audio as
6747    /// continuous with previously delivered packets. Conversely, users who wish
6748    /// to *always* explicitly schedule their audio packets exactly may specify
6749    /// a CT of 0.
6750    ///
6751    /// Note: explicitly specifying high-frequency PTS units reduces the default
6752    /// continuity threshold accordingly. Internally, this threshold is stored as an
6753    /// integer of 1/8192 subframes. The default threshold is computed as follows:
6754    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
6755    /// For this reason, specifying PTS units with a frequency greater than 8192x
6756    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
6757    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
6758    pub fn r#set_pts_continuity_threshold(
6759        &self,
6760        mut threshold_seconds: f32,
6761    ) -> Result<(), fidl::Error> {
6762        AudioRendererProxyInterface::r#set_pts_continuity_threshold(self, threshold_seconds)
6763    }
6764
6765    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
6766    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
6767    pub fn r#get_reference_clock(
6768        &self,
6769    ) -> fidl::client::QueryResponseFut<
6770        fdomain_client::Clock,
6771        fdomain_client::fidl::FDomainResourceDialect,
6772    > {
6773        AudioRendererProxyInterface::r#get_reference_clock(self)
6774    }
6775
6776    /// Sets the reference clock that controls this renderer's playback rate. If the input
6777    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
6778    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
6779    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
6780    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
6781    ///
6782    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
6783    /// cannot be called a second time (even if the renderer format has not yet been set).
6784    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
6785    /// diverge at some later time, they should create a clone of the monotonic clock, set
6786    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
6787    pub fn r#set_reference_clock(
6788        &self,
6789        mut reference_clock: Option<fdomain_client::Clock>,
6790    ) -> Result<(), fidl::Error> {
6791        AudioRendererProxyInterface::r#set_reference_clock(self, reference_clock)
6792    }
6793
6794    /// Sets the usage of the render stream. This method may not be called after
6795    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
6796    pub fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
6797        AudioRendererProxyInterface::r#set_usage(self, usage)
6798    }
6799
6800    /// Sets the usage of the render stream. This method may not be called after
6801    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
6802    pub fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
6803        AudioRendererProxyInterface::r#set_usage2(self, usage2)
6804    }
6805
6806    /// Sets the type of the stream to be delivered by the client. Using this method implies
6807    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
6808    ///
6809    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
6810    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
6811    /// methods such as `SendPacket`/`SendPacketNoReply`.
6812    pub fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
6813        AudioRendererProxyInterface::r#set_pcm_stream_type(self, type_)
6814    }
6815
6816    /// Enables or disables notifications about changes to the minimum clock lead
6817    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
6818    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
6819    /// event with the current minimum lead time for the AudioRenderer. If the
6820    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
6821    /// new value. This behavior will continue until the user calls
6822    /// `EnableMinLeadTimeEvents(false)`.
6823    ///
6824    /// The minimum clock lead time is the amount of time ahead of the reference
6825    /// clock's understanding of "now" that packets needs to arrive (relative to
6826    /// the playback clock transformation) in order for the mixer to be able to
6827    /// mix packet. For example...
6828    ///
6829    /// + Let the PTS of packet X be P(X)
6830    /// + Let the function which transforms PTS -> RefClock be R(p) (this
6831    ///   function is determined by the call to Play(...)
6832    /// + Let the minimum lead time be MLT
6833    ///
6834    /// If R(P(X)) < RefClock.Now() + MLT
6835    /// Then the packet is late, and some (or all) of the packet's payload will
6836    /// need to be skipped in order to present the packet at the scheduled time.
6837    ///
6838    /// The value `min_lead_time_nsec = 0` is a special value which indicates
6839    /// that the AudioRenderer is not yet routed to an output device. If `Play`
6840    /// is called before the AudioRenderer is routed, any played packets will be
6841    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
6842    /// calling `Play`.
6843    pub fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
6844        AudioRendererProxyInterface::r#enable_min_lead_time_events(self, enabled)
6845    }
6846
6847    ///
6848    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
6849    /// there's little reason to do so. This is because lead time is a function
6850    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
6851    /// If min lead time events are enabled before `SetPcmStreamType` (with
6852    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
6853    /// response to `SetPcmStreamType`.
6854    pub fn r#get_min_lead_time(
6855        &self,
6856    ) -> fidl::client::QueryResponseFut<i64, fdomain_client::fidl::FDomainResourceDialect> {
6857        AudioRendererProxyInterface::r#get_min_lead_time(self)
6858    }
6859
6860    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
6861    /// of the media timeline, using specific values provided by the caller (or
6862    /// default values if not specified). In an optional callback, returns the
6863    /// timestamp values ultimately used -- these set the ongoing relationship
6864    /// between the media and reference timelines (i.e., how to translate between
6865    /// the domain of presentation timestamps, and the realm of local system
6866    /// time).
6867    ///
6868    /// Local system time is specified in units of nanoseconds; media_time is
6869    /// specified in the units defined by the user in the `SetPtsUnits` function,
6870    /// or nanoseconds if `SetPtsUnits` is not called.
6871    ///
6872    /// The act of placing an AudioRenderer into the playback state establishes a
6873    /// relationship between 1) the user-defined media (or presentation) timeline
6874    /// for this particular AudioRenderer, and 2) the real-world system reference
6875    /// timeline. To communicate how to translate between timelines, the Play()
6876    /// callback provides an equivalent timestamp in each time domain. The first
6877    /// value ('reference_time') is given in terms of this renderer's reference
6878    /// clock; the second value ('media_time') is what media instant exactly
6879    /// corresponds to that local time. Restated, the frame at 'media_time' in
6880    /// the audio stream should be presented at 'reference_time' according to
6881    /// the reference clock.
6882    ///
6883    /// Note: on calling this API, media_time immediately starts advancing. It is
6884    /// possible (if uncommon) for a caller to specify a system time that is
6885    /// far in the past, or far into the future. This, along with the specified
6886    /// media time, is simply used to determine what media time corresponds to
6887    /// 'now', and THAT media time is then intersected with presentation
6888    /// timestamps of packets already submitted, to determine which media frames
6889    /// should be presented next.
6890    ///
6891    /// With the corresponding reference_time and media_time values, a user can
6892    /// translate arbitrary time values from one timeline into the other. After
6893    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
6894    /// given the 'ref_start' and 'media_start' values from `Play`, then for
6895    /// any 'ref_time':
6896    ///
6897    /// media_time = ( (ref_time - ref_start) / 1e9
6898    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
6899    ///              + media_start
6900    ///
6901    /// Conversely, for any presentation timestamp 'media_time':
6902    ///
6903    /// ref_time = ( (media_time - media_start)
6904    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
6905    ///              * 1e9 )
6906    ///            + ref_start
6907    ///
6908    /// Users, depending on their use case, may optionally choose not to specify
6909    /// one or both of these timestamps. A timestamp may be omitted by supplying
6910    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
6911    /// any omitted timestamp value using the following rules:
6912    ///
6913    /// Reference Time
6914    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
6915    /// reference time to begin presentation, based on the minimum lead times for
6916    /// the output devices that are currently bound to this AudioRenderer. For
6917    /// example, if an AudioRenderer is bound to an internal audio output
6918    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
6919    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
6920    /// is omitted) select a reference time 80 mSec from now.
6921    ///
6922    /// Media Time
6923    /// If media_time is omitted, the AudioRenderer will select one of two
6924    /// values.
6925    /// - If the AudioRenderer is resuming from the paused state, and packets
6926    /// have not been discarded since being paused, then the AudioRenderer will
6927    /// use a media_time corresponding to the instant at which the presentation
6928    /// became paused.
6929    /// - If the AudioRenderer is being placed into a playing state for the first
6930    /// time following startup or a 'discard packets' operation, the initial
6931    /// media_time will be set to the PTS of the first payload in the pending
6932    /// packet queue. If the pending queue is empty, initial media_time will be
6933    /// set to zero.
6934    ///
6935    /// Return Value
6936    /// When requested, the AudioRenderer will return the 'reference_time' and
6937    /// 'media_time' which were selected and used (whether they were explicitly
6938    /// specified or not) in the return value of the play call.
6939    ///
6940    /// Examples
6941    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
6942    /// to start playing as soon as possible. The user may call Play without
6943    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
6944    ///
6945    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
6946    /// playback at a specified 'reference_time', in sync with some other media
6947    /// stream, either initially or after discarding packets. The user would call
6948    /// `Play(reference_time, NO_TIMESTAMP)`.
6949    ///
6950    /// 3. A user has queued some audio using `SendPacket`. The first of these
6951    /// packets has a PTS of zero, and the user wishes playback to begin as soon
6952    /// as possible, but wishes to skip all of the audio content between PTS 0
6953    /// and PTS 'media_time'. The user would call
6954    /// `Play(NO_TIMESTAMP, media_time)`.
6955    ///
6956    /// 4. A user has queued some audio using `SendPacket` and want to present
6957    /// this media in synch with another player in a different device. The
6958    /// coordinator of the group of distributed players sends an explicit
6959    /// message to each player telling them to begin presentation of audio at
6960    /// PTS 'media_time', at the time (based on the group's shared reference
6961    /// clock) 'reference_time'. Here the user would call
6962    /// `Play(reference_time, media_time)`.
6963    pub fn r#play(
6964        &self,
6965        mut reference_time: i64,
6966        mut media_time: i64,
6967    ) -> fidl::client::QueryResponseFut<(i64, i64), fdomain_client::fidl::FDomainResourceDialect>
6968    {
6969        AudioRendererProxyInterface::r#play(self, reference_time, media_time)
6970    }
6971
6972    pub fn r#play_no_reply(
6973        &self,
6974        mut reference_time: i64,
6975        mut media_time: i64,
6976    ) -> Result<(), fidl::Error> {
6977        AudioRendererProxyInterface::r#play_no_reply(self, reference_time, media_time)
6978    }
6979
6980    /// Immediately puts the AudioRenderer into the paused state and then report
6981    /// the relationship between the media and reference timelines which was
6982    /// established (if requested).
6983    ///
6984    /// If the AudioRenderer is already in the paused state when this called,
6985    /// the previously-established timeline values are returned (if requested).
6986    pub fn r#pause(
6987        &self,
6988    ) -> fidl::client::QueryResponseFut<(i64, i64), fdomain_client::fidl::FDomainResourceDialect>
6989    {
6990        AudioRendererProxyInterface::r#pause(self)
6991    }
6992
6993    pub fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
6994        AudioRendererProxyInterface::r#pause_no_reply(self)
6995    }
6996}
6997
6998impl AudioRendererProxyInterface for AudioRendererProxy {
6999    fn r#add_payload_buffer(
7000        &self,
7001        mut id: u32,
7002        mut payload_buffer: fdomain_client::Vmo,
7003    ) -> Result<(), fidl::Error> {
7004        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
7005            (id, payload_buffer),
7006            0x3b3a37fc34fe5b56,
7007            fidl::encoding::DynamicFlags::empty(),
7008        )
7009    }
7010
7011    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
7012        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
7013            (id,),
7014            0x5d1e4f74c3658262,
7015            fidl::encoding::DynamicFlags::empty(),
7016        )
7017    }
7018
7019    type SendPacketResponseFut =
7020        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
7021    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
7022        fn _decode(
7023            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7024        ) -> Result<(), fidl::Error> {
7025            let _response = fidl::client::decode_transaction_body::<
7026                fidl::encoding::EmptyPayload,
7027                fdomain_client::fidl::FDomainResourceDialect,
7028                0x67cddd607442775f,
7029            >(_buf?)?;
7030            Ok(_response)
7031        }
7032        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
7033            (packet,),
7034            0x67cddd607442775f,
7035            fidl::encoding::DynamicFlags::empty(),
7036            _decode,
7037        )
7038    }
7039
7040    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
7041        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
7042            (packet,),
7043            0x8d9b8b413ceba9d,
7044            fidl::encoding::DynamicFlags::empty(),
7045        )
7046    }
7047
7048    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
7049        self.client.send::<fidl::encoding::EmptyPayload>(
7050            (),
7051            0x6180fd6f7e793b71,
7052            fidl::encoding::DynamicFlags::empty(),
7053        )
7054    }
7055
7056    type DiscardAllPacketsResponseFut =
7057        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
7058    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
7059        fn _decode(
7060            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7061        ) -> Result<(), fidl::Error> {
7062            let _response = fidl::client::decode_transaction_body::<
7063                fidl::encoding::EmptyPayload,
7064                fdomain_client::fidl::FDomainResourceDialect,
7065                0x6f4dad7af2917665,
7066            >(_buf?)?;
7067            Ok(_response)
7068        }
7069        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
7070            (),
7071            0x6f4dad7af2917665,
7072            fidl::encoding::DynamicFlags::empty(),
7073            _decode,
7074        )
7075    }
7076
7077    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
7078        self.client.send::<fidl::encoding::EmptyPayload>(
7079            (),
7080            0x50d36d0d23081bc4,
7081            fidl::encoding::DynamicFlags::empty(),
7082        )
7083    }
7084
7085    fn r#bind_gain_control(
7086        &self,
7087        mut gain_control_request: fdomain_client::fidl::ServerEnd<
7088            fdomain_fuchsia_media_audio::GainControlMarker,
7089        >,
7090    ) -> Result<(), fidl::Error> {
7091        self.client.send::<AudioRendererBindGainControlRequest>(
7092            (gain_control_request,),
7093            0x293f5c7f8fba2bdc,
7094            fidl::encoding::DynamicFlags::empty(),
7095        )
7096    }
7097
7098    fn r#set_pts_units(
7099        &self,
7100        mut tick_per_second_numerator: u32,
7101        mut tick_per_second_denominator: u32,
7102    ) -> Result<(), fidl::Error> {
7103        self.client.send::<AudioRendererSetPtsUnitsRequest>(
7104            (tick_per_second_numerator, tick_per_second_denominator),
7105            0xf68cd108785a27c,
7106            fidl::encoding::DynamicFlags::empty(),
7107        )
7108    }
7109
7110    fn r#set_pts_continuity_threshold(
7111        &self,
7112        mut threshold_seconds: f32,
7113    ) -> Result<(), fidl::Error> {
7114        self.client.send::<AudioRendererSetPtsContinuityThresholdRequest>(
7115            (threshold_seconds,),
7116            0x2849ba571d1971ba,
7117            fidl::encoding::DynamicFlags::empty(),
7118        )
7119    }
7120
7121    type GetReferenceClockResponseFut = fidl::client::QueryResponseFut<
7122        fdomain_client::Clock,
7123        fdomain_client::fidl::FDomainResourceDialect,
7124    >;
7125    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
7126        fn _decode(
7127            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7128        ) -> Result<fdomain_client::Clock, fidl::Error> {
7129            let _response = fidl::client::decode_transaction_body::<
7130                AudioRendererGetReferenceClockResponse,
7131                fdomain_client::fidl::FDomainResourceDialect,
7132                0x2f7a7f011a172f7e,
7133            >(_buf?)?;
7134            Ok(_response.reference_clock)
7135        }
7136        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fdomain_client::Clock>(
7137            (),
7138            0x2f7a7f011a172f7e,
7139            fidl::encoding::DynamicFlags::empty(),
7140            _decode,
7141        )
7142    }
7143
7144    fn r#set_reference_clock(
7145        &self,
7146        mut reference_clock: Option<fdomain_client::Clock>,
7147    ) -> Result<(), fidl::Error> {
7148        self.client.send::<AudioRendererSetReferenceClockRequest>(
7149            (reference_clock,),
7150            0x39acd05d832b5fed,
7151            fidl::encoding::DynamicFlags::empty(),
7152        )
7153    }
7154
7155    fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
7156        self.client.send::<AudioRendererSetUsageRequest>(
7157            (usage,),
7158            0x3994bd23b55a733e,
7159            fidl::encoding::DynamicFlags::empty(),
7160        )
7161    }
7162
7163    fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
7164        self.client.send::<AudioRendererSetUsage2Request>(
7165            (usage2,),
7166            0x2904035c7132b103,
7167            fidl::encoding::DynamicFlags::FLEXIBLE,
7168        )
7169    }
7170
7171    fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
7172        self.client.send::<AudioRendererSetPcmStreamTypeRequest>(
7173            (type_,),
7174            0x27aa715d8901fa19,
7175            fidl::encoding::DynamicFlags::empty(),
7176        )
7177    }
7178
7179    fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
7180        self.client.send::<AudioRendererEnableMinLeadTimeEventsRequest>(
7181            (enabled,),
7182            0x62808dfad72bf890,
7183            fidl::encoding::DynamicFlags::empty(),
7184        )
7185    }
7186
7187    type GetMinLeadTimeResponseFut =
7188        fidl::client::QueryResponseFut<i64, fdomain_client::fidl::FDomainResourceDialect>;
7189    fn r#get_min_lead_time(&self) -> Self::GetMinLeadTimeResponseFut {
7190        fn _decode(
7191            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7192        ) -> Result<i64, fidl::Error> {
7193            let _response = fidl::client::decode_transaction_body::<
7194                AudioRendererGetMinLeadTimeResponse,
7195                fdomain_client::fidl::FDomainResourceDialect,
7196                0x1cf3c3ecd8fec26b,
7197            >(_buf?)?;
7198            Ok(_response.min_lead_time_nsec)
7199        }
7200        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i64>(
7201            (),
7202            0x1cf3c3ecd8fec26b,
7203            fidl::encoding::DynamicFlags::empty(),
7204            _decode,
7205        )
7206    }
7207
7208    type PlayResponseFut =
7209        fidl::client::QueryResponseFut<(i64, i64), fdomain_client::fidl::FDomainResourceDialect>;
7210    fn r#play(&self, mut reference_time: i64, mut media_time: i64) -> Self::PlayResponseFut {
7211        fn _decode(
7212            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7213        ) -> Result<(i64, i64), fidl::Error> {
7214            let _response = fidl::client::decode_transaction_body::<
7215                AudioRendererPlayResponse,
7216                fdomain_client::fidl::FDomainResourceDialect,
7217                0x3c0162db084f74a3,
7218            >(_buf?)?;
7219            Ok((_response.reference_time, _response.media_time))
7220        }
7221        self.client.send_query_and_decode::<AudioRendererPlayRequest, (i64, i64)>(
7222            (reference_time, media_time),
7223            0x3c0162db084f74a3,
7224            fidl::encoding::DynamicFlags::empty(),
7225            _decode,
7226        )
7227    }
7228
7229    fn r#play_no_reply(
7230        &self,
7231        mut reference_time: i64,
7232        mut media_time: i64,
7233    ) -> Result<(), fidl::Error> {
7234        self.client.send::<AudioRendererPlayNoReplyRequest>(
7235            (reference_time, media_time),
7236            0x1b7fe832b68c22ef,
7237            fidl::encoding::DynamicFlags::empty(),
7238        )
7239    }
7240
7241    type PauseResponseFut =
7242        fidl::client::QueryResponseFut<(i64, i64), fdomain_client::fidl::FDomainResourceDialect>;
7243    fn r#pause(&self) -> Self::PauseResponseFut {
7244        fn _decode(
7245            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7246        ) -> Result<(i64, i64), fidl::Error> {
7247            let _response = fidl::client::decode_transaction_body::<
7248                AudioRendererPauseResponse,
7249                fdomain_client::fidl::FDomainResourceDialect,
7250                0x41d557588d93d153,
7251            >(_buf?)?;
7252            Ok((_response.reference_time, _response.media_time))
7253        }
7254        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i64, i64)>(
7255            (),
7256            0x41d557588d93d153,
7257            fidl::encoding::DynamicFlags::empty(),
7258            _decode,
7259        )
7260    }
7261
7262    fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
7263        self.client.send::<fidl::encoding::EmptyPayload>(
7264            (),
7265            0x24cc45d4f3855ab,
7266            fidl::encoding::DynamicFlags::empty(),
7267        )
7268    }
7269}
7270
7271pub struct AudioRendererEventStream {
7272    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
7273}
7274
7275impl std::marker::Unpin for AudioRendererEventStream {}
7276
7277impl futures::stream::FusedStream for AudioRendererEventStream {
7278    fn is_terminated(&self) -> bool {
7279        self.event_receiver.is_terminated()
7280    }
7281}
7282
7283impl futures::Stream for AudioRendererEventStream {
7284    type Item = Result<AudioRendererEvent, fidl::Error>;
7285
7286    fn poll_next(
7287        mut self: std::pin::Pin<&mut Self>,
7288        cx: &mut std::task::Context<'_>,
7289    ) -> std::task::Poll<Option<Self::Item>> {
7290        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7291            &mut self.event_receiver,
7292            cx
7293        )?) {
7294            Some(buf) => std::task::Poll::Ready(Some(AudioRendererEvent::decode(buf))),
7295            None => std::task::Poll::Ready(None),
7296        }
7297    }
7298}
7299
7300#[derive(Debug)]
7301pub enum AudioRendererEvent {
7302    OnMinLeadTimeChanged {
7303        min_lead_time_nsec: i64,
7304    },
7305    #[non_exhaustive]
7306    _UnknownEvent {
7307        /// Ordinal of the event that was sent.
7308        ordinal: u64,
7309    },
7310}
7311
7312impl AudioRendererEvent {
7313    #[allow(irrefutable_let_patterns)]
7314    pub fn into_on_min_lead_time_changed(self) -> Option<i64> {
7315        if let AudioRendererEvent::OnMinLeadTimeChanged { min_lead_time_nsec } = self {
7316            Some((min_lead_time_nsec))
7317        } else {
7318            None
7319        }
7320    }
7321
7322    /// Decodes a message buffer as a [`AudioRendererEvent`].
7323    fn decode(
7324        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7325    ) -> Result<AudioRendererEvent, fidl::Error> {
7326        let (bytes, _handles) = buf.split_mut();
7327        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7328        debug_assert_eq!(tx_header.tx_id, 0);
7329        match tx_header.ordinal {
7330            0x4feff7d278978c4e => {
7331                let mut out = fidl::new_empty!(
7332                    AudioRendererOnMinLeadTimeChangedRequest,
7333                    fdomain_client::fidl::FDomainResourceDialect
7334                );
7335                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererOnMinLeadTimeChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7336                Ok((AudioRendererEvent::OnMinLeadTimeChanged {
7337                    min_lead_time_nsec: out.min_lead_time_nsec,
7338                }))
7339            }
7340            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7341                Ok(AudioRendererEvent::_UnknownEvent { ordinal: tx_header.ordinal })
7342            }
7343            _ => Err(fidl::Error::UnknownOrdinal {
7344                ordinal: tx_header.ordinal,
7345                protocol_name:
7346                    <AudioRendererMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
7347            }),
7348        }
7349    }
7350}
7351
7352/// A Stream of incoming requests for fuchsia.media/AudioRenderer.
7353pub struct AudioRendererRequestStream {
7354    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
7355    is_terminated: bool,
7356}
7357
7358impl std::marker::Unpin for AudioRendererRequestStream {}
7359
7360impl futures::stream::FusedStream for AudioRendererRequestStream {
7361    fn is_terminated(&self) -> bool {
7362        self.is_terminated
7363    }
7364}
7365
7366impl fdomain_client::fidl::RequestStream for AudioRendererRequestStream {
7367    type Protocol = AudioRendererMarker;
7368    type ControlHandle = AudioRendererControlHandle;
7369
7370    fn from_channel(channel: fdomain_client::Channel) -> Self {
7371        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7372    }
7373
7374    fn control_handle(&self) -> Self::ControlHandle {
7375        AudioRendererControlHandle { inner: self.inner.clone() }
7376    }
7377
7378    fn into_inner(
7379        self,
7380    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
7381    {
7382        (self.inner, self.is_terminated)
7383    }
7384
7385    fn from_inner(
7386        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
7387        is_terminated: bool,
7388    ) -> Self {
7389        Self { inner, is_terminated }
7390    }
7391}
7392
7393impl futures::Stream for AudioRendererRequestStream {
7394    type Item = Result<AudioRendererRequest, fidl::Error>;
7395
7396    fn poll_next(
7397        mut self: std::pin::Pin<&mut Self>,
7398        cx: &mut std::task::Context<'_>,
7399    ) -> std::task::Poll<Option<Self::Item>> {
7400        let this = &mut *self;
7401        if this.inner.check_shutdown(cx) {
7402            this.is_terminated = true;
7403            return std::task::Poll::Ready(None);
7404        }
7405        if this.is_terminated {
7406            panic!("polled AudioRendererRequestStream after completion");
7407        }
7408        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
7409            |bytes, handles| {
7410                match this.inner.channel().read_etc(cx, bytes, handles) {
7411                    std::task::Poll::Ready(Ok(())) => {}
7412                    std::task::Poll::Pending => return std::task::Poll::Pending,
7413                    std::task::Poll::Ready(Err(None)) => {
7414                        this.is_terminated = true;
7415                        return std::task::Poll::Ready(None);
7416                    }
7417                    std::task::Poll::Ready(Err(Some(e))) => {
7418                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7419                            e.into(),
7420                        ))));
7421                    }
7422                }
7423
7424                // A message has been received from the channel
7425                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7426
7427                std::task::Poll::Ready(Some(match header.ordinal {
7428                0x3b3a37fc34fe5b56 => {
7429                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7430                    let mut req = fidl::new_empty!(StreamBufferSetAddPayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
7431                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
7432                    let control_handle = AudioRendererControlHandle {
7433                        inner: this.inner.clone(),
7434                    };
7435                    Ok(AudioRendererRequest::AddPayloadBuffer {id: req.id,
7436payload_buffer: req.payload_buffer,
7437
7438                        control_handle,
7439                    })
7440                }
7441                0x5d1e4f74c3658262 => {
7442                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7443                    let mut req = fidl::new_empty!(StreamBufferSetRemovePayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
7444                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
7445                    let control_handle = AudioRendererControlHandle {
7446                        inner: this.inner.clone(),
7447                    };
7448                    Ok(AudioRendererRequest::RemovePayloadBuffer {id: req.id,
7449
7450                        control_handle,
7451                    })
7452                }
7453                0x67cddd607442775f => {
7454                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7455                    let mut req = fidl::new_empty!(StreamSinkSendPacketRequest, fdomain_client::fidl::FDomainResourceDialect);
7456                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
7457                    let control_handle = AudioRendererControlHandle {
7458                        inner: this.inner.clone(),
7459                    };
7460                    Ok(AudioRendererRequest::SendPacket {packet: req.packet,
7461
7462                        responder: AudioRendererSendPacketResponder {
7463                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7464                            tx_id: header.tx_id,
7465                        },
7466                    })
7467                }
7468                0x8d9b8b413ceba9d => {
7469                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7470                    let mut req = fidl::new_empty!(StreamSinkSendPacketNoReplyRequest, fdomain_client::fidl::FDomainResourceDialect);
7471                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
7472                    let control_handle = AudioRendererControlHandle {
7473                        inner: this.inner.clone(),
7474                    };
7475                    Ok(AudioRendererRequest::SendPacketNoReply {packet: req.packet,
7476
7477                        control_handle,
7478                    })
7479                }
7480                0x6180fd6f7e793b71 => {
7481                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7482                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7483                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7484                    let control_handle = AudioRendererControlHandle {
7485                        inner: this.inner.clone(),
7486                    };
7487                    Ok(AudioRendererRequest::EndOfStream {
7488                        control_handle,
7489                    })
7490                }
7491                0x6f4dad7af2917665 => {
7492                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7493                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7494                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7495                    let control_handle = AudioRendererControlHandle {
7496                        inner: this.inner.clone(),
7497                    };
7498                    Ok(AudioRendererRequest::DiscardAllPackets {
7499                        responder: AudioRendererDiscardAllPacketsResponder {
7500                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7501                            tx_id: header.tx_id,
7502                        },
7503                    })
7504                }
7505                0x50d36d0d23081bc4 => {
7506                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7507                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7508                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7509                    let control_handle = AudioRendererControlHandle {
7510                        inner: this.inner.clone(),
7511                    };
7512                    Ok(AudioRendererRequest::DiscardAllPacketsNoReply {
7513                        control_handle,
7514                    })
7515                }
7516                0x293f5c7f8fba2bdc => {
7517                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7518                    let mut req = fidl::new_empty!(AudioRendererBindGainControlRequest, fdomain_client::fidl::FDomainResourceDialect);
7519                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererBindGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
7520                    let control_handle = AudioRendererControlHandle {
7521                        inner: this.inner.clone(),
7522                    };
7523                    Ok(AudioRendererRequest::BindGainControl {gain_control_request: req.gain_control_request,
7524
7525                        control_handle,
7526                    })
7527                }
7528                0xf68cd108785a27c => {
7529                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7530                    let mut req = fidl::new_empty!(AudioRendererSetPtsUnitsRequest, fdomain_client::fidl::FDomainResourceDialect);
7531                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererSetPtsUnitsRequest>(&header, _body_bytes, handles, &mut req)?;
7532                    let control_handle = AudioRendererControlHandle {
7533                        inner: this.inner.clone(),
7534                    };
7535                    Ok(AudioRendererRequest::SetPtsUnits {tick_per_second_numerator: req.tick_per_second_numerator,
7536tick_per_second_denominator: req.tick_per_second_denominator,
7537
7538                        control_handle,
7539                    })
7540                }
7541                0x2849ba571d1971ba => {
7542                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7543                    let mut req = fidl::new_empty!(AudioRendererSetPtsContinuityThresholdRequest, fdomain_client::fidl::FDomainResourceDialect);
7544                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererSetPtsContinuityThresholdRequest>(&header, _body_bytes, handles, &mut req)?;
7545                    let control_handle = AudioRendererControlHandle {
7546                        inner: this.inner.clone(),
7547                    };
7548                    Ok(AudioRendererRequest::SetPtsContinuityThreshold {threshold_seconds: req.threshold_seconds,
7549
7550                        control_handle,
7551                    })
7552                }
7553                0x2f7a7f011a172f7e => {
7554                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7555                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7556                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7557                    let control_handle = AudioRendererControlHandle {
7558                        inner: this.inner.clone(),
7559                    };
7560                    Ok(AudioRendererRequest::GetReferenceClock {
7561                        responder: AudioRendererGetReferenceClockResponder {
7562                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7563                            tx_id: header.tx_id,
7564                        },
7565                    })
7566                }
7567                0x39acd05d832b5fed => {
7568                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7569                    let mut req = fidl::new_empty!(AudioRendererSetReferenceClockRequest, fdomain_client::fidl::FDomainResourceDialect);
7570                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererSetReferenceClockRequest>(&header, _body_bytes, handles, &mut req)?;
7571                    let control_handle = AudioRendererControlHandle {
7572                        inner: this.inner.clone(),
7573                    };
7574                    Ok(AudioRendererRequest::SetReferenceClock {reference_clock: req.reference_clock,
7575
7576                        control_handle,
7577                    })
7578                }
7579                0x3994bd23b55a733e => {
7580                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7581                    let mut req = fidl::new_empty!(AudioRendererSetUsageRequest, fdomain_client::fidl::FDomainResourceDialect);
7582                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererSetUsageRequest>(&header, _body_bytes, handles, &mut req)?;
7583                    let control_handle = AudioRendererControlHandle {
7584                        inner: this.inner.clone(),
7585                    };
7586                    Ok(AudioRendererRequest::SetUsage {usage: req.usage,
7587
7588                        control_handle,
7589                    })
7590                }
7591                0x2904035c7132b103 => {
7592                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7593                    let mut req = fidl::new_empty!(AudioRendererSetUsage2Request, fdomain_client::fidl::FDomainResourceDialect);
7594                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererSetUsage2Request>(&header, _body_bytes, handles, &mut req)?;
7595                    let control_handle = AudioRendererControlHandle {
7596                        inner: this.inner.clone(),
7597                    };
7598                    Ok(AudioRendererRequest::SetUsage2 {usage2: req.usage2,
7599
7600                        control_handle,
7601                    })
7602                }
7603                0x27aa715d8901fa19 => {
7604                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7605                    let mut req = fidl::new_empty!(AudioRendererSetPcmStreamTypeRequest, fdomain_client::fidl::FDomainResourceDialect);
7606                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererSetPcmStreamTypeRequest>(&header, _body_bytes, handles, &mut req)?;
7607                    let control_handle = AudioRendererControlHandle {
7608                        inner: this.inner.clone(),
7609                    };
7610                    Ok(AudioRendererRequest::SetPcmStreamType {type_: req.type_,
7611
7612                        control_handle,
7613                    })
7614                }
7615                0x62808dfad72bf890 => {
7616                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7617                    let mut req = fidl::new_empty!(AudioRendererEnableMinLeadTimeEventsRequest, fdomain_client::fidl::FDomainResourceDialect);
7618                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererEnableMinLeadTimeEventsRequest>(&header, _body_bytes, handles, &mut req)?;
7619                    let control_handle = AudioRendererControlHandle {
7620                        inner: this.inner.clone(),
7621                    };
7622                    Ok(AudioRendererRequest::EnableMinLeadTimeEvents {enabled: req.enabled,
7623
7624                        control_handle,
7625                    })
7626                }
7627                0x1cf3c3ecd8fec26b => {
7628                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7629                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7630                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7631                    let control_handle = AudioRendererControlHandle {
7632                        inner: this.inner.clone(),
7633                    };
7634                    Ok(AudioRendererRequest::GetMinLeadTime {
7635                        responder: AudioRendererGetMinLeadTimeResponder {
7636                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7637                            tx_id: header.tx_id,
7638                        },
7639                    })
7640                }
7641                0x3c0162db084f74a3 => {
7642                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7643                    let mut req = fidl::new_empty!(AudioRendererPlayRequest, fdomain_client::fidl::FDomainResourceDialect);
7644                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererPlayRequest>(&header, _body_bytes, handles, &mut req)?;
7645                    let control_handle = AudioRendererControlHandle {
7646                        inner: this.inner.clone(),
7647                    };
7648                    Ok(AudioRendererRequest::Play {reference_time: req.reference_time,
7649media_time: req.media_time,
7650
7651                        responder: AudioRendererPlayResponder {
7652                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7653                            tx_id: header.tx_id,
7654                        },
7655                    })
7656                }
7657                0x1b7fe832b68c22ef => {
7658                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7659                    let mut req = fidl::new_empty!(AudioRendererPlayNoReplyRequest, fdomain_client::fidl::FDomainResourceDialect);
7660                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererPlayNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
7661                    let control_handle = AudioRendererControlHandle {
7662                        inner: this.inner.clone(),
7663                    };
7664                    Ok(AudioRendererRequest::PlayNoReply {reference_time: req.reference_time,
7665media_time: req.media_time,
7666
7667                        control_handle,
7668                    })
7669                }
7670                0x41d557588d93d153 => {
7671                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7672                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7673                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7674                    let control_handle = AudioRendererControlHandle {
7675                        inner: this.inner.clone(),
7676                    };
7677                    Ok(AudioRendererRequest::Pause {
7678                        responder: AudioRendererPauseResponder {
7679                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7680                            tx_id: header.tx_id,
7681                        },
7682                    })
7683                }
7684                0x24cc45d4f3855ab => {
7685                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7686                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7687                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7688                    let control_handle = AudioRendererControlHandle {
7689                        inner: this.inner.clone(),
7690                    };
7691                    Ok(AudioRendererRequest::PauseNoReply {
7692                        control_handle,
7693                    })
7694                }
7695                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7696                    Ok(AudioRendererRequest::_UnknownMethod {
7697                        ordinal: header.ordinal,
7698                        control_handle: AudioRendererControlHandle { inner: this.inner.clone() },
7699                        method_type: fidl::MethodType::OneWay,
7700                    })
7701                }
7702                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7703                    this.inner.send_framework_err(
7704                        fidl::encoding::FrameworkErr::UnknownMethod,
7705                        header.tx_id,
7706                        header.ordinal,
7707                        header.dynamic_flags(),
7708                        (bytes, handles),
7709                    )?;
7710                    Ok(AudioRendererRequest::_UnknownMethod {
7711                        ordinal: header.ordinal,
7712                        control_handle: AudioRendererControlHandle { inner: this.inner.clone() },
7713                        method_type: fidl::MethodType::TwoWay,
7714                    })
7715                }
7716                _ => Err(fidl::Error::UnknownOrdinal {
7717                    ordinal: header.ordinal,
7718                    protocol_name: <AudioRendererMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
7719                }),
7720            }))
7721            },
7722        )
7723    }
7724}
7725
7726/// AudioRenderers can be in one of two states at any time: _configurable_ or _operational_. A
7727/// renderer is considered operational whenever it has packets queued to be rendered; otherwise it
7728/// is _configurable_. Once an AudioRenderer enters the operational state, calls to "configuring"
7729/// methods are disallowed and will cause the audio service to disconnect the client's connection.
7730/// The following are considered configuring methods: `AddPayloadBuffer`, `SetPcmStreamType`,
7731/// `SetStreamType`, `SetPtsUnits`, `SetPtsContinuityThreshold`.
7732///
7733/// If an AudioRenderer must be reconfigured, the client must ensure that no packets are still
7734/// enqueued when these "configuring" methods are called. Thus it is best practice to call
7735/// `DiscardAllPackets` on the AudioRenderer (and ideally `Stop` before `DiscardAllPackets`), prior
7736/// to reconfiguring the renderer.
7737#[derive(Debug)]
7738pub enum AudioRendererRequest {
7739    /// Adds a payload buffer to the current buffer set associated with the
7740    /// connection. A `StreamPacket` struct reference a payload buffer in the
7741    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
7742    ///
7743    /// A buffer with ID `id` must not be in the current set when this method is
7744    /// invoked, otherwise the service will close the connection.
7745    AddPayloadBuffer {
7746        id: u32,
7747        payload_buffer: fdomain_client::Vmo,
7748        control_handle: AudioRendererControlHandle,
7749    },
7750    /// Removes a payload buffer from the current buffer set associated with the
7751    /// connection.
7752    ///
7753    /// A buffer with ID `id` must exist in the current set when this method is
7754    /// invoked, otherwise the service will will close the connection.
7755    RemovePayloadBuffer {
7756        id: u32,
7757        control_handle: AudioRendererControlHandle,
7758    },
7759    /// Sends a packet to the service. The response is sent when the service is
7760    /// done with the associated payload memory.
7761    ///
7762    /// `packet` must be valid for the current buffer set, otherwise the service
7763    /// will close the connection.
7764    SendPacket {
7765        packet: StreamPacket,
7766        responder: AudioRendererSendPacketResponder,
7767    },
7768    /// Sends a packet to the service. This interface doesn't define how the
7769    /// client knows when the sink is done with the associated payload memory.
7770    /// The inheriting interface must define that.
7771    ///
7772    /// `packet` must be valid for the current buffer set, otherwise the service
7773    /// will close the connection.
7774    SendPacketNoReply {
7775        packet: StreamPacket,
7776        control_handle: AudioRendererControlHandle,
7777    },
7778    /// Indicates the stream has ended. The precise semantics of this method are
7779    /// determined by the inheriting interface.
7780    EndOfStream {
7781        control_handle: AudioRendererControlHandle,
7782    },
7783    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
7784    /// and not yet released. The response is sent after all packets have been
7785    /// released.
7786    DiscardAllPackets {
7787        responder: AudioRendererDiscardAllPacketsResponder,
7788    },
7789    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
7790    /// and not yet released.
7791    DiscardAllPacketsNoReply {
7792        control_handle: AudioRendererControlHandle,
7793    },
7794    /// Binds to the gain control for this AudioRenderer.
7795    BindGainControl {
7796        gain_control_request:
7797            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
7798        control_handle: AudioRendererControlHandle,
7799    },
7800    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
7801    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
7802    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
7803    SetPtsUnits {
7804        tick_per_second_numerator: u32,
7805        tick_per_second_denominator: u32,
7806        control_handle: AudioRendererControlHandle,
7807    },
7808    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
7809    /// and expected PTS (determined using interpolation). Beyond this threshold,
7810    /// a stream is no longer considered 'continuous' by the renderer.
7811    ///
7812    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
7813    /// Most users should not need to change this value from its default.
7814    ///
7815    /// Example:
7816    /// A user is playing back 48KHz audio from a container, which also contains
7817    /// video and needs to be synchronized with the audio. The timestamps are
7818    /// provided explicitly per packet by the container, and expressed in mSec
7819    /// units. This means that a single tick of the media timeline (1 mSec)
7820    /// represents exactly 48 frames of audio. The application in this scenario
7821    /// delivers packets of audio to the AudioRenderer, each with exactly 470
7822    /// frames of audio, and each with an explicit timestamp set to the best
7823    /// possible representation of the presentation time (given this media
7824    /// clock's resolution). So, starting from zero, the timestamps would be..
7825    ///
7826    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
7827    ///
7828    /// In this example, attempting to use the presentation time to compute the
7829    /// starting frame number of the audio in the packet would be wrong the
7830    /// majority of the time. The first timestamp is correct (by definition), but
7831    /// it will be 24 packets before the timestamps and frame numbers come back
7832    /// into alignment (the 24th packet would start with the 11280th audio frame
7833    /// and have a PTS of exactly 235).
7834    ///
7835    /// One way to fix this situation is to set the PTS continuity threshold
7836    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
7837    /// the number of frames contained within a single tick of the media clock,
7838    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
7839    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
7840    /// explicitly provided PTS would be considered to be a continuation of the
7841    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
7842    /// would work well.
7843    ///
7844    /// Other possible uses:
7845    /// Users who are scheduling audio explicitly, relative to a clock which has
7846    /// not been configured as the reference clock, can use this value to control
7847    /// the maximum acceptable synchronization error before a discontinuity is
7848    /// introduced. E.g., if a user is scheduling audio based on a recovered
7849    /// common media clock, and has not published that clock as the reference
7850    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
7851    /// can accumulate before the AudioRenderer deliberately inserts a
7852    /// presentation discontinuity to account for the error.
7853    ///
7854    /// Users whose need to deal with a container where their timestamps may be
7855    /// even less correct than +/- 1/2 of a PTS tick may set this value to
7856    /// something larger. This should be the maximum level of inaccuracy present
7857    /// in the container timestamps, if known. Failing that, it could be set to
7858    /// the maximum tolerable level of drift error before absolute timestamps are
7859    /// explicitly obeyed. Finally, a user could set this number to a very large
7860    /// value (86400.0 seconds, for example) to effectively cause *all*
7861    /// timestamps to be ignored after the first, thus treating all audio as
7862    /// continuous with previously delivered packets. Conversely, users who wish
7863    /// to *always* explicitly schedule their audio packets exactly may specify
7864    /// a CT of 0.
7865    ///
7866    /// Note: explicitly specifying high-frequency PTS units reduces the default
7867    /// continuity threshold accordingly. Internally, this threshold is stored as an
7868    /// integer of 1/8192 subframes. The default threshold is computed as follows:
7869    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
7870    /// For this reason, specifying PTS units with a frequency greater than 8192x
7871    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
7872    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
7873    SetPtsContinuityThreshold {
7874        threshold_seconds: f32,
7875        control_handle: AudioRendererControlHandle,
7876    },
7877    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
7878    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
7879    GetReferenceClock {
7880        responder: AudioRendererGetReferenceClockResponder,
7881    },
7882    /// Sets the reference clock that controls this renderer's playback rate. If the input
7883    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
7884    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
7885    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
7886    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
7887    ///
7888    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
7889    /// cannot be called a second time (even if the renderer format has not yet been set).
7890    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
7891    /// diverge at some later time, they should create a clone of the monotonic clock, set
7892    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
7893    SetReferenceClock {
7894        reference_clock: Option<fdomain_client::Clock>,
7895        control_handle: AudioRendererControlHandle,
7896    },
7897    /// Sets the usage of the render stream. This method may not be called after
7898    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
7899    SetUsage {
7900        usage: AudioRenderUsage,
7901        control_handle: AudioRendererControlHandle,
7902    },
7903    /// Sets the usage of the render stream. This method may not be called after
7904    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
7905    SetUsage2 {
7906        usage2: AudioRenderUsage2,
7907        control_handle: AudioRendererControlHandle,
7908    },
7909    /// Sets the type of the stream to be delivered by the client. Using this method implies
7910    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
7911    ///
7912    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
7913    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
7914    /// methods such as `SendPacket`/`SendPacketNoReply`.
7915    SetPcmStreamType {
7916        type_: AudioStreamType,
7917        control_handle: AudioRendererControlHandle,
7918    },
7919    /// Enables or disables notifications about changes to the minimum clock lead
7920    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
7921    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
7922    /// event with the current minimum lead time for the AudioRenderer. If the
7923    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
7924    /// new value. This behavior will continue until the user calls
7925    /// `EnableMinLeadTimeEvents(false)`.
7926    ///
7927    /// The minimum clock lead time is the amount of time ahead of the reference
7928    /// clock's understanding of "now" that packets needs to arrive (relative to
7929    /// the playback clock transformation) in order for the mixer to be able to
7930    /// mix packet. For example...
7931    ///
7932    /// + Let the PTS of packet X be P(X)
7933    /// + Let the function which transforms PTS -> RefClock be R(p) (this
7934    ///   function is determined by the call to Play(...)
7935    /// + Let the minimum lead time be MLT
7936    ///
7937    /// If R(P(X)) < RefClock.Now() + MLT
7938    /// Then the packet is late, and some (or all) of the packet's payload will
7939    /// need to be skipped in order to present the packet at the scheduled time.
7940    ///
7941    /// The value `min_lead_time_nsec = 0` is a special value which indicates
7942    /// that the AudioRenderer is not yet routed to an output device. If `Play`
7943    /// is called before the AudioRenderer is routed, any played packets will be
7944    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
7945    /// calling `Play`.
7946    EnableMinLeadTimeEvents {
7947        enabled: bool,
7948        control_handle: AudioRendererControlHandle,
7949    },
7950    ///
7951    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
7952    /// there's little reason to do so. This is because lead time is a function
7953    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
7954    /// If min lead time events are enabled before `SetPcmStreamType` (with
7955    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
7956    /// response to `SetPcmStreamType`.
7957    GetMinLeadTime {
7958        responder: AudioRendererGetMinLeadTimeResponder,
7959    },
7960    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
7961    /// of the media timeline, using specific values provided by the caller (or
7962    /// default values if not specified). In an optional callback, returns the
7963    /// timestamp values ultimately used -- these set the ongoing relationship
7964    /// between the media and reference timelines (i.e., how to translate between
7965    /// the domain of presentation timestamps, and the realm of local system
7966    /// time).
7967    ///
7968    /// Local system time is specified in units of nanoseconds; media_time is
7969    /// specified in the units defined by the user in the `SetPtsUnits` function,
7970    /// or nanoseconds if `SetPtsUnits` is not called.
7971    ///
7972    /// The act of placing an AudioRenderer into the playback state establishes a
7973    /// relationship between 1) the user-defined media (or presentation) timeline
7974    /// for this particular AudioRenderer, and 2) the real-world system reference
7975    /// timeline. To communicate how to translate between timelines, the Play()
7976    /// callback provides an equivalent timestamp in each time domain. The first
7977    /// value ('reference_time') is given in terms of this renderer's reference
7978    /// clock; the second value ('media_time') is what media instant exactly
7979    /// corresponds to that local time. Restated, the frame at 'media_time' in
7980    /// the audio stream should be presented at 'reference_time' according to
7981    /// the reference clock.
7982    ///
7983    /// Note: on calling this API, media_time immediately starts advancing. It is
7984    /// possible (if uncommon) for a caller to specify a system time that is
7985    /// far in the past, or far into the future. This, along with the specified
7986    /// media time, is simply used to determine what media time corresponds to
7987    /// 'now', and THAT media time is then intersected with presentation
7988    /// timestamps of packets already submitted, to determine which media frames
7989    /// should be presented next.
7990    ///
7991    /// With the corresponding reference_time and media_time values, a user can
7992    /// translate arbitrary time values from one timeline into the other. After
7993    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
7994    /// given the 'ref_start' and 'media_start' values from `Play`, then for
7995    /// any 'ref_time':
7996    ///
7997    /// media_time = ( (ref_time - ref_start) / 1e9
7998    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
7999    ///              + media_start
8000    ///
8001    /// Conversely, for any presentation timestamp 'media_time':
8002    ///
8003    /// ref_time = ( (media_time - media_start)
8004    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
8005    ///              * 1e9 )
8006    ///            + ref_start
8007    ///
8008    /// Users, depending on their use case, may optionally choose not to specify
8009    /// one or both of these timestamps. A timestamp may be omitted by supplying
8010    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
8011    /// any omitted timestamp value using the following rules:
8012    ///
8013    /// Reference Time
8014    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
8015    /// reference time to begin presentation, based on the minimum lead times for
8016    /// the output devices that are currently bound to this AudioRenderer. For
8017    /// example, if an AudioRenderer is bound to an internal audio output
8018    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
8019    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
8020    /// is omitted) select a reference time 80 mSec from now.
8021    ///
8022    /// Media Time
8023    /// If media_time is omitted, the AudioRenderer will select one of two
8024    /// values.
8025    /// - If the AudioRenderer is resuming from the paused state, and packets
8026    /// have not been discarded since being paused, then the AudioRenderer will
8027    /// use a media_time corresponding to the instant at which the presentation
8028    /// became paused.
8029    /// - If the AudioRenderer is being placed into a playing state for the first
8030    /// time following startup or a 'discard packets' operation, the initial
8031    /// media_time will be set to the PTS of the first payload in the pending
8032    /// packet queue. If the pending queue is empty, initial media_time will be
8033    /// set to zero.
8034    ///
8035    /// Return Value
8036    /// When requested, the AudioRenderer will return the 'reference_time' and
8037    /// 'media_time' which were selected and used (whether they were explicitly
8038    /// specified or not) in the return value of the play call.
8039    ///
8040    /// Examples
8041    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
8042    /// to start playing as soon as possible. The user may call Play without
8043    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
8044    ///
8045    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
8046    /// playback at a specified 'reference_time', in sync with some other media
8047    /// stream, either initially or after discarding packets. The user would call
8048    /// `Play(reference_time, NO_TIMESTAMP)`.
8049    ///
8050    /// 3. A user has queued some audio using `SendPacket`. The first of these
8051    /// packets has a PTS of zero, and the user wishes playback to begin as soon
8052    /// as possible, but wishes to skip all of the audio content between PTS 0
8053    /// and PTS 'media_time'. The user would call
8054    /// `Play(NO_TIMESTAMP, media_time)`.
8055    ///
8056    /// 4. A user has queued some audio using `SendPacket` and want to present
8057    /// this media in synch with another player in a different device. The
8058    /// coordinator of the group of distributed players sends an explicit
8059    /// message to each player telling them to begin presentation of audio at
8060    /// PTS 'media_time', at the time (based on the group's shared reference
8061    /// clock) 'reference_time'. Here the user would call
8062    /// `Play(reference_time, media_time)`.
8063    Play {
8064        reference_time: i64,
8065        media_time: i64,
8066        responder: AudioRendererPlayResponder,
8067    },
8068    PlayNoReply {
8069        reference_time: i64,
8070        media_time: i64,
8071        control_handle: AudioRendererControlHandle,
8072    },
8073    /// Immediately puts the AudioRenderer into the paused state and then report
8074    /// the relationship between the media and reference timelines which was
8075    /// established (if requested).
8076    ///
8077    /// If the AudioRenderer is already in the paused state when this called,
8078    /// the previously-established timeline values are returned (if requested).
8079    Pause {
8080        responder: AudioRendererPauseResponder,
8081    },
8082    PauseNoReply {
8083        control_handle: AudioRendererControlHandle,
8084    },
8085    /// An interaction was received which does not match any known method.
8086    #[non_exhaustive]
8087    _UnknownMethod {
8088        /// Ordinal of the method that was called.
8089        ordinal: u64,
8090        control_handle: AudioRendererControlHandle,
8091        method_type: fidl::MethodType,
8092    },
8093}
8094
8095impl AudioRendererRequest {
8096    #[allow(irrefutable_let_patterns)]
8097    pub fn into_add_payload_buffer(
8098        self,
8099    ) -> Option<(u32, fdomain_client::Vmo, AudioRendererControlHandle)> {
8100        if let AudioRendererRequest::AddPayloadBuffer { id, payload_buffer, control_handle } = self
8101        {
8102            Some((id, payload_buffer, control_handle))
8103        } else {
8104            None
8105        }
8106    }
8107
8108    #[allow(irrefutable_let_patterns)]
8109    pub fn into_remove_payload_buffer(self) -> Option<(u32, AudioRendererControlHandle)> {
8110        if let AudioRendererRequest::RemovePayloadBuffer { id, control_handle } = self {
8111            Some((id, control_handle))
8112        } else {
8113            None
8114        }
8115    }
8116
8117    #[allow(irrefutable_let_patterns)]
8118    pub fn into_send_packet(self) -> Option<(StreamPacket, AudioRendererSendPacketResponder)> {
8119        if let AudioRendererRequest::SendPacket { packet, responder } = self {
8120            Some((packet, responder))
8121        } else {
8122            None
8123        }
8124    }
8125
8126    #[allow(irrefutable_let_patterns)]
8127    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, AudioRendererControlHandle)> {
8128        if let AudioRendererRequest::SendPacketNoReply { packet, control_handle } = self {
8129            Some((packet, control_handle))
8130        } else {
8131            None
8132        }
8133    }
8134
8135    #[allow(irrefutable_let_patterns)]
8136    pub fn into_end_of_stream(self) -> Option<(AudioRendererControlHandle)> {
8137        if let AudioRendererRequest::EndOfStream { control_handle } = self {
8138            Some((control_handle))
8139        } else {
8140            None
8141        }
8142    }
8143
8144    #[allow(irrefutable_let_patterns)]
8145    pub fn into_discard_all_packets(self) -> Option<(AudioRendererDiscardAllPacketsResponder)> {
8146        if let AudioRendererRequest::DiscardAllPackets { responder } = self {
8147            Some((responder))
8148        } else {
8149            None
8150        }
8151    }
8152
8153    #[allow(irrefutable_let_patterns)]
8154    pub fn into_discard_all_packets_no_reply(self) -> Option<(AudioRendererControlHandle)> {
8155        if let AudioRendererRequest::DiscardAllPacketsNoReply { control_handle } = self {
8156            Some((control_handle))
8157        } else {
8158            None
8159        }
8160    }
8161
8162    #[allow(irrefutable_let_patterns)]
8163    pub fn into_bind_gain_control(
8164        self,
8165    ) -> Option<(
8166        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
8167        AudioRendererControlHandle,
8168    )> {
8169        if let AudioRendererRequest::BindGainControl { gain_control_request, control_handle } = self
8170        {
8171            Some((gain_control_request, control_handle))
8172        } else {
8173            None
8174        }
8175    }
8176
8177    #[allow(irrefutable_let_patterns)]
8178    pub fn into_set_pts_units(self) -> Option<(u32, u32, AudioRendererControlHandle)> {
8179        if let AudioRendererRequest::SetPtsUnits {
8180            tick_per_second_numerator,
8181            tick_per_second_denominator,
8182            control_handle,
8183        } = self
8184        {
8185            Some((tick_per_second_numerator, tick_per_second_denominator, control_handle))
8186        } else {
8187            None
8188        }
8189    }
8190
8191    #[allow(irrefutable_let_patterns)]
8192    pub fn into_set_pts_continuity_threshold(self) -> Option<(f32, AudioRendererControlHandle)> {
8193        if let AudioRendererRequest::SetPtsContinuityThreshold {
8194            threshold_seconds,
8195            control_handle,
8196        } = self
8197        {
8198            Some((threshold_seconds, control_handle))
8199        } else {
8200            None
8201        }
8202    }
8203
8204    #[allow(irrefutable_let_patterns)]
8205    pub fn into_get_reference_clock(self) -> Option<(AudioRendererGetReferenceClockResponder)> {
8206        if let AudioRendererRequest::GetReferenceClock { responder } = self {
8207            Some((responder))
8208        } else {
8209            None
8210        }
8211    }
8212
8213    #[allow(irrefutable_let_patterns)]
8214    pub fn into_set_reference_clock(
8215        self,
8216    ) -> Option<(Option<fdomain_client::Clock>, AudioRendererControlHandle)> {
8217        if let AudioRendererRequest::SetReferenceClock { reference_clock, control_handle } = self {
8218            Some((reference_clock, control_handle))
8219        } else {
8220            None
8221        }
8222    }
8223
8224    #[allow(irrefutable_let_patterns)]
8225    pub fn into_set_usage(self) -> Option<(AudioRenderUsage, AudioRendererControlHandle)> {
8226        if let AudioRendererRequest::SetUsage { usage, control_handle } = self {
8227            Some((usage, control_handle))
8228        } else {
8229            None
8230        }
8231    }
8232
8233    #[allow(irrefutable_let_patterns)]
8234    pub fn into_set_usage2(self) -> Option<(AudioRenderUsage2, AudioRendererControlHandle)> {
8235        if let AudioRendererRequest::SetUsage2 { usage2, control_handle } = self {
8236            Some((usage2, control_handle))
8237        } else {
8238            None
8239        }
8240    }
8241
8242    #[allow(irrefutable_let_patterns)]
8243    pub fn into_set_pcm_stream_type(self) -> Option<(AudioStreamType, AudioRendererControlHandle)> {
8244        if let AudioRendererRequest::SetPcmStreamType { type_, control_handle } = self {
8245            Some((type_, control_handle))
8246        } else {
8247            None
8248        }
8249    }
8250
8251    #[allow(irrefutable_let_patterns)]
8252    pub fn into_enable_min_lead_time_events(self) -> Option<(bool, AudioRendererControlHandle)> {
8253        if let AudioRendererRequest::EnableMinLeadTimeEvents { enabled, control_handle } = self {
8254            Some((enabled, control_handle))
8255        } else {
8256            None
8257        }
8258    }
8259
8260    #[allow(irrefutable_let_patterns)]
8261    pub fn into_get_min_lead_time(self) -> Option<(AudioRendererGetMinLeadTimeResponder)> {
8262        if let AudioRendererRequest::GetMinLeadTime { responder } = self {
8263            Some((responder))
8264        } else {
8265            None
8266        }
8267    }
8268
8269    #[allow(irrefutable_let_patterns)]
8270    pub fn into_play(self) -> Option<(i64, i64, AudioRendererPlayResponder)> {
8271        if let AudioRendererRequest::Play { reference_time, media_time, responder } = self {
8272            Some((reference_time, media_time, responder))
8273        } else {
8274            None
8275        }
8276    }
8277
8278    #[allow(irrefutable_let_patterns)]
8279    pub fn into_play_no_reply(self) -> Option<(i64, i64, AudioRendererControlHandle)> {
8280        if let AudioRendererRequest::PlayNoReply { reference_time, media_time, control_handle } =
8281            self
8282        {
8283            Some((reference_time, media_time, control_handle))
8284        } else {
8285            None
8286        }
8287    }
8288
8289    #[allow(irrefutable_let_patterns)]
8290    pub fn into_pause(self) -> Option<(AudioRendererPauseResponder)> {
8291        if let AudioRendererRequest::Pause { responder } = self { Some((responder)) } else { None }
8292    }
8293
8294    #[allow(irrefutable_let_patterns)]
8295    pub fn into_pause_no_reply(self) -> Option<(AudioRendererControlHandle)> {
8296        if let AudioRendererRequest::PauseNoReply { control_handle } = self {
8297            Some((control_handle))
8298        } else {
8299            None
8300        }
8301    }
8302
8303    /// Name of the method defined in FIDL
8304    pub fn method_name(&self) -> &'static str {
8305        match *self {
8306            AudioRendererRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
8307            AudioRendererRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
8308            AudioRendererRequest::SendPacket { .. } => "send_packet",
8309            AudioRendererRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
8310            AudioRendererRequest::EndOfStream { .. } => "end_of_stream",
8311            AudioRendererRequest::DiscardAllPackets { .. } => "discard_all_packets",
8312            AudioRendererRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
8313            AudioRendererRequest::BindGainControl { .. } => "bind_gain_control",
8314            AudioRendererRequest::SetPtsUnits { .. } => "set_pts_units",
8315            AudioRendererRequest::SetPtsContinuityThreshold { .. } => {
8316                "set_pts_continuity_threshold"
8317            }
8318            AudioRendererRequest::GetReferenceClock { .. } => "get_reference_clock",
8319            AudioRendererRequest::SetReferenceClock { .. } => "set_reference_clock",
8320            AudioRendererRequest::SetUsage { .. } => "set_usage",
8321            AudioRendererRequest::SetUsage2 { .. } => "set_usage2",
8322            AudioRendererRequest::SetPcmStreamType { .. } => "set_pcm_stream_type",
8323            AudioRendererRequest::EnableMinLeadTimeEvents { .. } => "enable_min_lead_time_events",
8324            AudioRendererRequest::GetMinLeadTime { .. } => "get_min_lead_time",
8325            AudioRendererRequest::Play { .. } => "play",
8326            AudioRendererRequest::PlayNoReply { .. } => "play_no_reply",
8327            AudioRendererRequest::Pause { .. } => "pause",
8328            AudioRendererRequest::PauseNoReply { .. } => "pause_no_reply",
8329            AudioRendererRequest::_UnknownMethod {
8330                method_type: fidl::MethodType::OneWay, ..
8331            } => "unknown one-way method",
8332            AudioRendererRequest::_UnknownMethod {
8333                method_type: fidl::MethodType::TwoWay, ..
8334            } => "unknown two-way method",
8335        }
8336    }
8337}
8338
8339#[derive(Debug, Clone)]
8340pub struct AudioRendererControlHandle {
8341    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
8342}
8343
8344impl fdomain_client::fidl::ControlHandle for AudioRendererControlHandle {
8345    fn shutdown(&self) {
8346        self.inner.shutdown()
8347    }
8348
8349    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8350        self.inner.shutdown_with_epitaph(status)
8351    }
8352
8353    fn is_closed(&self) -> bool {
8354        self.inner.channel().is_closed()
8355    }
8356    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
8357        self.inner.channel().on_closed()
8358    }
8359}
8360
8361impl AudioRendererControlHandle {
8362    pub fn send_on_min_lead_time_changed(
8363        &self,
8364        mut min_lead_time_nsec: i64,
8365    ) -> Result<(), fidl::Error> {
8366        self.inner.send::<AudioRendererOnMinLeadTimeChangedRequest>(
8367            (min_lead_time_nsec,),
8368            0,
8369            0x4feff7d278978c4e,
8370            fidl::encoding::DynamicFlags::empty(),
8371        )
8372    }
8373}
8374
8375#[must_use = "FIDL methods require a response to be sent"]
8376#[derive(Debug)]
8377pub struct AudioRendererSendPacketResponder {
8378    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
8379    tx_id: u32,
8380}
8381
8382/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
8383/// if the responder is dropped without sending a response, so that the client
8384/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8385impl std::ops::Drop for AudioRendererSendPacketResponder {
8386    fn drop(&mut self) {
8387        self.control_handle.shutdown();
8388        // Safety: drops once, never accessed again
8389        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8390    }
8391}
8392
8393impl fdomain_client::fidl::Responder for AudioRendererSendPacketResponder {
8394    type ControlHandle = AudioRendererControlHandle;
8395
8396    fn control_handle(&self) -> &AudioRendererControlHandle {
8397        &self.control_handle
8398    }
8399
8400    fn drop_without_shutdown(mut self) {
8401        // Safety: drops once, never accessed again due to mem::forget
8402        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8403        // Prevent Drop from running (which would shut down the channel)
8404        std::mem::forget(self);
8405    }
8406}
8407
8408impl AudioRendererSendPacketResponder {
8409    /// Sends a response to the FIDL transaction.
8410    ///
8411    /// Sets the channel to shutdown if an error occurs.
8412    pub fn send(self) -> Result<(), fidl::Error> {
8413        let _result = self.send_raw();
8414        if _result.is_err() {
8415            self.control_handle.shutdown();
8416        }
8417        self.drop_without_shutdown();
8418        _result
8419    }
8420
8421    /// Similar to "send" but does not shutdown the channel if an error occurs.
8422    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8423        let _result = self.send_raw();
8424        self.drop_without_shutdown();
8425        _result
8426    }
8427
8428    fn send_raw(&self) -> Result<(), fidl::Error> {
8429        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8430            (),
8431            self.tx_id,
8432            0x67cddd607442775f,
8433            fidl::encoding::DynamicFlags::empty(),
8434        )
8435    }
8436}
8437
8438#[must_use = "FIDL methods require a response to be sent"]
8439#[derive(Debug)]
8440pub struct AudioRendererDiscardAllPacketsResponder {
8441    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
8442    tx_id: u32,
8443}
8444
8445/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
8446/// if the responder is dropped without sending a response, so that the client
8447/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8448impl std::ops::Drop for AudioRendererDiscardAllPacketsResponder {
8449    fn drop(&mut self) {
8450        self.control_handle.shutdown();
8451        // Safety: drops once, never accessed again
8452        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8453    }
8454}
8455
8456impl fdomain_client::fidl::Responder for AudioRendererDiscardAllPacketsResponder {
8457    type ControlHandle = AudioRendererControlHandle;
8458
8459    fn control_handle(&self) -> &AudioRendererControlHandle {
8460        &self.control_handle
8461    }
8462
8463    fn drop_without_shutdown(mut self) {
8464        // Safety: drops once, never accessed again due to mem::forget
8465        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8466        // Prevent Drop from running (which would shut down the channel)
8467        std::mem::forget(self);
8468    }
8469}
8470
8471impl AudioRendererDiscardAllPacketsResponder {
8472    /// Sends a response to the FIDL transaction.
8473    ///
8474    /// Sets the channel to shutdown if an error occurs.
8475    pub fn send(self) -> Result<(), fidl::Error> {
8476        let _result = self.send_raw();
8477        if _result.is_err() {
8478            self.control_handle.shutdown();
8479        }
8480        self.drop_without_shutdown();
8481        _result
8482    }
8483
8484    /// Similar to "send" but does not shutdown the channel if an error occurs.
8485    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8486        let _result = self.send_raw();
8487        self.drop_without_shutdown();
8488        _result
8489    }
8490
8491    fn send_raw(&self) -> Result<(), fidl::Error> {
8492        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8493            (),
8494            self.tx_id,
8495            0x6f4dad7af2917665,
8496            fidl::encoding::DynamicFlags::empty(),
8497        )
8498    }
8499}
8500
8501#[must_use = "FIDL methods require a response to be sent"]
8502#[derive(Debug)]
8503pub struct AudioRendererGetReferenceClockResponder {
8504    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
8505    tx_id: u32,
8506}
8507
8508/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
8509/// if the responder is dropped without sending a response, so that the client
8510/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8511impl std::ops::Drop for AudioRendererGetReferenceClockResponder {
8512    fn drop(&mut self) {
8513        self.control_handle.shutdown();
8514        // Safety: drops once, never accessed again
8515        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8516    }
8517}
8518
8519impl fdomain_client::fidl::Responder for AudioRendererGetReferenceClockResponder {
8520    type ControlHandle = AudioRendererControlHandle;
8521
8522    fn control_handle(&self) -> &AudioRendererControlHandle {
8523        &self.control_handle
8524    }
8525
8526    fn drop_without_shutdown(mut self) {
8527        // Safety: drops once, never accessed again due to mem::forget
8528        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8529        // Prevent Drop from running (which would shut down the channel)
8530        std::mem::forget(self);
8531    }
8532}
8533
8534impl AudioRendererGetReferenceClockResponder {
8535    /// Sends a response to the FIDL transaction.
8536    ///
8537    /// Sets the channel to shutdown if an error occurs.
8538    pub fn send(self, mut reference_clock: fdomain_client::Clock) -> Result<(), fidl::Error> {
8539        let _result = self.send_raw(reference_clock);
8540        if _result.is_err() {
8541            self.control_handle.shutdown();
8542        }
8543        self.drop_without_shutdown();
8544        _result
8545    }
8546
8547    /// Similar to "send" but does not shutdown the channel if an error occurs.
8548    pub fn send_no_shutdown_on_err(
8549        self,
8550        mut reference_clock: fdomain_client::Clock,
8551    ) -> Result<(), fidl::Error> {
8552        let _result = self.send_raw(reference_clock);
8553        self.drop_without_shutdown();
8554        _result
8555    }
8556
8557    fn send_raw(&self, mut reference_clock: fdomain_client::Clock) -> Result<(), fidl::Error> {
8558        self.control_handle.inner.send::<AudioRendererGetReferenceClockResponse>(
8559            (reference_clock,),
8560            self.tx_id,
8561            0x2f7a7f011a172f7e,
8562            fidl::encoding::DynamicFlags::empty(),
8563        )
8564    }
8565}
8566
8567#[must_use = "FIDL methods require a response to be sent"]
8568#[derive(Debug)]
8569pub struct AudioRendererGetMinLeadTimeResponder {
8570    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
8571    tx_id: u32,
8572}
8573
8574/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
8575/// if the responder is dropped without sending a response, so that the client
8576/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8577impl std::ops::Drop for AudioRendererGetMinLeadTimeResponder {
8578    fn drop(&mut self) {
8579        self.control_handle.shutdown();
8580        // Safety: drops once, never accessed again
8581        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8582    }
8583}
8584
8585impl fdomain_client::fidl::Responder for AudioRendererGetMinLeadTimeResponder {
8586    type ControlHandle = AudioRendererControlHandle;
8587
8588    fn control_handle(&self) -> &AudioRendererControlHandle {
8589        &self.control_handle
8590    }
8591
8592    fn drop_without_shutdown(mut self) {
8593        // Safety: drops once, never accessed again due to mem::forget
8594        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8595        // Prevent Drop from running (which would shut down the channel)
8596        std::mem::forget(self);
8597    }
8598}
8599
8600impl AudioRendererGetMinLeadTimeResponder {
8601    /// Sends a response to the FIDL transaction.
8602    ///
8603    /// Sets the channel to shutdown if an error occurs.
8604    pub fn send(self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
8605        let _result = self.send_raw(min_lead_time_nsec);
8606        if _result.is_err() {
8607            self.control_handle.shutdown();
8608        }
8609        self.drop_without_shutdown();
8610        _result
8611    }
8612
8613    /// Similar to "send" but does not shutdown the channel if an error occurs.
8614    pub fn send_no_shutdown_on_err(self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
8615        let _result = self.send_raw(min_lead_time_nsec);
8616        self.drop_without_shutdown();
8617        _result
8618    }
8619
8620    fn send_raw(&self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
8621        self.control_handle.inner.send::<AudioRendererGetMinLeadTimeResponse>(
8622            (min_lead_time_nsec,),
8623            self.tx_id,
8624            0x1cf3c3ecd8fec26b,
8625            fidl::encoding::DynamicFlags::empty(),
8626        )
8627    }
8628}
8629
8630#[must_use = "FIDL methods require a response to be sent"]
8631#[derive(Debug)]
8632pub struct AudioRendererPlayResponder {
8633    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
8634    tx_id: u32,
8635}
8636
8637/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
8638/// if the responder is dropped without sending a response, so that the client
8639/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8640impl std::ops::Drop for AudioRendererPlayResponder {
8641    fn drop(&mut self) {
8642        self.control_handle.shutdown();
8643        // Safety: drops once, never accessed again
8644        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8645    }
8646}
8647
8648impl fdomain_client::fidl::Responder for AudioRendererPlayResponder {
8649    type ControlHandle = AudioRendererControlHandle;
8650
8651    fn control_handle(&self) -> &AudioRendererControlHandle {
8652        &self.control_handle
8653    }
8654
8655    fn drop_without_shutdown(mut self) {
8656        // Safety: drops once, never accessed again due to mem::forget
8657        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8658        // Prevent Drop from running (which would shut down the channel)
8659        std::mem::forget(self);
8660    }
8661}
8662
8663impl AudioRendererPlayResponder {
8664    /// Sends a response to the FIDL transaction.
8665    ///
8666    /// Sets the channel to shutdown if an error occurs.
8667    pub fn send(self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
8668        let _result = self.send_raw(reference_time, media_time);
8669        if _result.is_err() {
8670            self.control_handle.shutdown();
8671        }
8672        self.drop_without_shutdown();
8673        _result
8674    }
8675
8676    /// Similar to "send" but does not shutdown the channel if an error occurs.
8677    pub fn send_no_shutdown_on_err(
8678        self,
8679        mut reference_time: i64,
8680        mut media_time: i64,
8681    ) -> Result<(), fidl::Error> {
8682        let _result = self.send_raw(reference_time, media_time);
8683        self.drop_without_shutdown();
8684        _result
8685    }
8686
8687    fn send_raw(&self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
8688        self.control_handle.inner.send::<AudioRendererPlayResponse>(
8689            (reference_time, media_time),
8690            self.tx_id,
8691            0x3c0162db084f74a3,
8692            fidl::encoding::DynamicFlags::empty(),
8693        )
8694    }
8695}
8696
8697#[must_use = "FIDL methods require a response to be sent"]
8698#[derive(Debug)]
8699pub struct AudioRendererPauseResponder {
8700    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
8701    tx_id: u32,
8702}
8703
8704/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
8705/// if the responder is dropped without sending a response, so that the client
8706/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8707impl std::ops::Drop for AudioRendererPauseResponder {
8708    fn drop(&mut self) {
8709        self.control_handle.shutdown();
8710        // Safety: drops once, never accessed again
8711        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8712    }
8713}
8714
8715impl fdomain_client::fidl::Responder for AudioRendererPauseResponder {
8716    type ControlHandle = AudioRendererControlHandle;
8717
8718    fn control_handle(&self) -> &AudioRendererControlHandle {
8719        &self.control_handle
8720    }
8721
8722    fn drop_without_shutdown(mut self) {
8723        // Safety: drops once, never accessed again due to mem::forget
8724        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8725        // Prevent Drop from running (which would shut down the channel)
8726        std::mem::forget(self);
8727    }
8728}
8729
8730impl AudioRendererPauseResponder {
8731    /// Sends a response to the FIDL transaction.
8732    ///
8733    /// Sets the channel to shutdown if an error occurs.
8734    pub fn send(self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
8735        let _result = self.send_raw(reference_time, media_time);
8736        if _result.is_err() {
8737            self.control_handle.shutdown();
8738        }
8739        self.drop_without_shutdown();
8740        _result
8741    }
8742
8743    /// Similar to "send" but does not shutdown the channel if an error occurs.
8744    pub fn send_no_shutdown_on_err(
8745        self,
8746        mut reference_time: i64,
8747        mut media_time: i64,
8748    ) -> Result<(), fidl::Error> {
8749        let _result = self.send_raw(reference_time, media_time);
8750        self.drop_without_shutdown();
8751        _result
8752    }
8753
8754    fn send_raw(&self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
8755        self.control_handle.inner.send::<AudioRendererPauseResponse>(
8756            (reference_time, media_time),
8757            self.tx_id,
8758            0x41d557588d93d153,
8759            fidl::encoding::DynamicFlags::empty(),
8760        )
8761    }
8762}
8763
8764#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8765pub struct ProfileProviderMarker;
8766
8767impl fdomain_client::fidl::ProtocolMarker for ProfileProviderMarker {
8768    type Proxy = ProfileProviderProxy;
8769    type RequestStream = ProfileProviderRequestStream;
8770
8771    const DEBUG_NAME: &'static str = "fuchsia.media.ProfileProvider";
8772}
8773impl fdomain_client::fidl::DiscoverableProtocolMarker for ProfileProviderMarker {}
8774
8775pub trait ProfileProviderProxyInterface: Send + Sync {
8776    type RegisterHandlerWithCapacityResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>>
8777        + Send;
8778    fn r#register_handler_with_capacity(
8779        &self,
8780        thread_handle: fdomain_client::Thread,
8781        name: &str,
8782        period: i64,
8783        capacity: f32,
8784    ) -> Self::RegisterHandlerWithCapacityResponseFut;
8785    type UnregisterHandlerResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8786    fn r#unregister_handler(
8787        &self,
8788        thread_handle: fdomain_client::Thread,
8789        name: &str,
8790    ) -> Self::UnregisterHandlerResponseFut;
8791    type RegisterMemoryRangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
8792        + Send;
8793    fn r#register_memory_range(
8794        &self,
8795        vmar_handle: fdomain_client::Vmar,
8796        name: &str,
8797    ) -> Self::RegisterMemoryRangeResponseFut;
8798    type UnregisterMemoryRangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
8799        + Send;
8800    fn r#unregister_memory_range(
8801        &self,
8802        vmar_handle: fdomain_client::Vmar,
8803    ) -> Self::UnregisterMemoryRangeResponseFut;
8804}
8805
8806#[derive(Debug, Clone)]
8807pub struct ProfileProviderProxy {
8808    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
8809}
8810
8811impl fdomain_client::fidl::Proxy for ProfileProviderProxy {
8812    type Protocol = ProfileProviderMarker;
8813
8814    fn from_channel(inner: fdomain_client::Channel) -> Self {
8815        Self::new(inner)
8816    }
8817
8818    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
8819        self.client.into_channel().map_err(|client| Self { client })
8820    }
8821
8822    fn as_channel(&self) -> &fdomain_client::Channel {
8823        self.client.as_channel()
8824    }
8825}
8826
8827impl ProfileProviderProxy {
8828    /// Create a new Proxy for fuchsia.media/ProfileProvider.
8829    pub fn new(channel: fdomain_client::Channel) -> Self {
8830        let protocol_name =
8831            <ProfileProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
8832        Self { client: fidl::client::Client::new(channel, protocol_name) }
8833    }
8834
8835    /// Get a Stream of events from the remote end of the protocol.
8836    ///
8837    /// # Panics
8838    ///
8839    /// Panics if the event stream was already taken.
8840    pub fn take_event_stream(&self) -> ProfileProviderEventStream {
8841        ProfileProviderEventStream { event_receiver: self.client.take_event_receiver() }
8842    }
8843
8844    /// Register a thread as a media thread. This notifies the media subsystem that this thread
8845    /// should have an elevated scheduling profile applied to it in order to meet audio or video
8846    /// deadlines.
8847    ///
8848    /// `name` is the name of a system scheduling role to apply to the thread given by
8849    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
8850    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
8851    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
8852    /// the scheduling interval the thread needs to be running to achieve good performance or to
8853    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
8854    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
8855    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
8856    /// be rejected or result in scaling back the performance of other threads to fit resource
8857    /// limits.
8858    ///
8859    /// Capacity, max runtime, and period have the following relationship:
8860    ///
8861    ///   capacity = max runtime / period
8862    ///
8863    /// Where:
8864    ///
8865    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
8866    ///
8867    /// For heterogeneous systems, the capacity should be planned / measured against the highest
8868    /// performance processor(s) in the system. The system will automatically adjust the effective
8869    /// capacity to account for slower processors and operating points and will avoid processors and
8870    /// operating points that are too slow to meet the requested scheduling parameters (provided
8871    /// they are reasonable).
8872    ///
8873    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
8874    /// may be zero to indicate not applicable.
8875    pub fn r#register_handler_with_capacity(
8876        &self,
8877        mut thread_handle: fdomain_client::Thread,
8878        mut name: &str,
8879        mut period: i64,
8880        mut capacity: f32,
8881    ) -> fidl::client::QueryResponseFut<(i64, i64), fdomain_client::fidl::FDomainResourceDialect>
8882    {
8883        ProfileProviderProxyInterface::r#register_handler_with_capacity(
8884            self,
8885            thread_handle,
8886            name,
8887            period,
8888            capacity,
8889        )
8890    }
8891
8892    /// Reset a thread's scheduling profile to the default.
8893    pub fn r#unregister_handler(
8894        &self,
8895        mut thread_handle: fdomain_client::Thread,
8896        mut name: &str,
8897    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
8898        ProfileProviderProxyInterface::r#unregister_handler(self, thread_handle, name)
8899    }
8900
8901    /// Register a memory range as being used for media processing. This notifies the media
8902    /// subsystem that this memory should have an elevated memory profile applied to it in order to
8903    /// meet audio or video deadlines.
8904    ///
8905    /// `name` is the name of a system memory role to apply to the memory given by
8906    /// `vmar_handle` -- different products may customize the underlying memory strategy based
8907    /// on the requested role.
8908    pub fn r#register_memory_range(
8909        &self,
8910        mut vmar_handle: fdomain_client::Vmar,
8911        mut name: &str,
8912    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
8913        ProfileProviderProxyInterface::r#register_memory_range(self, vmar_handle, name)
8914    }
8915
8916    /// Reset a memory range's memory profile.
8917    pub fn r#unregister_memory_range(
8918        &self,
8919        mut vmar_handle: fdomain_client::Vmar,
8920    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
8921        ProfileProviderProxyInterface::r#unregister_memory_range(self, vmar_handle)
8922    }
8923}
8924
8925impl ProfileProviderProxyInterface for ProfileProviderProxy {
8926    type RegisterHandlerWithCapacityResponseFut =
8927        fidl::client::QueryResponseFut<(i64, i64), fdomain_client::fidl::FDomainResourceDialect>;
8928    fn r#register_handler_with_capacity(
8929        &self,
8930        mut thread_handle: fdomain_client::Thread,
8931        mut name: &str,
8932        mut period: i64,
8933        mut capacity: f32,
8934    ) -> Self::RegisterHandlerWithCapacityResponseFut {
8935        fn _decode(
8936            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8937        ) -> Result<(i64, i64), fidl::Error> {
8938            let _response = fidl::client::decode_transaction_body::<
8939                ProfileProviderRegisterHandlerWithCapacityResponse,
8940                fdomain_client::fidl::FDomainResourceDialect,
8941                0x60459ecef7458176,
8942            >(_buf?)?;
8943            Ok((_response.period, _response.capacity))
8944        }
8945        self.client
8946            .send_query_and_decode::<ProfileProviderRegisterHandlerWithCapacityRequest, (i64, i64)>(
8947                (thread_handle, name, period, capacity),
8948                0x60459ecef7458176,
8949                fidl::encoding::DynamicFlags::empty(),
8950                _decode,
8951            )
8952    }
8953
8954    type UnregisterHandlerResponseFut =
8955        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
8956    fn r#unregister_handler(
8957        &self,
8958        mut thread_handle: fdomain_client::Thread,
8959        mut name: &str,
8960    ) -> Self::UnregisterHandlerResponseFut {
8961        fn _decode(
8962            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8963        ) -> Result<(), fidl::Error> {
8964            let _response = fidl::client::decode_transaction_body::<
8965                fidl::encoding::EmptyPayload,
8966                fdomain_client::fidl::FDomainResourceDialect,
8967                0x724d9d5fd8ef544c,
8968            >(_buf?)?;
8969            Ok(_response)
8970        }
8971        self.client.send_query_and_decode::<ProfileProviderUnregisterHandlerRequest, ()>(
8972            (thread_handle, name),
8973            0x724d9d5fd8ef544c,
8974            fidl::encoding::DynamicFlags::empty(),
8975            _decode,
8976        )
8977    }
8978
8979    type RegisterMemoryRangeResponseFut =
8980        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
8981    fn r#register_memory_range(
8982        &self,
8983        mut vmar_handle: fdomain_client::Vmar,
8984        mut name: &str,
8985    ) -> Self::RegisterMemoryRangeResponseFut {
8986        fn _decode(
8987            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8988        ) -> Result<(), fidl::Error> {
8989            let _response = fidl::client::decode_transaction_body::<
8990                fidl::encoding::EmptyPayload,
8991                fdomain_client::fidl::FDomainResourceDialect,
8992                0x2f509d3523e9562d,
8993            >(_buf?)?;
8994            Ok(_response)
8995        }
8996        self.client.send_query_and_decode::<ProfileProviderRegisterMemoryRangeRequest, ()>(
8997            (vmar_handle, name),
8998            0x2f509d3523e9562d,
8999            fidl::encoding::DynamicFlags::empty(),
9000            _decode,
9001        )
9002    }
9003
9004    type UnregisterMemoryRangeResponseFut =
9005        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
9006    fn r#unregister_memory_range(
9007        &self,
9008        mut vmar_handle: fdomain_client::Vmar,
9009    ) -> Self::UnregisterMemoryRangeResponseFut {
9010        fn _decode(
9011            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9012        ) -> Result<(), fidl::Error> {
9013            let _response = fidl::client::decode_transaction_body::<
9014                fidl::encoding::EmptyPayload,
9015                fdomain_client::fidl::FDomainResourceDialect,
9016                0x2dc313d6aa81ad27,
9017            >(_buf?)?;
9018            Ok(_response)
9019        }
9020        self.client.send_query_and_decode::<ProfileProviderUnregisterMemoryRangeRequest, ()>(
9021            (vmar_handle,),
9022            0x2dc313d6aa81ad27,
9023            fidl::encoding::DynamicFlags::empty(),
9024            _decode,
9025        )
9026    }
9027}
9028
9029pub struct ProfileProviderEventStream {
9030    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
9031}
9032
9033impl std::marker::Unpin for ProfileProviderEventStream {}
9034
9035impl futures::stream::FusedStream for ProfileProviderEventStream {
9036    fn is_terminated(&self) -> bool {
9037        self.event_receiver.is_terminated()
9038    }
9039}
9040
9041impl futures::Stream for ProfileProviderEventStream {
9042    type Item = Result<ProfileProviderEvent, fidl::Error>;
9043
9044    fn poll_next(
9045        mut self: std::pin::Pin<&mut Self>,
9046        cx: &mut std::task::Context<'_>,
9047    ) -> std::task::Poll<Option<Self::Item>> {
9048        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9049            &mut self.event_receiver,
9050            cx
9051        )?) {
9052            Some(buf) => std::task::Poll::Ready(Some(ProfileProviderEvent::decode(buf))),
9053            None => std::task::Poll::Ready(None),
9054        }
9055    }
9056}
9057
9058#[derive(Debug)]
9059pub enum ProfileProviderEvent {}
9060
9061impl ProfileProviderEvent {
9062    /// Decodes a message buffer as a [`ProfileProviderEvent`].
9063    fn decode(
9064        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9065    ) -> Result<ProfileProviderEvent, fidl::Error> {
9066        let (bytes, _handles) = buf.split_mut();
9067        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9068        debug_assert_eq!(tx_header.tx_id, 0);
9069        match tx_header.ordinal {
9070            _ => Err(fidl::Error::UnknownOrdinal {
9071                ordinal: tx_header.ordinal,
9072                protocol_name:
9073                    <ProfileProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
9074            }),
9075        }
9076    }
9077}
9078
9079/// A Stream of incoming requests for fuchsia.media/ProfileProvider.
9080pub struct ProfileProviderRequestStream {
9081    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
9082    is_terminated: bool,
9083}
9084
9085impl std::marker::Unpin for ProfileProviderRequestStream {}
9086
9087impl futures::stream::FusedStream for ProfileProviderRequestStream {
9088    fn is_terminated(&self) -> bool {
9089        self.is_terminated
9090    }
9091}
9092
9093impl fdomain_client::fidl::RequestStream for ProfileProviderRequestStream {
9094    type Protocol = ProfileProviderMarker;
9095    type ControlHandle = ProfileProviderControlHandle;
9096
9097    fn from_channel(channel: fdomain_client::Channel) -> Self {
9098        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9099    }
9100
9101    fn control_handle(&self) -> Self::ControlHandle {
9102        ProfileProviderControlHandle { inner: self.inner.clone() }
9103    }
9104
9105    fn into_inner(
9106        self,
9107    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
9108    {
9109        (self.inner, self.is_terminated)
9110    }
9111
9112    fn from_inner(
9113        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
9114        is_terminated: bool,
9115    ) -> Self {
9116        Self { inner, is_terminated }
9117    }
9118}
9119
9120impl futures::Stream for ProfileProviderRequestStream {
9121    type Item = Result<ProfileProviderRequest, fidl::Error>;
9122
9123    fn poll_next(
9124        mut self: std::pin::Pin<&mut Self>,
9125        cx: &mut std::task::Context<'_>,
9126    ) -> std::task::Poll<Option<Self::Item>> {
9127        let this = &mut *self;
9128        if this.inner.check_shutdown(cx) {
9129            this.is_terminated = true;
9130            return std::task::Poll::Ready(None);
9131        }
9132        if this.is_terminated {
9133            panic!("polled ProfileProviderRequestStream after completion");
9134        }
9135        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
9136            |bytes, handles| {
9137                match this.inner.channel().read_etc(cx, bytes, handles) {
9138                    std::task::Poll::Ready(Ok(())) => {}
9139                    std::task::Poll::Pending => return std::task::Poll::Pending,
9140                    std::task::Poll::Ready(Err(None)) => {
9141                        this.is_terminated = true;
9142                        return std::task::Poll::Ready(None);
9143                    }
9144                    std::task::Poll::Ready(Err(Some(e))) => {
9145                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9146                            e.into(),
9147                        ))));
9148                    }
9149                }
9150
9151                // A message has been received from the channel
9152                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9153
9154                std::task::Poll::Ready(Some(match header.ordinal {
9155                0x60459ecef7458176 => {
9156                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9157                    let mut req = fidl::new_empty!(ProfileProviderRegisterHandlerWithCapacityRequest, fdomain_client::fidl::FDomainResourceDialect);
9158                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProfileProviderRegisterHandlerWithCapacityRequest>(&header, _body_bytes, handles, &mut req)?;
9159                    let control_handle = ProfileProviderControlHandle {
9160                        inner: this.inner.clone(),
9161                    };
9162                    Ok(ProfileProviderRequest::RegisterHandlerWithCapacity {thread_handle: req.thread_handle,
9163name: req.name,
9164period: req.period,
9165capacity: req.capacity,
9166
9167                        responder: ProfileProviderRegisterHandlerWithCapacityResponder {
9168                            control_handle: std::mem::ManuallyDrop::new(control_handle),
9169                            tx_id: header.tx_id,
9170                        },
9171                    })
9172                }
9173                0x724d9d5fd8ef544c => {
9174                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9175                    let mut req = fidl::new_empty!(ProfileProviderUnregisterHandlerRequest, fdomain_client::fidl::FDomainResourceDialect);
9176                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProfileProviderUnregisterHandlerRequest>(&header, _body_bytes, handles, &mut req)?;
9177                    let control_handle = ProfileProviderControlHandle {
9178                        inner: this.inner.clone(),
9179                    };
9180                    Ok(ProfileProviderRequest::UnregisterHandler {thread_handle: req.thread_handle,
9181name: req.name,
9182
9183                        responder: ProfileProviderUnregisterHandlerResponder {
9184                            control_handle: std::mem::ManuallyDrop::new(control_handle),
9185                            tx_id: header.tx_id,
9186                        },
9187                    })
9188                }
9189                0x2f509d3523e9562d => {
9190                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9191                    let mut req = fidl::new_empty!(ProfileProviderRegisterMemoryRangeRequest, fdomain_client::fidl::FDomainResourceDialect);
9192                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProfileProviderRegisterMemoryRangeRequest>(&header, _body_bytes, handles, &mut req)?;
9193                    let control_handle = ProfileProviderControlHandle {
9194                        inner: this.inner.clone(),
9195                    };
9196                    Ok(ProfileProviderRequest::RegisterMemoryRange {vmar_handle: req.vmar_handle,
9197name: req.name,
9198
9199                        responder: ProfileProviderRegisterMemoryRangeResponder {
9200                            control_handle: std::mem::ManuallyDrop::new(control_handle),
9201                            tx_id: header.tx_id,
9202                        },
9203                    })
9204                }
9205                0x2dc313d6aa81ad27 => {
9206                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9207                    let mut req = fidl::new_empty!(ProfileProviderUnregisterMemoryRangeRequest, fdomain_client::fidl::FDomainResourceDialect);
9208                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProfileProviderUnregisterMemoryRangeRequest>(&header, _body_bytes, handles, &mut req)?;
9209                    let control_handle = ProfileProviderControlHandle {
9210                        inner: this.inner.clone(),
9211                    };
9212                    Ok(ProfileProviderRequest::UnregisterMemoryRange {vmar_handle: req.vmar_handle,
9213
9214                        responder: ProfileProviderUnregisterMemoryRangeResponder {
9215                            control_handle: std::mem::ManuallyDrop::new(control_handle),
9216                            tx_id: header.tx_id,
9217                        },
9218                    })
9219                }
9220                _ => Err(fidl::Error::UnknownOrdinal {
9221                    ordinal: header.ordinal,
9222                    protocol_name: <ProfileProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
9223                }),
9224            }))
9225            },
9226        )
9227    }
9228}
9229
9230#[derive(Debug)]
9231pub enum ProfileProviderRequest {
9232    /// Register a thread as a media thread. This notifies the media subsystem that this thread
9233    /// should have an elevated scheduling profile applied to it in order to meet audio or video
9234    /// deadlines.
9235    ///
9236    /// `name` is the name of a system scheduling role to apply to the thread given by
9237    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
9238    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
9239    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
9240    /// the scheduling interval the thread needs to be running to achieve good performance or to
9241    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
9242    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
9243    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
9244    /// be rejected or result in scaling back the performance of other threads to fit resource
9245    /// limits.
9246    ///
9247    /// Capacity, max runtime, and period have the following relationship:
9248    ///
9249    ///   capacity = max runtime / period
9250    ///
9251    /// Where:
9252    ///
9253    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
9254    ///
9255    /// For heterogeneous systems, the capacity should be planned / measured against the highest
9256    /// performance processor(s) in the system. The system will automatically adjust the effective
9257    /// capacity to account for slower processors and operating points and will avoid processors and
9258    /// operating points that are too slow to meet the requested scheduling parameters (provided
9259    /// they are reasonable).
9260    ///
9261    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
9262    /// may be zero to indicate not applicable.
9263    RegisterHandlerWithCapacity {
9264        thread_handle: fdomain_client::Thread,
9265        name: String,
9266        period: i64,
9267        capacity: f32,
9268        responder: ProfileProviderRegisterHandlerWithCapacityResponder,
9269    },
9270    /// Reset a thread's scheduling profile to the default.
9271    UnregisterHandler {
9272        thread_handle: fdomain_client::Thread,
9273        name: String,
9274        responder: ProfileProviderUnregisterHandlerResponder,
9275    },
9276    /// Register a memory range as being used for media processing. This notifies the media
9277    /// subsystem that this memory should have an elevated memory profile applied to it in order to
9278    /// meet audio or video deadlines.
9279    ///
9280    /// `name` is the name of a system memory role to apply to the memory given by
9281    /// `vmar_handle` -- different products may customize the underlying memory strategy based
9282    /// on the requested role.
9283    RegisterMemoryRange {
9284        vmar_handle: fdomain_client::Vmar,
9285        name: String,
9286        responder: ProfileProviderRegisterMemoryRangeResponder,
9287    },
9288    /// Reset a memory range's memory profile.
9289    UnregisterMemoryRange {
9290        vmar_handle: fdomain_client::Vmar,
9291        responder: ProfileProviderUnregisterMemoryRangeResponder,
9292    },
9293}
9294
9295impl ProfileProviderRequest {
9296    #[allow(irrefutable_let_patterns)]
9297    pub fn into_register_handler_with_capacity(
9298        self,
9299    ) -> Option<(
9300        fdomain_client::Thread,
9301        String,
9302        i64,
9303        f32,
9304        ProfileProviderRegisterHandlerWithCapacityResponder,
9305    )> {
9306        if let ProfileProviderRequest::RegisterHandlerWithCapacity {
9307            thread_handle,
9308            name,
9309            period,
9310            capacity,
9311            responder,
9312        } = self
9313        {
9314            Some((thread_handle, name, period, capacity, responder))
9315        } else {
9316            None
9317        }
9318    }
9319
9320    #[allow(irrefutable_let_patterns)]
9321    pub fn into_unregister_handler(
9322        self,
9323    ) -> Option<(fdomain_client::Thread, String, ProfileProviderUnregisterHandlerResponder)> {
9324        if let ProfileProviderRequest::UnregisterHandler { thread_handle, name, responder } = self {
9325            Some((thread_handle, name, responder))
9326        } else {
9327            None
9328        }
9329    }
9330
9331    #[allow(irrefutable_let_patterns)]
9332    pub fn into_register_memory_range(
9333        self,
9334    ) -> Option<(fdomain_client::Vmar, String, ProfileProviderRegisterMemoryRangeResponder)> {
9335        if let ProfileProviderRequest::RegisterMemoryRange { vmar_handle, name, responder } = self {
9336            Some((vmar_handle, name, responder))
9337        } else {
9338            None
9339        }
9340    }
9341
9342    #[allow(irrefutable_let_patterns)]
9343    pub fn into_unregister_memory_range(
9344        self,
9345    ) -> Option<(fdomain_client::Vmar, ProfileProviderUnregisterMemoryRangeResponder)> {
9346        if let ProfileProviderRequest::UnregisterMemoryRange { vmar_handle, responder } = self {
9347            Some((vmar_handle, responder))
9348        } else {
9349            None
9350        }
9351    }
9352
9353    /// Name of the method defined in FIDL
9354    pub fn method_name(&self) -> &'static str {
9355        match *self {
9356            ProfileProviderRequest::RegisterHandlerWithCapacity { .. } => {
9357                "register_handler_with_capacity"
9358            }
9359            ProfileProviderRequest::UnregisterHandler { .. } => "unregister_handler",
9360            ProfileProviderRequest::RegisterMemoryRange { .. } => "register_memory_range",
9361            ProfileProviderRequest::UnregisterMemoryRange { .. } => "unregister_memory_range",
9362        }
9363    }
9364}
9365
9366#[derive(Debug, Clone)]
9367pub struct ProfileProviderControlHandle {
9368    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
9369}
9370
9371impl fdomain_client::fidl::ControlHandle for ProfileProviderControlHandle {
9372    fn shutdown(&self) {
9373        self.inner.shutdown()
9374    }
9375
9376    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
9377        self.inner.shutdown_with_epitaph(status)
9378    }
9379
9380    fn is_closed(&self) -> bool {
9381        self.inner.channel().is_closed()
9382    }
9383    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
9384        self.inner.channel().on_closed()
9385    }
9386}
9387
9388impl ProfileProviderControlHandle {}
9389
9390#[must_use = "FIDL methods require a response to be sent"]
9391#[derive(Debug)]
9392pub struct ProfileProviderRegisterHandlerWithCapacityResponder {
9393    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
9394    tx_id: u32,
9395}
9396
9397/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
9398/// if the responder is dropped without sending a response, so that the client
9399/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9400impl std::ops::Drop for ProfileProviderRegisterHandlerWithCapacityResponder {
9401    fn drop(&mut self) {
9402        self.control_handle.shutdown();
9403        // Safety: drops once, never accessed again
9404        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9405    }
9406}
9407
9408impl fdomain_client::fidl::Responder for ProfileProviderRegisterHandlerWithCapacityResponder {
9409    type ControlHandle = ProfileProviderControlHandle;
9410
9411    fn control_handle(&self) -> &ProfileProviderControlHandle {
9412        &self.control_handle
9413    }
9414
9415    fn drop_without_shutdown(mut self) {
9416        // Safety: drops once, never accessed again due to mem::forget
9417        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9418        // Prevent Drop from running (which would shut down the channel)
9419        std::mem::forget(self);
9420    }
9421}
9422
9423impl ProfileProviderRegisterHandlerWithCapacityResponder {
9424    /// Sends a response to the FIDL transaction.
9425    ///
9426    /// Sets the channel to shutdown if an error occurs.
9427    pub fn send(self, mut period: i64, mut capacity: i64) -> Result<(), fidl::Error> {
9428        let _result = self.send_raw(period, capacity);
9429        if _result.is_err() {
9430            self.control_handle.shutdown();
9431        }
9432        self.drop_without_shutdown();
9433        _result
9434    }
9435
9436    /// Similar to "send" but does not shutdown the channel if an error occurs.
9437    pub fn send_no_shutdown_on_err(
9438        self,
9439        mut period: i64,
9440        mut capacity: i64,
9441    ) -> Result<(), fidl::Error> {
9442        let _result = self.send_raw(period, capacity);
9443        self.drop_without_shutdown();
9444        _result
9445    }
9446
9447    fn send_raw(&self, mut period: i64, mut capacity: i64) -> Result<(), fidl::Error> {
9448        self.control_handle.inner.send::<ProfileProviderRegisterHandlerWithCapacityResponse>(
9449            (period, capacity),
9450            self.tx_id,
9451            0x60459ecef7458176,
9452            fidl::encoding::DynamicFlags::empty(),
9453        )
9454    }
9455}
9456
9457#[must_use = "FIDL methods require a response to be sent"]
9458#[derive(Debug)]
9459pub struct ProfileProviderUnregisterHandlerResponder {
9460    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
9461    tx_id: u32,
9462}
9463
9464/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
9465/// if the responder is dropped without sending a response, so that the client
9466/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9467impl std::ops::Drop for ProfileProviderUnregisterHandlerResponder {
9468    fn drop(&mut self) {
9469        self.control_handle.shutdown();
9470        // Safety: drops once, never accessed again
9471        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9472    }
9473}
9474
9475impl fdomain_client::fidl::Responder for ProfileProviderUnregisterHandlerResponder {
9476    type ControlHandle = ProfileProviderControlHandle;
9477
9478    fn control_handle(&self) -> &ProfileProviderControlHandle {
9479        &self.control_handle
9480    }
9481
9482    fn drop_without_shutdown(mut self) {
9483        // Safety: drops once, never accessed again due to mem::forget
9484        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9485        // Prevent Drop from running (which would shut down the channel)
9486        std::mem::forget(self);
9487    }
9488}
9489
9490impl ProfileProviderUnregisterHandlerResponder {
9491    /// Sends a response to the FIDL transaction.
9492    ///
9493    /// Sets the channel to shutdown if an error occurs.
9494    pub fn send(self) -> Result<(), fidl::Error> {
9495        let _result = self.send_raw();
9496        if _result.is_err() {
9497            self.control_handle.shutdown();
9498        }
9499        self.drop_without_shutdown();
9500        _result
9501    }
9502
9503    /// Similar to "send" but does not shutdown the channel if an error occurs.
9504    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9505        let _result = self.send_raw();
9506        self.drop_without_shutdown();
9507        _result
9508    }
9509
9510    fn send_raw(&self) -> Result<(), fidl::Error> {
9511        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9512            (),
9513            self.tx_id,
9514            0x724d9d5fd8ef544c,
9515            fidl::encoding::DynamicFlags::empty(),
9516        )
9517    }
9518}
9519
9520#[must_use = "FIDL methods require a response to be sent"]
9521#[derive(Debug)]
9522pub struct ProfileProviderRegisterMemoryRangeResponder {
9523    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
9524    tx_id: u32,
9525}
9526
9527/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
9528/// if the responder is dropped without sending a response, so that the client
9529/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9530impl std::ops::Drop for ProfileProviderRegisterMemoryRangeResponder {
9531    fn drop(&mut self) {
9532        self.control_handle.shutdown();
9533        // Safety: drops once, never accessed again
9534        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9535    }
9536}
9537
9538impl fdomain_client::fidl::Responder for ProfileProviderRegisterMemoryRangeResponder {
9539    type ControlHandle = ProfileProviderControlHandle;
9540
9541    fn control_handle(&self) -> &ProfileProviderControlHandle {
9542        &self.control_handle
9543    }
9544
9545    fn drop_without_shutdown(mut self) {
9546        // Safety: drops once, never accessed again due to mem::forget
9547        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9548        // Prevent Drop from running (which would shut down the channel)
9549        std::mem::forget(self);
9550    }
9551}
9552
9553impl ProfileProviderRegisterMemoryRangeResponder {
9554    /// Sends a response to the FIDL transaction.
9555    ///
9556    /// Sets the channel to shutdown if an error occurs.
9557    pub fn send(self) -> Result<(), fidl::Error> {
9558        let _result = self.send_raw();
9559        if _result.is_err() {
9560            self.control_handle.shutdown();
9561        }
9562        self.drop_without_shutdown();
9563        _result
9564    }
9565
9566    /// Similar to "send" but does not shutdown the channel if an error occurs.
9567    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9568        let _result = self.send_raw();
9569        self.drop_without_shutdown();
9570        _result
9571    }
9572
9573    fn send_raw(&self) -> Result<(), fidl::Error> {
9574        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9575            (),
9576            self.tx_id,
9577            0x2f509d3523e9562d,
9578            fidl::encoding::DynamicFlags::empty(),
9579        )
9580    }
9581}
9582
9583#[must_use = "FIDL methods require a response to be sent"]
9584#[derive(Debug)]
9585pub struct ProfileProviderUnregisterMemoryRangeResponder {
9586    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
9587    tx_id: u32,
9588}
9589
9590/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
9591/// if the responder is dropped without sending a response, so that the client
9592/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9593impl std::ops::Drop for ProfileProviderUnregisterMemoryRangeResponder {
9594    fn drop(&mut self) {
9595        self.control_handle.shutdown();
9596        // Safety: drops once, never accessed again
9597        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9598    }
9599}
9600
9601impl fdomain_client::fidl::Responder for ProfileProviderUnregisterMemoryRangeResponder {
9602    type ControlHandle = ProfileProviderControlHandle;
9603
9604    fn control_handle(&self) -> &ProfileProviderControlHandle {
9605        &self.control_handle
9606    }
9607
9608    fn drop_without_shutdown(mut self) {
9609        // Safety: drops once, never accessed again due to mem::forget
9610        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9611        // Prevent Drop from running (which would shut down the channel)
9612        std::mem::forget(self);
9613    }
9614}
9615
9616impl ProfileProviderUnregisterMemoryRangeResponder {
9617    /// Sends a response to the FIDL transaction.
9618    ///
9619    /// Sets the channel to shutdown if an error occurs.
9620    pub fn send(self) -> Result<(), fidl::Error> {
9621        let _result = self.send_raw();
9622        if _result.is_err() {
9623            self.control_handle.shutdown();
9624        }
9625        self.drop_without_shutdown();
9626        _result
9627    }
9628
9629    /// Similar to "send" but does not shutdown the channel if an error occurs.
9630    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9631        let _result = self.send_raw();
9632        self.drop_without_shutdown();
9633        _result
9634    }
9635
9636    fn send_raw(&self) -> Result<(), fidl::Error> {
9637        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9638            (),
9639            self.tx_id,
9640            0x2dc313d6aa81ad27,
9641            fidl::encoding::DynamicFlags::empty(),
9642        )
9643    }
9644}
9645
9646#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
9647pub struct SessionAudioConsumerFactoryMarker;
9648
9649impl fdomain_client::fidl::ProtocolMarker for SessionAudioConsumerFactoryMarker {
9650    type Proxy = SessionAudioConsumerFactoryProxy;
9651    type RequestStream = SessionAudioConsumerFactoryRequestStream;
9652
9653    const DEBUG_NAME: &'static str = "fuchsia.media.SessionAudioConsumerFactory";
9654}
9655impl fdomain_client::fidl::DiscoverableProtocolMarker for SessionAudioConsumerFactoryMarker {}
9656
9657pub trait SessionAudioConsumerFactoryProxyInterface: Send + Sync {
9658    fn r#create_audio_consumer(
9659        &self,
9660        session_id: u64,
9661        audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
9662    ) -> Result<(), fidl::Error>;
9663}
9664
9665#[derive(Debug, Clone)]
9666pub struct SessionAudioConsumerFactoryProxy {
9667    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
9668}
9669
9670impl fdomain_client::fidl::Proxy for SessionAudioConsumerFactoryProxy {
9671    type Protocol = SessionAudioConsumerFactoryMarker;
9672
9673    fn from_channel(inner: fdomain_client::Channel) -> Self {
9674        Self::new(inner)
9675    }
9676
9677    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
9678        self.client.into_channel().map_err(|client| Self { client })
9679    }
9680
9681    fn as_channel(&self) -> &fdomain_client::Channel {
9682        self.client.as_channel()
9683    }
9684}
9685
9686impl SessionAudioConsumerFactoryProxy {
9687    /// Create a new Proxy for fuchsia.media/SessionAudioConsumerFactory.
9688    pub fn new(channel: fdomain_client::Channel) -> Self {
9689        let protocol_name =
9690            <SessionAudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
9691        Self { client: fidl::client::Client::new(channel, protocol_name) }
9692    }
9693
9694    /// Get a Stream of events from the remote end of the protocol.
9695    ///
9696    /// # Panics
9697    ///
9698    /// Panics if the event stream was already taken.
9699    pub fn take_event_stream(&self) -> SessionAudioConsumerFactoryEventStream {
9700        SessionAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
9701    }
9702
9703    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
9704    /// to a particular session. `session_id` is the identifier of the media session
9705    /// for which audio is to be rendered.
9706    pub fn r#create_audio_consumer(
9707        &self,
9708        mut session_id: u64,
9709        mut audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
9710    ) -> Result<(), fidl::Error> {
9711        SessionAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
9712            self,
9713            session_id,
9714            audio_consumer_request,
9715        )
9716    }
9717}
9718
9719impl SessionAudioConsumerFactoryProxyInterface for SessionAudioConsumerFactoryProxy {
9720    fn r#create_audio_consumer(
9721        &self,
9722        mut session_id: u64,
9723        mut audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
9724    ) -> Result<(), fidl::Error> {
9725        self.client.send::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
9726            (session_id, audio_consumer_request),
9727            0x6fab96f988e7d7fb,
9728            fidl::encoding::DynamicFlags::empty(),
9729        )
9730    }
9731}
9732
9733pub struct SessionAudioConsumerFactoryEventStream {
9734    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
9735}
9736
9737impl std::marker::Unpin for SessionAudioConsumerFactoryEventStream {}
9738
9739impl futures::stream::FusedStream for SessionAudioConsumerFactoryEventStream {
9740    fn is_terminated(&self) -> bool {
9741        self.event_receiver.is_terminated()
9742    }
9743}
9744
9745impl futures::Stream for SessionAudioConsumerFactoryEventStream {
9746    type Item = Result<SessionAudioConsumerFactoryEvent, fidl::Error>;
9747
9748    fn poll_next(
9749        mut self: std::pin::Pin<&mut Self>,
9750        cx: &mut std::task::Context<'_>,
9751    ) -> std::task::Poll<Option<Self::Item>> {
9752        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9753            &mut self.event_receiver,
9754            cx
9755        )?) {
9756            Some(buf) => {
9757                std::task::Poll::Ready(Some(SessionAudioConsumerFactoryEvent::decode(buf)))
9758            }
9759            None => std::task::Poll::Ready(None),
9760        }
9761    }
9762}
9763
9764#[derive(Debug)]
9765pub enum SessionAudioConsumerFactoryEvent {}
9766
9767impl SessionAudioConsumerFactoryEvent {
9768    /// Decodes a message buffer as a [`SessionAudioConsumerFactoryEvent`].
9769    fn decode(
9770        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9771    ) -> Result<SessionAudioConsumerFactoryEvent, fidl::Error> {
9772        let (bytes, _handles) = buf.split_mut();
9773        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9774        debug_assert_eq!(tx_header.tx_id, 0);
9775        match tx_header.ordinal {
9776            _ => Err(fidl::Error::UnknownOrdinal {
9777                ordinal: tx_header.ordinal,
9778                protocol_name: <SessionAudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
9779            })
9780        }
9781    }
9782}
9783
9784/// A Stream of incoming requests for fuchsia.media/SessionAudioConsumerFactory.
9785pub struct SessionAudioConsumerFactoryRequestStream {
9786    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
9787    is_terminated: bool,
9788}
9789
9790impl std::marker::Unpin for SessionAudioConsumerFactoryRequestStream {}
9791
9792impl futures::stream::FusedStream for SessionAudioConsumerFactoryRequestStream {
9793    fn is_terminated(&self) -> bool {
9794        self.is_terminated
9795    }
9796}
9797
9798impl fdomain_client::fidl::RequestStream for SessionAudioConsumerFactoryRequestStream {
9799    type Protocol = SessionAudioConsumerFactoryMarker;
9800    type ControlHandle = SessionAudioConsumerFactoryControlHandle;
9801
9802    fn from_channel(channel: fdomain_client::Channel) -> Self {
9803        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9804    }
9805
9806    fn control_handle(&self) -> Self::ControlHandle {
9807        SessionAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
9808    }
9809
9810    fn into_inner(
9811        self,
9812    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
9813    {
9814        (self.inner, self.is_terminated)
9815    }
9816
9817    fn from_inner(
9818        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
9819        is_terminated: bool,
9820    ) -> Self {
9821        Self { inner, is_terminated }
9822    }
9823}
9824
9825impl futures::Stream for SessionAudioConsumerFactoryRequestStream {
9826    type Item = Result<SessionAudioConsumerFactoryRequest, fidl::Error>;
9827
9828    fn poll_next(
9829        mut self: std::pin::Pin<&mut Self>,
9830        cx: &mut std::task::Context<'_>,
9831    ) -> std::task::Poll<Option<Self::Item>> {
9832        let this = &mut *self;
9833        if this.inner.check_shutdown(cx) {
9834            this.is_terminated = true;
9835            return std::task::Poll::Ready(None);
9836        }
9837        if this.is_terminated {
9838            panic!("polled SessionAudioConsumerFactoryRequestStream after completion");
9839        }
9840        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
9841            |bytes, handles| {
9842                match this.inner.channel().read_etc(cx, bytes, handles) {
9843                    std::task::Poll::Ready(Ok(())) => {}
9844                    std::task::Poll::Pending => return std::task::Poll::Pending,
9845                    std::task::Poll::Ready(Err(None)) => {
9846                        this.is_terminated = true;
9847                        return std::task::Poll::Ready(None);
9848                    }
9849                    std::task::Poll::Ready(Err(Some(e))) => {
9850                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9851                            e.into(),
9852                        ))));
9853                    }
9854                }
9855
9856                // A message has been received from the channel
9857                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9858
9859                std::task::Poll::Ready(Some(match header.ordinal {
9860                0x6fab96f988e7d7fb => {
9861                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9862                    let mut req = fidl::new_empty!(SessionAudioConsumerFactoryCreateAudioConsumerRequest, fdomain_client::fidl::FDomainResourceDialect);
9863                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
9864                    let control_handle = SessionAudioConsumerFactoryControlHandle {
9865                        inner: this.inner.clone(),
9866                    };
9867                    Ok(SessionAudioConsumerFactoryRequest::CreateAudioConsumer {session_id: req.session_id,
9868audio_consumer_request: req.audio_consumer_request,
9869
9870                        control_handle,
9871                    })
9872                }
9873                _ => Err(fidl::Error::UnknownOrdinal {
9874                    ordinal: header.ordinal,
9875                    protocol_name: <SessionAudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
9876                }),
9877            }))
9878            },
9879        )
9880    }
9881}
9882
9883/// Interface for creating audio consumers bound to a session.
9884#[derive(Debug)]
9885pub enum SessionAudioConsumerFactoryRequest {
9886    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
9887    /// to a particular session. `session_id` is the identifier of the media session
9888    /// for which audio is to be rendered.
9889    CreateAudioConsumer {
9890        session_id: u64,
9891        audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
9892        control_handle: SessionAudioConsumerFactoryControlHandle,
9893    },
9894}
9895
9896impl SessionAudioConsumerFactoryRequest {
9897    #[allow(irrefutable_let_patterns)]
9898    pub fn into_create_audio_consumer(
9899        self,
9900    ) -> Option<(
9901        u64,
9902        fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
9903        SessionAudioConsumerFactoryControlHandle,
9904    )> {
9905        if let SessionAudioConsumerFactoryRequest::CreateAudioConsumer {
9906            session_id,
9907            audio_consumer_request,
9908            control_handle,
9909        } = self
9910        {
9911            Some((session_id, audio_consumer_request, control_handle))
9912        } else {
9913            None
9914        }
9915    }
9916
9917    /// Name of the method defined in FIDL
9918    pub fn method_name(&self) -> &'static str {
9919        match *self {
9920            SessionAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
9921                "create_audio_consumer"
9922            }
9923        }
9924    }
9925}
9926
9927#[derive(Debug, Clone)]
9928pub struct SessionAudioConsumerFactoryControlHandle {
9929    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
9930}
9931
9932impl fdomain_client::fidl::ControlHandle for SessionAudioConsumerFactoryControlHandle {
9933    fn shutdown(&self) {
9934        self.inner.shutdown()
9935    }
9936
9937    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
9938        self.inner.shutdown_with_epitaph(status)
9939    }
9940
9941    fn is_closed(&self) -> bool {
9942        self.inner.channel().is_closed()
9943    }
9944    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
9945        self.inner.channel().on_closed()
9946    }
9947}
9948
9949impl SessionAudioConsumerFactoryControlHandle {}
9950
9951#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
9952pub struct SimpleStreamSinkMarker;
9953
9954impl fdomain_client::fidl::ProtocolMarker for SimpleStreamSinkMarker {
9955    type Proxy = SimpleStreamSinkProxy;
9956    type RequestStream = SimpleStreamSinkRequestStream;
9957
9958    const DEBUG_NAME: &'static str = "(anonymous) SimpleStreamSink";
9959}
9960
9961pub trait SimpleStreamSinkProxyInterface: Send + Sync {
9962    fn r#add_payload_buffer(
9963        &self,
9964        id: u32,
9965        payload_buffer: fdomain_client::Vmo,
9966    ) -> Result<(), fidl::Error>;
9967    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
9968    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
9969    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
9970    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
9971    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
9972    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
9973    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
9974    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
9975}
9976
9977#[derive(Debug, Clone)]
9978pub struct SimpleStreamSinkProxy {
9979    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
9980}
9981
9982impl fdomain_client::fidl::Proxy for SimpleStreamSinkProxy {
9983    type Protocol = SimpleStreamSinkMarker;
9984
9985    fn from_channel(inner: fdomain_client::Channel) -> Self {
9986        Self::new(inner)
9987    }
9988
9989    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
9990        self.client.into_channel().map_err(|client| Self { client })
9991    }
9992
9993    fn as_channel(&self) -> &fdomain_client::Channel {
9994        self.client.as_channel()
9995    }
9996}
9997
9998impl SimpleStreamSinkProxy {
9999    /// Create a new Proxy for fuchsia.media/SimpleStreamSink.
10000    pub fn new(channel: fdomain_client::Channel) -> Self {
10001        let protocol_name =
10002            <SimpleStreamSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
10003        Self { client: fidl::client::Client::new(channel, protocol_name) }
10004    }
10005
10006    /// Get a Stream of events from the remote end of the protocol.
10007    ///
10008    /// # Panics
10009    ///
10010    /// Panics if the event stream was already taken.
10011    pub fn take_event_stream(&self) -> SimpleStreamSinkEventStream {
10012        SimpleStreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
10013    }
10014
10015    /// Adds a payload buffer to the current buffer set associated with the
10016    /// connection. A `StreamPacket` struct reference a payload buffer in the
10017    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
10018    ///
10019    /// A buffer with ID `id` must not be in the current set when this method is
10020    /// invoked, otherwise the service will close the connection.
10021    pub fn r#add_payload_buffer(
10022        &self,
10023        mut id: u32,
10024        mut payload_buffer: fdomain_client::Vmo,
10025    ) -> Result<(), fidl::Error> {
10026        SimpleStreamSinkProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
10027    }
10028
10029    /// Removes a payload buffer from the current buffer set associated with the
10030    /// connection.
10031    ///
10032    /// A buffer with ID `id` must exist in the current set when this method is
10033    /// invoked, otherwise the service will will close the connection.
10034    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
10035        SimpleStreamSinkProxyInterface::r#remove_payload_buffer(self, id)
10036    }
10037
10038    /// Sends a packet to the service. The response is sent when the service is
10039    /// done with the associated payload memory.
10040    ///
10041    /// `packet` must be valid for the current buffer set, otherwise the service
10042    /// will close the connection.
10043    pub fn r#send_packet(
10044        &self,
10045        mut packet: &StreamPacket,
10046    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
10047        SimpleStreamSinkProxyInterface::r#send_packet(self, packet)
10048    }
10049
10050    /// Sends a packet to the service. This interface doesn't define how the
10051    /// client knows when the sink is done with the associated payload memory.
10052    /// The inheriting interface must define that.
10053    ///
10054    /// `packet` must be valid for the current buffer set, otherwise the service
10055    /// will close the connection.
10056    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
10057        SimpleStreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
10058    }
10059
10060    /// Indicates the stream has ended. The precise semantics of this method are
10061    /// determined by the inheriting interface.
10062    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
10063        SimpleStreamSinkProxyInterface::r#end_of_stream(self)
10064    }
10065
10066    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
10067    /// and not yet released. The response is sent after all packets have been
10068    /// released.
10069    pub fn r#discard_all_packets(
10070        &self,
10071    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
10072        SimpleStreamSinkProxyInterface::r#discard_all_packets(self)
10073    }
10074
10075    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
10076    /// and not yet released.
10077    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
10078        SimpleStreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
10079    }
10080}
10081
10082impl SimpleStreamSinkProxyInterface for SimpleStreamSinkProxy {
10083    fn r#add_payload_buffer(
10084        &self,
10085        mut id: u32,
10086        mut payload_buffer: fdomain_client::Vmo,
10087    ) -> Result<(), fidl::Error> {
10088        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
10089            (id, payload_buffer),
10090            0x3b3a37fc34fe5b56,
10091            fidl::encoding::DynamicFlags::empty(),
10092        )
10093    }
10094
10095    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
10096        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
10097            (id,),
10098            0x5d1e4f74c3658262,
10099            fidl::encoding::DynamicFlags::empty(),
10100        )
10101    }
10102
10103    type SendPacketResponseFut =
10104        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
10105    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
10106        fn _decode(
10107            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10108        ) -> Result<(), fidl::Error> {
10109            let _response = fidl::client::decode_transaction_body::<
10110                fidl::encoding::EmptyPayload,
10111                fdomain_client::fidl::FDomainResourceDialect,
10112                0x67cddd607442775f,
10113            >(_buf?)?;
10114            Ok(_response)
10115        }
10116        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
10117            (packet,),
10118            0x67cddd607442775f,
10119            fidl::encoding::DynamicFlags::empty(),
10120            _decode,
10121        )
10122    }
10123
10124    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
10125        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
10126            (packet,),
10127            0x8d9b8b413ceba9d,
10128            fidl::encoding::DynamicFlags::empty(),
10129        )
10130    }
10131
10132    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
10133        self.client.send::<fidl::encoding::EmptyPayload>(
10134            (),
10135            0x6180fd6f7e793b71,
10136            fidl::encoding::DynamicFlags::empty(),
10137        )
10138    }
10139
10140    type DiscardAllPacketsResponseFut =
10141        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
10142    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
10143        fn _decode(
10144            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10145        ) -> Result<(), fidl::Error> {
10146            let _response = fidl::client::decode_transaction_body::<
10147                fidl::encoding::EmptyPayload,
10148                fdomain_client::fidl::FDomainResourceDialect,
10149                0x6f4dad7af2917665,
10150            >(_buf?)?;
10151            Ok(_response)
10152        }
10153        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
10154            (),
10155            0x6f4dad7af2917665,
10156            fidl::encoding::DynamicFlags::empty(),
10157            _decode,
10158        )
10159    }
10160
10161    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
10162        self.client.send::<fidl::encoding::EmptyPayload>(
10163            (),
10164            0x50d36d0d23081bc4,
10165            fidl::encoding::DynamicFlags::empty(),
10166        )
10167    }
10168}
10169
10170pub struct SimpleStreamSinkEventStream {
10171    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
10172}
10173
10174impl std::marker::Unpin for SimpleStreamSinkEventStream {}
10175
10176impl futures::stream::FusedStream for SimpleStreamSinkEventStream {
10177    fn is_terminated(&self) -> bool {
10178        self.event_receiver.is_terminated()
10179    }
10180}
10181
10182impl futures::Stream for SimpleStreamSinkEventStream {
10183    type Item = Result<SimpleStreamSinkEvent, fidl::Error>;
10184
10185    fn poll_next(
10186        mut self: std::pin::Pin<&mut Self>,
10187        cx: &mut std::task::Context<'_>,
10188    ) -> std::task::Poll<Option<Self::Item>> {
10189        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
10190            &mut self.event_receiver,
10191            cx
10192        )?) {
10193            Some(buf) => std::task::Poll::Ready(Some(SimpleStreamSinkEvent::decode(buf))),
10194            None => std::task::Poll::Ready(None),
10195        }
10196    }
10197}
10198
10199#[derive(Debug)]
10200pub enum SimpleStreamSinkEvent {}
10201
10202impl SimpleStreamSinkEvent {
10203    /// Decodes a message buffer as a [`SimpleStreamSinkEvent`].
10204    fn decode(
10205        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
10206    ) -> Result<SimpleStreamSinkEvent, fidl::Error> {
10207        let (bytes, _handles) = buf.split_mut();
10208        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10209        debug_assert_eq!(tx_header.tx_id, 0);
10210        match tx_header.ordinal {
10211            _ => Err(fidl::Error::UnknownOrdinal {
10212                ordinal: tx_header.ordinal,
10213                protocol_name:
10214                    <SimpleStreamSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
10215            }),
10216        }
10217    }
10218}
10219
10220/// A Stream of incoming requests for fuchsia.media/SimpleStreamSink.
10221pub struct SimpleStreamSinkRequestStream {
10222    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10223    is_terminated: bool,
10224}
10225
10226impl std::marker::Unpin for SimpleStreamSinkRequestStream {}
10227
10228impl futures::stream::FusedStream for SimpleStreamSinkRequestStream {
10229    fn is_terminated(&self) -> bool {
10230        self.is_terminated
10231    }
10232}
10233
10234impl fdomain_client::fidl::RequestStream for SimpleStreamSinkRequestStream {
10235    type Protocol = SimpleStreamSinkMarker;
10236    type ControlHandle = SimpleStreamSinkControlHandle;
10237
10238    fn from_channel(channel: fdomain_client::Channel) -> Self {
10239        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
10240    }
10241
10242    fn control_handle(&self) -> Self::ControlHandle {
10243        SimpleStreamSinkControlHandle { inner: self.inner.clone() }
10244    }
10245
10246    fn into_inner(
10247        self,
10248    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
10249    {
10250        (self.inner, self.is_terminated)
10251    }
10252
10253    fn from_inner(
10254        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10255        is_terminated: bool,
10256    ) -> Self {
10257        Self { inner, is_terminated }
10258    }
10259}
10260
10261impl futures::Stream for SimpleStreamSinkRequestStream {
10262    type Item = Result<SimpleStreamSinkRequest, fidl::Error>;
10263
10264    fn poll_next(
10265        mut self: std::pin::Pin<&mut Self>,
10266        cx: &mut std::task::Context<'_>,
10267    ) -> std::task::Poll<Option<Self::Item>> {
10268        let this = &mut *self;
10269        if this.inner.check_shutdown(cx) {
10270            this.is_terminated = true;
10271            return std::task::Poll::Ready(None);
10272        }
10273        if this.is_terminated {
10274            panic!("polled SimpleStreamSinkRequestStream after completion");
10275        }
10276        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
10277            |bytes, handles| {
10278                match this.inner.channel().read_etc(cx, bytes, handles) {
10279                    std::task::Poll::Ready(Ok(())) => {}
10280                    std::task::Poll::Pending => return std::task::Poll::Pending,
10281                    std::task::Poll::Ready(Err(None)) => {
10282                        this.is_terminated = true;
10283                        return std::task::Poll::Ready(None);
10284                    }
10285                    std::task::Poll::Ready(Err(Some(e))) => {
10286                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
10287                            e.into(),
10288                        ))));
10289                    }
10290                }
10291
10292                // A message has been received from the channel
10293                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10294
10295                std::task::Poll::Ready(Some(match header.ordinal {
10296                0x3b3a37fc34fe5b56 => {
10297                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10298                    let mut req = fidl::new_empty!(StreamBufferSetAddPayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
10299                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
10300                    let control_handle = SimpleStreamSinkControlHandle {
10301                        inner: this.inner.clone(),
10302                    };
10303                    Ok(SimpleStreamSinkRequest::AddPayloadBuffer {id: req.id,
10304payload_buffer: req.payload_buffer,
10305
10306                        control_handle,
10307                    })
10308                }
10309                0x5d1e4f74c3658262 => {
10310                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10311                    let mut req = fidl::new_empty!(StreamBufferSetRemovePayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
10312                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
10313                    let control_handle = SimpleStreamSinkControlHandle {
10314                        inner: this.inner.clone(),
10315                    };
10316                    Ok(SimpleStreamSinkRequest::RemovePayloadBuffer {id: req.id,
10317
10318                        control_handle,
10319                    })
10320                }
10321                0x67cddd607442775f => {
10322                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10323                    let mut req = fidl::new_empty!(StreamSinkSendPacketRequest, fdomain_client::fidl::FDomainResourceDialect);
10324                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
10325                    let control_handle = SimpleStreamSinkControlHandle {
10326                        inner: this.inner.clone(),
10327                    };
10328                    Ok(SimpleStreamSinkRequest::SendPacket {packet: req.packet,
10329
10330                        responder: SimpleStreamSinkSendPacketResponder {
10331                            control_handle: std::mem::ManuallyDrop::new(control_handle),
10332                            tx_id: header.tx_id,
10333                        },
10334                    })
10335                }
10336                0x8d9b8b413ceba9d => {
10337                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10338                    let mut req = fidl::new_empty!(StreamSinkSendPacketNoReplyRequest, fdomain_client::fidl::FDomainResourceDialect);
10339                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
10340                    let control_handle = SimpleStreamSinkControlHandle {
10341                        inner: this.inner.clone(),
10342                    };
10343                    Ok(SimpleStreamSinkRequest::SendPacketNoReply {packet: req.packet,
10344
10345                        control_handle,
10346                    })
10347                }
10348                0x6180fd6f7e793b71 => {
10349                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10350                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
10351                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10352                    let control_handle = SimpleStreamSinkControlHandle {
10353                        inner: this.inner.clone(),
10354                    };
10355                    Ok(SimpleStreamSinkRequest::EndOfStream {
10356                        control_handle,
10357                    })
10358                }
10359                0x6f4dad7af2917665 => {
10360                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10361                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
10362                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10363                    let control_handle = SimpleStreamSinkControlHandle {
10364                        inner: this.inner.clone(),
10365                    };
10366                    Ok(SimpleStreamSinkRequest::DiscardAllPackets {
10367                        responder: SimpleStreamSinkDiscardAllPacketsResponder {
10368                            control_handle: std::mem::ManuallyDrop::new(control_handle),
10369                            tx_id: header.tx_id,
10370                        },
10371                    })
10372                }
10373                0x50d36d0d23081bc4 => {
10374                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10375                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
10376                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10377                    let control_handle = SimpleStreamSinkControlHandle {
10378                        inner: this.inner.clone(),
10379                    };
10380                    Ok(SimpleStreamSinkRequest::DiscardAllPacketsNoReply {
10381                        control_handle,
10382                    })
10383                }
10384                _ => Err(fidl::Error::UnknownOrdinal {
10385                    ordinal: header.ordinal,
10386                    protocol_name: <SimpleStreamSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
10387                }),
10388            }))
10389            },
10390        )
10391    }
10392}
10393
10394/// A StreamSink that uses StreamBufferSet for buffer management.
10395#[derive(Debug)]
10396pub enum SimpleStreamSinkRequest {
10397    /// Adds a payload buffer to the current buffer set associated with the
10398    /// connection. A `StreamPacket` struct reference a payload buffer in the
10399    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
10400    ///
10401    /// A buffer with ID `id` must not be in the current set when this method is
10402    /// invoked, otherwise the service will close the connection.
10403    AddPayloadBuffer {
10404        id: u32,
10405        payload_buffer: fdomain_client::Vmo,
10406        control_handle: SimpleStreamSinkControlHandle,
10407    },
10408    /// Removes a payload buffer from the current buffer set associated with the
10409    /// connection.
10410    ///
10411    /// A buffer with ID `id` must exist in the current set when this method is
10412    /// invoked, otherwise the service will will close the connection.
10413    RemovePayloadBuffer { id: u32, control_handle: SimpleStreamSinkControlHandle },
10414    /// Sends a packet to the service. The response is sent when the service is
10415    /// done with the associated payload memory.
10416    ///
10417    /// `packet` must be valid for the current buffer set, otherwise the service
10418    /// will close the connection.
10419    SendPacket { packet: StreamPacket, responder: SimpleStreamSinkSendPacketResponder },
10420    /// Sends a packet to the service. This interface doesn't define how the
10421    /// client knows when the sink is done with the associated payload memory.
10422    /// The inheriting interface must define that.
10423    ///
10424    /// `packet` must be valid for the current buffer set, otherwise the service
10425    /// will close the connection.
10426    SendPacketNoReply { packet: StreamPacket, control_handle: SimpleStreamSinkControlHandle },
10427    /// Indicates the stream has ended. The precise semantics of this method are
10428    /// determined by the inheriting interface.
10429    EndOfStream { control_handle: SimpleStreamSinkControlHandle },
10430    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
10431    /// and not yet released. The response is sent after all packets have been
10432    /// released.
10433    DiscardAllPackets { responder: SimpleStreamSinkDiscardAllPacketsResponder },
10434    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
10435    /// and not yet released.
10436    DiscardAllPacketsNoReply { control_handle: SimpleStreamSinkControlHandle },
10437}
10438
10439impl SimpleStreamSinkRequest {
10440    #[allow(irrefutable_let_patterns)]
10441    pub fn into_add_payload_buffer(
10442        self,
10443    ) -> Option<(u32, fdomain_client::Vmo, SimpleStreamSinkControlHandle)> {
10444        if let SimpleStreamSinkRequest::AddPayloadBuffer { id, payload_buffer, control_handle } =
10445            self
10446        {
10447            Some((id, payload_buffer, control_handle))
10448        } else {
10449            None
10450        }
10451    }
10452
10453    #[allow(irrefutable_let_patterns)]
10454    pub fn into_remove_payload_buffer(self) -> Option<(u32, SimpleStreamSinkControlHandle)> {
10455        if let SimpleStreamSinkRequest::RemovePayloadBuffer { id, control_handle } = self {
10456            Some((id, control_handle))
10457        } else {
10458            None
10459        }
10460    }
10461
10462    #[allow(irrefutable_let_patterns)]
10463    pub fn into_send_packet(self) -> Option<(StreamPacket, SimpleStreamSinkSendPacketResponder)> {
10464        if let SimpleStreamSinkRequest::SendPacket { packet, responder } = self {
10465            Some((packet, responder))
10466        } else {
10467            None
10468        }
10469    }
10470
10471    #[allow(irrefutable_let_patterns)]
10472    pub fn into_send_packet_no_reply(
10473        self,
10474    ) -> Option<(StreamPacket, SimpleStreamSinkControlHandle)> {
10475        if let SimpleStreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
10476            Some((packet, control_handle))
10477        } else {
10478            None
10479        }
10480    }
10481
10482    #[allow(irrefutable_let_patterns)]
10483    pub fn into_end_of_stream(self) -> Option<(SimpleStreamSinkControlHandle)> {
10484        if let SimpleStreamSinkRequest::EndOfStream { control_handle } = self {
10485            Some((control_handle))
10486        } else {
10487            None
10488        }
10489    }
10490
10491    #[allow(irrefutable_let_patterns)]
10492    pub fn into_discard_all_packets(self) -> Option<(SimpleStreamSinkDiscardAllPacketsResponder)> {
10493        if let SimpleStreamSinkRequest::DiscardAllPackets { responder } = self {
10494            Some((responder))
10495        } else {
10496            None
10497        }
10498    }
10499
10500    #[allow(irrefutable_let_patterns)]
10501    pub fn into_discard_all_packets_no_reply(self) -> Option<(SimpleStreamSinkControlHandle)> {
10502        if let SimpleStreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
10503            Some((control_handle))
10504        } else {
10505            None
10506        }
10507    }
10508
10509    /// Name of the method defined in FIDL
10510    pub fn method_name(&self) -> &'static str {
10511        match *self {
10512            SimpleStreamSinkRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
10513            SimpleStreamSinkRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
10514            SimpleStreamSinkRequest::SendPacket { .. } => "send_packet",
10515            SimpleStreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
10516            SimpleStreamSinkRequest::EndOfStream { .. } => "end_of_stream",
10517            SimpleStreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
10518            SimpleStreamSinkRequest::DiscardAllPacketsNoReply { .. } => {
10519                "discard_all_packets_no_reply"
10520            }
10521        }
10522    }
10523}
10524
10525#[derive(Debug, Clone)]
10526pub struct SimpleStreamSinkControlHandle {
10527    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10528}
10529
10530impl fdomain_client::fidl::ControlHandle for SimpleStreamSinkControlHandle {
10531    fn shutdown(&self) {
10532        self.inner.shutdown()
10533    }
10534
10535    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
10536        self.inner.shutdown_with_epitaph(status)
10537    }
10538
10539    fn is_closed(&self) -> bool {
10540        self.inner.channel().is_closed()
10541    }
10542    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
10543        self.inner.channel().on_closed()
10544    }
10545}
10546
10547impl SimpleStreamSinkControlHandle {}
10548
10549#[must_use = "FIDL methods require a response to be sent"]
10550#[derive(Debug)]
10551pub struct SimpleStreamSinkSendPacketResponder {
10552    control_handle: std::mem::ManuallyDrop<SimpleStreamSinkControlHandle>,
10553    tx_id: u32,
10554}
10555
10556/// Set the the channel to be shutdown (see [`SimpleStreamSinkControlHandle::shutdown`])
10557/// if the responder is dropped without sending a response, so that the client
10558/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10559impl std::ops::Drop for SimpleStreamSinkSendPacketResponder {
10560    fn drop(&mut self) {
10561        self.control_handle.shutdown();
10562        // Safety: drops once, never accessed again
10563        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10564    }
10565}
10566
10567impl fdomain_client::fidl::Responder for SimpleStreamSinkSendPacketResponder {
10568    type ControlHandle = SimpleStreamSinkControlHandle;
10569
10570    fn control_handle(&self) -> &SimpleStreamSinkControlHandle {
10571        &self.control_handle
10572    }
10573
10574    fn drop_without_shutdown(mut self) {
10575        // Safety: drops once, never accessed again due to mem::forget
10576        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10577        // Prevent Drop from running (which would shut down the channel)
10578        std::mem::forget(self);
10579    }
10580}
10581
10582impl SimpleStreamSinkSendPacketResponder {
10583    /// Sends a response to the FIDL transaction.
10584    ///
10585    /// Sets the channel to shutdown if an error occurs.
10586    pub fn send(self) -> Result<(), fidl::Error> {
10587        let _result = self.send_raw();
10588        if _result.is_err() {
10589            self.control_handle.shutdown();
10590        }
10591        self.drop_without_shutdown();
10592        _result
10593    }
10594
10595    /// Similar to "send" but does not shutdown the channel if an error occurs.
10596    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10597        let _result = self.send_raw();
10598        self.drop_without_shutdown();
10599        _result
10600    }
10601
10602    fn send_raw(&self) -> Result<(), fidl::Error> {
10603        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10604            (),
10605            self.tx_id,
10606            0x67cddd607442775f,
10607            fidl::encoding::DynamicFlags::empty(),
10608        )
10609    }
10610}
10611
10612#[must_use = "FIDL methods require a response to be sent"]
10613#[derive(Debug)]
10614pub struct SimpleStreamSinkDiscardAllPacketsResponder {
10615    control_handle: std::mem::ManuallyDrop<SimpleStreamSinkControlHandle>,
10616    tx_id: u32,
10617}
10618
10619/// Set the the channel to be shutdown (see [`SimpleStreamSinkControlHandle::shutdown`])
10620/// if the responder is dropped without sending a response, so that the client
10621/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10622impl std::ops::Drop for SimpleStreamSinkDiscardAllPacketsResponder {
10623    fn drop(&mut self) {
10624        self.control_handle.shutdown();
10625        // Safety: drops once, never accessed again
10626        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10627    }
10628}
10629
10630impl fdomain_client::fidl::Responder for SimpleStreamSinkDiscardAllPacketsResponder {
10631    type ControlHandle = SimpleStreamSinkControlHandle;
10632
10633    fn control_handle(&self) -> &SimpleStreamSinkControlHandle {
10634        &self.control_handle
10635    }
10636
10637    fn drop_without_shutdown(mut self) {
10638        // Safety: drops once, never accessed again due to mem::forget
10639        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10640        // Prevent Drop from running (which would shut down the channel)
10641        std::mem::forget(self);
10642    }
10643}
10644
10645impl SimpleStreamSinkDiscardAllPacketsResponder {
10646    /// Sends a response to the FIDL transaction.
10647    ///
10648    /// Sets the channel to shutdown if an error occurs.
10649    pub fn send(self) -> Result<(), fidl::Error> {
10650        let _result = self.send_raw();
10651        if _result.is_err() {
10652            self.control_handle.shutdown();
10653        }
10654        self.drop_without_shutdown();
10655        _result
10656    }
10657
10658    /// Similar to "send" but does not shutdown the channel if an error occurs.
10659    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10660        let _result = self.send_raw();
10661        self.drop_without_shutdown();
10662        _result
10663    }
10664
10665    fn send_raw(&self) -> Result<(), fidl::Error> {
10666        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10667            (),
10668            self.tx_id,
10669            0x6f4dad7af2917665,
10670            fidl::encoding::DynamicFlags::empty(),
10671        )
10672    }
10673}
10674
10675#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
10676pub struct StreamBufferSetMarker;
10677
10678impl fdomain_client::fidl::ProtocolMarker for StreamBufferSetMarker {
10679    type Proxy = StreamBufferSetProxy;
10680    type RequestStream = StreamBufferSetRequestStream;
10681
10682    const DEBUG_NAME: &'static str = "(anonymous) StreamBufferSet";
10683}
10684
10685pub trait StreamBufferSetProxyInterface: Send + Sync {
10686    fn r#add_payload_buffer(
10687        &self,
10688        id: u32,
10689        payload_buffer: fdomain_client::Vmo,
10690    ) -> Result<(), fidl::Error>;
10691    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
10692}
10693
10694#[derive(Debug, Clone)]
10695pub struct StreamBufferSetProxy {
10696    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
10697}
10698
10699impl fdomain_client::fidl::Proxy for StreamBufferSetProxy {
10700    type Protocol = StreamBufferSetMarker;
10701
10702    fn from_channel(inner: fdomain_client::Channel) -> Self {
10703        Self::new(inner)
10704    }
10705
10706    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
10707        self.client.into_channel().map_err(|client| Self { client })
10708    }
10709
10710    fn as_channel(&self) -> &fdomain_client::Channel {
10711        self.client.as_channel()
10712    }
10713}
10714
10715impl StreamBufferSetProxy {
10716    /// Create a new Proxy for fuchsia.media/StreamBufferSet.
10717    pub fn new(channel: fdomain_client::Channel) -> Self {
10718        let protocol_name =
10719            <StreamBufferSetMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
10720        Self { client: fidl::client::Client::new(channel, protocol_name) }
10721    }
10722
10723    /// Get a Stream of events from the remote end of the protocol.
10724    ///
10725    /// # Panics
10726    ///
10727    /// Panics if the event stream was already taken.
10728    pub fn take_event_stream(&self) -> StreamBufferSetEventStream {
10729        StreamBufferSetEventStream { event_receiver: self.client.take_event_receiver() }
10730    }
10731
10732    /// Adds a payload buffer to the current buffer set associated with the
10733    /// connection. A `StreamPacket` struct reference a payload buffer in the
10734    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
10735    ///
10736    /// A buffer with ID `id` must not be in the current set when this method is
10737    /// invoked, otherwise the service will close the connection.
10738    pub fn r#add_payload_buffer(
10739        &self,
10740        mut id: u32,
10741        mut payload_buffer: fdomain_client::Vmo,
10742    ) -> Result<(), fidl::Error> {
10743        StreamBufferSetProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
10744    }
10745
10746    /// Removes a payload buffer from the current buffer set associated with the
10747    /// connection.
10748    ///
10749    /// A buffer with ID `id` must exist in the current set when this method is
10750    /// invoked, otherwise the service will will close the connection.
10751    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
10752        StreamBufferSetProxyInterface::r#remove_payload_buffer(self, id)
10753    }
10754}
10755
10756impl StreamBufferSetProxyInterface for StreamBufferSetProxy {
10757    fn r#add_payload_buffer(
10758        &self,
10759        mut id: u32,
10760        mut payload_buffer: fdomain_client::Vmo,
10761    ) -> Result<(), fidl::Error> {
10762        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
10763            (id, payload_buffer),
10764            0x3b3a37fc34fe5b56,
10765            fidl::encoding::DynamicFlags::empty(),
10766        )
10767    }
10768
10769    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
10770        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
10771            (id,),
10772            0x5d1e4f74c3658262,
10773            fidl::encoding::DynamicFlags::empty(),
10774        )
10775    }
10776}
10777
10778pub struct StreamBufferSetEventStream {
10779    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
10780}
10781
10782impl std::marker::Unpin for StreamBufferSetEventStream {}
10783
10784impl futures::stream::FusedStream for StreamBufferSetEventStream {
10785    fn is_terminated(&self) -> bool {
10786        self.event_receiver.is_terminated()
10787    }
10788}
10789
10790impl futures::Stream for StreamBufferSetEventStream {
10791    type Item = Result<StreamBufferSetEvent, fidl::Error>;
10792
10793    fn poll_next(
10794        mut self: std::pin::Pin<&mut Self>,
10795        cx: &mut std::task::Context<'_>,
10796    ) -> std::task::Poll<Option<Self::Item>> {
10797        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
10798            &mut self.event_receiver,
10799            cx
10800        )?) {
10801            Some(buf) => std::task::Poll::Ready(Some(StreamBufferSetEvent::decode(buf))),
10802            None => std::task::Poll::Ready(None),
10803        }
10804    }
10805}
10806
10807#[derive(Debug)]
10808pub enum StreamBufferSetEvent {}
10809
10810impl StreamBufferSetEvent {
10811    /// Decodes a message buffer as a [`StreamBufferSetEvent`].
10812    fn decode(
10813        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
10814    ) -> Result<StreamBufferSetEvent, fidl::Error> {
10815        let (bytes, _handles) = buf.split_mut();
10816        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10817        debug_assert_eq!(tx_header.tx_id, 0);
10818        match tx_header.ordinal {
10819            _ => Err(fidl::Error::UnknownOrdinal {
10820                ordinal: tx_header.ordinal,
10821                protocol_name:
10822                    <StreamBufferSetMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
10823            }),
10824        }
10825    }
10826}
10827
10828/// A Stream of incoming requests for fuchsia.media/StreamBufferSet.
10829pub struct StreamBufferSetRequestStream {
10830    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10831    is_terminated: bool,
10832}
10833
10834impl std::marker::Unpin for StreamBufferSetRequestStream {}
10835
10836impl futures::stream::FusedStream for StreamBufferSetRequestStream {
10837    fn is_terminated(&self) -> bool {
10838        self.is_terminated
10839    }
10840}
10841
10842impl fdomain_client::fidl::RequestStream for StreamBufferSetRequestStream {
10843    type Protocol = StreamBufferSetMarker;
10844    type ControlHandle = StreamBufferSetControlHandle;
10845
10846    fn from_channel(channel: fdomain_client::Channel) -> Self {
10847        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
10848    }
10849
10850    fn control_handle(&self) -> Self::ControlHandle {
10851        StreamBufferSetControlHandle { inner: self.inner.clone() }
10852    }
10853
10854    fn into_inner(
10855        self,
10856    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
10857    {
10858        (self.inner, self.is_terminated)
10859    }
10860
10861    fn from_inner(
10862        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10863        is_terminated: bool,
10864    ) -> Self {
10865        Self { inner, is_terminated }
10866    }
10867}
10868
10869impl futures::Stream for StreamBufferSetRequestStream {
10870    type Item = Result<StreamBufferSetRequest, fidl::Error>;
10871
10872    fn poll_next(
10873        mut self: std::pin::Pin<&mut Self>,
10874        cx: &mut std::task::Context<'_>,
10875    ) -> std::task::Poll<Option<Self::Item>> {
10876        let this = &mut *self;
10877        if this.inner.check_shutdown(cx) {
10878            this.is_terminated = true;
10879            return std::task::Poll::Ready(None);
10880        }
10881        if this.is_terminated {
10882            panic!("polled StreamBufferSetRequestStream after completion");
10883        }
10884        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
10885            |bytes, handles| {
10886                match this.inner.channel().read_etc(cx, bytes, handles) {
10887                    std::task::Poll::Ready(Ok(())) => {}
10888                    std::task::Poll::Pending => return std::task::Poll::Pending,
10889                    std::task::Poll::Ready(Err(None)) => {
10890                        this.is_terminated = true;
10891                        return std::task::Poll::Ready(None);
10892                    }
10893                    std::task::Poll::Ready(Err(Some(e))) => {
10894                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
10895                            e.into(),
10896                        ))));
10897                    }
10898                }
10899
10900                // A message has been received from the channel
10901                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10902
10903                std::task::Poll::Ready(Some(match header.ordinal {
10904                0x3b3a37fc34fe5b56 => {
10905                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10906                    let mut req = fidl::new_empty!(StreamBufferSetAddPayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
10907                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
10908                    let control_handle = StreamBufferSetControlHandle {
10909                        inner: this.inner.clone(),
10910                    };
10911                    Ok(StreamBufferSetRequest::AddPayloadBuffer {id: req.id,
10912payload_buffer: req.payload_buffer,
10913
10914                        control_handle,
10915                    })
10916                }
10917                0x5d1e4f74c3658262 => {
10918                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10919                    let mut req = fidl::new_empty!(StreamBufferSetRemovePayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
10920                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
10921                    let control_handle = StreamBufferSetControlHandle {
10922                        inner: this.inner.clone(),
10923                    };
10924                    Ok(StreamBufferSetRequest::RemovePayloadBuffer {id: req.id,
10925
10926                        control_handle,
10927                    })
10928                }
10929                _ => Err(fidl::Error::UnknownOrdinal {
10930                    ordinal: header.ordinal,
10931                    protocol_name: <StreamBufferSetMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
10932                }),
10933            }))
10934            },
10935        )
10936    }
10937}
10938
10939/// Manages a set of payload buffers for a stream. This interface is typically
10940/// inherited along with `StreamSink` or `StreamSource` to enable the transport
10941/// of elementary streams between clients and services.
10942#[derive(Debug)]
10943pub enum StreamBufferSetRequest {
10944    /// Adds a payload buffer to the current buffer set associated with the
10945    /// connection. A `StreamPacket` struct reference a payload buffer in the
10946    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
10947    ///
10948    /// A buffer with ID `id` must not be in the current set when this method is
10949    /// invoked, otherwise the service will close the connection.
10950    AddPayloadBuffer {
10951        id: u32,
10952        payload_buffer: fdomain_client::Vmo,
10953        control_handle: StreamBufferSetControlHandle,
10954    },
10955    /// Removes a payload buffer from the current buffer set associated with the
10956    /// connection.
10957    ///
10958    /// A buffer with ID `id` must exist in the current set when this method is
10959    /// invoked, otherwise the service will will close the connection.
10960    RemovePayloadBuffer { id: u32, control_handle: StreamBufferSetControlHandle },
10961}
10962
10963impl StreamBufferSetRequest {
10964    #[allow(irrefutable_let_patterns)]
10965    pub fn into_add_payload_buffer(
10966        self,
10967    ) -> Option<(u32, fdomain_client::Vmo, StreamBufferSetControlHandle)> {
10968        if let StreamBufferSetRequest::AddPayloadBuffer { id, payload_buffer, control_handle } =
10969            self
10970        {
10971            Some((id, payload_buffer, control_handle))
10972        } else {
10973            None
10974        }
10975    }
10976
10977    #[allow(irrefutable_let_patterns)]
10978    pub fn into_remove_payload_buffer(self) -> Option<(u32, StreamBufferSetControlHandle)> {
10979        if let StreamBufferSetRequest::RemovePayloadBuffer { id, control_handle } = self {
10980            Some((id, control_handle))
10981        } else {
10982            None
10983        }
10984    }
10985
10986    /// Name of the method defined in FIDL
10987    pub fn method_name(&self) -> &'static str {
10988        match *self {
10989            StreamBufferSetRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
10990            StreamBufferSetRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
10991        }
10992    }
10993}
10994
10995#[derive(Debug, Clone)]
10996pub struct StreamBufferSetControlHandle {
10997    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10998}
10999
11000impl fdomain_client::fidl::ControlHandle for StreamBufferSetControlHandle {
11001    fn shutdown(&self) {
11002        self.inner.shutdown()
11003    }
11004
11005    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
11006        self.inner.shutdown_with_epitaph(status)
11007    }
11008
11009    fn is_closed(&self) -> bool {
11010        self.inner.channel().is_closed()
11011    }
11012    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
11013        self.inner.channel().on_closed()
11014    }
11015}
11016
11017impl StreamBufferSetControlHandle {}
11018
11019#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
11020pub struct StreamProcessorMarker;
11021
11022impl fdomain_client::fidl::ProtocolMarker for StreamProcessorMarker {
11023    type Proxy = StreamProcessorProxy;
11024    type RequestStream = StreamProcessorRequestStream;
11025
11026    const DEBUG_NAME: &'static str = "(anonymous) StreamProcessor";
11027}
11028
11029pub trait StreamProcessorProxyInterface: Send + Sync {
11030    fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error>;
11031    fn r#set_input_buffer_partial_settings(
11032        &self,
11033        input_settings: StreamBufferPartialSettings,
11034    ) -> Result<(), fidl::Error>;
11035    fn r#set_output_buffer_partial_settings(
11036        &self,
11037        output_settings: StreamBufferPartialSettings,
11038    ) -> Result<(), fidl::Error>;
11039    fn r#complete_output_buffer_partial_settings(
11040        &self,
11041        buffer_lifetime_ordinal: u64,
11042    ) -> Result<(), fidl::Error>;
11043    fn r#flush_end_of_stream_and_close_stream(
11044        &self,
11045        stream_lifetime_ordinal: u64,
11046    ) -> Result<(), fidl::Error>;
11047    fn r#close_current_stream(
11048        &self,
11049        stream_lifetime_ordinal: u64,
11050        release_input_buffers: bool,
11051        release_output_buffers: bool,
11052    ) -> Result<(), fidl::Error>;
11053    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
11054    fn r#sync(&self) -> Self::SyncResponseFut;
11055    fn r#recycle_output_packet(
11056        &self,
11057        available_output_packet: &PacketHeader,
11058    ) -> Result<(), fidl::Error>;
11059    fn r#queue_input_format_details(
11060        &self,
11061        stream_lifetime_ordinal: u64,
11062        format_details: &FormatDetails,
11063    ) -> Result<(), fidl::Error>;
11064    fn r#queue_input_packet(&self, packet: &Packet) -> Result<(), fidl::Error>;
11065    fn r#queue_input_end_of_stream(&self, stream_lifetime_ordinal: u64) -> Result<(), fidl::Error>;
11066}
11067
11068#[derive(Debug, Clone)]
11069pub struct StreamProcessorProxy {
11070    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
11071}
11072
11073impl fdomain_client::fidl::Proxy for StreamProcessorProxy {
11074    type Protocol = StreamProcessorMarker;
11075
11076    fn from_channel(inner: fdomain_client::Channel) -> Self {
11077        Self::new(inner)
11078    }
11079
11080    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
11081        self.client.into_channel().map_err(|client| Self { client })
11082    }
11083
11084    fn as_channel(&self) -> &fdomain_client::Channel {
11085        self.client.as_channel()
11086    }
11087}
11088
11089impl StreamProcessorProxy {
11090    /// Create a new Proxy for fuchsia.media/StreamProcessor.
11091    pub fn new(channel: fdomain_client::Channel) -> Self {
11092        let protocol_name =
11093            <StreamProcessorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
11094        Self { client: fidl::client::Client::new(channel, protocol_name) }
11095    }
11096
11097    /// Get a Stream of events from the remote end of the protocol.
11098    ///
11099    /// # Panics
11100    ///
11101    /// Panics if the event stream was already taken.
11102    pub fn take_event_stream(&self) -> StreamProcessorEventStream {
11103        StreamProcessorEventStream { event_receiver: self.client.take_event_receiver() }
11104    }
11105
11106    /// Permit the server to use OnStreamFailed() instead of the server just
11107    /// closing the whole StreamProcessor channel on stream failure.
11108    ///
11109    /// If the server hasn't seen this message by the time a stream fails, the
11110    /// server will close the StreamProcessor channel instead of sending
11111    /// OnStreamFailed().
11112    pub fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
11113        StreamProcessorProxyInterface::r#enable_on_stream_failed(self)
11114    }
11115
11116    /// This is the replacement for SetInputBufferSettings().
11117    ///
11118    /// When the client is using sysmem to allocate buffers, this message is
11119    /// used instead of SetInputBufferSettings()+AddInputBuffer().  Instead, a
11120    /// single SetInputBufferPartialSettings() provides the StreamProcessor with
11121    /// the client-specified input settings and a BufferCollectionToken which
11122    /// the StreamProcessor will use to convey constraints to sysmem.  Both the
11123    /// client and the StreamProcessor will be informed of the allocated buffers
11124    /// directly by sysmem via their BufferCollection channel (not via the
11125    /// StreamProcessor channel).
11126    ///
11127    /// The client must not QueueInput...() until after sysmem informs the client
11128    /// that buffer allocation has completed and was successful.
11129    ///
11130    /// The server should be prepared to see QueueInput...() before the server
11131    /// has necessarily heard from sysmem that the buffers are allocated - the
11132    /// server must tolerate either ordering, as the QueueInput...() and
11133    /// notification of sysmem allocation completion arrive on different
11134    /// channels, so the client having heard that allocation is complete doesn't
11135    /// mean the server knows that allocation is complete yet.  However, the
11136    /// server can expect that allocation is in fact complete and can expect to
11137    /// get the allocation information from sysmem immediately upon requesting
11138    /// the information from sysmem.
11139    pub fn r#set_input_buffer_partial_settings(
11140        &self,
11141        mut input_settings: StreamBufferPartialSettings,
11142    ) -> Result<(), fidl::Error> {
11143        StreamProcessorProxyInterface::r#set_input_buffer_partial_settings(self, input_settings)
11144    }
11145
11146    /// This is the replacement for SetOutputBufferSettings().
11147    ///
11148    /// When the client is using sysmem to allocate buffers, this message is
11149    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
11150    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
11151    /// with the client-specified output settings and a BufferCollectionToken
11152    /// which the StreamProcessor will use to convey constraints to sysmem.
11153    /// Both the client and the StreamProcessor will be informed of the
11154    /// allocated buffers directly by sysmem via their BufferCollection channel
11155    /// (not via the StreamProcessor channel).
11156    ///
11157    /// Configuring output buffers is _required_ after OnOutputConstraints() is
11158    /// received by the client with buffer_constraints_action_required true and
11159    /// stream_lifetime_ordinal equal to the client's current
11160    /// stream_lifetime_ordinal (even if there is an active stream), and is
11161    /// _permitted_ any time there is no current stream.
11162    ///
11163    /// Closing the current stream occurs on the StreamControl ordering domain,
11164    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
11165    /// subsequent Sync() completion must be received by the client before the
11166    /// client knows that there's no longer a current stream.
11167    ///
11168    /// See also CompleteOutputBufferPartialSettings().
11169    pub fn r#set_output_buffer_partial_settings(
11170        &self,
11171        mut output_settings: StreamBufferPartialSettings,
11172    ) -> Result<(), fidl::Error> {
11173        StreamProcessorProxyInterface::r#set_output_buffer_partial_settings(self, output_settings)
11174    }
11175
11176    /// After SetOutputBufferPartialSettings(), the server won't send
11177    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
11178    /// OnOutputEndOfStream() until after the client sends
11179    /// CompleteOutputBufferPartialSettings().
11180    ///
11181    /// Some clients may be able to send
11182    /// CompleteOutputBufferPartialSettings() immediately after
11183    /// SetOutputBufferPartialSettings() - in that case the client needs to be
11184    /// prepared to receive output without knowing the buffer count or packet
11185    /// count yet - such clients may internally delay processing the received
11186    /// output until the client has heard from sysmem (which is when the client
11187    /// will learn the buffer count and packet count).
11188    ///
11189    /// Other clients may first wait for sysmem to allocate, prepare to receive
11190    /// output, and then send CompleteOutputBufferPartialSettings().
11191    pub fn r#complete_output_buffer_partial_settings(
11192        &self,
11193        mut buffer_lifetime_ordinal: u64,
11194    ) -> Result<(), fidl::Error> {
11195        StreamProcessorProxyInterface::r#complete_output_buffer_partial_settings(
11196            self,
11197            buffer_lifetime_ordinal,
11198        )
11199    }
11200
11201    /// This message is optional.
11202    ///
11203    /// This message is only valid after QueueInputEndOfStream() for this stream.
11204    /// The stream_lifetime_ordinal input parameter must match the
11205    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
11206    /// will close the channel.
11207    ///
11208    /// A client can use this message to flush through (not discard) the last
11209    /// input data of a stream so that the stream processor server generates
11210    /// corresponding output data for all the input data before the server moves
11211    /// on to the next stream, without forcing the client to wait for
11212    /// OnOutputEndOfStream() before queueing data of another stream.
11213    ///
11214    /// The difference between QueueInputEndOfStream() and
11215    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
11216    /// from the client that there will not be any more input data for the
11217    /// stream (and this info is needed by some stream processors for the stream
11218    /// processor to ever emit the very last output data).  The
11219    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
11220    /// later completely discarding the rest of the current stream by closing
11221    /// the current stream (with or without a stream switch).  In contrast,
11222    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
11223    /// the previously-queued input data be processed including the logical
11224    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
11225    /// before moving on to any newer stream - this essentially changes the
11226    /// close-stream handling from discard to flush-through for this stream
11227    /// only.
11228    ///
11229    /// A client using this message can start providing input data for a new
11230    /// stream without that causing discard of old stream data.  That's the
11231    /// purpose of this message - to allow a client to flush through (not
11232    /// discard) the old stream's last data (instead of the default when closing
11233    /// or switching streams which is discard).
11234    ///
11235    /// Because the old stream is not done processing yet and the old stream's
11236    /// data is not being discarded, the client must be prepared to continue to
11237    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
11238    /// is done. The client will know the stream_lifetime_ordinal is done when
11239    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
11240    /// closes.
11241    pub fn r#flush_end_of_stream_and_close_stream(
11242        &self,
11243        mut stream_lifetime_ordinal: u64,
11244    ) -> Result<(), fidl::Error> {
11245        StreamProcessorProxyInterface::r#flush_end_of_stream_and_close_stream(
11246            self,
11247            stream_lifetime_ordinal,
11248        )
11249    }
11250
11251    /// This "closes" the current stream, leaving no current stream.  In
11252    /// addition, this message can optionally release input buffers or output
11253    /// buffers.
11254    ///
11255    /// If there has never been any active stream, the stream_lifetime_ordinal
11256    /// must be zero or the server will close the channel.  If there has been an
11257    /// active stream, the stream_lifetime_ordinal must be the most recent
11258    /// active stream whether that stream is still active or not.  Else the
11259    /// server will close the channel.
11260    ///
11261    /// Multiple of this message without any new active stream in between is not
11262    /// to be considered an error, which allows a client to use this message to
11263    /// close the current stream to stop wasting processing power on a stream the
11264    /// user no longer cares about, then later decide that buffers should be
11265    /// released and send this message again with release_input_buffers and/or
11266    /// release_output_buffers true to get the buffers released, if the client is
11267    /// interested in trying to avoid overlap in resource usage between old
11268    /// buffers and new buffers (not all clients are).
11269    ///
11270    /// See also Sync().
11271    pub fn r#close_current_stream(
11272        &self,
11273        mut stream_lifetime_ordinal: u64,
11274        mut release_input_buffers: bool,
11275        mut release_output_buffers: bool,
11276    ) -> Result<(), fidl::Error> {
11277        StreamProcessorProxyInterface::r#close_current_stream(
11278            self,
11279            stream_lifetime_ordinal,
11280            release_input_buffers,
11281            release_output_buffers,
11282        )
11283    }
11284
11285    /// On completion, all previous StreamProcessor calls have done what they're
11286    /// going to do server-side, _except_ for processing of data queued using
11287    /// QueueInputPacket().
11288    ///
11289    /// The main purpose of this call is to enable the client to wait until
11290    /// CloseCurrentStream() with release_input_buffers and/or
11291    /// release_output_buffers set to true to take effect, before the client
11292    /// allocates new buffers and re-sets-up input and/or output buffers.  This
11293    /// de-overlapping of resource usage can be worthwhile for media buffers
11294    /// which can consume resource types whose overall pools aren't necessarily
11295    /// vast in comparison to resources consumed.  Especially if a client is
11296    /// reconfiguring buffers multiple times.
11297    ///
11298    /// Note that Sync() prior to allocating new media buffers is not alone
11299    /// sufficient to achieve non-overlap of media buffer resource usage system
11300    /// wide, but it can be a useful part of achieving that.
11301    ///
11302    /// The Sync() transits the Output ordering domain and the StreamControl
11303    /// ordering domain, but not the InputData ordering domain.
11304    ///
11305    /// This request can be used to avoid hitting kMaxInFlightStreams which is
11306    /// presently 10.  A client that stays <= 8 in-flight streams will
11307    /// comfortably stay under the limit of 10.  While the protocol permits
11308    /// repeated SetInputBufferSettings() and the like, a client that spams the
11309    /// channel can expect that the channel will just close if the server or the
11310    /// channel itself gets too far behind.
11311    pub fn r#sync(
11312        &self,
11313    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
11314        StreamProcessorProxyInterface::r#sync(self)
11315    }
11316
11317    /// After the client is done with an output packet, the client needs to tell
11318    /// the stream processor that the output packet can be re-used for more
11319    /// output, via this method.
11320    ///
11321    /// It's not permitted to recycle an output packet that's already free with
11322    /// the stream processor server.  It's permitted but discouraged for a
11323    /// client to recycle an output packet that has been deallocated by an
11324    /// explicit or implicit output buffer de-configuration().  See
11325    /// buffer_lifetime_ordinal for more on that. A server must ignore any such
11326    /// stale RecycleOutputPacket() calls.
11327    pub fn r#recycle_output_packet(
11328        &self,
11329        mut available_output_packet: &PacketHeader,
11330    ) -> Result<(), fidl::Error> {
11331        StreamProcessorProxyInterface::r#recycle_output_packet(self, available_output_packet)
11332    }
11333
11334    /// If the input format details are still the same as specified during
11335    /// StreamProcessor creation, this message is unnecessary and does not need
11336    /// to be sent.
11337    ///
11338    /// If the stream doesn't exist yet, this message creates the stream.
11339    ///
11340    /// The server won't send OnOutputConstraints() until after the client has
11341    /// sent at least one QueueInput* message.
11342    ///
11343    /// All servers must permit QueueInputFormatDetails() at the start of a
11344    /// stream without failing, as long as the new format is supported by the
11345    /// StreamProcessor instance.  Technically this allows for a server to only
11346    /// support the exact input format set during StreamProcessor creation, and
11347    /// that is by design.  A client that tries to switch formats and gets a
11348    /// StreamProcessor channel failure should try again one more time with a
11349    /// fresh StreamProcessor instance created with CodecFactory using the new
11350    /// input format during creation, before giving up.
11351    ///
11352    /// These format details override the format details specified during stream
11353    /// processor creation for this stream only.  The next stream will default
11354    /// back to the format details set during stream processor creation.
11355    ///
11356    /// This message is permitted at the start of the first stream (just like at
11357    /// the start of any stream).  The format specified need not match what was
11358    /// specified during stream processor creation, but if it doesn't match, the
11359    /// StreamProcessor channel might close as described above.
11360    pub fn r#queue_input_format_details(
11361        &self,
11362        mut stream_lifetime_ordinal: u64,
11363        mut format_details: &FormatDetails,
11364    ) -> Result<(), fidl::Error> {
11365        StreamProcessorProxyInterface::r#queue_input_format_details(
11366            self,
11367            stream_lifetime_ordinal,
11368            format_details,
11369        )
11370    }
11371
11372    /// This message queues input data to the stream processor for processing.
11373    ///
11374    /// If the stream doesn't exist yet, this message creates the new stream.
11375    ///
11376    /// The server won't send OnOutputConstraints() until after the client has
11377    /// sent at least one QueueInput* message.
11378    ///
11379    /// The client must continue to deliver input data via this message even if
11380    /// the stream processor has not yet generated the first OnOutputConstraints(),
11381    /// and even if the StreamProcessor is generating OnFreeInputPacket() for
11382    /// previously-queued input packets.  The input data must continue as long
11383    /// as there are free packets to be assured that the server will ever
11384    /// generate the first OnOutputConstraints().
11385    pub fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
11386        StreamProcessorProxyInterface::r#queue_input_packet(self, packet)
11387    }
11388
11389    /// Inform the server that all QueueInputPacket() messages for this stream
11390    /// have been sent.
11391    ///
11392    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
11393    /// or StreamProcessor channel closing), there will later be a corresponding
11394    /// OnOutputEndOfStream().
11395    ///
11396    /// The corresponding OnOutputEndOfStream() message will be generated only if
11397    /// the server finishes processing the stream before the server sees the
11398    /// client close the stream (such as by starting a new stream).  A way to
11399    /// force the server to finish the stream before closing is to use
11400    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before any
11401    /// new stream.  Another way to force the server to finish the stream before
11402    /// closing is to wait for the OnOutputEndOfStream() before taking any action
11403    /// that closes the stream.
11404    ///
11405    /// In addition to serving as an "EndOfStream" marker to make it obvious
11406    /// client-side when all input data has been processed, if a client never
11407    /// sends QueueInputEndOfStream(), no amount of waiting will necessarily
11408    /// result in all input data getting processed through to the output.  Some
11409    /// stream processors have some internally-delayed data which only gets
11410    /// pushed through by additional input data _or_ by this EndOfStream marker.
11411    /// In that sense, this message can be viewed as a flush-through at
11412    /// InputData domain level, but the flush-through only takes effect if the
11413    /// stream processor even gets that far before the stream is just closed at
11414    /// StreamControl domain level.  This message is not alone sufficient to act
11415    /// as an overall flush-through at StreamControl level. For that, send this
11416    /// message first and then send FlushEndOfStreamAndCloseStream() (at which
11417    /// point it becomes possible to queue input data for a new stream without
11418    /// causing discard of this older stream's data), or wait for the
11419    /// OnOutputEndOfStream() before closing the current stream.
11420    ///
11421    /// If a client sends QueueInputPacket(), QueueInputFormatDetails(),
11422    /// QueueInputEndOfStream() for this stream after the first
11423    /// QueueInputEndOfStream() for this stream, a server should close the
11424    /// StreamProcessor channel.
11425    pub fn r#queue_input_end_of_stream(
11426        &self,
11427        mut stream_lifetime_ordinal: u64,
11428    ) -> Result<(), fidl::Error> {
11429        StreamProcessorProxyInterface::r#queue_input_end_of_stream(self, stream_lifetime_ordinal)
11430    }
11431}
11432
11433impl StreamProcessorProxyInterface for StreamProcessorProxy {
11434    fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
11435        self.client.send::<fidl::encoding::EmptyPayload>(
11436            (),
11437            0x3940929617dbf02b,
11438            fidl::encoding::DynamicFlags::empty(),
11439        )
11440    }
11441
11442    fn r#set_input_buffer_partial_settings(
11443        &self,
11444        mut input_settings: StreamBufferPartialSettings,
11445    ) -> Result<(), fidl::Error> {
11446        self.client.send::<StreamProcessorSetInputBufferPartialSettingsRequest>(
11447            (&mut input_settings,),
11448            0xb02e0663a40e4c4,
11449            fidl::encoding::DynamicFlags::empty(),
11450        )
11451    }
11452
11453    fn r#set_output_buffer_partial_settings(
11454        &self,
11455        mut output_settings: StreamBufferPartialSettings,
11456    ) -> Result<(), fidl::Error> {
11457        self.client.send::<StreamProcessorSetOutputBufferPartialSettingsRequest>(
11458            (&mut output_settings,),
11459            0x118bb8c819a7bbbb,
11460            fidl::encoding::DynamicFlags::empty(),
11461        )
11462    }
11463
11464    fn r#complete_output_buffer_partial_settings(
11465        &self,
11466        mut buffer_lifetime_ordinal: u64,
11467    ) -> Result<(), fidl::Error> {
11468        self.client.send::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(
11469            (buffer_lifetime_ordinal,),
11470            0x50529e5c680ae3ab,
11471            fidl::encoding::DynamicFlags::empty(),
11472        )
11473    }
11474
11475    fn r#flush_end_of_stream_and_close_stream(
11476        &self,
11477        mut stream_lifetime_ordinal: u64,
11478    ) -> Result<(), fidl::Error> {
11479        self.client.send::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(
11480            (stream_lifetime_ordinal,),
11481            0x2b62c3e26d0667e6,
11482            fidl::encoding::DynamicFlags::empty(),
11483        )
11484    }
11485
11486    fn r#close_current_stream(
11487        &self,
11488        mut stream_lifetime_ordinal: u64,
11489        mut release_input_buffers: bool,
11490        mut release_output_buffers: bool,
11491    ) -> Result<(), fidl::Error> {
11492        self.client.send::<StreamProcessorCloseCurrentStreamRequest>(
11493            (stream_lifetime_ordinal, release_input_buffers, release_output_buffers),
11494            0x1d8a67522170ca07,
11495            fidl::encoding::DynamicFlags::empty(),
11496        )
11497    }
11498
11499    type SyncResponseFut =
11500        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
11501    fn r#sync(&self) -> Self::SyncResponseFut {
11502        fn _decode(
11503            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11504        ) -> Result<(), fidl::Error> {
11505            let _response = fidl::client::decode_transaction_body::<
11506                fidl::encoding::EmptyPayload,
11507                fdomain_client::fidl::FDomainResourceDialect,
11508                0x4b3e44300b0ec6aa,
11509            >(_buf?)?;
11510            Ok(_response)
11511        }
11512        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
11513            (),
11514            0x4b3e44300b0ec6aa,
11515            fidl::encoding::DynamicFlags::empty(),
11516            _decode,
11517        )
11518    }
11519
11520    fn r#recycle_output_packet(
11521        &self,
11522        mut available_output_packet: &PacketHeader,
11523    ) -> Result<(), fidl::Error> {
11524        self.client.send::<StreamProcessorRecycleOutputPacketRequest>(
11525            (available_output_packet,),
11526            0x32763632b94e0bd5,
11527            fidl::encoding::DynamicFlags::empty(),
11528        )
11529    }
11530
11531    fn r#queue_input_format_details(
11532        &self,
11533        mut stream_lifetime_ordinal: u64,
11534        mut format_details: &FormatDetails,
11535    ) -> Result<(), fidl::Error> {
11536        self.client.send::<StreamProcessorQueueInputFormatDetailsRequest>(
11537            (stream_lifetime_ordinal, format_details),
11538            0x170dc0979d52231,
11539            fidl::encoding::DynamicFlags::empty(),
11540        )
11541    }
11542
11543    fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
11544        self.client.send::<StreamProcessorQueueInputPacketRequest>(
11545            (packet,),
11546            0x47173d2652d9df3b,
11547            fidl::encoding::DynamicFlags::empty(),
11548        )
11549    }
11550
11551    fn r#queue_input_end_of_stream(
11552        &self,
11553        mut stream_lifetime_ordinal: u64,
11554    ) -> Result<(), fidl::Error> {
11555        self.client.send::<StreamProcessorQueueInputEndOfStreamRequest>(
11556            (stream_lifetime_ordinal,),
11557            0x2051b6ad00f20b37,
11558            fidl::encoding::DynamicFlags::empty(),
11559        )
11560    }
11561}
11562
11563pub struct StreamProcessorEventStream {
11564    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
11565}
11566
11567impl std::marker::Unpin for StreamProcessorEventStream {}
11568
11569impl futures::stream::FusedStream for StreamProcessorEventStream {
11570    fn is_terminated(&self) -> bool {
11571        self.event_receiver.is_terminated()
11572    }
11573}
11574
11575impl futures::Stream for StreamProcessorEventStream {
11576    type Item = Result<StreamProcessorEvent, fidl::Error>;
11577
11578    fn poll_next(
11579        mut self: std::pin::Pin<&mut Self>,
11580        cx: &mut std::task::Context<'_>,
11581    ) -> std::task::Poll<Option<Self::Item>> {
11582        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
11583            &mut self.event_receiver,
11584            cx
11585        )?) {
11586            Some(buf) => std::task::Poll::Ready(Some(StreamProcessorEvent::decode(buf))),
11587            None => std::task::Poll::Ready(None),
11588        }
11589    }
11590}
11591
11592#[derive(Debug)]
11593pub enum StreamProcessorEvent {
11594    OnStreamFailed {
11595        stream_lifetime_ordinal: u64,
11596        error: StreamError,
11597    },
11598    OnInputConstraints {
11599        input_constraints: StreamBufferConstraints,
11600    },
11601    OnOutputConstraints {
11602        output_config: StreamOutputConstraints,
11603    },
11604    OnOutputFormat {
11605        output_format: StreamOutputFormat,
11606    },
11607    OnOutputPacket {
11608        output_packet: Packet,
11609        error_detected_before: bool,
11610        error_detected_during: bool,
11611    },
11612    OnOutputEndOfStream {
11613        stream_lifetime_ordinal: u64,
11614        error_detected_before: bool,
11615    },
11616    OnFreeInputPacket {
11617        free_input_packet: PacketHeader,
11618    },
11619    #[non_exhaustive]
11620    _UnknownEvent {
11621        /// Ordinal of the event that was sent.
11622        ordinal: u64,
11623    },
11624}
11625
11626impl StreamProcessorEvent {
11627    #[allow(irrefutable_let_patterns)]
11628    pub fn into_on_stream_failed(self) -> Option<(u64, StreamError)> {
11629        if let StreamProcessorEvent::OnStreamFailed { stream_lifetime_ordinal, error } = self {
11630            Some((stream_lifetime_ordinal, error))
11631        } else {
11632            None
11633        }
11634    }
11635    #[allow(irrefutable_let_patterns)]
11636    pub fn into_on_input_constraints(self) -> Option<StreamBufferConstraints> {
11637        if let StreamProcessorEvent::OnInputConstraints { input_constraints } = self {
11638            Some((input_constraints))
11639        } else {
11640            None
11641        }
11642    }
11643    #[allow(irrefutable_let_patterns)]
11644    pub fn into_on_output_constraints(self) -> Option<StreamOutputConstraints> {
11645        if let StreamProcessorEvent::OnOutputConstraints { output_config } = self {
11646            Some((output_config))
11647        } else {
11648            None
11649        }
11650    }
11651    #[allow(irrefutable_let_patterns)]
11652    pub fn into_on_output_format(self) -> Option<StreamOutputFormat> {
11653        if let StreamProcessorEvent::OnOutputFormat { output_format } = self {
11654            Some((output_format))
11655        } else {
11656            None
11657        }
11658    }
11659    #[allow(irrefutable_let_patterns)]
11660    pub fn into_on_output_packet(self) -> Option<(Packet, bool, bool)> {
11661        if let StreamProcessorEvent::OnOutputPacket {
11662            output_packet,
11663            error_detected_before,
11664            error_detected_during,
11665        } = self
11666        {
11667            Some((output_packet, error_detected_before, error_detected_during))
11668        } else {
11669            None
11670        }
11671    }
11672    #[allow(irrefutable_let_patterns)]
11673    pub fn into_on_output_end_of_stream(self) -> Option<(u64, bool)> {
11674        if let StreamProcessorEvent::OnOutputEndOfStream {
11675            stream_lifetime_ordinal,
11676            error_detected_before,
11677        } = self
11678        {
11679            Some((stream_lifetime_ordinal, error_detected_before))
11680        } else {
11681            None
11682        }
11683    }
11684    #[allow(irrefutable_let_patterns)]
11685    pub fn into_on_free_input_packet(self) -> Option<PacketHeader> {
11686        if let StreamProcessorEvent::OnFreeInputPacket { free_input_packet } = self {
11687            Some((free_input_packet))
11688        } else {
11689            None
11690        }
11691    }
11692
11693    /// Decodes a message buffer as a [`StreamProcessorEvent`].
11694    fn decode(
11695        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
11696    ) -> Result<StreamProcessorEvent, fidl::Error> {
11697        let (bytes, _handles) = buf.split_mut();
11698        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11699        debug_assert_eq!(tx_header.tx_id, 0);
11700        match tx_header.ordinal {
11701            0x77ccf70bb061cf8e => {
11702                let mut out = fidl::new_empty!(
11703                    StreamProcessorOnStreamFailedRequest,
11704                    fdomain_client::fidl::FDomainResourceDialect
11705                );
11706                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnStreamFailedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
11707                Ok((StreamProcessorEvent::OnStreamFailed {
11708                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
11709                    error: out.error,
11710                }))
11711            }
11712            0x211da9966a8ca0 => {
11713                let mut out = fidl::new_empty!(
11714                    StreamProcessorOnInputConstraintsRequest,
11715                    fdomain_client::fidl::FDomainResourceDialect
11716                );
11717                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnInputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
11718                Ok((StreamProcessorEvent::OnInputConstraints {
11719                    input_constraints: out.input_constraints,
11720                }))
11721            }
11722            0x40d8234504c170f3 => {
11723                let mut out = fidl::new_empty!(
11724                    StreamProcessorOnOutputConstraintsRequest,
11725                    fdomain_client::fidl::FDomainResourceDialect
11726                );
11727                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnOutputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
11728                Ok((StreamProcessorEvent::OnOutputConstraints { output_config: out.output_config }))
11729            }
11730            0x131b77ae120360bc => {
11731                let mut out = fidl::new_empty!(
11732                    StreamProcessorOnOutputFormatRequest,
11733                    fdomain_client::fidl::FDomainResourceDialect
11734                );
11735                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnOutputFormatRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
11736                Ok((StreamProcessorEvent::OnOutputFormat { output_format: out.output_format }))
11737            }
11738            0x5c2029be1090ce93 => {
11739                let mut out = fidl::new_empty!(
11740                    StreamProcessorOnOutputPacketRequest,
11741                    fdomain_client::fidl::FDomainResourceDialect
11742                );
11743                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnOutputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
11744                Ok((StreamProcessorEvent::OnOutputPacket {
11745                    output_packet: out.output_packet,
11746                    error_detected_before: out.error_detected_before,
11747                    error_detected_during: out.error_detected_during,
11748                }))
11749            }
11750            0x3bb65d237cfa50e6 => {
11751                let mut out = fidl::new_empty!(
11752                    StreamProcessorOnOutputEndOfStreamRequest,
11753                    fdomain_client::fidl::FDomainResourceDialect
11754                );
11755                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnOutputEndOfStreamRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
11756                Ok((StreamProcessorEvent::OnOutputEndOfStream {
11757                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
11758                    error_detected_before: out.error_detected_before,
11759                }))
11760            }
11761            0xeef799b28708bbd => {
11762                let mut out = fidl::new_empty!(
11763                    StreamProcessorOnFreeInputPacketRequest,
11764                    fdomain_client::fidl::FDomainResourceDialect
11765                );
11766                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnFreeInputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
11767                Ok((StreamProcessorEvent::OnFreeInputPacket {
11768                    free_input_packet: out.free_input_packet,
11769                }))
11770            }
11771            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
11772                Ok(StreamProcessorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
11773            }
11774            _ => Err(fidl::Error::UnknownOrdinal {
11775                ordinal: tx_header.ordinal,
11776                protocol_name:
11777                    <StreamProcessorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
11778            }),
11779        }
11780    }
11781}
11782
11783/// A Stream of incoming requests for fuchsia.media/StreamProcessor.
11784pub struct StreamProcessorRequestStream {
11785    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
11786    is_terminated: bool,
11787}
11788
11789impl std::marker::Unpin for StreamProcessorRequestStream {}
11790
11791impl futures::stream::FusedStream for StreamProcessorRequestStream {
11792    fn is_terminated(&self) -> bool {
11793        self.is_terminated
11794    }
11795}
11796
11797impl fdomain_client::fidl::RequestStream for StreamProcessorRequestStream {
11798    type Protocol = StreamProcessorMarker;
11799    type ControlHandle = StreamProcessorControlHandle;
11800
11801    fn from_channel(channel: fdomain_client::Channel) -> Self {
11802        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
11803    }
11804
11805    fn control_handle(&self) -> Self::ControlHandle {
11806        StreamProcessorControlHandle { inner: self.inner.clone() }
11807    }
11808
11809    fn into_inner(
11810        self,
11811    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
11812    {
11813        (self.inner, self.is_terminated)
11814    }
11815
11816    fn from_inner(
11817        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
11818        is_terminated: bool,
11819    ) -> Self {
11820        Self { inner, is_terminated }
11821    }
11822}
11823
11824impl futures::Stream for StreamProcessorRequestStream {
11825    type Item = Result<StreamProcessorRequest, fidl::Error>;
11826
11827    fn poll_next(
11828        mut self: std::pin::Pin<&mut Self>,
11829        cx: &mut std::task::Context<'_>,
11830    ) -> std::task::Poll<Option<Self::Item>> {
11831        let this = &mut *self;
11832        if this.inner.check_shutdown(cx) {
11833            this.is_terminated = true;
11834            return std::task::Poll::Ready(None);
11835        }
11836        if this.is_terminated {
11837            panic!("polled StreamProcessorRequestStream after completion");
11838        }
11839        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
11840            |bytes, handles| {
11841                match this.inner.channel().read_etc(cx, bytes, handles) {
11842                    std::task::Poll::Ready(Ok(())) => {}
11843                    std::task::Poll::Pending => return std::task::Poll::Pending,
11844                    std::task::Poll::Ready(Err(None)) => {
11845                        this.is_terminated = true;
11846                        return std::task::Poll::Ready(None);
11847                    }
11848                    std::task::Poll::Ready(Err(Some(e))) => {
11849                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
11850                            e.into(),
11851                        ))));
11852                    }
11853                }
11854
11855                // A message has been received from the channel
11856                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11857
11858                std::task::Poll::Ready(Some(match header.ordinal {
11859                0x3940929617dbf02b => {
11860                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11861                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
11862                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
11863                    let control_handle = StreamProcessorControlHandle {
11864                        inner: this.inner.clone(),
11865                    };
11866                    Ok(StreamProcessorRequest::EnableOnStreamFailed {
11867                        control_handle,
11868                    })
11869                }
11870                0xb02e0663a40e4c4 => {
11871                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11872                    let mut req = fidl::new_empty!(StreamProcessorSetInputBufferPartialSettingsRequest, fdomain_client::fidl::FDomainResourceDialect);
11873                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorSetInputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
11874                    let control_handle = StreamProcessorControlHandle {
11875                        inner: this.inner.clone(),
11876                    };
11877                    Ok(StreamProcessorRequest::SetInputBufferPartialSettings {input_settings: req.input_settings,
11878
11879                        control_handle,
11880                    })
11881                }
11882                0x118bb8c819a7bbbb => {
11883                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11884                    let mut req = fidl::new_empty!(StreamProcessorSetOutputBufferPartialSettingsRequest, fdomain_client::fidl::FDomainResourceDialect);
11885                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorSetOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
11886                    let control_handle = StreamProcessorControlHandle {
11887                        inner: this.inner.clone(),
11888                    };
11889                    Ok(StreamProcessorRequest::SetOutputBufferPartialSettings {output_settings: req.output_settings,
11890
11891                        control_handle,
11892                    })
11893                }
11894                0x50529e5c680ae3ab => {
11895                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11896                    let mut req = fidl::new_empty!(StreamProcessorCompleteOutputBufferPartialSettingsRequest, fdomain_client::fidl::FDomainResourceDialect);
11897                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
11898                    let control_handle = StreamProcessorControlHandle {
11899                        inner: this.inner.clone(),
11900                    };
11901                    Ok(StreamProcessorRequest::CompleteOutputBufferPartialSettings {buffer_lifetime_ordinal: req.buffer_lifetime_ordinal,
11902
11903                        control_handle,
11904                    })
11905                }
11906                0x2b62c3e26d0667e6 => {
11907                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11908                    let mut req = fidl::new_empty!(StreamProcessorFlushEndOfStreamAndCloseStreamRequest, fdomain_client::fidl::FDomainResourceDialect);
11909                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(&header, _body_bytes, handles, &mut req)?;
11910                    let control_handle = StreamProcessorControlHandle {
11911                        inner: this.inner.clone(),
11912                    };
11913                    Ok(StreamProcessorRequest::FlushEndOfStreamAndCloseStream {stream_lifetime_ordinal: req.stream_lifetime_ordinal,
11914
11915                        control_handle,
11916                    })
11917                }
11918                0x1d8a67522170ca07 => {
11919                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11920                    let mut req = fidl::new_empty!(StreamProcessorCloseCurrentStreamRequest, fdomain_client::fidl::FDomainResourceDialect);
11921                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorCloseCurrentStreamRequest>(&header, _body_bytes, handles, &mut req)?;
11922                    let control_handle = StreamProcessorControlHandle {
11923                        inner: this.inner.clone(),
11924                    };
11925                    Ok(StreamProcessorRequest::CloseCurrentStream {stream_lifetime_ordinal: req.stream_lifetime_ordinal,
11926release_input_buffers: req.release_input_buffers,
11927release_output_buffers: req.release_output_buffers,
11928
11929                        control_handle,
11930                    })
11931                }
11932                0x4b3e44300b0ec6aa => {
11933                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11934                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
11935                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
11936                    let control_handle = StreamProcessorControlHandle {
11937                        inner: this.inner.clone(),
11938                    };
11939                    Ok(StreamProcessorRequest::Sync {
11940                        responder: StreamProcessorSyncResponder {
11941                            control_handle: std::mem::ManuallyDrop::new(control_handle),
11942                            tx_id: header.tx_id,
11943                        },
11944                    })
11945                }
11946                0x32763632b94e0bd5 => {
11947                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11948                    let mut req = fidl::new_empty!(StreamProcessorRecycleOutputPacketRequest, fdomain_client::fidl::FDomainResourceDialect);
11949                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorRecycleOutputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
11950                    let control_handle = StreamProcessorControlHandle {
11951                        inner: this.inner.clone(),
11952                    };
11953                    Ok(StreamProcessorRequest::RecycleOutputPacket {available_output_packet: req.available_output_packet,
11954
11955                        control_handle,
11956                    })
11957                }
11958                0x170dc0979d52231 => {
11959                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11960                    let mut req = fidl::new_empty!(StreamProcessorQueueInputFormatDetailsRequest, fdomain_client::fidl::FDomainResourceDialect);
11961                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorQueueInputFormatDetailsRequest>(&header, _body_bytes, handles, &mut req)?;
11962                    let control_handle = StreamProcessorControlHandle {
11963                        inner: this.inner.clone(),
11964                    };
11965                    Ok(StreamProcessorRequest::QueueInputFormatDetails {stream_lifetime_ordinal: req.stream_lifetime_ordinal,
11966format_details: req.format_details,
11967
11968                        control_handle,
11969                    })
11970                }
11971                0x47173d2652d9df3b => {
11972                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11973                    let mut req = fidl::new_empty!(StreamProcessorQueueInputPacketRequest, fdomain_client::fidl::FDomainResourceDialect);
11974                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorQueueInputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
11975                    let control_handle = StreamProcessorControlHandle {
11976                        inner: this.inner.clone(),
11977                    };
11978                    Ok(StreamProcessorRequest::QueueInputPacket {packet: req.packet,
11979
11980                        control_handle,
11981                    })
11982                }
11983                0x2051b6ad00f20b37 => {
11984                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11985                    let mut req = fidl::new_empty!(StreamProcessorQueueInputEndOfStreamRequest, fdomain_client::fidl::FDomainResourceDialect);
11986                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorQueueInputEndOfStreamRequest>(&header, _body_bytes, handles, &mut req)?;
11987                    let control_handle = StreamProcessorControlHandle {
11988                        inner: this.inner.clone(),
11989                    };
11990                    Ok(StreamProcessorRequest::QueueInputEndOfStream {stream_lifetime_ordinal: req.stream_lifetime_ordinal,
11991
11992                        control_handle,
11993                    })
11994                }
11995                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
11996                    Ok(StreamProcessorRequest::_UnknownMethod {
11997                        ordinal: header.ordinal,
11998                        control_handle: StreamProcessorControlHandle { inner: this.inner.clone() },
11999                        method_type: fidl::MethodType::OneWay,
12000                    })
12001                }
12002                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
12003                    this.inner.send_framework_err(
12004                        fidl::encoding::FrameworkErr::UnknownMethod,
12005                        header.tx_id,
12006                        header.ordinal,
12007                        header.dynamic_flags(),
12008                        (bytes, handles),
12009                    )?;
12010                    Ok(StreamProcessorRequest::_UnknownMethod {
12011                        ordinal: header.ordinal,
12012                        control_handle: StreamProcessorControlHandle { inner: this.inner.clone() },
12013                        method_type: fidl::MethodType::TwoWay,
12014                    })
12015                }
12016                _ => Err(fidl::Error::UnknownOrdinal {
12017                    ordinal: header.ordinal,
12018                    protocol_name: <StreamProcessorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
12019                }),
12020            }))
12021            },
12022        )
12023    }
12024}
12025
12026/// Overview of operation:
12027///
12028/// 1. Create
12029///   * create via CodecFactory - see CodecFactory
12030///   * create via LicenseSession - see LicenseSession
12031/// 2. Get input constraints
12032///   * OnInputConstraints() - sent unsolicited by stream processor shortly after
12033///     stream processor creation.
12034/// 3. Provide input buffers
12035///   * SetInputBufferPartialSettings()
12036/// 4. Deliver input data
12037///   * QueueInputPacket() + OnFreeInputPacket(), for as long as it takes,
12038///     possibly working through all input packets repeatedly before...
12039/// 5. Get output constraints and format
12040///   * OnOutputConstraints()
12041///   * This is not sent until after at least one QueueInput* message is sent by
12042///     the client, even if the underlying processor behind the StreamProcessor
12043///     doesn't fundamentally need any input data to determine its output
12044///     constraints.  This server behavior prevents clients taking an incorrect
12045///     dependency on the output constraints showing up before input is
12046///     delivered.
12047///   * A client must tolerate this arriving as late as after substantial input
12048///     data has been delivered, including lots of input packet recycling via
12049///     OnFreeInputPacket().
12050///   * This message can arrive more than once before the first output data.
12051/// 6. Provide output buffers
12052///   * SetOutputBufferPartialSettings() / CompleteOutputBufferPartialSettings()
12053/// 7. Data flows, with optional EndOfStream
12054///   * OnOutputPacket() / RecycleOutputPacket() / QueueInputPacket() /
12055///     OnFreeInputPacket() / QueueInputEndOfStream() / OnOutputEndOfStream()
12056///
12057/// Semi-trusted StreamProcessor server - SW decoders run in an isolate (with
12058/// very few capabilities) just in case the decoding SW has a vulnerability
12059/// which could be used to take over the StreamProcessor server.  Clients of the
12060/// stream processor interface using decoders and processing streams of separate
12061/// security contexts, to a greater extent than some other interfaces, need to
12062/// protect themselves against invalid server behavior, such as double-free of a
12063/// packet_index and any other invalid server behavior.  Having fed in
12064/// compressed data of one security context, don't place too much trust in a
12065/// single StreamProcessor instance to not mix data among any buffers that
12066/// StreamProcessor server has ever been told about.  Instead, create separate
12067/// StreamProcessor instances for use by security-separate client-side contexts.
12068/// While the picture for HW-based decoders looks somewhat different and is out
12069/// of scope of this paragraph, the client should always use separate
12070/// StreamProcessor instances for security-separate client-side contexts.
12071///
12072/// Descriptions of actions taken by methods of this protocol and the states of
12073/// things are given as if the methods are synchronously executed by the stream
12074/// processor server, but in reality, as is typical of FIDL interfaces, the
12075/// message processing is async.  The states described are to be read as the
12076/// state from the client's point of view unless otherwise stated.  Events
12077/// coming back from the server are of course delivered async, and a client that
12078/// processes more than one stream per StreamProcessor instance needs to care
12079/// whether a given event is from the current stream vs. some older
12080/// soon-to-be-gone stream.
12081///
12082/// The Sync() method's main purpose is to enable the client to robustly prevent
12083/// having both old and new buffers allocated in the system at the same time,
12084/// since media buffers can be significantly large, depending. The Sync() method
12085/// achieves this by only delivering it's response when all previous calls to
12086/// the StreamProcessor protocol have actually taken effect in the
12087/// StreamControl ordering domain. Sync() can also be used to wait for the
12088/// stream processor server to catch up if there's a possibility that a client
12089/// might otherwise get too far ahead of the StreamProcessor server, by for
12090/// example requesting creation of a large number of streams in a row.  It can
12091/// also be used during debugging to ensure that a stream processor server
12092/// hasn't gotten stuck.  Calling Sync() is entirely optional and never required
12093/// for correctness - only potentially required to de-overlap resource usage.
12094///
12095/// It's possible to re-use a StreamProcessor instance for another stream, and
12096/// doing so can sometimes skip over re-allocation of buffers. This can be a
12097/// useful thing to do for cases like seeking to a new location - at the
12098/// StreamProcessor interface that can look like switching to a new stream.
12099#[derive(Debug)]
12100pub enum StreamProcessorRequest {
12101    /// Permit the server to use OnStreamFailed() instead of the server just
12102    /// closing the whole StreamProcessor channel on stream failure.
12103    ///
12104    /// If the server hasn't seen this message by the time a stream fails, the
12105    /// server will close the StreamProcessor channel instead of sending
12106    /// OnStreamFailed().
12107    EnableOnStreamFailed { control_handle: StreamProcessorControlHandle },
12108    /// This is the replacement for SetInputBufferSettings().
12109    ///
12110    /// When the client is using sysmem to allocate buffers, this message is
12111    /// used instead of SetInputBufferSettings()+AddInputBuffer().  Instead, a
12112    /// single SetInputBufferPartialSettings() provides the StreamProcessor with
12113    /// the client-specified input settings and a BufferCollectionToken which
12114    /// the StreamProcessor will use to convey constraints to sysmem.  Both the
12115    /// client and the StreamProcessor will be informed of the allocated buffers
12116    /// directly by sysmem via their BufferCollection channel (not via the
12117    /// StreamProcessor channel).
12118    ///
12119    /// The client must not QueueInput...() until after sysmem informs the client
12120    /// that buffer allocation has completed and was successful.
12121    ///
12122    /// The server should be prepared to see QueueInput...() before the server
12123    /// has necessarily heard from sysmem that the buffers are allocated - the
12124    /// server must tolerate either ordering, as the QueueInput...() and
12125    /// notification of sysmem allocation completion arrive on different
12126    /// channels, so the client having heard that allocation is complete doesn't
12127    /// mean the server knows that allocation is complete yet.  However, the
12128    /// server can expect that allocation is in fact complete and can expect to
12129    /// get the allocation information from sysmem immediately upon requesting
12130    /// the information from sysmem.
12131    SetInputBufferPartialSettings {
12132        input_settings: StreamBufferPartialSettings,
12133        control_handle: StreamProcessorControlHandle,
12134    },
12135    /// This is the replacement for SetOutputBufferSettings().
12136    ///
12137    /// When the client is using sysmem to allocate buffers, this message is
12138    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
12139    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
12140    /// with the client-specified output settings and a BufferCollectionToken
12141    /// which the StreamProcessor will use to convey constraints to sysmem.
12142    /// Both the client and the StreamProcessor will be informed of the
12143    /// allocated buffers directly by sysmem via their BufferCollection channel
12144    /// (not via the StreamProcessor channel).
12145    ///
12146    /// Configuring output buffers is _required_ after OnOutputConstraints() is
12147    /// received by the client with buffer_constraints_action_required true and
12148    /// stream_lifetime_ordinal equal to the client's current
12149    /// stream_lifetime_ordinal (even if there is an active stream), and is
12150    /// _permitted_ any time there is no current stream.
12151    ///
12152    /// Closing the current stream occurs on the StreamControl ordering domain,
12153    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
12154    /// subsequent Sync() completion must be received by the client before the
12155    /// client knows that there's no longer a current stream.
12156    ///
12157    /// See also CompleteOutputBufferPartialSettings().
12158    SetOutputBufferPartialSettings {
12159        output_settings: StreamBufferPartialSettings,
12160        control_handle: StreamProcessorControlHandle,
12161    },
12162    /// After SetOutputBufferPartialSettings(), the server won't send
12163    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
12164    /// OnOutputEndOfStream() until after the client sends
12165    /// CompleteOutputBufferPartialSettings().
12166    ///
12167    /// Some clients may be able to send
12168    /// CompleteOutputBufferPartialSettings() immediately after
12169    /// SetOutputBufferPartialSettings() - in that case the client needs to be
12170    /// prepared to receive output without knowing the buffer count or packet
12171    /// count yet - such clients may internally delay processing the received
12172    /// output until the client has heard from sysmem (which is when the client
12173    /// will learn the buffer count and packet count).
12174    ///
12175    /// Other clients may first wait for sysmem to allocate, prepare to receive
12176    /// output, and then send CompleteOutputBufferPartialSettings().
12177    CompleteOutputBufferPartialSettings {
12178        buffer_lifetime_ordinal: u64,
12179        control_handle: StreamProcessorControlHandle,
12180    },
12181    /// This message is optional.
12182    ///
12183    /// This message is only valid after QueueInputEndOfStream() for this stream.
12184    /// The stream_lifetime_ordinal input parameter must match the
12185    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
12186    /// will close the channel.
12187    ///
12188    /// A client can use this message to flush through (not discard) the last
12189    /// input data of a stream so that the stream processor server generates
12190    /// corresponding output data for all the input data before the server moves
12191    /// on to the next stream, without forcing the client to wait for
12192    /// OnOutputEndOfStream() before queueing data of another stream.
12193    ///
12194    /// The difference between QueueInputEndOfStream() and
12195    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
12196    /// from the client that there will not be any more input data for the
12197    /// stream (and this info is needed by some stream processors for the stream
12198    /// processor to ever emit the very last output data).  The
12199    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
12200    /// later completely discarding the rest of the current stream by closing
12201    /// the current stream (with or without a stream switch).  In contrast,
12202    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
12203    /// the previously-queued input data be processed including the logical
12204    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
12205    /// before moving on to any newer stream - this essentially changes the
12206    /// close-stream handling from discard to flush-through for this stream
12207    /// only.
12208    ///
12209    /// A client using this message can start providing input data for a new
12210    /// stream without that causing discard of old stream data.  That's the
12211    /// purpose of this message - to allow a client to flush through (not
12212    /// discard) the old stream's last data (instead of the default when closing
12213    /// or switching streams which is discard).
12214    ///
12215    /// Because the old stream is not done processing yet and the old stream's
12216    /// data is not being discarded, the client must be prepared to continue to
12217    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
12218    /// is done. The client will know the stream_lifetime_ordinal is done when
12219    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
12220    /// closes.
12221    FlushEndOfStreamAndCloseStream {
12222        stream_lifetime_ordinal: u64,
12223        control_handle: StreamProcessorControlHandle,
12224    },
12225    /// This "closes" the current stream, leaving no current stream.  In
12226    /// addition, this message can optionally release input buffers or output
12227    /// buffers.
12228    ///
12229    /// If there has never been any active stream, the stream_lifetime_ordinal
12230    /// must be zero or the server will close the channel.  If there has been an
12231    /// active stream, the stream_lifetime_ordinal must be the most recent
12232    /// active stream whether that stream is still active or not.  Else the
12233    /// server will close the channel.
12234    ///
12235    /// Multiple of this message without any new active stream in between is not
12236    /// to be considered an error, which allows a client to use this message to
12237    /// close the current stream to stop wasting processing power on a stream the
12238    /// user no longer cares about, then later decide that buffers should be
12239    /// released and send this message again with release_input_buffers and/or
12240    /// release_output_buffers true to get the buffers released, if the client is
12241    /// interested in trying to avoid overlap in resource usage between old
12242    /// buffers and new buffers (not all clients are).
12243    ///
12244    /// See also Sync().
12245    CloseCurrentStream {
12246        stream_lifetime_ordinal: u64,
12247        release_input_buffers: bool,
12248        release_output_buffers: bool,
12249        control_handle: StreamProcessorControlHandle,
12250    },
12251    /// On completion, all previous StreamProcessor calls have done what they're
12252    /// going to do server-side, _except_ for processing of data queued using
12253    /// QueueInputPacket().
12254    ///
12255    /// The main purpose of this call is to enable the client to wait until
12256    /// CloseCurrentStream() with release_input_buffers and/or
12257    /// release_output_buffers set to true to take effect, before the client
12258    /// allocates new buffers and re-sets-up input and/or output buffers.  This
12259    /// de-overlapping of resource usage can be worthwhile for media buffers
12260    /// which can consume resource types whose overall pools aren't necessarily
12261    /// vast in comparison to resources consumed.  Especially if a client is
12262    /// reconfiguring buffers multiple times.
12263    ///
12264    /// Note that Sync() prior to allocating new media buffers is not alone
12265    /// sufficient to achieve non-overlap of media buffer resource usage system
12266    /// wide, but it can be a useful part of achieving that.
12267    ///
12268    /// The Sync() transits the Output ordering domain and the StreamControl
12269    /// ordering domain, but not the InputData ordering domain.
12270    ///
12271    /// This request can be used to avoid hitting kMaxInFlightStreams which is
12272    /// presently 10.  A client that stays <= 8 in-flight streams will
12273    /// comfortably stay under the limit of 10.  While the protocol permits
12274    /// repeated SetInputBufferSettings() and the like, a client that spams the
12275    /// channel can expect that the channel will just close if the server or the
12276    /// channel itself gets too far behind.
12277    Sync { responder: StreamProcessorSyncResponder },
12278    /// After the client is done with an output packet, the client needs to tell
12279    /// the stream processor that the output packet can be re-used for more
12280    /// output, via this method.
12281    ///
12282    /// It's not permitted to recycle an output packet that's already free with
12283    /// the stream processor server.  It's permitted but discouraged for a
12284    /// client to recycle an output packet that has been deallocated by an
12285    /// explicit or implicit output buffer de-configuration().  See
12286    /// buffer_lifetime_ordinal for more on that. A server must ignore any such
12287    /// stale RecycleOutputPacket() calls.
12288    RecycleOutputPacket {
12289        available_output_packet: PacketHeader,
12290        control_handle: StreamProcessorControlHandle,
12291    },
12292    /// If the input format details are still the same as specified during
12293    /// StreamProcessor creation, this message is unnecessary and does not need
12294    /// to be sent.
12295    ///
12296    /// If the stream doesn't exist yet, this message creates the stream.
12297    ///
12298    /// The server won't send OnOutputConstraints() until after the client has
12299    /// sent at least one QueueInput* message.
12300    ///
12301    /// All servers must permit QueueInputFormatDetails() at the start of a
12302    /// stream without failing, as long as the new format is supported by the
12303    /// StreamProcessor instance.  Technically this allows for a server to only
12304    /// support the exact input format set during StreamProcessor creation, and
12305    /// that is by design.  A client that tries to switch formats and gets a
12306    /// StreamProcessor channel failure should try again one more time with a
12307    /// fresh StreamProcessor instance created with CodecFactory using the new
12308    /// input format during creation, before giving up.
12309    ///
12310    /// These format details override the format details specified during stream
12311    /// processor creation for this stream only.  The next stream will default
12312    /// back to the format details set during stream processor creation.
12313    ///
12314    /// This message is permitted at the start of the first stream (just like at
12315    /// the start of any stream).  The format specified need not match what was
12316    /// specified during stream processor creation, but if it doesn't match, the
12317    /// StreamProcessor channel might close as described above.
12318    QueueInputFormatDetails {
12319        stream_lifetime_ordinal: u64,
12320        format_details: FormatDetails,
12321        control_handle: StreamProcessorControlHandle,
12322    },
12323    /// This message queues input data to the stream processor for processing.
12324    ///
12325    /// If the stream doesn't exist yet, this message creates the new stream.
12326    ///
12327    /// The server won't send OnOutputConstraints() until after the client has
12328    /// sent at least one QueueInput* message.
12329    ///
12330    /// The client must continue to deliver input data via this message even if
12331    /// the stream processor has not yet generated the first OnOutputConstraints(),
12332    /// and even if the StreamProcessor is generating OnFreeInputPacket() for
12333    /// previously-queued input packets.  The input data must continue as long
12334    /// as there are free packets to be assured that the server will ever
12335    /// generate the first OnOutputConstraints().
12336    QueueInputPacket { packet: Packet, control_handle: StreamProcessorControlHandle },
12337    /// Inform the server that all QueueInputPacket() messages for this stream
12338    /// have been sent.
12339    ///
12340    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
12341    /// or StreamProcessor channel closing), there will later be a corresponding
12342    /// OnOutputEndOfStream().
12343    ///
12344    /// The corresponding OnOutputEndOfStream() message will be generated only if
12345    /// the server finishes processing the stream before the server sees the
12346    /// client close the stream (such as by starting a new stream).  A way to
12347    /// force the server to finish the stream before closing is to use
12348    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before any
12349    /// new stream.  Another way to force the server to finish the stream before
12350    /// closing is to wait for the OnOutputEndOfStream() before taking any action
12351    /// that closes the stream.
12352    ///
12353    /// In addition to serving as an "EndOfStream" marker to make it obvious
12354    /// client-side when all input data has been processed, if a client never
12355    /// sends QueueInputEndOfStream(), no amount of waiting will necessarily
12356    /// result in all input data getting processed through to the output.  Some
12357    /// stream processors have some internally-delayed data which only gets
12358    /// pushed through by additional input data _or_ by this EndOfStream marker.
12359    /// In that sense, this message can be viewed as a flush-through at
12360    /// InputData domain level, but the flush-through only takes effect if the
12361    /// stream processor even gets that far before the stream is just closed at
12362    /// StreamControl domain level.  This message is not alone sufficient to act
12363    /// as an overall flush-through at StreamControl level. For that, send this
12364    /// message first and then send FlushEndOfStreamAndCloseStream() (at which
12365    /// point it becomes possible to queue input data for a new stream without
12366    /// causing discard of this older stream's data), or wait for the
12367    /// OnOutputEndOfStream() before closing the current stream.
12368    ///
12369    /// If a client sends QueueInputPacket(), QueueInputFormatDetails(),
12370    /// QueueInputEndOfStream() for this stream after the first
12371    /// QueueInputEndOfStream() for this stream, a server should close the
12372    /// StreamProcessor channel.
12373    QueueInputEndOfStream {
12374        stream_lifetime_ordinal: u64,
12375        control_handle: StreamProcessorControlHandle,
12376    },
12377    /// An interaction was received which does not match any known method.
12378    #[non_exhaustive]
12379    _UnknownMethod {
12380        /// Ordinal of the method that was called.
12381        ordinal: u64,
12382        control_handle: StreamProcessorControlHandle,
12383        method_type: fidl::MethodType,
12384    },
12385}
12386
12387impl StreamProcessorRequest {
12388    #[allow(irrefutable_let_patterns)]
12389    pub fn into_enable_on_stream_failed(self) -> Option<(StreamProcessorControlHandle)> {
12390        if let StreamProcessorRequest::EnableOnStreamFailed { control_handle } = self {
12391            Some((control_handle))
12392        } else {
12393            None
12394        }
12395    }
12396
12397    #[allow(irrefutable_let_patterns)]
12398    pub fn into_set_input_buffer_partial_settings(
12399        self,
12400    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
12401        if let StreamProcessorRequest::SetInputBufferPartialSettings {
12402            input_settings,
12403            control_handle,
12404        } = self
12405        {
12406            Some((input_settings, control_handle))
12407        } else {
12408            None
12409        }
12410    }
12411
12412    #[allow(irrefutable_let_patterns)]
12413    pub fn into_set_output_buffer_partial_settings(
12414        self,
12415    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
12416        if let StreamProcessorRequest::SetOutputBufferPartialSettings {
12417            output_settings,
12418            control_handle,
12419        } = self
12420        {
12421            Some((output_settings, control_handle))
12422        } else {
12423            None
12424        }
12425    }
12426
12427    #[allow(irrefutable_let_patterns)]
12428    pub fn into_complete_output_buffer_partial_settings(
12429        self,
12430    ) -> Option<(u64, StreamProcessorControlHandle)> {
12431        if let StreamProcessorRequest::CompleteOutputBufferPartialSettings {
12432            buffer_lifetime_ordinal,
12433            control_handle,
12434        } = self
12435        {
12436            Some((buffer_lifetime_ordinal, control_handle))
12437        } else {
12438            None
12439        }
12440    }
12441
12442    #[allow(irrefutable_let_patterns)]
12443    pub fn into_flush_end_of_stream_and_close_stream(
12444        self,
12445    ) -> Option<(u64, StreamProcessorControlHandle)> {
12446        if let StreamProcessorRequest::FlushEndOfStreamAndCloseStream {
12447            stream_lifetime_ordinal,
12448            control_handle,
12449        } = self
12450        {
12451            Some((stream_lifetime_ordinal, control_handle))
12452        } else {
12453            None
12454        }
12455    }
12456
12457    #[allow(irrefutable_let_patterns)]
12458    pub fn into_close_current_stream(
12459        self,
12460    ) -> Option<(u64, bool, bool, StreamProcessorControlHandle)> {
12461        if let StreamProcessorRequest::CloseCurrentStream {
12462            stream_lifetime_ordinal,
12463            release_input_buffers,
12464            release_output_buffers,
12465            control_handle,
12466        } = self
12467        {
12468            Some((
12469                stream_lifetime_ordinal,
12470                release_input_buffers,
12471                release_output_buffers,
12472                control_handle,
12473            ))
12474        } else {
12475            None
12476        }
12477    }
12478
12479    #[allow(irrefutable_let_patterns)]
12480    pub fn into_sync(self) -> Option<(StreamProcessorSyncResponder)> {
12481        if let StreamProcessorRequest::Sync { responder } = self { Some((responder)) } else { None }
12482    }
12483
12484    #[allow(irrefutable_let_patterns)]
12485    pub fn into_recycle_output_packet(
12486        self,
12487    ) -> Option<(PacketHeader, StreamProcessorControlHandle)> {
12488        if let StreamProcessorRequest::RecycleOutputPacket {
12489            available_output_packet,
12490            control_handle,
12491        } = self
12492        {
12493            Some((available_output_packet, control_handle))
12494        } else {
12495            None
12496        }
12497    }
12498
12499    #[allow(irrefutable_let_patterns)]
12500    pub fn into_queue_input_format_details(
12501        self,
12502    ) -> Option<(u64, FormatDetails, StreamProcessorControlHandle)> {
12503        if let StreamProcessorRequest::QueueInputFormatDetails {
12504            stream_lifetime_ordinal,
12505            format_details,
12506            control_handle,
12507        } = self
12508        {
12509            Some((stream_lifetime_ordinal, format_details, control_handle))
12510        } else {
12511            None
12512        }
12513    }
12514
12515    #[allow(irrefutable_let_patterns)]
12516    pub fn into_queue_input_packet(self) -> Option<(Packet, StreamProcessorControlHandle)> {
12517        if let StreamProcessorRequest::QueueInputPacket { packet, control_handle } = self {
12518            Some((packet, control_handle))
12519        } else {
12520            None
12521        }
12522    }
12523
12524    #[allow(irrefutable_let_patterns)]
12525    pub fn into_queue_input_end_of_stream(self) -> Option<(u64, StreamProcessorControlHandle)> {
12526        if let StreamProcessorRequest::QueueInputEndOfStream {
12527            stream_lifetime_ordinal,
12528            control_handle,
12529        } = self
12530        {
12531            Some((stream_lifetime_ordinal, control_handle))
12532        } else {
12533            None
12534        }
12535    }
12536
12537    /// Name of the method defined in FIDL
12538    pub fn method_name(&self) -> &'static str {
12539        match *self {
12540            StreamProcessorRequest::EnableOnStreamFailed { .. } => "enable_on_stream_failed",
12541            StreamProcessorRequest::SetInputBufferPartialSettings { .. } => {
12542                "set_input_buffer_partial_settings"
12543            }
12544            StreamProcessorRequest::SetOutputBufferPartialSettings { .. } => {
12545                "set_output_buffer_partial_settings"
12546            }
12547            StreamProcessorRequest::CompleteOutputBufferPartialSettings { .. } => {
12548                "complete_output_buffer_partial_settings"
12549            }
12550            StreamProcessorRequest::FlushEndOfStreamAndCloseStream { .. } => {
12551                "flush_end_of_stream_and_close_stream"
12552            }
12553            StreamProcessorRequest::CloseCurrentStream { .. } => "close_current_stream",
12554            StreamProcessorRequest::Sync { .. } => "sync",
12555            StreamProcessorRequest::RecycleOutputPacket { .. } => "recycle_output_packet",
12556            StreamProcessorRequest::QueueInputFormatDetails { .. } => "queue_input_format_details",
12557            StreamProcessorRequest::QueueInputPacket { .. } => "queue_input_packet",
12558            StreamProcessorRequest::QueueInputEndOfStream { .. } => "queue_input_end_of_stream",
12559            StreamProcessorRequest::_UnknownMethod {
12560                method_type: fidl::MethodType::OneWay,
12561                ..
12562            } => "unknown one-way method",
12563            StreamProcessorRequest::_UnknownMethod {
12564                method_type: fidl::MethodType::TwoWay,
12565                ..
12566            } => "unknown two-way method",
12567        }
12568    }
12569}
12570
12571#[derive(Debug, Clone)]
12572pub struct StreamProcessorControlHandle {
12573    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
12574}
12575
12576impl fdomain_client::fidl::ControlHandle for StreamProcessorControlHandle {
12577    fn shutdown(&self) {
12578        self.inner.shutdown()
12579    }
12580
12581    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
12582        self.inner.shutdown_with_epitaph(status)
12583    }
12584
12585    fn is_closed(&self) -> bool {
12586        self.inner.channel().is_closed()
12587    }
12588    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
12589        self.inner.channel().on_closed()
12590    }
12591}
12592
12593impl StreamProcessorControlHandle {
12594    pub fn send_on_stream_failed(
12595        &self,
12596        mut stream_lifetime_ordinal: u64,
12597        mut error: StreamError,
12598    ) -> Result<(), fidl::Error> {
12599        self.inner.send::<StreamProcessorOnStreamFailedRequest>(
12600            (stream_lifetime_ordinal, error),
12601            0,
12602            0x77ccf70bb061cf8e,
12603            fidl::encoding::DynamicFlags::empty(),
12604        )
12605    }
12606
12607    pub fn send_on_input_constraints(
12608        &self,
12609        mut input_constraints: &StreamBufferConstraints,
12610    ) -> Result<(), fidl::Error> {
12611        self.inner.send::<StreamProcessorOnInputConstraintsRequest>(
12612            (input_constraints,),
12613            0,
12614            0x211da9966a8ca0,
12615            fidl::encoding::DynamicFlags::empty(),
12616        )
12617    }
12618
12619    pub fn send_on_output_constraints(
12620        &self,
12621        mut output_config: &StreamOutputConstraints,
12622    ) -> Result<(), fidl::Error> {
12623        self.inner.send::<StreamProcessorOnOutputConstraintsRequest>(
12624            (output_config,),
12625            0,
12626            0x40d8234504c170f3,
12627            fidl::encoding::DynamicFlags::empty(),
12628        )
12629    }
12630
12631    pub fn send_on_output_format(
12632        &self,
12633        mut output_format: &StreamOutputFormat,
12634    ) -> Result<(), fidl::Error> {
12635        self.inner.send::<StreamProcessorOnOutputFormatRequest>(
12636            (output_format,),
12637            0,
12638            0x131b77ae120360bc,
12639            fidl::encoding::DynamicFlags::empty(),
12640        )
12641    }
12642
12643    pub fn send_on_output_packet(
12644        &self,
12645        mut output_packet: &Packet,
12646        mut error_detected_before: bool,
12647        mut error_detected_during: bool,
12648    ) -> Result<(), fidl::Error> {
12649        self.inner.send::<StreamProcessorOnOutputPacketRequest>(
12650            (output_packet, error_detected_before, error_detected_during),
12651            0,
12652            0x5c2029be1090ce93,
12653            fidl::encoding::DynamicFlags::empty(),
12654        )
12655    }
12656
12657    pub fn send_on_output_end_of_stream(
12658        &self,
12659        mut stream_lifetime_ordinal: u64,
12660        mut error_detected_before: bool,
12661    ) -> Result<(), fidl::Error> {
12662        self.inner.send::<StreamProcessorOnOutputEndOfStreamRequest>(
12663            (stream_lifetime_ordinal, error_detected_before),
12664            0,
12665            0x3bb65d237cfa50e6,
12666            fidl::encoding::DynamicFlags::empty(),
12667        )
12668    }
12669
12670    pub fn send_on_free_input_packet(
12671        &self,
12672        mut free_input_packet: &PacketHeader,
12673    ) -> Result<(), fidl::Error> {
12674        self.inner.send::<StreamProcessorOnFreeInputPacketRequest>(
12675            (free_input_packet,),
12676            0,
12677            0xeef799b28708bbd,
12678            fidl::encoding::DynamicFlags::empty(),
12679        )
12680    }
12681}
12682
12683#[must_use = "FIDL methods require a response to be sent"]
12684#[derive(Debug)]
12685pub struct StreamProcessorSyncResponder {
12686    control_handle: std::mem::ManuallyDrop<StreamProcessorControlHandle>,
12687    tx_id: u32,
12688}
12689
12690/// Set the the channel to be shutdown (see [`StreamProcessorControlHandle::shutdown`])
12691/// if the responder is dropped without sending a response, so that the client
12692/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12693impl std::ops::Drop for StreamProcessorSyncResponder {
12694    fn drop(&mut self) {
12695        self.control_handle.shutdown();
12696        // Safety: drops once, never accessed again
12697        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12698    }
12699}
12700
12701impl fdomain_client::fidl::Responder for StreamProcessorSyncResponder {
12702    type ControlHandle = StreamProcessorControlHandle;
12703
12704    fn control_handle(&self) -> &StreamProcessorControlHandle {
12705        &self.control_handle
12706    }
12707
12708    fn drop_without_shutdown(mut self) {
12709        // Safety: drops once, never accessed again due to mem::forget
12710        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12711        // Prevent Drop from running (which would shut down the channel)
12712        std::mem::forget(self);
12713    }
12714}
12715
12716impl StreamProcessorSyncResponder {
12717    /// Sends a response to the FIDL transaction.
12718    ///
12719    /// Sets the channel to shutdown if an error occurs.
12720    pub fn send(self) -> Result<(), fidl::Error> {
12721        let _result = self.send_raw();
12722        if _result.is_err() {
12723            self.control_handle.shutdown();
12724        }
12725        self.drop_without_shutdown();
12726        _result
12727    }
12728
12729    /// Similar to "send" but does not shutdown the channel if an error occurs.
12730    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
12731        let _result = self.send_raw();
12732        self.drop_without_shutdown();
12733        _result
12734    }
12735
12736    fn send_raw(&self) -> Result<(), fidl::Error> {
12737        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
12738            (),
12739            self.tx_id,
12740            0x4b3e44300b0ec6aa,
12741            fidl::encoding::DynamicFlags::empty(),
12742        )
12743    }
12744}
12745
12746#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
12747pub struct StreamSinkMarker;
12748
12749impl fdomain_client::fidl::ProtocolMarker for StreamSinkMarker {
12750    type Proxy = StreamSinkProxy;
12751    type RequestStream = StreamSinkRequestStream;
12752
12753    const DEBUG_NAME: &'static str = "(anonymous) StreamSink";
12754}
12755
12756pub trait StreamSinkProxyInterface: Send + Sync {
12757    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
12758    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
12759    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
12760    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
12761    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
12762    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
12763    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
12764}
12765
12766#[derive(Debug, Clone)]
12767pub struct StreamSinkProxy {
12768    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
12769}
12770
12771impl fdomain_client::fidl::Proxy for StreamSinkProxy {
12772    type Protocol = StreamSinkMarker;
12773
12774    fn from_channel(inner: fdomain_client::Channel) -> Self {
12775        Self::new(inner)
12776    }
12777
12778    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
12779        self.client.into_channel().map_err(|client| Self { client })
12780    }
12781
12782    fn as_channel(&self) -> &fdomain_client::Channel {
12783        self.client.as_channel()
12784    }
12785}
12786
12787impl StreamSinkProxy {
12788    /// Create a new Proxy for fuchsia.media/StreamSink.
12789    pub fn new(channel: fdomain_client::Channel) -> Self {
12790        let protocol_name = <StreamSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
12791        Self { client: fidl::client::Client::new(channel, protocol_name) }
12792    }
12793
12794    /// Get a Stream of events from the remote end of the protocol.
12795    ///
12796    /// # Panics
12797    ///
12798    /// Panics if the event stream was already taken.
12799    pub fn take_event_stream(&self) -> StreamSinkEventStream {
12800        StreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
12801    }
12802
12803    /// Sends a packet to the service. The response is sent when the service is
12804    /// done with the associated payload memory.
12805    ///
12806    /// `packet` must be valid for the current buffer set, otherwise the service
12807    /// will close the connection.
12808    pub fn r#send_packet(
12809        &self,
12810        mut packet: &StreamPacket,
12811    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
12812        StreamSinkProxyInterface::r#send_packet(self, packet)
12813    }
12814
12815    /// Sends a packet to the service. This interface doesn't define how the
12816    /// client knows when the sink is done with the associated payload memory.
12817    /// The inheriting interface must define that.
12818    ///
12819    /// `packet` must be valid for the current buffer set, otherwise the service
12820    /// will close the connection.
12821    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12822        StreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
12823    }
12824
12825    /// Indicates the stream has ended. The precise semantics of this method are
12826    /// determined by the inheriting interface.
12827    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12828        StreamSinkProxyInterface::r#end_of_stream(self)
12829    }
12830
12831    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12832    /// and not yet released. The response is sent after all packets have been
12833    /// released.
12834    pub fn r#discard_all_packets(
12835        &self,
12836    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
12837        StreamSinkProxyInterface::r#discard_all_packets(self)
12838    }
12839
12840    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12841    /// and not yet released.
12842    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12843        StreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
12844    }
12845}
12846
12847impl StreamSinkProxyInterface for StreamSinkProxy {
12848    type SendPacketResponseFut =
12849        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
12850    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
12851        fn _decode(
12852            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12853        ) -> Result<(), fidl::Error> {
12854            let _response = fidl::client::decode_transaction_body::<
12855                fidl::encoding::EmptyPayload,
12856                fdomain_client::fidl::FDomainResourceDialect,
12857                0x67cddd607442775f,
12858            >(_buf?)?;
12859            Ok(_response)
12860        }
12861        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
12862            (packet,),
12863            0x67cddd607442775f,
12864            fidl::encoding::DynamicFlags::empty(),
12865            _decode,
12866        )
12867    }
12868
12869    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12870        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
12871            (packet,),
12872            0x8d9b8b413ceba9d,
12873            fidl::encoding::DynamicFlags::empty(),
12874        )
12875    }
12876
12877    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12878        self.client.send::<fidl::encoding::EmptyPayload>(
12879            (),
12880            0x6180fd6f7e793b71,
12881            fidl::encoding::DynamicFlags::empty(),
12882        )
12883    }
12884
12885    type DiscardAllPacketsResponseFut =
12886        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
12887    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
12888        fn _decode(
12889            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12890        ) -> Result<(), fidl::Error> {
12891            let _response = fidl::client::decode_transaction_body::<
12892                fidl::encoding::EmptyPayload,
12893                fdomain_client::fidl::FDomainResourceDialect,
12894                0x6f4dad7af2917665,
12895            >(_buf?)?;
12896            Ok(_response)
12897        }
12898        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
12899            (),
12900            0x6f4dad7af2917665,
12901            fidl::encoding::DynamicFlags::empty(),
12902            _decode,
12903        )
12904    }
12905
12906    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12907        self.client.send::<fidl::encoding::EmptyPayload>(
12908            (),
12909            0x50d36d0d23081bc4,
12910            fidl::encoding::DynamicFlags::empty(),
12911        )
12912    }
12913}
12914
12915pub struct StreamSinkEventStream {
12916    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
12917}
12918
12919impl std::marker::Unpin for StreamSinkEventStream {}
12920
12921impl futures::stream::FusedStream for StreamSinkEventStream {
12922    fn is_terminated(&self) -> bool {
12923        self.event_receiver.is_terminated()
12924    }
12925}
12926
12927impl futures::Stream for StreamSinkEventStream {
12928    type Item = Result<StreamSinkEvent, fidl::Error>;
12929
12930    fn poll_next(
12931        mut self: std::pin::Pin<&mut Self>,
12932        cx: &mut std::task::Context<'_>,
12933    ) -> std::task::Poll<Option<Self::Item>> {
12934        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
12935            &mut self.event_receiver,
12936            cx
12937        )?) {
12938            Some(buf) => std::task::Poll::Ready(Some(StreamSinkEvent::decode(buf))),
12939            None => std::task::Poll::Ready(None),
12940        }
12941    }
12942}
12943
12944#[derive(Debug)]
12945pub enum StreamSinkEvent {}
12946
12947impl StreamSinkEvent {
12948    /// Decodes a message buffer as a [`StreamSinkEvent`].
12949    fn decode(
12950        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
12951    ) -> Result<StreamSinkEvent, fidl::Error> {
12952        let (bytes, _handles) = buf.split_mut();
12953        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12954        debug_assert_eq!(tx_header.tx_id, 0);
12955        match tx_header.ordinal {
12956            _ => Err(fidl::Error::UnknownOrdinal {
12957                ordinal: tx_header.ordinal,
12958                protocol_name:
12959                    <StreamSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
12960            }),
12961        }
12962    }
12963}
12964
12965/// A Stream of incoming requests for fuchsia.media/StreamSink.
12966pub struct StreamSinkRequestStream {
12967    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
12968    is_terminated: bool,
12969}
12970
12971impl std::marker::Unpin for StreamSinkRequestStream {}
12972
12973impl futures::stream::FusedStream for StreamSinkRequestStream {
12974    fn is_terminated(&self) -> bool {
12975        self.is_terminated
12976    }
12977}
12978
12979impl fdomain_client::fidl::RequestStream for StreamSinkRequestStream {
12980    type Protocol = StreamSinkMarker;
12981    type ControlHandle = StreamSinkControlHandle;
12982
12983    fn from_channel(channel: fdomain_client::Channel) -> Self {
12984        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
12985    }
12986
12987    fn control_handle(&self) -> Self::ControlHandle {
12988        StreamSinkControlHandle { inner: self.inner.clone() }
12989    }
12990
12991    fn into_inner(
12992        self,
12993    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
12994    {
12995        (self.inner, self.is_terminated)
12996    }
12997
12998    fn from_inner(
12999        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
13000        is_terminated: bool,
13001    ) -> Self {
13002        Self { inner, is_terminated }
13003    }
13004}
13005
13006impl futures::Stream for StreamSinkRequestStream {
13007    type Item = Result<StreamSinkRequest, fidl::Error>;
13008
13009    fn poll_next(
13010        mut self: std::pin::Pin<&mut Self>,
13011        cx: &mut std::task::Context<'_>,
13012    ) -> std::task::Poll<Option<Self::Item>> {
13013        let this = &mut *self;
13014        if this.inner.check_shutdown(cx) {
13015            this.is_terminated = true;
13016            return std::task::Poll::Ready(None);
13017        }
13018        if this.is_terminated {
13019            panic!("polled StreamSinkRequestStream after completion");
13020        }
13021        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
13022            |bytes, handles| {
13023                match this.inner.channel().read_etc(cx, bytes, handles) {
13024                    std::task::Poll::Ready(Ok(())) => {}
13025                    std::task::Poll::Pending => return std::task::Poll::Pending,
13026                    std::task::Poll::Ready(Err(None)) => {
13027                        this.is_terminated = true;
13028                        return std::task::Poll::Ready(None);
13029                    }
13030                    std::task::Poll::Ready(Err(Some(e))) => {
13031                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
13032                            e.into(),
13033                        ))));
13034                    }
13035                }
13036
13037                // A message has been received from the channel
13038                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13039
13040                std::task::Poll::Ready(Some(match header.ordinal {
13041                    0x67cddd607442775f => {
13042                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
13043                        let mut req = fidl::new_empty!(
13044                            StreamSinkSendPacketRequest,
13045                            fdomain_client::fidl::FDomainResourceDialect
13046                        );
13047                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
13048                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
13049                        Ok(StreamSinkRequest::SendPacket {
13050                            packet: req.packet,
13051
13052                            responder: StreamSinkSendPacketResponder {
13053                                control_handle: std::mem::ManuallyDrop::new(control_handle),
13054                                tx_id: header.tx_id,
13055                            },
13056                        })
13057                    }
13058                    0x8d9b8b413ceba9d => {
13059                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13060                        let mut req = fidl::new_empty!(
13061                            StreamSinkSendPacketNoReplyRequest,
13062                            fdomain_client::fidl::FDomainResourceDialect
13063                        );
13064                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
13065                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
13066                        Ok(StreamSinkRequest::SendPacketNoReply {
13067                            packet: req.packet,
13068
13069                            control_handle,
13070                        })
13071                    }
13072                    0x6180fd6f7e793b71 => {
13073                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13074                        let mut req = fidl::new_empty!(
13075                            fidl::encoding::EmptyPayload,
13076                            fdomain_client::fidl::FDomainResourceDialect
13077                        );
13078                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
13079                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
13080                        Ok(StreamSinkRequest::EndOfStream { control_handle })
13081                    }
13082                    0x6f4dad7af2917665 => {
13083                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
13084                        let mut req = fidl::new_empty!(
13085                            fidl::encoding::EmptyPayload,
13086                            fdomain_client::fidl::FDomainResourceDialect
13087                        );
13088                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
13089                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
13090                        Ok(StreamSinkRequest::DiscardAllPackets {
13091                            responder: StreamSinkDiscardAllPacketsResponder {
13092                                control_handle: std::mem::ManuallyDrop::new(control_handle),
13093                                tx_id: header.tx_id,
13094                            },
13095                        })
13096                    }
13097                    0x50d36d0d23081bc4 => {
13098                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13099                        let mut req = fidl::new_empty!(
13100                            fidl::encoding::EmptyPayload,
13101                            fdomain_client::fidl::FDomainResourceDialect
13102                        );
13103                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
13104                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
13105                        Ok(StreamSinkRequest::DiscardAllPacketsNoReply { control_handle })
13106                    }
13107                    _ => Err(fidl::Error::UnknownOrdinal {
13108                        ordinal: header.ordinal,
13109                        protocol_name:
13110                            <StreamSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
13111                    }),
13112                }))
13113            },
13114        )
13115    }
13116}
13117
13118/// Consumes a stream of packets. This interface is typically inherited along
13119/// with `StreamBufferSet` to enable the transport of elementary streams from
13120/// clients to services.
13121#[derive(Debug)]
13122pub enum StreamSinkRequest {
13123    /// Sends a packet to the service. The response is sent when the service is
13124    /// done with the associated payload memory.
13125    ///
13126    /// `packet` must be valid for the current buffer set, otherwise the service
13127    /// will close the connection.
13128    SendPacket { packet: StreamPacket, responder: StreamSinkSendPacketResponder },
13129    /// Sends a packet to the service. This interface doesn't define how the
13130    /// client knows when the sink is done with the associated payload memory.
13131    /// The inheriting interface must define that.
13132    ///
13133    /// `packet` must be valid for the current buffer set, otherwise the service
13134    /// will close the connection.
13135    SendPacketNoReply { packet: StreamPacket, control_handle: StreamSinkControlHandle },
13136    /// Indicates the stream has ended. The precise semantics of this method are
13137    /// determined by the inheriting interface.
13138    EndOfStream { control_handle: StreamSinkControlHandle },
13139    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
13140    /// and not yet released. The response is sent after all packets have been
13141    /// released.
13142    DiscardAllPackets { responder: StreamSinkDiscardAllPacketsResponder },
13143    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
13144    /// and not yet released.
13145    DiscardAllPacketsNoReply { control_handle: StreamSinkControlHandle },
13146}
13147
13148impl StreamSinkRequest {
13149    #[allow(irrefutable_let_patterns)]
13150    pub fn into_send_packet(self) -> Option<(StreamPacket, StreamSinkSendPacketResponder)> {
13151        if let StreamSinkRequest::SendPacket { packet, responder } = self {
13152            Some((packet, responder))
13153        } else {
13154            None
13155        }
13156    }
13157
13158    #[allow(irrefutable_let_patterns)]
13159    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, StreamSinkControlHandle)> {
13160        if let StreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
13161            Some((packet, control_handle))
13162        } else {
13163            None
13164        }
13165    }
13166
13167    #[allow(irrefutable_let_patterns)]
13168    pub fn into_end_of_stream(self) -> Option<(StreamSinkControlHandle)> {
13169        if let StreamSinkRequest::EndOfStream { control_handle } = self {
13170            Some((control_handle))
13171        } else {
13172            None
13173        }
13174    }
13175
13176    #[allow(irrefutable_let_patterns)]
13177    pub fn into_discard_all_packets(self) -> Option<(StreamSinkDiscardAllPacketsResponder)> {
13178        if let StreamSinkRequest::DiscardAllPackets { responder } = self {
13179            Some((responder))
13180        } else {
13181            None
13182        }
13183    }
13184
13185    #[allow(irrefutable_let_patterns)]
13186    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSinkControlHandle)> {
13187        if let StreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
13188            Some((control_handle))
13189        } else {
13190            None
13191        }
13192    }
13193
13194    /// Name of the method defined in FIDL
13195    pub fn method_name(&self) -> &'static str {
13196        match *self {
13197            StreamSinkRequest::SendPacket { .. } => "send_packet",
13198            StreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
13199            StreamSinkRequest::EndOfStream { .. } => "end_of_stream",
13200            StreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
13201            StreamSinkRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
13202        }
13203    }
13204}
13205
13206#[derive(Debug, Clone)]
13207pub struct StreamSinkControlHandle {
13208    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
13209}
13210
13211impl fdomain_client::fidl::ControlHandle for StreamSinkControlHandle {
13212    fn shutdown(&self) {
13213        self.inner.shutdown()
13214    }
13215
13216    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
13217        self.inner.shutdown_with_epitaph(status)
13218    }
13219
13220    fn is_closed(&self) -> bool {
13221        self.inner.channel().is_closed()
13222    }
13223    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
13224        self.inner.channel().on_closed()
13225    }
13226}
13227
13228impl StreamSinkControlHandle {}
13229
13230#[must_use = "FIDL methods require a response to be sent"]
13231#[derive(Debug)]
13232pub struct StreamSinkSendPacketResponder {
13233    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
13234    tx_id: u32,
13235}
13236
13237/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
13238/// if the responder is dropped without sending a response, so that the client
13239/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13240impl std::ops::Drop for StreamSinkSendPacketResponder {
13241    fn drop(&mut self) {
13242        self.control_handle.shutdown();
13243        // Safety: drops once, never accessed again
13244        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13245    }
13246}
13247
13248impl fdomain_client::fidl::Responder for StreamSinkSendPacketResponder {
13249    type ControlHandle = StreamSinkControlHandle;
13250
13251    fn control_handle(&self) -> &StreamSinkControlHandle {
13252        &self.control_handle
13253    }
13254
13255    fn drop_without_shutdown(mut self) {
13256        // Safety: drops once, never accessed again due to mem::forget
13257        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13258        // Prevent Drop from running (which would shut down the channel)
13259        std::mem::forget(self);
13260    }
13261}
13262
13263impl StreamSinkSendPacketResponder {
13264    /// Sends a response to the FIDL transaction.
13265    ///
13266    /// Sets the channel to shutdown if an error occurs.
13267    pub fn send(self) -> Result<(), fidl::Error> {
13268        let _result = self.send_raw();
13269        if _result.is_err() {
13270            self.control_handle.shutdown();
13271        }
13272        self.drop_without_shutdown();
13273        _result
13274    }
13275
13276    /// Similar to "send" but does not shutdown the channel if an error occurs.
13277    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
13278        let _result = self.send_raw();
13279        self.drop_without_shutdown();
13280        _result
13281    }
13282
13283    fn send_raw(&self) -> Result<(), fidl::Error> {
13284        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
13285            (),
13286            self.tx_id,
13287            0x67cddd607442775f,
13288            fidl::encoding::DynamicFlags::empty(),
13289        )
13290    }
13291}
13292
13293#[must_use = "FIDL methods require a response to be sent"]
13294#[derive(Debug)]
13295pub struct StreamSinkDiscardAllPacketsResponder {
13296    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
13297    tx_id: u32,
13298}
13299
13300/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
13301/// if the responder is dropped without sending a response, so that the client
13302/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13303impl std::ops::Drop for StreamSinkDiscardAllPacketsResponder {
13304    fn drop(&mut self) {
13305        self.control_handle.shutdown();
13306        // Safety: drops once, never accessed again
13307        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13308    }
13309}
13310
13311impl fdomain_client::fidl::Responder for StreamSinkDiscardAllPacketsResponder {
13312    type ControlHandle = StreamSinkControlHandle;
13313
13314    fn control_handle(&self) -> &StreamSinkControlHandle {
13315        &self.control_handle
13316    }
13317
13318    fn drop_without_shutdown(mut self) {
13319        // Safety: drops once, never accessed again due to mem::forget
13320        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13321        // Prevent Drop from running (which would shut down the channel)
13322        std::mem::forget(self);
13323    }
13324}
13325
13326impl StreamSinkDiscardAllPacketsResponder {
13327    /// Sends a response to the FIDL transaction.
13328    ///
13329    /// Sets the channel to shutdown if an error occurs.
13330    pub fn send(self) -> Result<(), fidl::Error> {
13331        let _result = self.send_raw();
13332        if _result.is_err() {
13333            self.control_handle.shutdown();
13334        }
13335        self.drop_without_shutdown();
13336        _result
13337    }
13338
13339    /// Similar to "send" but does not shutdown the channel if an error occurs.
13340    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
13341        let _result = self.send_raw();
13342        self.drop_without_shutdown();
13343        _result
13344    }
13345
13346    fn send_raw(&self) -> Result<(), fidl::Error> {
13347        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
13348            (),
13349            self.tx_id,
13350            0x6f4dad7af2917665,
13351            fidl::encoding::DynamicFlags::empty(),
13352        )
13353    }
13354}
13355
13356#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
13357pub struct StreamSourceMarker;
13358
13359impl fdomain_client::fidl::ProtocolMarker for StreamSourceMarker {
13360    type Proxy = StreamSourceProxy;
13361    type RequestStream = StreamSourceRequestStream;
13362
13363    const DEBUG_NAME: &'static str = "(anonymous) StreamSource";
13364}
13365
13366pub trait StreamSourceProxyInterface: Send + Sync {
13367    fn r#release_packet(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
13368    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
13369    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
13370    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
13371}
13372
13373#[derive(Debug, Clone)]
13374pub struct StreamSourceProxy {
13375    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
13376}
13377
13378impl fdomain_client::fidl::Proxy for StreamSourceProxy {
13379    type Protocol = StreamSourceMarker;
13380
13381    fn from_channel(inner: fdomain_client::Channel) -> Self {
13382        Self::new(inner)
13383    }
13384
13385    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
13386        self.client.into_channel().map_err(|client| Self { client })
13387    }
13388
13389    fn as_channel(&self) -> &fdomain_client::Channel {
13390        self.client.as_channel()
13391    }
13392}
13393
13394impl StreamSourceProxy {
13395    /// Create a new Proxy for fuchsia.media/StreamSource.
13396    pub fn new(channel: fdomain_client::Channel) -> Self {
13397        let protocol_name =
13398            <StreamSourceMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
13399        Self { client: fidl::client::Client::new(channel, protocol_name) }
13400    }
13401
13402    /// Get a Stream of events from the remote end of the protocol.
13403    ///
13404    /// # Panics
13405    ///
13406    /// Panics if the event stream was already taken.
13407    pub fn take_event_stream(&self) -> StreamSourceEventStream {
13408        StreamSourceEventStream { event_receiver: self.client.take_event_receiver() }
13409    }
13410
13411    /// Releases payload memory associated with a packet previously delivered
13412    /// via `OnPacketProduced`.
13413    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
13414        StreamSourceProxyInterface::r#release_packet(self, packet)
13415    }
13416
13417    pub fn r#discard_all_packets(
13418        &self,
13419    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
13420        StreamSourceProxyInterface::r#discard_all_packets(self)
13421    }
13422
13423    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
13424        StreamSourceProxyInterface::r#discard_all_packets_no_reply(self)
13425    }
13426}
13427
13428impl StreamSourceProxyInterface for StreamSourceProxy {
13429    fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
13430        self.client.send::<StreamSourceReleasePacketRequest>(
13431            (packet,),
13432            0x7a7b57f0f7d9e4bb,
13433            fidl::encoding::DynamicFlags::empty(),
13434        )
13435    }
13436
13437    type DiscardAllPacketsResponseFut =
13438        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
13439    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
13440        fn _decode(
13441            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
13442        ) -> Result<(), fidl::Error> {
13443            let _response = fidl::client::decode_transaction_body::<
13444                fidl::encoding::EmptyPayload,
13445                fdomain_client::fidl::FDomainResourceDialect,
13446                0x27afd605e97b09d2,
13447            >(_buf?)?;
13448            Ok(_response)
13449        }
13450        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
13451            (),
13452            0x27afd605e97b09d2,
13453            fidl::encoding::DynamicFlags::empty(),
13454            _decode,
13455        )
13456    }
13457
13458    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
13459        self.client.send::<fidl::encoding::EmptyPayload>(
13460            (),
13461            0x35f9d721e905b831,
13462            fidl::encoding::DynamicFlags::empty(),
13463        )
13464    }
13465}
13466
13467pub struct StreamSourceEventStream {
13468    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
13469}
13470
13471impl std::marker::Unpin for StreamSourceEventStream {}
13472
13473impl futures::stream::FusedStream for StreamSourceEventStream {
13474    fn is_terminated(&self) -> bool {
13475        self.event_receiver.is_terminated()
13476    }
13477}
13478
13479impl futures::Stream for StreamSourceEventStream {
13480    type Item = Result<StreamSourceEvent, fidl::Error>;
13481
13482    fn poll_next(
13483        mut self: std::pin::Pin<&mut Self>,
13484        cx: &mut std::task::Context<'_>,
13485    ) -> std::task::Poll<Option<Self::Item>> {
13486        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
13487            &mut self.event_receiver,
13488            cx
13489        )?) {
13490            Some(buf) => std::task::Poll::Ready(Some(StreamSourceEvent::decode(buf))),
13491            None => std::task::Poll::Ready(None),
13492        }
13493    }
13494}
13495
13496#[derive(Debug)]
13497pub enum StreamSourceEvent {
13498    OnPacketProduced { packet: StreamPacket },
13499    OnEndOfStream {},
13500}
13501
13502impl StreamSourceEvent {
13503    #[allow(irrefutable_let_patterns)]
13504    pub fn into_on_packet_produced(self) -> Option<StreamPacket> {
13505        if let StreamSourceEvent::OnPacketProduced { packet } = self {
13506            Some((packet))
13507        } else {
13508            None
13509        }
13510    }
13511    #[allow(irrefutable_let_patterns)]
13512    pub fn into_on_end_of_stream(self) -> Option<()> {
13513        if let StreamSourceEvent::OnEndOfStream {} = self { Some(()) } else { None }
13514    }
13515
13516    /// Decodes a message buffer as a [`StreamSourceEvent`].
13517    fn decode(
13518        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
13519    ) -> Result<StreamSourceEvent, fidl::Error> {
13520        let (bytes, _handles) = buf.split_mut();
13521        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13522        debug_assert_eq!(tx_header.tx_id, 0);
13523        match tx_header.ordinal {
13524            0x6bbe69746a3c8bd9 => {
13525                let mut out = fidl::new_empty!(
13526                    StreamSourceOnPacketProducedRequest,
13527                    fdomain_client::fidl::FDomainResourceDialect
13528                );
13529                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
13530                Ok((StreamSourceEvent::OnPacketProduced { packet: out.packet }))
13531            }
13532            0x550e69b41d03e2c2 => {
13533                let mut out = fidl::new_empty!(
13534                    fidl::encoding::EmptyPayload,
13535                    fdomain_client::fidl::FDomainResourceDialect
13536                );
13537                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
13538                Ok((StreamSourceEvent::OnEndOfStream {}))
13539            }
13540            _ => Err(fidl::Error::UnknownOrdinal {
13541                ordinal: tx_header.ordinal,
13542                protocol_name:
13543                    <StreamSourceMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
13544            }),
13545        }
13546    }
13547}
13548
13549/// A Stream of incoming requests for fuchsia.media/StreamSource.
13550pub struct StreamSourceRequestStream {
13551    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
13552    is_terminated: bool,
13553}
13554
13555impl std::marker::Unpin for StreamSourceRequestStream {}
13556
13557impl futures::stream::FusedStream for StreamSourceRequestStream {
13558    fn is_terminated(&self) -> bool {
13559        self.is_terminated
13560    }
13561}
13562
13563impl fdomain_client::fidl::RequestStream for StreamSourceRequestStream {
13564    type Protocol = StreamSourceMarker;
13565    type ControlHandle = StreamSourceControlHandle;
13566
13567    fn from_channel(channel: fdomain_client::Channel) -> Self {
13568        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
13569    }
13570
13571    fn control_handle(&self) -> Self::ControlHandle {
13572        StreamSourceControlHandle { inner: self.inner.clone() }
13573    }
13574
13575    fn into_inner(
13576        self,
13577    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
13578    {
13579        (self.inner, self.is_terminated)
13580    }
13581
13582    fn from_inner(
13583        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
13584        is_terminated: bool,
13585    ) -> Self {
13586        Self { inner, is_terminated }
13587    }
13588}
13589
13590impl futures::Stream for StreamSourceRequestStream {
13591    type Item = Result<StreamSourceRequest, fidl::Error>;
13592
13593    fn poll_next(
13594        mut self: std::pin::Pin<&mut Self>,
13595        cx: &mut std::task::Context<'_>,
13596    ) -> std::task::Poll<Option<Self::Item>> {
13597        let this = &mut *self;
13598        if this.inner.check_shutdown(cx) {
13599            this.is_terminated = true;
13600            return std::task::Poll::Ready(None);
13601        }
13602        if this.is_terminated {
13603            panic!("polled StreamSourceRequestStream after completion");
13604        }
13605        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
13606            |bytes, handles| {
13607                match this.inner.channel().read_etc(cx, bytes, handles) {
13608                    std::task::Poll::Ready(Ok(())) => {}
13609                    std::task::Poll::Pending => return std::task::Poll::Pending,
13610                    std::task::Poll::Ready(Err(None)) => {
13611                        this.is_terminated = true;
13612                        return std::task::Poll::Ready(None);
13613                    }
13614                    std::task::Poll::Ready(Err(Some(e))) => {
13615                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
13616                            e.into(),
13617                        ))));
13618                    }
13619                }
13620
13621                // A message has been received from the channel
13622                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13623
13624                std::task::Poll::Ready(Some(match header.ordinal {
13625                    0x7a7b57f0f7d9e4bb => {
13626                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13627                        let mut req = fidl::new_empty!(
13628                            StreamSourceReleasePacketRequest,
13629                            fdomain_client::fidl::FDomainResourceDialect
13630                        );
13631                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
13632                        let control_handle =
13633                            StreamSourceControlHandle { inner: this.inner.clone() };
13634                        Ok(StreamSourceRequest::ReleasePacket {
13635                            packet: req.packet,
13636
13637                            control_handle,
13638                        })
13639                    }
13640                    0x27afd605e97b09d2 => {
13641                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
13642                        let mut req = fidl::new_empty!(
13643                            fidl::encoding::EmptyPayload,
13644                            fdomain_client::fidl::FDomainResourceDialect
13645                        );
13646                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
13647                        let control_handle =
13648                            StreamSourceControlHandle { inner: this.inner.clone() };
13649                        Ok(StreamSourceRequest::DiscardAllPackets {
13650                            responder: StreamSourceDiscardAllPacketsResponder {
13651                                control_handle: std::mem::ManuallyDrop::new(control_handle),
13652                                tx_id: header.tx_id,
13653                            },
13654                        })
13655                    }
13656                    0x35f9d721e905b831 => {
13657                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13658                        let mut req = fidl::new_empty!(
13659                            fidl::encoding::EmptyPayload,
13660                            fdomain_client::fidl::FDomainResourceDialect
13661                        );
13662                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
13663                        let control_handle =
13664                            StreamSourceControlHandle { inner: this.inner.clone() };
13665                        Ok(StreamSourceRequest::DiscardAllPacketsNoReply { control_handle })
13666                    }
13667                    _ => Err(fidl::Error::UnknownOrdinal {
13668                        ordinal: header.ordinal,
13669                        protocol_name:
13670                            <StreamSourceMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
13671                    }),
13672                }))
13673            },
13674        )
13675    }
13676}
13677
13678/// Produces a stream of packets. This interface is typically inherited along
13679/// with `StreamBufferSet` to enable the transport of elementary streams from
13680/// services to clients.
13681#[derive(Debug)]
13682pub enum StreamSourceRequest {
13683    /// Releases payload memory associated with a packet previously delivered
13684    /// via `OnPacketProduced`.
13685    ReleasePacket {
13686        packet: StreamPacket,
13687        control_handle: StreamSourceControlHandle,
13688    },
13689    DiscardAllPackets {
13690        responder: StreamSourceDiscardAllPacketsResponder,
13691    },
13692    DiscardAllPacketsNoReply {
13693        control_handle: StreamSourceControlHandle,
13694    },
13695}
13696
13697impl StreamSourceRequest {
13698    #[allow(irrefutable_let_patterns)]
13699    pub fn into_release_packet(self) -> Option<(StreamPacket, StreamSourceControlHandle)> {
13700        if let StreamSourceRequest::ReleasePacket { packet, control_handle } = self {
13701            Some((packet, control_handle))
13702        } else {
13703            None
13704        }
13705    }
13706
13707    #[allow(irrefutable_let_patterns)]
13708    pub fn into_discard_all_packets(self) -> Option<(StreamSourceDiscardAllPacketsResponder)> {
13709        if let StreamSourceRequest::DiscardAllPackets { responder } = self {
13710            Some((responder))
13711        } else {
13712            None
13713        }
13714    }
13715
13716    #[allow(irrefutable_let_patterns)]
13717    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSourceControlHandle)> {
13718        if let StreamSourceRequest::DiscardAllPacketsNoReply { control_handle } = self {
13719            Some((control_handle))
13720        } else {
13721            None
13722        }
13723    }
13724
13725    /// Name of the method defined in FIDL
13726    pub fn method_name(&self) -> &'static str {
13727        match *self {
13728            StreamSourceRequest::ReleasePacket { .. } => "release_packet",
13729            StreamSourceRequest::DiscardAllPackets { .. } => "discard_all_packets",
13730            StreamSourceRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
13731        }
13732    }
13733}
13734
13735#[derive(Debug, Clone)]
13736pub struct StreamSourceControlHandle {
13737    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
13738}
13739
13740impl fdomain_client::fidl::ControlHandle for StreamSourceControlHandle {
13741    fn shutdown(&self) {
13742        self.inner.shutdown()
13743    }
13744
13745    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
13746        self.inner.shutdown_with_epitaph(status)
13747    }
13748
13749    fn is_closed(&self) -> bool {
13750        self.inner.channel().is_closed()
13751    }
13752    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
13753        self.inner.channel().on_closed()
13754    }
13755}
13756
13757impl StreamSourceControlHandle {
13758    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
13759        self.inner.send::<StreamSourceOnPacketProducedRequest>(
13760            (packet,),
13761            0,
13762            0x6bbe69746a3c8bd9,
13763            fidl::encoding::DynamicFlags::empty(),
13764        )
13765    }
13766
13767    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
13768        self.inner.send::<fidl::encoding::EmptyPayload>(
13769            (),
13770            0,
13771            0x550e69b41d03e2c2,
13772            fidl::encoding::DynamicFlags::empty(),
13773        )
13774    }
13775}
13776
13777#[must_use = "FIDL methods require a response to be sent"]
13778#[derive(Debug)]
13779pub struct StreamSourceDiscardAllPacketsResponder {
13780    control_handle: std::mem::ManuallyDrop<StreamSourceControlHandle>,
13781    tx_id: u32,
13782}
13783
13784/// Set the the channel to be shutdown (see [`StreamSourceControlHandle::shutdown`])
13785/// if the responder is dropped without sending a response, so that the client
13786/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13787impl std::ops::Drop for StreamSourceDiscardAllPacketsResponder {
13788    fn drop(&mut self) {
13789        self.control_handle.shutdown();
13790        // Safety: drops once, never accessed again
13791        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13792    }
13793}
13794
13795impl fdomain_client::fidl::Responder for StreamSourceDiscardAllPacketsResponder {
13796    type ControlHandle = StreamSourceControlHandle;
13797
13798    fn control_handle(&self) -> &StreamSourceControlHandle {
13799        &self.control_handle
13800    }
13801
13802    fn drop_without_shutdown(mut self) {
13803        // Safety: drops once, never accessed again due to mem::forget
13804        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13805        // Prevent Drop from running (which would shut down the channel)
13806        std::mem::forget(self);
13807    }
13808}
13809
13810impl StreamSourceDiscardAllPacketsResponder {
13811    /// Sends a response to the FIDL transaction.
13812    ///
13813    /// Sets the channel to shutdown if an error occurs.
13814    pub fn send(self) -> Result<(), fidl::Error> {
13815        let _result = self.send_raw();
13816        if _result.is_err() {
13817            self.control_handle.shutdown();
13818        }
13819        self.drop_without_shutdown();
13820        _result
13821    }
13822
13823    /// Similar to "send" but does not shutdown the channel if an error occurs.
13824    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
13825        let _result = self.send_raw();
13826        self.drop_without_shutdown();
13827        _result
13828    }
13829
13830    fn send_raw(&self) -> Result<(), fidl::Error> {
13831        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
13832            (),
13833            self.tx_id,
13834            0x27afd605e97b09d2,
13835            fidl::encoding::DynamicFlags::empty(),
13836        )
13837    }
13838}
13839
13840#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
13841pub struct Usage2AudioConsumerFactoryMarker;
13842
13843impl fdomain_client::fidl::ProtocolMarker for Usage2AudioConsumerFactoryMarker {
13844    type Proxy = Usage2AudioConsumerFactoryProxy;
13845    type RequestStream = Usage2AudioConsumerFactoryRequestStream;
13846
13847    const DEBUG_NAME: &'static str = "fuchsia.media.Usage2AudioConsumerFactory";
13848}
13849impl fdomain_client::fidl::DiscoverableProtocolMarker for Usage2AudioConsumerFactoryMarker {}
13850
13851pub trait Usage2AudioConsumerFactoryProxyInterface: Send + Sync {
13852    fn r#create_audio_consumer(
13853        &self,
13854        usage: AudioRenderUsage2,
13855        audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
13856    ) -> Result<(), fidl::Error>;
13857}
13858
13859#[derive(Debug, Clone)]
13860pub struct Usage2AudioConsumerFactoryProxy {
13861    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
13862}
13863
13864impl fdomain_client::fidl::Proxy for Usage2AudioConsumerFactoryProxy {
13865    type Protocol = Usage2AudioConsumerFactoryMarker;
13866
13867    fn from_channel(inner: fdomain_client::Channel) -> Self {
13868        Self::new(inner)
13869    }
13870
13871    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
13872        self.client.into_channel().map_err(|client| Self { client })
13873    }
13874
13875    fn as_channel(&self) -> &fdomain_client::Channel {
13876        self.client.as_channel()
13877    }
13878}
13879
13880impl Usage2AudioConsumerFactoryProxy {
13881    /// Create a new Proxy for fuchsia.media/Usage2AudioConsumerFactory.
13882    pub fn new(channel: fdomain_client::Channel) -> Self {
13883        let protocol_name =
13884            <Usage2AudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
13885        Self { client: fidl::client::Client::new(channel, protocol_name) }
13886    }
13887
13888    /// Get a Stream of events from the remote end of the protocol.
13889    ///
13890    /// # Panics
13891    ///
13892    /// Panics if the event stream was already taken.
13893    pub fn take_event_stream(&self) -> Usage2AudioConsumerFactoryEventStream {
13894        Usage2AudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
13895    }
13896
13897    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
13898    /// Audio submitted to such a consumer is always rendered locally.
13899    pub fn r#create_audio_consumer(
13900        &self,
13901        mut usage: AudioRenderUsage2,
13902        mut audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
13903    ) -> Result<(), fidl::Error> {
13904        Usage2AudioConsumerFactoryProxyInterface::r#create_audio_consumer(
13905            self,
13906            usage,
13907            audio_consumer_request,
13908        )
13909    }
13910}
13911
13912impl Usage2AudioConsumerFactoryProxyInterface for Usage2AudioConsumerFactoryProxy {
13913    fn r#create_audio_consumer(
13914        &self,
13915        mut usage: AudioRenderUsage2,
13916        mut audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
13917    ) -> Result<(), fidl::Error> {
13918        self.client.send::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(
13919            (usage, audio_consumer_request),
13920            0x767722302a171873,
13921            fidl::encoding::DynamicFlags::FLEXIBLE,
13922        )
13923    }
13924}
13925
13926pub struct Usage2AudioConsumerFactoryEventStream {
13927    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
13928}
13929
13930impl std::marker::Unpin for Usage2AudioConsumerFactoryEventStream {}
13931
13932impl futures::stream::FusedStream for Usage2AudioConsumerFactoryEventStream {
13933    fn is_terminated(&self) -> bool {
13934        self.event_receiver.is_terminated()
13935    }
13936}
13937
13938impl futures::Stream for Usage2AudioConsumerFactoryEventStream {
13939    type Item = Result<Usage2AudioConsumerFactoryEvent, fidl::Error>;
13940
13941    fn poll_next(
13942        mut self: std::pin::Pin<&mut Self>,
13943        cx: &mut std::task::Context<'_>,
13944    ) -> std::task::Poll<Option<Self::Item>> {
13945        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
13946            &mut self.event_receiver,
13947            cx
13948        )?) {
13949            Some(buf) => std::task::Poll::Ready(Some(Usage2AudioConsumerFactoryEvent::decode(buf))),
13950            None => std::task::Poll::Ready(None),
13951        }
13952    }
13953}
13954
13955#[derive(Debug)]
13956pub enum Usage2AudioConsumerFactoryEvent {
13957    #[non_exhaustive]
13958    _UnknownEvent {
13959        /// Ordinal of the event that was sent.
13960        ordinal: u64,
13961    },
13962}
13963
13964impl Usage2AudioConsumerFactoryEvent {
13965    /// Decodes a message buffer as a [`Usage2AudioConsumerFactoryEvent`].
13966    fn decode(
13967        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
13968    ) -> Result<Usage2AudioConsumerFactoryEvent, fidl::Error> {
13969        let (bytes, _handles) = buf.split_mut();
13970        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13971        debug_assert_eq!(tx_header.tx_id, 0);
13972        match tx_header.ordinal {
13973            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
13974                Ok(Usage2AudioConsumerFactoryEvent::_UnknownEvent {
13975                    ordinal: tx_header.ordinal,
13976                })
13977            }
13978            _ => Err(fidl::Error::UnknownOrdinal {
13979                ordinal: tx_header.ordinal,
13980                protocol_name: <Usage2AudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
13981            })
13982        }
13983    }
13984}
13985
13986/// A Stream of incoming requests for fuchsia.media/Usage2AudioConsumerFactory.
13987pub struct Usage2AudioConsumerFactoryRequestStream {
13988    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
13989    is_terminated: bool,
13990}
13991
13992impl std::marker::Unpin for Usage2AudioConsumerFactoryRequestStream {}
13993
13994impl futures::stream::FusedStream for Usage2AudioConsumerFactoryRequestStream {
13995    fn is_terminated(&self) -> bool {
13996        self.is_terminated
13997    }
13998}
13999
14000impl fdomain_client::fidl::RequestStream for Usage2AudioConsumerFactoryRequestStream {
14001    type Protocol = Usage2AudioConsumerFactoryMarker;
14002    type ControlHandle = Usage2AudioConsumerFactoryControlHandle;
14003
14004    fn from_channel(channel: fdomain_client::Channel) -> Self {
14005        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
14006    }
14007
14008    fn control_handle(&self) -> Self::ControlHandle {
14009        Usage2AudioConsumerFactoryControlHandle { inner: self.inner.clone() }
14010    }
14011
14012    fn into_inner(
14013        self,
14014    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
14015    {
14016        (self.inner, self.is_terminated)
14017    }
14018
14019    fn from_inner(
14020        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
14021        is_terminated: bool,
14022    ) -> Self {
14023        Self { inner, is_terminated }
14024    }
14025}
14026
14027impl futures::Stream for Usage2AudioConsumerFactoryRequestStream {
14028    type Item = Result<Usage2AudioConsumerFactoryRequest, fidl::Error>;
14029
14030    fn poll_next(
14031        mut self: std::pin::Pin<&mut Self>,
14032        cx: &mut std::task::Context<'_>,
14033    ) -> std::task::Poll<Option<Self::Item>> {
14034        let this = &mut *self;
14035        if this.inner.check_shutdown(cx) {
14036            this.is_terminated = true;
14037            return std::task::Poll::Ready(None);
14038        }
14039        if this.is_terminated {
14040            panic!("polled Usage2AudioConsumerFactoryRequestStream after completion");
14041        }
14042        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
14043            |bytes, handles| {
14044                match this.inner.channel().read_etc(cx, bytes, handles) {
14045                    std::task::Poll::Ready(Ok(())) => {}
14046                    std::task::Poll::Pending => return std::task::Poll::Pending,
14047                    std::task::Poll::Ready(Err(None)) => {
14048                        this.is_terminated = true;
14049                        return std::task::Poll::Ready(None);
14050                    }
14051                    std::task::Poll::Ready(Err(Some(e))) => {
14052                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
14053                            e.into(),
14054                        ))));
14055                    }
14056                }
14057
14058                // A message has been received from the channel
14059                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14060
14061                std::task::Poll::Ready(Some(match header.ordinal {
14062                0x767722302a171873 => {
14063                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14064                    let mut req = fidl::new_empty!(Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fdomain_client::fidl::FDomainResourceDialect);
14065                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
14066                    let control_handle = Usage2AudioConsumerFactoryControlHandle {
14067                        inner: this.inner.clone(),
14068                    };
14069                    Ok(Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
14070audio_consumer_request: req.audio_consumer_request,
14071
14072                        control_handle,
14073                    })
14074                }
14075                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
14076                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
14077                        ordinal: header.ordinal,
14078                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
14079                        method_type: fidl::MethodType::OneWay,
14080                    })
14081                }
14082                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
14083                    this.inner.send_framework_err(
14084                        fidl::encoding::FrameworkErr::UnknownMethod,
14085                        header.tx_id,
14086                        header.ordinal,
14087                        header.dynamic_flags(),
14088                        (bytes, handles),
14089                    )?;
14090                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
14091                        ordinal: header.ordinal,
14092                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
14093                        method_type: fidl::MethodType::TwoWay,
14094                    })
14095                }
14096                _ => Err(fidl::Error::UnknownOrdinal {
14097                    ordinal: header.ordinal,
14098                    protocol_name: <Usage2AudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
14099                }),
14100            }))
14101            },
14102        )
14103    }
14104}
14105
14106/// Interface for creating audio consumers for local rendering.
14107#[derive(Debug)]
14108pub enum Usage2AudioConsumerFactoryRequest {
14109    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
14110    /// Audio submitted to such a consumer is always rendered locally.
14111    CreateAudioConsumer {
14112        usage: AudioRenderUsage2,
14113        audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
14114        control_handle: Usage2AudioConsumerFactoryControlHandle,
14115    },
14116    /// An interaction was received which does not match any known method.
14117    #[non_exhaustive]
14118    _UnknownMethod {
14119        /// Ordinal of the method that was called.
14120        ordinal: u64,
14121        control_handle: Usage2AudioConsumerFactoryControlHandle,
14122        method_type: fidl::MethodType,
14123    },
14124}
14125
14126impl Usage2AudioConsumerFactoryRequest {
14127    #[allow(irrefutable_let_patterns)]
14128    pub fn into_create_audio_consumer(
14129        self,
14130    ) -> Option<(
14131        AudioRenderUsage2,
14132        fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
14133        Usage2AudioConsumerFactoryControlHandle,
14134    )> {
14135        if let Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {
14136            usage,
14137            audio_consumer_request,
14138            control_handle,
14139        } = self
14140        {
14141            Some((usage, audio_consumer_request, control_handle))
14142        } else {
14143            None
14144        }
14145    }
14146
14147    /// Name of the method defined in FIDL
14148    pub fn method_name(&self) -> &'static str {
14149        match *self {
14150            Usage2AudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
14151                "create_audio_consumer"
14152            }
14153            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
14154                method_type: fidl::MethodType::OneWay,
14155                ..
14156            } => "unknown one-way method",
14157            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
14158                method_type: fidl::MethodType::TwoWay,
14159                ..
14160            } => "unknown two-way method",
14161        }
14162    }
14163}
14164
14165#[derive(Debug, Clone)]
14166pub struct Usage2AudioConsumerFactoryControlHandle {
14167    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
14168}
14169
14170impl fdomain_client::fidl::ControlHandle for Usage2AudioConsumerFactoryControlHandle {
14171    fn shutdown(&self) {
14172        self.inner.shutdown()
14173    }
14174
14175    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
14176        self.inner.shutdown_with_epitaph(status)
14177    }
14178
14179    fn is_closed(&self) -> bool {
14180        self.inner.channel().is_closed()
14181    }
14182    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
14183        self.inner.channel().on_closed()
14184    }
14185}
14186
14187impl Usage2AudioConsumerFactoryControlHandle {}
14188
14189#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
14190pub struct UsageAudioConsumerFactoryMarker;
14191
14192impl fdomain_client::fidl::ProtocolMarker for UsageAudioConsumerFactoryMarker {
14193    type Proxy = UsageAudioConsumerFactoryProxy;
14194    type RequestStream = UsageAudioConsumerFactoryRequestStream;
14195
14196    const DEBUG_NAME: &'static str = "fuchsia.media.UsageAudioConsumerFactory";
14197}
14198impl fdomain_client::fidl::DiscoverableProtocolMarker for UsageAudioConsumerFactoryMarker {}
14199
14200pub trait UsageAudioConsumerFactoryProxyInterface: Send + Sync {
14201    fn r#create_audio_consumer(
14202        &self,
14203        usage: AudioRenderUsage,
14204        audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
14205    ) -> Result<(), fidl::Error>;
14206}
14207
14208#[derive(Debug, Clone)]
14209pub struct UsageAudioConsumerFactoryProxy {
14210    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
14211}
14212
14213impl fdomain_client::fidl::Proxy for UsageAudioConsumerFactoryProxy {
14214    type Protocol = UsageAudioConsumerFactoryMarker;
14215
14216    fn from_channel(inner: fdomain_client::Channel) -> Self {
14217        Self::new(inner)
14218    }
14219
14220    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
14221        self.client.into_channel().map_err(|client| Self { client })
14222    }
14223
14224    fn as_channel(&self) -> &fdomain_client::Channel {
14225        self.client.as_channel()
14226    }
14227}
14228
14229impl UsageAudioConsumerFactoryProxy {
14230    /// Create a new Proxy for fuchsia.media/UsageAudioConsumerFactory.
14231    pub fn new(channel: fdomain_client::Channel) -> Self {
14232        let protocol_name =
14233            <UsageAudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
14234        Self { client: fidl::client::Client::new(channel, protocol_name) }
14235    }
14236
14237    /// Get a Stream of events from the remote end of the protocol.
14238    ///
14239    /// # Panics
14240    ///
14241    /// Panics if the event stream was already taken.
14242    pub fn take_event_stream(&self) -> UsageAudioConsumerFactoryEventStream {
14243        UsageAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
14244    }
14245
14246    pub fn r#create_audio_consumer(
14247        &self,
14248        mut usage: AudioRenderUsage,
14249        mut audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
14250    ) -> Result<(), fidl::Error> {
14251        UsageAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
14252            self,
14253            usage,
14254            audio_consumer_request,
14255        )
14256    }
14257}
14258
14259impl UsageAudioConsumerFactoryProxyInterface for UsageAudioConsumerFactoryProxy {
14260    fn r#create_audio_consumer(
14261        &self,
14262        mut usage: AudioRenderUsage,
14263        mut audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
14264    ) -> Result<(), fidl::Error> {
14265        self.client.send::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(
14266            (usage, audio_consumer_request),
14267            0x4d975ca9b8f625a3,
14268            fidl::encoding::DynamicFlags::empty(),
14269        )
14270    }
14271}
14272
14273pub struct UsageAudioConsumerFactoryEventStream {
14274    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
14275}
14276
14277impl std::marker::Unpin for UsageAudioConsumerFactoryEventStream {}
14278
14279impl futures::stream::FusedStream for UsageAudioConsumerFactoryEventStream {
14280    fn is_terminated(&self) -> bool {
14281        self.event_receiver.is_terminated()
14282    }
14283}
14284
14285impl futures::Stream for UsageAudioConsumerFactoryEventStream {
14286    type Item = Result<UsageAudioConsumerFactoryEvent, fidl::Error>;
14287
14288    fn poll_next(
14289        mut self: std::pin::Pin<&mut Self>,
14290        cx: &mut std::task::Context<'_>,
14291    ) -> std::task::Poll<Option<Self::Item>> {
14292        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
14293            &mut self.event_receiver,
14294            cx
14295        )?) {
14296            Some(buf) => std::task::Poll::Ready(Some(UsageAudioConsumerFactoryEvent::decode(buf))),
14297            None => std::task::Poll::Ready(None),
14298        }
14299    }
14300}
14301
14302#[derive(Debug)]
14303pub enum UsageAudioConsumerFactoryEvent {}
14304
14305impl UsageAudioConsumerFactoryEvent {
14306    /// Decodes a message buffer as a [`UsageAudioConsumerFactoryEvent`].
14307    fn decode(
14308        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
14309    ) -> Result<UsageAudioConsumerFactoryEvent, fidl::Error> {
14310        let (bytes, _handles) = buf.split_mut();
14311        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14312        debug_assert_eq!(tx_header.tx_id, 0);
14313        match tx_header.ordinal {
14314            _ => Err(fidl::Error::UnknownOrdinal {
14315                ordinal: tx_header.ordinal,
14316                protocol_name: <UsageAudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
14317            })
14318        }
14319    }
14320}
14321
14322/// A Stream of incoming requests for fuchsia.media/UsageAudioConsumerFactory.
14323pub struct UsageAudioConsumerFactoryRequestStream {
14324    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
14325    is_terminated: bool,
14326}
14327
14328impl std::marker::Unpin for UsageAudioConsumerFactoryRequestStream {}
14329
14330impl futures::stream::FusedStream for UsageAudioConsumerFactoryRequestStream {
14331    fn is_terminated(&self) -> bool {
14332        self.is_terminated
14333    }
14334}
14335
14336impl fdomain_client::fidl::RequestStream for UsageAudioConsumerFactoryRequestStream {
14337    type Protocol = UsageAudioConsumerFactoryMarker;
14338    type ControlHandle = UsageAudioConsumerFactoryControlHandle;
14339
14340    fn from_channel(channel: fdomain_client::Channel) -> Self {
14341        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
14342    }
14343
14344    fn control_handle(&self) -> Self::ControlHandle {
14345        UsageAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
14346    }
14347
14348    fn into_inner(
14349        self,
14350    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
14351    {
14352        (self.inner, self.is_terminated)
14353    }
14354
14355    fn from_inner(
14356        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
14357        is_terminated: bool,
14358    ) -> Self {
14359        Self { inner, is_terminated }
14360    }
14361}
14362
14363impl futures::Stream for UsageAudioConsumerFactoryRequestStream {
14364    type Item = Result<UsageAudioConsumerFactoryRequest, fidl::Error>;
14365
14366    fn poll_next(
14367        mut self: std::pin::Pin<&mut Self>,
14368        cx: &mut std::task::Context<'_>,
14369    ) -> std::task::Poll<Option<Self::Item>> {
14370        let this = &mut *self;
14371        if this.inner.check_shutdown(cx) {
14372            this.is_terminated = true;
14373            return std::task::Poll::Ready(None);
14374        }
14375        if this.is_terminated {
14376            panic!("polled UsageAudioConsumerFactoryRequestStream after completion");
14377        }
14378        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
14379            |bytes, handles| {
14380                match this.inner.channel().read_etc(cx, bytes, handles) {
14381                    std::task::Poll::Ready(Ok(())) => {}
14382                    std::task::Poll::Pending => return std::task::Poll::Pending,
14383                    std::task::Poll::Ready(Err(None)) => {
14384                        this.is_terminated = true;
14385                        return std::task::Poll::Ready(None);
14386                    }
14387                    std::task::Poll::Ready(Err(Some(e))) => {
14388                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
14389                            e.into(),
14390                        ))));
14391                    }
14392                }
14393
14394                // A message has been received from the channel
14395                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14396
14397                std::task::Poll::Ready(Some(match header.ordinal {
14398                0x4d975ca9b8f625a3 => {
14399                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14400                    let mut req = fidl::new_empty!(UsageAudioConsumerFactoryCreateAudioConsumerRequest, fdomain_client::fidl::FDomainResourceDialect);
14401                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
14402                    let control_handle = UsageAudioConsumerFactoryControlHandle {
14403                        inner: this.inner.clone(),
14404                    };
14405                    Ok(UsageAudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
14406audio_consumer_request: req.audio_consumer_request,
14407
14408                        control_handle,
14409                    })
14410                }
14411                _ => Err(fidl::Error::UnknownOrdinal {
14412                    ordinal: header.ordinal,
14413                    protocol_name: <UsageAudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
14414                }),
14415            }))
14416            },
14417        )
14418    }
14419}
14420
14421/// Interface for creating audio consumers for local rendering.
14422#[derive(Debug)]
14423pub enum UsageAudioConsumerFactoryRequest {
14424    CreateAudioConsumer {
14425        usage: AudioRenderUsage,
14426        audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
14427        control_handle: UsageAudioConsumerFactoryControlHandle,
14428    },
14429}
14430
14431impl UsageAudioConsumerFactoryRequest {
14432    #[allow(irrefutable_let_patterns)]
14433    pub fn into_create_audio_consumer(
14434        self,
14435    ) -> Option<(
14436        AudioRenderUsage,
14437        fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
14438        UsageAudioConsumerFactoryControlHandle,
14439    )> {
14440        if let UsageAudioConsumerFactoryRequest::CreateAudioConsumer {
14441            usage,
14442            audio_consumer_request,
14443            control_handle,
14444        } = self
14445        {
14446            Some((usage, audio_consumer_request, control_handle))
14447        } else {
14448            None
14449        }
14450    }
14451
14452    /// Name of the method defined in FIDL
14453    pub fn method_name(&self) -> &'static str {
14454        match *self {
14455            UsageAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => "create_audio_consumer",
14456        }
14457    }
14458}
14459
14460#[derive(Debug, Clone)]
14461pub struct UsageAudioConsumerFactoryControlHandle {
14462    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
14463}
14464
14465impl fdomain_client::fidl::ControlHandle for UsageAudioConsumerFactoryControlHandle {
14466    fn shutdown(&self) {
14467        self.inner.shutdown()
14468    }
14469
14470    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
14471        self.inner.shutdown_with_epitaph(status)
14472    }
14473
14474    fn is_closed(&self) -> bool {
14475        self.inner.channel().is_closed()
14476    }
14477    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
14478        self.inner.channel().on_closed()
14479    }
14480}
14481
14482impl UsageAudioConsumerFactoryControlHandle {}
14483
14484#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
14485pub struct UsageGainListenerMarker;
14486
14487impl fdomain_client::fidl::ProtocolMarker for UsageGainListenerMarker {
14488    type Proxy = UsageGainListenerProxy;
14489    type RequestStream = UsageGainListenerRequestStream;
14490
14491    const DEBUG_NAME: &'static str = "(anonymous) UsageGainListener";
14492}
14493
14494pub trait UsageGainListenerProxyInterface: Send + Sync {
14495    type OnGainMuteChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
14496    fn r#on_gain_mute_changed(
14497        &self,
14498        muted: bool,
14499        gain_dbfs: f32,
14500    ) -> Self::OnGainMuteChangedResponseFut;
14501}
14502
14503#[derive(Debug, Clone)]
14504pub struct UsageGainListenerProxy {
14505    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
14506}
14507
14508impl fdomain_client::fidl::Proxy for UsageGainListenerProxy {
14509    type Protocol = UsageGainListenerMarker;
14510
14511    fn from_channel(inner: fdomain_client::Channel) -> Self {
14512        Self::new(inner)
14513    }
14514
14515    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
14516        self.client.into_channel().map_err(|client| Self { client })
14517    }
14518
14519    fn as_channel(&self) -> &fdomain_client::Channel {
14520        self.client.as_channel()
14521    }
14522}
14523
14524impl UsageGainListenerProxy {
14525    /// Create a new Proxy for fuchsia.media/UsageGainListener.
14526    pub fn new(channel: fdomain_client::Channel) -> Self {
14527        let protocol_name =
14528            <UsageGainListenerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
14529        Self { client: fidl::client::Client::new(channel, protocol_name) }
14530    }
14531
14532    /// Get a Stream of events from the remote end of the protocol.
14533    ///
14534    /// # Panics
14535    ///
14536    /// Panics if the event stream was already taken.
14537    pub fn take_event_stream(&self) -> UsageGainListenerEventStream {
14538        UsageGainListenerEventStream { event_receiver: self.client.take_event_receiver() }
14539    }
14540
14541    /// Called immediately on connection and afterward any time
14542    /// the usage gain setting changes.
14543    ///
14544    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
14545    /// events will eventually be disconnected.
14546    ///
14547    /// Note: This API does not have mute reporting implemented; `muted` is always false.
14548    pub fn r#on_gain_mute_changed(
14549        &self,
14550        mut muted: bool,
14551        mut gain_dbfs: f32,
14552    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
14553        UsageGainListenerProxyInterface::r#on_gain_mute_changed(self, muted, gain_dbfs)
14554    }
14555}
14556
14557impl UsageGainListenerProxyInterface for UsageGainListenerProxy {
14558    type OnGainMuteChangedResponseFut =
14559        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
14560    fn r#on_gain_mute_changed(
14561        &self,
14562        mut muted: bool,
14563        mut gain_dbfs: f32,
14564    ) -> Self::OnGainMuteChangedResponseFut {
14565        fn _decode(
14566            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
14567        ) -> Result<(), fidl::Error> {
14568            let _response = fidl::client::decode_transaction_body::<
14569                fidl::encoding::EmptyPayload,
14570                fdomain_client::fidl::FDomainResourceDialect,
14571                0x681570258eac3a8d,
14572            >(_buf?)?;
14573            Ok(_response)
14574        }
14575        self.client.send_query_and_decode::<UsageGainListenerOnGainMuteChangedRequest, ()>(
14576            (muted, gain_dbfs),
14577            0x681570258eac3a8d,
14578            fidl::encoding::DynamicFlags::empty(),
14579            _decode,
14580        )
14581    }
14582}
14583
14584pub struct UsageGainListenerEventStream {
14585    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
14586}
14587
14588impl std::marker::Unpin for UsageGainListenerEventStream {}
14589
14590impl futures::stream::FusedStream for UsageGainListenerEventStream {
14591    fn is_terminated(&self) -> bool {
14592        self.event_receiver.is_terminated()
14593    }
14594}
14595
14596impl futures::Stream for UsageGainListenerEventStream {
14597    type Item = Result<UsageGainListenerEvent, fidl::Error>;
14598
14599    fn poll_next(
14600        mut self: std::pin::Pin<&mut Self>,
14601        cx: &mut std::task::Context<'_>,
14602    ) -> std::task::Poll<Option<Self::Item>> {
14603        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
14604            &mut self.event_receiver,
14605            cx
14606        )?) {
14607            Some(buf) => std::task::Poll::Ready(Some(UsageGainListenerEvent::decode(buf))),
14608            None => std::task::Poll::Ready(None),
14609        }
14610    }
14611}
14612
14613#[derive(Debug)]
14614pub enum UsageGainListenerEvent {}
14615
14616impl UsageGainListenerEvent {
14617    /// Decodes a message buffer as a [`UsageGainListenerEvent`].
14618    fn decode(
14619        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
14620    ) -> Result<UsageGainListenerEvent, fidl::Error> {
14621        let (bytes, _handles) = buf.split_mut();
14622        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14623        debug_assert_eq!(tx_header.tx_id, 0);
14624        match tx_header.ordinal {
14625            _ => Err(fidl::Error::UnknownOrdinal {
14626                ordinal: tx_header.ordinal,
14627                protocol_name:
14628                    <UsageGainListenerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
14629            }),
14630        }
14631    }
14632}
14633
14634/// A Stream of incoming requests for fuchsia.media/UsageGainListener.
14635pub struct UsageGainListenerRequestStream {
14636    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
14637    is_terminated: bool,
14638}
14639
14640impl std::marker::Unpin for UsageGainListenerRequestStream {}
14641
14642impl futures::stream::FusedStream for UsageGainListenerRequestStream {
14643    fn is_terminated(&self) -> bool {
14644        self.is_terminated
14645    }
14646}
14647
14648impl fdomain_client::fidl::RequestStream for UsageGainListenerRequestStream {
14649    type Protocol = UsageGainListenerMarker;
14650    type ControlHandle = UsageGainListenerControlHandle;
14651
14652    fn from_channel(channel: fdomain_client::Channel) -> Self {
14653        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
14654    }
14655
14656    fn control_handle(&self) -> Self::ControlHandle {
14657        UsageGainListenerControlHandle { inner: self.inner.clone() }
14658    }
14659
14660    fn into_inner(
14661        self,
14662    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
14663    {
14664        (self.inner, self.is_terminated)
14665    }
14666
14667    fn from_inner(
14668        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
14669        is_terminated: bool,
14670    ) -> Self {
14671        Self { inner, is_terminated }
14672    }
14673}
14674
14675impl futures::Stream for UsageGainListenerRequestStream {
14676    type Item = Result<UsageGainListenerRequest, fidl::Error>;
14677
14678    fn poll_next(
14679        mut self: std::pin::Pin<&mut Self>,
14680        cx: &mut std::task::Context<'_>,
14681    ) -> std::task::Poll<Option<Self::Item>> {
14682        let this = &mut *self;
14683        if this.inner.check_shutdown(cx) {
14684            this.is_terminated = true;
14685            return std::task::Poll::Ready(None);
14686        }
14687        if this.is_terminated {
14688            panic!("polled UsageGainListenerRequestStream after completion");
14689        }
14690        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
14691            |bytes, handles| {
14692                match this.inner.channel().read_etc(cx, bytes, handles) {
14693                    std::task::Poll::Ready(Ok(())) => {}
14694                    std::task::Poll::Pending => return std::task::Poll::Pending,
14695                    std::task::Poll::Ready(Err(None)) => {
14696                        this.is_terminated = true;
14697                        return std::task::Poll::Ready(None);
14698                    }
14699                    std::task::Poll::Ready(Err(Some(e))) => {
14700                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
14701                            e.into(),
14702                        ))));
14703                    }
14704                }
14705
14706                // A message has been received from the channel
14707                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14708
14709                std::task::Poll::Ready(Some(match header.ordinal {
14710                0x681570258eac3a8d => {
14711                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
14712                    let mut req = fidl::new_empty!(UsageGainListenerOnGainMuteChangedRequest, fdomain_client::fidl::FDomainResourceDialect);
14713                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageGainListenerOnGainMuteChangedRequest>(&header, _body_bytes, handles, &mut req)?;
14714                    let control_handle = UsageGainListenerControlHandle {
14715                        inner: this.inner.clone(),
14716                    };
14717                    Ok(UsageGainListenerRequest::OnGainMuteChanged {muted: req.muted,
14718gain_dbfs: req.gain_dbfs,
14719
14720                        responder: UsageGainListenerOnGainMuteChangedResponder {
14721                            control_handle: std::mem::ManuallyDrop::new(control_handle),
14722                            tx_id: header.tx_id,
14723                        },
14724                    })
14725                }
14726                _ => Err(fidl::Error::UnknownOrdinal {
14727                    ordinal: header.ordinal,
14728                    protocol_name: <UsageGainListenerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
14729                }),
14730            }))
14731            },
14732        )
14733    }
14734}
14735
14736/// A protocol for watching changes to usage gain settings.
14737///
14738/// The channel will close when the device is not present.
14739#[derive(Debug)]
14740pub enum UsageGainListenerRequest {
14741    /// Called immediately on connection and afterward any time
14742    /// the usage gain setting changes.
14743    ///
14744    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
14745    /// events will eventually be disconnected.
14746    ///
14747    /// Note: This API does not have mute reporting implemented; `muted` is always false.
14748    OnGainMuteChanged {
14749        muted: bool,
14750        gain_dbfs: f32,
14751        responder: UsageGainListenerOnGainMuteChangedResponder,
14752    },
14753}
14754
14755impl UsageGainListenerRequest {
14756    #[allow(irrefutable_let_patterns)]
14757    pub fn into_on_gain_mute_changed(
14758        self,
14759    ) -> Option<(bool, f32, UsageGainListenerOnGainMuteChangedResponder)> {
14760        if let UsageGainListenerRequest::OnGainMuteChanged { muted, gain_dbfs, responder } = self {
14761            Some((muted, gain_dbfs, responder))
14762        } else {
14763            None
14764        }
14765    }
14766
14767    /// Name of the method defined in FIDL
14768    pub fn method_name(&self) -> &'static str {
14769        match *self {
14770            UsageGainListenerRequest::OnGainMuteChanged { .. } => "on_gain_mute_changed",
14771        }
14772    }
14773}
14774
14775#[derive(Debug, Clone)]
14776pub struct UsageGainListenerControlHandle {
14777    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
14778}
14779
14780impl fdomain_client::fidl::ControlHandle for UsageGainListenerControlHandle {
14781    fn shutdown(&self) {
14782        self.inner.shutdown()
14783    }
14784
14785    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
14786        self.inner.shutdown_with_epitaph(status)
14787    }
14788
14789    fn is_closed(&self) -> bool {
14790        self.inner.channel().is_closed()
14791    }
14792    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
14793        self.inner.channel().on_closed()
14794    }
14795}
14796
14797impl UsageGainListenerControlHandle {}
14798
14799#[must_use = "FIDL methods require a response to be sent"]
14800#[derive(Debug)]
14801pub struct UsageGainListenerOnGainMuteChangedResponder {
14802    control_handle: std::mem::ManuallyDrop<UsageGainListenerControlHandle>,
14803    tx_id: u32,
14804}
14805
14806/// Set the the channel to be shutdown (see [`UsageGainListenerControlHandle::shutdown`])
14807/// if the responder is dropped without sending a response, so that the client
14808/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
14809impl std::ops::Drop for UsageGainListenerOnGainMuteChangedResponder {
14810    fn drop(&mut self) {
14811        self.control_handle.shutdown();
14812        // Safety: drops once, never accessed again
14813        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
14814    }
14815}
14816
14817impl fdomain_client::fidl::Responder for UsageGainListenerOnGainMuteChangedResponder {
14818    type ControlHandle = UsageGainListenerControlHandle;
14819
14820    fn control_handle(&self) -> &UsageGainListenerControlHandle {
14821        &self.control_handle
14822    }
14823
14824    fn drop_without_shutdown(mut self) {
14825        // Safety: drops once, never accessed again due to mem::forget
14826        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
14827        // Prevent Drop from running (which would shut down the channel)
14828        std::mem::forget(self);
14829    }
14830}
14831
14832impl UsageGainListenerOnGainMuteChangedResponder {
14833    /// Sends a response to the FIDL transaction.
14834    ///
14835    /// Sets the channel to shutdown if an error occurs.
14836    pub fn send(self) -> Result<(), fidl::Error> {
14837        let _result = self.send_raw();
14838        if _result.is_err() {
14839            self.control_handle.shutdown();
14840        }
14841        self.drop_without_shutdown();
14842        _result
14843    }
14844
14845    /// Similar to "send" but does not shutdown the channel if an error occurs.
14846    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
14847        let _result = self.send_raw();
14848        self.drop_without_shutdown();
14849        _result
14850    }
14851
14852    fn send_raw(&self) -> Result<(), fidl::Error> {
14853        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
14854            (),
14855            self.tx_id,
14856            0x681570258eac3a8d,
14857            fidl::encoding::DynamicFlags::empty(),
14858        )
14859    }
14860}
14861
14862#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
14863pub struct UsageGainReporterMarker;
14864
14865impl fdomain_client::fidl::ProtocolMarker for UsageGainReporterMarker {
14866    type Proxy = UsageGainReporterProxy;
14867    type RequestStream = UsageGainReporterRequestStream;
14868
14869    const DEBUG_NAME: &'static str = "fuchsia.media.UsageGainReporter";
14870}
14871impl fdomain_client::fidl::DiscoverableProtocolMarker for UsageGainReporterMarker {}
14872
14873pub trait UsageGainReporterProxyInterface: Send + Sync {
14874    fn r#register_listener(
14875        &self,
14876        device_unique_id: &str,
14877        usage: &Usage,
14878        usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
14879    ) -> Result<(), fidl::Error>;
14880    fn r#register_listener2(
14881        &self,
14882        device_unique_id: &str,
14883        usage: &Usage2,
14884        usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
14885    ) -> Result<(), fidl::Error>;
14886}
14887
14888#[derive(Debug, Clone)]
14889pub struct UsageGainReporterProxy {
14890    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
14891}
14892
14893impl fdomain_client::fidl::Proxy for UsageGainReporterProxy {
14894    type Protocol = UsageGainReporterMarker;
14895
14896    fn from_channel(inner: fdomain_client::Channel) -> Self {
14897        Self::new(inner)
14898    }
14899
14900    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
14901        self.client.into_channel().map_err(|client| Self { client })
14902    }
14903
14904    fn as_channel(&self) -> &fdomain_client::Channel {
14905        self.client.as_channel()
14906    }
14907}
14908
14909impl UsageGainReporterProxy {
14910    /// Create a new Proxy for fuchsia.media/UsageGainReporter.
14911    pub fn new(channel: fdomain_client::Channel) -> Self {
14912        let protocol_name =
14913            <UsageGainReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
14914        Self { client: fidl::client::Client::new(channel, protocol_name) }
14915    }
14916
14917    /// Get a Stream of events from the remote end of the protocol.
14918    ///
14919    /// # Panics
14920    ///
14921    /// Panics if the event stream was already taken.
14922    pub fn take_event_stream(&self) -> UsageGainReporterEventStream {
14923        UsageGainReporterEventStream { event_receiver: self.client.take_event_receiver() }
14924    }
14925
14926    /// Connects a listener to a stream of usage gain setting changes
14927    /// for `usage` on the device identified by `device_token`. Usage
14928    /// Gain is not set directly by any client; it is a translation of
14929    /// the usage volume setting for each device, summed with active
14930    /// muting/ducking gain adjustments.
14931    ///
14932    /// Devices may map the same volume level to different dbfs, so
14933    /// a `device_unique_id` is needed to identify the device.
14934    ///
14935    /// `AudioDeviceEnumerator` provides programmatic access to devices
14936    /// and their unique ids if it is necessary for a client to select
14937    /// an id at runtime.
14938    pub fn r#register_listener(
14939        &self,
14940        mut device_unique_id: &str,
14941        mut usage: &Usage,
14942        mut usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
14943    ) -> Result<(), fidl::Error> {
14944        UsageGainReporterProxyInterface::r#register_listener(
14945            self,
14946            device_unique_id,
14947            usage,
14948            usage_gain_listener,
14949        )
14950    }
14951
14952    /// Connects a listener to a stream of usage gain setting changes
14953    /// for `usage` on the device identified by `device_token`. Usage
14954    /// Gain is not set directly by any client; it is a translation of
14955    /// the usage volume setting for each device, summed with active
14956    /// muting/ducking gain adjustments.
14957    ///
14958    /// Devices may map the same volume level to different dbfs, so
14959    /// a `device_unique_id` is needed to identify the device.
14960    ///
14961    /// `AudioDeviceEnumerator` provides programmatic access to devices
14962    /// and their unique ids if it is necessary for a client to select
14963    /// an id at runtime.
14964    pub fn r#register_listener2(
14965        &self,
14966        mut device_unique_id: &str,
14967        mut usage: &Usage2,
14968        mut usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
14969    ) -> Result<(), fidl::Error> {
14970        UsageGainReporterProxyInterface::r#register_listener2(
14971            self,
14972            device_unique_id,
14973            usage,
14974            usage_gain_listener,
14975        )
14976    }
14977}
14978
14979impl UsageGainReporterProxyInterface for UsageGainReporterProxy {
14980    fn r#register_listener(
14981        &self,
14982        mut device_unique_id: &str,
14983        mut usage: &Usage,
14984        mut usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
14985    ) -> Result<(), fidl::Error> {
14986        self.client.send::<UsageGainReporterRegisterListenerRequest>(
14987            (device_unique_id, usage, usage_gain_listener),
14988            0x767107c168c226af,
14989            fidl::encoding::DynamicFlags::empty(),
14990        )
14991    }
14992
14993    fn r#register_listener2(
14994        &self,
14995        mut device_unique_id: &str,
14996        mut usage: &Usage2,
14997        mut usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
14998    ) -> Result<(), fidl::Error> {
14999        self.client.send::<UsageGainReporterRegisterListener2Request>(
15000            (device_unique_id, usage, usage_gain_listener),
15001            0x760a8e1c5873629c,
15002            fidl::encoding::DynamicFlags::FLEXIBLE,
15003        )
15004    }
15005}
15006
15007pub struct UsageGainReporterEventStream {
15008    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
15009}
15010
15011impl std::marker::Unpin for UsageGainReporterEventStream {}
15012
15013impl futures::stream::FusedStream for UsageGainReporterEventStream {
15014    fn is_terminated(&self) -> bool {
15015        self.event_receiver.is_terminated()
15016    }
15017}
15018
15019impl futures::Stream for UsageGainReporterEventStream {
15020    type Item = Result<UsageGainReporterEvent, fidl::Error>;
15021
15022    fn poll_next(
15023        mut self: std::pin::Pin<&mut Self>,
15024        cx: &mut std::task::Context<'_>,
15025    ) -> std::task::Poll<Option<Self::Item>> {
15026        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
15027            &mut self.event_receiver,
15028            cx
15029        )?) {
15030            Some(buf) => std::task::Poll::Ready(Some(UsageGainReporterEvent::decode(buf))),
15031            None => std::task::Poll::Ready(None),
15032        }
15033    }
15034}
15035
15036#[derive(Debug)]
15037pub enum UsageGainReporterEvent {
15038    #[non_exhaustive]
15039    _UnknownEvent {
15040        /// Ordinal of the event that was sent.
15041        ordinal: u64,
15042    },
15043}
15044
15045impl UsageGainReporterEvent {
15046    /// Decodes a message buffer as a [`UsageGainReporterEvent`].
15047    fn decode(
15048        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
15049    ) -> Result<UsageGainReporterEvent, fidl::Error> {
15050        let (bytes, _handles) = buf.split_mut();
15051        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
15052        debug_assert_eq!(tx_header.tx_id, 0);
15053        match tx_header.ordinal {
15054            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
15055                Ok(UsageGainReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
15056            }
15057            _ => Err(fidl::Error::UnknownOrdinal {
15058                ordinal: tx_header.ordinal,
15059                protocol_name:
15060                    <UsageGainReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
15061            }),
15062        }
15063    }
15064}
15065
15066/// A Stream of incoming requests for fuchsia.media/UsageGainReporter.
15067pub struct UsageGainReporterRequestStream {
15068    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15069    is_terminated: bool,
15070}
15071
15072impl std::marker::Unpin for UsageGainReporterRequestStream {}
15073
15074impl futures::stream::FusedStream for UsageGainReporterRequestStream {
15075    fn is_terminated(&self) -> bool {
15076        self.is_terminated
15077    }
15078}
15079
15080impl fdomain_client::fidl::RequestStream for UsageGainReporterRequestStream {
15081    type Protocol = UsageGainReporterMarker;
15082    type ControlHandle = UsageGainReporterControlHandle;
15083
15084    fn from_channel(channel: fdomain_client::Channel) -> Self {
15085        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
15086    }
15087
15088    fn control_handle(&self) -> Self::ControlHandle {
15089        UsageGainReporterControlHandle { inner: self.inner.clone() }
15090    }
15091
15092    fn into_inner(
15093        self,
15094    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
15095    {
15096        (self.inner, self.is_terminated)
15097    }
15098
15099    fn from_inner(
15100        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15101        is_terminated: bool,
15102    ) -> Self {
15103        Self { inner, is_terminated }
15104    }
15105}
15106
15107impl futures::Stream for UsageGainReporterRequestStream {
15108    type Item = Result<UsageGainReporterRequest, fidl::Error>;
15109
15110    fn poll_next(
15111        mut self: std::pin::Pin<&mut Self>,
15112        cx: &mut std::task::Context<'_>,
15113    ) -> std::task::Poll<Option<Self::Item>> {
15114        let this = &mut *self;
15115        if this.inner.check_shutdown(cx) {
15116            this.is_terminated = true;
15117            return std::task::Poll::Ready(None);
15118        }
15119        if this.is_terminated {
15120            panic!("polled UsageGainReporterRequestStream after completion");
15121        }
15122        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
15123            |bytes, handles| {
15124                match this.inner.channel().read_etc(cx, bytes, handles) {
15125                    std::task::Poll::Ready(Ok(())) => {}
15126                    std::task::Poll::Pending => return std::task::Poll::Pending,
15127                    std::task::Poll::Ready(Err(None)) => {
15128                        this.is_terminated = true;
15129                        return std::task::Poll::Ready(None);
15130                    }
15131                    std::task::Poll::Ready(Err(Some(e))) => {
15132                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
15133                            e.into(),
15134                        ))));
15135                    }
15136                }
15137
15138                // A message has been received from the channel
15139                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
15140
15141                std::task::Poll::Ready(Some(match header.ordinal {
15142                0x767107c168c226af => {
15143                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
15144                    let mut req = fidl::new_empty!(UsageGainReporterRegisterListenerRequest, fdomain_client::fidl::FDomainResourceDialect);
15145                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageGainReporterRegisterListenerRequest>(&header, _body_bytes, handles, &mut req)?;
15146                    let control_handle = UsageGainReporterControlHandle {
15147                        inner: this.inner.clone(),
15148                    };
15149                    Ok(UsageGainReporterRequest::RegisterListener {device_unique_id: req.device_unique_id,
15150usage: req.usage,
15151usage_gain_listener: req.usage_gain_listener,
15152
15153                        control_handle,
15154                    })
15155                }
15156                0x760a8e1c5873629c => {
15157                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
15158                    let mut req = fidl::new_empty!(UsageGainReporterRegisterListener2Request, fdomain_client::fidl::FDomainResourceDialect);
15159                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageGainReporterRegisterListener2Request>(&header, _body_bytes, handles, &mut req)?;
15160                    let control_handle = UsageGainReporterControlHandle {
15161                        inner: this.inner.clone(),
15162                    };
15163                    Ok(UsageGainReporterRequest::RegisterListener2 {device_unique_id: req.device_unique_id,
15164usage: req.usage,
15165usage_gain_listener: req.usage_gain_listener,
15166
15167                        control_handle,
15168                    })
15169                }
15170                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
15171                    Ok(UsageGainReporterRequest::_UnknownMethod {
15172                        ordinal: header.ordinal,
15173                        control_handle: UsageGainReporterControlHandle { inner: this.inner.clone() },
15174                        method_type: fidl::MethodType::OneWay,
15175                    })
15176                }
15177                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
15178                    this.inner.send_framework_err(
15179                        fidl::encoding::FrameworkErr::UnknownMethod,
15180                        header.tx_id,
15181                        header.ordinal,
15182                        header.dynamic_flags(),
15183                        (bytes, handles),
15184                    )?;
15185                    Ok(UsageGainReporterRequest::_UnknownMethod {
15186                        ordinal: header.ordinal,
15187                        control_handle: UsageGainReporterControlHandle { inner: this.inner.clone() },
15188                        method_type: fidl::MethodType::TwoWay,
15189                    })
15190                }
15191                _ => Err(fidl::Error::UnknownOrdinal {
15192                    ordinal: header.ordinal,
15193                    protocol_name: <UsageGainReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
15194                }),
15195            }))
15196            },
15197        )
15198    }
15199}
15200
15201/// A protocol for setting up watchers of usage gain.
15202#[derive(Debug)]
15203pub enum UsageGainReporterRequest {
15204    /// Connects a listener to a stream of usage gain setting changes
15205    /// for `usage` on the device identified by `device_token`. Usage
15206    /// Gain is not set directly by any client; it is a translation of
15207    /// the usage volume setting for each device, summed with active
15208    /// muting/ducking gain adjustments.
15209    ///
15210    /// Devices may map the same volume level to different dbfs, so
15211    /// a `device_unique_id` is needed to identify the device.
15212    ///
15213    /// `AudioDeviceEnumerator` provides programmatic access to devices
15214    /// and their unique ids if it is necessary for a client to select
15215    /// an id at runtime.
15216    RegisterListener {
15217        device_unique_id: String,
15218        usage: Usage,
15219        usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
15220        control_handle: UsageGainReporterControlHandle,
15221    },
15222    /// Connects a listener to a stream of usage gain setting changes
15223    /// for `usage` on the device identified by `device_token`. Usage
15224    /// Gain is not set directly by any client; it is a translation of
15225    /// the usage volume setting for each device, summed with active
15226    /// muting/ducking gain adjustments.
15227    ///
15228    /// Devices may map the same volume level to different dbfs, so
15229    /// a `device_unique_id` is needed to identify the device.
15230    ///
15231    /// `AudioDeviceEnumerator` provides programmatic access to devices
15232    /// and their unique ids if it is necessary for a client to select
15233    /// an id at runtime.
15234    RegisterListener2 {
15235        device_unique_id: String,
15236        usage: Usage2,
15237        usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
15238        control_handle: UsageGainReporterControlHandle,
15239    },
15240    /// An interaction was received which does not match any known method.
15241    #[non_exhaustive]
15242    _UnknownMethod {
15243        /// Ordinal of the method that was called.
15244        ordinal: u64,
15245        control_handle: UsageGainReporterControlHandle,
15246        method_type: fidl::MethodType,
15247    },
15248}
15249
15250impl UsageGainReporterRequest {
15251    #[allow(irrefutable_let_patterns)]
15252    pub fn into_register_listener(
15253        self,
15254    ) -> Option<(
15255        String,
15256        Usage,
15257        fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
15258        UsageGainReporterControlHandle,
15259    )> {
15260        if let UsageGainReporterRequest::RegisterListener {
15261            device_unique_id,
15262            usage,
15263            usage_gain_listener,
15264            control_handle,
15265        } = self
15266        {
15267            Some((device_unique_id, usage, usage_gain_listener, control_handle))
15268        } else {
15269            None
15270        }
15271    }
15272
15273    #[allow(irrefutable_let_patterns)]
15274    pub fn into_register_listener2(
15275        self,
15276    ) -> Option<(
15277        String,
15278        Usage2,
15279        fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
15280        UsageGainReporterControlHandle,
15281    )> {
15282        if let UsageGainReporterRequest::RegisterListener2 {
15283            device_unique_id,
15284            usage,
15285            usage_gain_listener,
15286            control_handle,
15287        } = self
15288        {
15289            Some((device_unique_id, usage, usage_gain_listener, control_handle))
15290        } else {
15291            None
15292        }
15293    }
15294
15295    /// Name of the method defined in FIDL
15296    pub fn method_name(&self) -> &'static str {
15297        match *self {
15298            UsageGainReporterRequest::RegisterListener { .. } => "register_listener",
15299            UsageGainReporterRequest::RegisterListener2 { .. } => "register_listener2",
15300            UsageGainReporterRequest::_UnknownMethod {
15301                method_type: fidl::MethodType::OneWay,
15302                ..
15303            } => "unknown one-way method",
15304            UsageGainReporterRequest::_UnknownMethod {
15305                method_type: fidl::MethodType::TwoWay,
15306                ..
15307            } => "unknown two-way method",
15308        }
15309    }
15310}
15311
15312#[derive(Debug, Clone)]
15313pub struct UsageGainReporterControlHandle {
15314    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15315}
15316
15317impl fdomain_client::fidl::ControlHandle for UsageGainReporterControlHandle {
15318    fn shutdown(&self) {
15319        self.inner.shutdown()
15320    }
15321
15322    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
15323        self.inner.shutdown_with_epitaph(status)
15324    }
15325
15326    fn is_closed(&self) -> bool {
15327        self.inner.channel().is_closed()
15328    }
15329    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
15330        self.inner.channel().on_closed()
15331    }
15332}
15333
15334impl UsageGainReporterControlHandle {}
15335
15336#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15337pub struct UsageReporterMarker;
15338
15339impl fdomain_client::fidl::ProtocolMarker for UsageReporterMarker {
15340    type Proxy = UsageReporterProxy;
15341    type RequestStream = UsageReporterRequestStream;
15342
15343    const DEBUG_NAME: &'static str = "fuchsia.media.UsageReporter";
15344}
15345impl fdomain_client::fidl::DiscoverableProtocolMarker for UsageReporterMarker {}
15346
15347pub trait UsageReporterProxyInterface: Send + Sync {
15348    fn r#watch(
15349        &self,
15350        usage: &Usage,
15351        usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcherMarker>,
15352    ) -> Result<(), fidl::Error>;
15353    fn r#watch2(
15354        &self,
15355        usage: &Usage2,
15356        usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>,
15357    ) -> Result<(), fidl::Error>;
15358}
15359
15360#[derive(Debug, Clone)]
15361pub struct UsageReporterProxy {
15362    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
15363}
15364
15365impl fdomain_client::fidl::Proxy for UsageReporterProxy {
15366    type Protocol = UsageReporterMarker;
15367
15368    fn from_channel(inner: fdomain_client::Channel) -> Self {
15369        Self::new(inner)
15370    }
15371
15372    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
15373        self.client.into_channel().map_err(|client| Self { client })
15374    }
15375
15376    fn as_channel(&self) -> &fdomain_client::Channel {
15377        self.client.as_channel()
15378    }
15379}
15380
15381impl UsageReporterProxy {
15382    /// Create a new Proxy for fuchsia.media/UsageReporter.
15383    pub fn new(channel: fdomain_client::Channel) -> Self {
15384        let protocol_name =
15385            <UsageReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
15386        Self { client: fidl::client::Client::new(channel, protocol_name) }
15387    }
15388
15389    /// Get a Stream of events from the remote end of the protocol.
15390    ///
15391    /// # Panics
15392    ///
15393    /// Panics if the event stream was already taken.
15394    pub fn take_event_stream(&self) -> UsageReporterEventStream {
15395        UsageReporterEventStream { event_receiver: self.client.take_event_receiver() }
15396    }
15397
15398    pub fn r#watch(
15399        &self,
15400        mut usage: &Usage,
15401        mut usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcherMarker>,
15402    ) -> Result<(), fidl::Error> {
15403        UsageReporterProxyInterface::r#watch(self, usage, usage_watcher)
15404    }
15405
15406    pub fn r#watch2(
15407        &self,
15408        mut usage: &Usage2,
15409        mut usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>,
15410    ) -> Result<(), fidl::Error> {
15411        UsageReporterProxyInterface::r#watch2(self, usage, usage_watcher)
15412    }
15413}
15414
15415impl UsageReporterProxyInterface for UsageReporterProxy {
15416    fn r#watch(
15417        &self,
15418        mut usage: &Usage,
15419        mut usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcherMarker>,
15420    ) -> Result<(), fidl::Error> {
15421        self.client.send::<UsageReporterWatchRequest>(
15422            (usage, usage_watcher),
15423            0x769e6fb17075c959,
15424            fidl::encoding::DynamicFlags::empty(),
15425        )
15426    }
15427
15428    fn r#watch2(
15429        &self,
15430        mut usage: &Usage2,
15431        mut usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>,
15432    ) -> Result<(), fidl::Error> {
15433        self.client.send::<UsageReporterWatch2Request>(
15434            (usage, usage_watcher),
15435            0x4a43c4c82f5d8ce8,
15436            fidl::encoding::DynamicFlags::FLEXIBLE,
15437        )
15438    }
15439}
15440
15441pub struct UsageReporterEventStream {
15442    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
15443}
15444
15445impl std::marker::Unpin for UsageReporterEventStream {}
15446
15447impl futures::stream::FusedStream for UsageReporterEventStream {
15448    fn is_terminated(&self) -> bool {
15449        self.event_receiver.is_terminated()
15450    }
15451}
15452
15453impl futures::Stream for UsageReporterEventStream {
15454    type Item = Result<UsageReporterEvent, fidl::Error>;
15455
15456    fn poll_next(
15457        mut self: std::pin::Pin<&mut Self>,
15458        cx: &mut std::task::Context<'_>,
15459    ) -> std::task::Poll<Option<Self::Item>> {
15460        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
15461            &mut self.event_receiver,
15462            cx
15463        )?) {
15464            Some(buf) => std::task::Poll::Ready(Some(UsageReporterEvent::decode(buf))),
15465            None => std::task::Poll::Ready(None),
15466        }
15467    }
15468}
15469
15470#[derive(Debug)]
15471pub enum UsageReporterEvent {
15472    #[non_exhaustive]
15473    _UnknownEvent {
15474        /// Ordinal of the event that was sent.
15475        ordinal: u64,
15476    },
15477}
15478
15479impl UsageReporterEvent {
15480    /// Decodes a message buffer as a [`UsageReporterEvent`].
15481    fn decode(
15482        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
15483    ) -> Result<UsageReporterEvent, fidl::Error> {
15484        let (bytes, _handles) = buf.split_mut();
15485        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
15486        debug_assert_eq!(tx_header.tx_id, 0);
15487        match tx_header.ordinal {
15488            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
15489                Ok(UsageReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
15490            }
15491            _ => Err(fidl::Error::UnknownOrdinal {
15492                ordinal: tx_header.ordinal,
15493                protocol_name:
15494                    <UsageReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
15495            }),
15496        }
15497    }
15498}
15499
15500/// A Stream of incoming requests for fuchsia.media/UsageReporter.
15501pub struct UsageReporterRequestStream {
15502    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15503    is_terminated: bool,
15504}
15505
15506impl std::marker::Unpin for UsageReporterRequestStream {}
15507
15508impl futures::stream::FusedStream for UsageReporterRequestStream {
15509    fn is_terminated(&self) -> bool {
15510        self.is_terminated
15511    }
15512}
15513
15514impl fdomain_client::fidl::RequestStream for UsageReporterRequestStream {
15515    type Protocol = UsageReporterMarker;
15516    type ControlHandle = UsageReporterControlHandle;
15517
15518    fn from_channel(channel: fdomain_client::Channel) -> Self {
15519        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
15520    }
15521
15522    fn control_handle(&self) -> Self::ControlHandle {
15523        UsageReporterControlHandle { inner: self.inner.clone() }
15524    }
15525
15526    fn into_inner(
15527        self,
15528    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
15529    {
15530        (self.inner, self.is_terminated)
15531    }
15532
15533    fn from_inner(
15534        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15535        is_terminated: bool,
15536    ) -> Self {
15537        Self { inner, is_terminated }
15538    }
15539}
15540
15541impl futures::Stream for UsageReporterRequestStream {
15542    type Item = Result<UsageReporterRequest, fidl::Error>;
15543
15544    fn poll_next(
15545        mut self: std::pin::Pin<&mut Self>,
15546        cx: &mut std::task::Context<'_>,
15547    ) -> std::task::Poll<Option<Self::Item>> {
15548        let this = &mut *self;
15549        if this.inner.check_shutdown(cx) {
15550            this.is_terminated = true;
15551            return std::task::Poll::Ready(None);
15552        }
15553        if this.is_terminated {
15554            panic!("polled UsageReporterRequestStream after completion");
15555        }
15556        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
15557            |bytes, handles| {
15558                match this.inner.channel().read_etc(cx, bytes, handles) {
15559                    std::task::Poll::Ready(Ok(())) => {}
15560                    std::task::Poll::Pending => return std::task::Poll::Pending,
15561                    std::task::Poll::Ready(Err(None)) => {
15562                        this.is_terminated = true;
15563                        return std::task::Poll::Ready(None);
15564                    }
15565                    std::task::Poll::Ready(Err(Some(e))) => {
15566                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
15567                            e.into(),
15568                        ))));
15569                    }
15570                }
15571
15572                // A message has been received from the channel
15573                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
15574
15575                std::task::Poll::Ready(Some(match header.ordinal {
15576                0x769e6fb17075c959 => {
15577                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
15578                    let mut req = fidl::new_empty!(UsageReporterWatchRequest, fdomain_client::fidl::FDomainResourceDialect);
15579                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageReporterWatchRequest>(&header, _body_bytes, handles, &mut req)?;
15580                    let control_handle = UsageReporterControlHandle {
15581                        inner: this.inner.clone(),
15582                    };
15583                    Ok(UsageReporterRequest::Watch {usage: req.usage,
15584usage_watcher: req.usage_watcher,
15585
15586                        control_handle,
15587                    })
15588                }
15589                0x4a43c4c82f5d8ce8 => {
15590                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
15591                    let mut req = fidl::new_empty!(UsageReporterWatch2Request, fdomain_client::fidl::FDomainResourceDialect);
15592                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageReporterWatch2Request>(&header, _body_bytes, handles, &mut req)?;
15593                    let control_handle = UsageReporterControlHandle {
15594                        inner: this.inner.clone(),
15595                    };
15596                    Ok(UsageReporterRequest::Watch2 {usage: req.usage,
15597usage_watcher: req.usage_watcher,
15598
15599                        control_handle,
15600                    })
15601                }
15602                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
15603                    Ok(UsageReporterRequest::_UnknownMethod {
15604                        ordinal: header.ordinal,
15605                        control_handle: UsageReporterControlHandle { inner: this.inner.clone() },
15606                        method_type: fidl::MethodType::OneWay,
15607                    })
15608                }
15609                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
15610                    this.inner.send_framework_err(
15611                        fidl::encoding::FrameworkErr::UnknownMethod,
15612                        header.tx_id,
15613                        header.ordinal,
15614                        header.dynamic_flags(),
15615                        (bytes, handles),
15616                    )?;
15617                    Ok(UsageReporterRequest::_UnknownMethod {
15618                        ordinal: header.ordinal,
15619                        control_handle: UsageReporterControlHandle { inner: this.inner.clone() },
15620                        method_type: fidl::MethodType::TwoWay,
15621                    })
15622                }
15623                _ => Err(fidl::Error::UnknownOrdinal {
15624                    ordinal: header.ordinal,
15625                    protocol_name: <UsageReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
15626                }),
15627            }))
15628            },
15629        )
15630    }
15631}
15632
15633/// A protocol for setting up watchers of audio usages.
15634#[derive(Debug)]
15635pub enum UsageReporterRequest {
15636    Watch {
15637        usage: Usage,
15638        usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcherMarker>,
15639        control_handle: UsageReporterControlHandle,
15640    },
15641    Watch2 {
15642        usage: Usage2,
15643        usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>,
15644        control_handle: UsageReporterControlHandle,
15645    },
15646    /// An interaction was received which does not match any known method.
15647    #[non_exhaustive]
15648    _UnknownMethod {
15649        /// Ordinal of the method that was called.
15650        ordinal: u64,
15651        control_handle: UsageReporterControlHandle,
15652        method_type: fidl::MethodType,
15653    },
15654}
15655
15656impl UsageReporterRequest {
15657    #[allow(irrefutable_let_patterns)]
15658    pub fn into_watch(
15659        self,
15660    ) -> Option<(
15661        Usage,
15662        fdomain_client::fidl::ClientEnd<UsageWatcherMarker>,
15663        UsageReporterControlHandle,
15664    )> {
15665        if let UsageReporterRequest::Watch { usage, usage_watcher, control_handle } = self {
15666            Some((usage, usage_watcher, control_handle))
15667        } else {
15668            None
15669        }
15670    }
15671
15672    #[allow(irrefutable_let_patterns)]
15673    pub fn into_watch2(
15674        self,
15675    ) -> Option<(
15676        Usage2,
15677        fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>,
15678        UsageReporterControlHandle,
15679    )> {
15680        if let UsageReporterRequest::Watch2 { usage, usage_watcher, control_handle } = self {
15681            Some((usage, usage_watcher, control_handle))
15682        } else {
15683            None
15684        }
15685    }
15686
15687    /// Name of the method defined in FIDL
15688    pub fn method_name(&self) -> &'static str {
15689        match *self {
15690            UsageReporterRequest::Watch { .. } => "watch",
15691            UsageReporterRequest::Watch2 { .. } => "watch2",
15692            UsageReporterRequest::_UnknownMethod {
15693                method_type: fidl::MethodType::OneWay, ..
15694            } => "unknown one-way method",
15695            UsageReporterRequest::_UnknownMethod {
15696                method_type: fidl::MethodType::TwoWay, ..
15697            } => "unknown two-way method",
15698        }
15699    }
15700}
15701
15702#[derive(Debug, Clone)]
15703pub struct UsageReporterControlHandle {
15704    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15705}
15706
15707impl fdomain_client::fidl::ControlHandle for UsageReporterControlHandle {
15708    fn shutdown(&self) {
15709        self.inner.shutdown()
15710    }
15711
15712    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
15713        self.inner.shutdown_with_epitaph(status)
15714    }
15715
15716    fn is_closed(&self) -> bool {
15717        self.inner.channel().is_closed()
15718    }
15719    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
15720        self.inner.channel().on_closed()
15721    }
15722}
15723
15724impl UsageReporterControlHandle {}
15725
15726#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15727pub struct UsageWatcherMarker;
15728
15729impl fdomain_client::fidl::ProtocolMarker for UsageWatcherMarker {
15730    type Proxy = UsageWatcherProxy;
15731    type RequestStream = UsageWatcherRequestStream;
15732
15733    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher";
15734}
15735
15736pub trait UsageWatcherProxyInterface: Send + Sync {
15737    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
15738    fn r#on_state_changed(
15739        &self,
15740        usage: &Usage,
15741        state: &UsageState,
15742    ) -> Self::OnStateChangedResponseFut;
15743}
15744
15745#[derive(Debug, Clone)]
15746pub struct UsageWatcherProxy {
15747    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
15748}
15749
15750impl fdomain_client::fidl::Proxy for UsageWatcherProxy {
15751    type Protocol = UsageWatcherMarker;
15752
15753    fn from_channel(inner: fdomain_client::Channel) -> Self {
15754        Self::new(inner)
15755    }
15756
15757    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
15758        self.client.into_channel().map_err(|client| Self { client })
15759    }
15760
15761    fn as_channel(&self) -> &fdomain_client::Channel {
15762        self.client.as_channel()
15763    }
15764}
15765
15766impl UsageWatcherProxy {
15767    /// Create a new Proxy for fuchsia.media/UsageWatcher.
15768    pub fn new(channel: fdomain_client::Channel) -> Self {
15769        let protocol_name =
15770            <UsageWatcherMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
15771        Self { client: fidl::client::Client::new(channel, protocol_name) }
15772    }
15773
15774    /// Get a Stream of events from the remote end of the protocol.
15775    ///
15776    /// # Panics
15777    ///
15778    /// Panics if the event stream was already taken.
15779    pub fn take_event_stream(&self) -> UsageWatcherEventStream {
15780        UsageWatcherEventStream { event_receiver: self.client.take_event_receiver() }
15781    }
15782
15783    /// Called on first connection and whenever the watched usage changes. The provided
15784    /// usage will always be the bound usage; it is provided so that an implementation of
15785    /// this protocol may be bound to more than one usage.
15786    ///
15787    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
15788    /// events will eventually be disconnected.
15789    pub fn r#on_state_changed(
15790        &self,
15791        mut usage: &Usage,
15792        mut state: &UsageState,
15793    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
15794        UsageWatcherProxyInterface::r#on_state_changed(self, usage, state)
15795    }
15796}
15797
15798impl UsageWatcherProxyInterface for UsageWatcherProxy {
15799    type OnStateChangedResponseFut =
15800        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
15801    fn r#on_state_changed(
15802        &self,
15803        mut usage: &Usage,
15804        mut state: &UsageState,
15805    ) -> Self::OnStateChangedResponseFut {
15806        fn _decode(
15807            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
15808        ) -> Result<(), fidl::Error> {
15809            let _response = fidl::client::decode_transaction_body::<
15810                fidl::encoding::EmptyPayload,
15811                fdomain_client::fidl::FDomainResourceDialect,
15812                0x5b955c5768ec75c5,
15813            >(_buf?)?;
15814            Ok(_response)
15815        }
15816        self.client.send_query_and_decode::<UsageWatcherOnStateChangedRequest, ()>(
15817            (usage, state),
15818            0x5b955c5768ec75c5,
15819            fidl::encoding::DynamicFlags::empty(),
15820            _decode,
15821        )
15822    }
15823}
15824
15825pub struct UsageWatcherEventStream {
15826    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
15827}
15828
15829impl std::marker::Unpin for UsageWatcherEventStream {}
15830
15831impl futures::stream::FusedStream for UsageWatcherEventStream {
15832    fn is_terminated(&self) -> bool {
15833        self.event_receiver.is_terminated()
15834    }
15835}
15836
15837impl futures::Stream for UsageWatcherEventStream {
15838    type Item = Result<UsageWatcherEvent, fidl::Error>;
15839
15840    fn poll_next(
15841        mut self: std::pin::Pin<&mut Self>,
15842        cx: &mut std::task::Context<'_>,
15843    ) -> std::task::Poll<Option<Self::Item>> {
15844        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
15845            &mut self.event_receiver,
15846            cx
15847        )?) {
15848            Some(buf) => std::task::Poll::Ready(Some(UsageWatcherEvent::decode(buf))),
15849            None => std::task::Poll::Ready(None),
15850        }
15851    }
15852}
15853
15854#[derive(Debug)]
15855pub enum UsageWatcherEvent {}
15856
15857impl UsageWatcherEvent {
15858    /// Decodes a message buffer as a [`UsageWatcherEvent`].
15859    fn decode(
15860        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
15861    ) -> Result<UsageWatcherEvent, fidl::Error> {
15862        let (bytes, _handles) = buf.split_mut();
15863        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
15864        debug_assert_eq!(tx_header.tx_id, 0);
15865        match tx_header.ordinal {
15866            _ => Err(fidl::Error::UnknownOrdinal {
15867                ordinal: tx_header.ordinal,
15868                protocol_name:
15869                    <UsageWatcherMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
15870            }),
15871        }
15872    }
15873}
15874
15875/// A Stream of incoming requests for fuchsia.media/UsageWatcher.
15876pub struct UsageWatcherRequestStream {
15877    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15878    is_terminated: bool,
15879}
15880
15881impl std::marker::Unpin for UsageWatcherRequestStream {}
15882
15883impl futures::stream::FusedStream for UsageWatcherRequestStream {
15884    fn is_terminated(&self) -> bool {
15885        self.is_terminated
15886    }
15887}
15888
15889impl fdomain_client::fidl::RequestStream for UsageWatcherRequestStream {
15890    type Protocol = UsageWatcherMarker;
15891    type ControlHandle = UsageWatcherControlHandle;
15892
15893    fn from_channel(channel: fdomain_client::Channel) -> Self {
15894        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
15895    }
15896
15897    fn control_handle(&self) -> Self::ControlHandle {
15898        UsageWatcherControlHandle { inner: self.inner.clone() }
15899    }
15900
15901    fn into_inner(
15902        self,
15903    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
15904    {
15905        (self.inner, self.is_terminated)
15906    }
15907
15908    fn from_inner(
15909        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15910        is_terminated: bool,
15911    ) -> Self {
15912        Self { inner, is_terminated }
15913    }
15914}
15915
15916impl futures::Stream for UsageWatcherRequestStream {
15917    type Item = Result<UsageWatcherRequest, fidl::Error>;
15918
15919    fn poll_next(
15920        mut self: std::pin::Pin<&mut Self>,
15921        cx: &mut std::task::Context<'_>,
15922    ) -> std::task::Poll<Option<Self::Item>> {
15923        let this = &mut *self;
15924        if this.inner.check_shutdown(cx) {
15925            this.is_terminated = true;
15926            return std::task::Poll::Ready(None);
15927        }
15928        if this.is_terminated {
15929            panic!("polled UsageWatcherRequestStream after completion");
15930        }
15931        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
15932            |bytes, handles| {
15933                match this.inner.channel().read_etc(cx, bytes, handles) {
15934                    std::task::Poll::Ready(Ok(())) => {}
15935                    std::task::Poll::Pending => return std::task::Poll::Pending,
15936                    std::task::Poll::Ready(Err(None)) => {
15937                        this.is_terminated = true;
15938                        return std::task::Poll::Ready(None);
15939                    }
15940                    std::task::Poll::Ready(Err(Some(e))) => {
15941                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
15942                            e.into(),
15943                        ))));
15944                    }
15945                }
15946
15947                // A message has been received from the channel
15948                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
15949
15950                std::task::Poll::Ready(Some(match header.ordinal {
15951                    0x5b955c5768ec75c5 => {
15952                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
15953                        let mut req = fidl::new_empty!(
15954                            UsageWatcherOnStateChangedRequest,
15955                            fdomain_client::fidl::FDomainResourceDialect
15956                        );
15957                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageWatcherOnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
15958                        let control_handle =
15959                            UsageWatcherControlHandle { inner: this.inner.clone() };
15960                        Ok(UsageWatcherRequest::OnStateChanged {
15961                            usage: req.usage,
15962                            state: req.state,
15963
15964                            responder: UsageWatcherOnStateChangedResponder {
15965                                control_handle: std::mem::ManuallyDrop::new(control_handle),
15966                                tx_id: header.tx_id,
15967                            },
15968                        })
15969                    }
15970                    _ => Err(fidl::Error::UnknownOrdinal {
15971                        ordinal: header.ordinal,
15972                        protocol_name:
15973                            <UsageWatcherMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
15974                    }),
15975                }))
15976            },
15977        )
15978    }
15979}
15980
15981/// A protocol for listening to changes to the policy state of an audio usage.
15982///
15983/// User actions, such as lowering the volume or muting a stream, are not reflected in this API.
15984#[derive(Debug)]
15985pub enum UsageWatcherRequest {
15986    /// Called on first connection and whenever the watched usage changes. The provided
15987    /// usage will always be the bound usage; it is provided so that an implementation of
15988    /// this protocol may be bound to more than one usage.
15989    ///
15990    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
15991    /// events will eventually be disconnected.
15992    OnStateChanged {
15993        usage: Usage,
15994        state: UsageState,
15995        responder: UsageWatcherOnStateChangedResponder,
15996    },
15997}
15998
15999impl UsageWatcherRequest {
16000    #[allow(irrefutable_let_patterns)]
16001    pub fn into_on_state_changed(
16002        self,
16003    ) -> Option<(Usage, UsageState, UsageWatcherOnStateChangedResponder)> {
16004        if let UsageWatcherRequest::OnStateChanged { usage, state, responder } = self {
16005            Some((usage, state, responder))
16006        } else {
16007            None
16008        }
16009    }
16010
16011    /// Name of the method defined in FIDL
16012    pub fn method_name(&self) -> &'static str {
16013        match *self {
16014            UsageWatcherRequest::OnStateChanged { .. } => "on_state_changed",
16015        }
16016    }
16017}
16018
16019#[derive(Debug, Clone)]
16020pub struct UsageWatcherControlHandle {
16021    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
16022}
16023
16024impl fdomain_client::fidl::ControlHandle for UsageWatcherControlHandle {
16025    fn shutdown(&self) {
16026        self.inner.shutdown()
16027    }
16028
16029    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
16030        self.inner.shutdown_with_epitaph(status)
16031    }
16032
16033    fn is_closed(&self) -> bool {
16034        self.inner.channel().is_closed()
16035    }
16036    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
16037        self.inner.channel().on_closed()
16038    }
16039}
16040
16041impl UsageWatcherControlHandle {}
16042
16043#[must_use = "FIDL methods require a response to be sent"]
16044#[derive(Debug)]
16045pub struct UsageWatcherOnStateChangedResponder {
16046    control_handle: std::mem::ManuallyDrop<UsageWatcherControlHandle>,
16047    tx_id: u32,
16048}
16049
16050/// Set the the channel to be shutdown (see [`UsageWatcherControlHandle::shutdown`])
16051/// if the responder is dropped without sending a response, so that the client
16052/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
16053impl std::ops::Drop for UsageWatcherOnStateChangedResponder {
16054    fn drop(&mut self) {
16055        self.control_handle.shutdown();
16056        // Safety: drops once, never accessed again
16057        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16058    }
16059}
16060
16061impl fdomain_client::fidl::Responder for UsageWatcherOnStateChangedResponder {
16062    type ControlHandle = UsageWatcherControlHandle;
16063
16064    fn control_handle(&self) -> &UsageWatcherControlHandle {
16065        &self.control_handle
16066    }
16067
16068    fn drop_without_shutdown(mut self) {
16069        // Safety: drops once, never accessed again due to mem::forget
16070        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16071        // Prevent Drop from running (which would shut down the channel)
16072        std::mem::forget(self);
16073    }
16074}
16075
16076impl UsageWatcherOnStateChangedResponder {
16077    /// Sends a response to the FIDL transaction.
16078    ///
16079    /// Sets the channel to shutdown if an error occurs.
16080    pub fn send(self) -> Result<(), fidl::Error> {
16081        let _result = self.send_raw();
16082        if _result.is_err() {
16083            self.control_handle.shutdown();
16084        }
16085        self.drop_without_shutdown();
16086        _result
16087    }
16088
16089    /// Similar to "send" but does not shutdown the channel if an error occurs.
16090    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
16091        let _result = self.send_raw();
16092        self.drop_without_shutdown();
16093        _result
16094    }
16095
16096    fn send_raw(&self) -> Result<(), fidl::Error> {
16097        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
16098            (),
16099            self.tx_id,
16100            0x5b955c5768ec75c5,
16101            fidl::encoding::DynamicFlags::empty(),
16102        )
16103    }
16104}
16105
16106#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
16107pub struct UsageWatcher2Marker;
16108
16109impl fdomain_client::fidl::ProtocolMarker for UsageWatcher2Marker {
16110    type Proxy = UsageWatcher2Proxy;
16111    type RequestStream = UsageWatcher2RequestStream;
16112
16113    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher2";
16114}
16115
16116pub trait UsageWatcher2ProxyInterface: Send + Sync {
16117    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
16118    fn r#on_state_changed(
16119        &self,
16120        usage: &Usage2,
16121        state: &UsageState,
16122    ) -> Self::OnStateChangedResponseFut;
16123}
16124
16125#[derive(Debug, Clone)]
16126pub struct UsageWatcher2Proxy {
16127    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
16128}
16129
16130impl fdomain_client::fidl::Proxy for UsageWatcher2Proxy {
16131    type Protocol = UsageWatcher2Marker;
16132
16133    fn from_channel(inner: fdomain_client::Channel) -> Self {
16134        Self::new(inner)
16135    }
16136
16137    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
16138        self.client.into_channel().map_err(|client| Self { client })
16139    }
16140
16141    fn as_channel(&self) -> &fdomain_client::Channel {
16142        self.client.as_channel()
16143    }
16144}
16145
16146impl UsageWatcher2Proxy {
16147    /// Create a new Proxy for fuchsia.media/UsageWatcher2.
16148    pub fn new(channel: fdomain_client::Channel) -> Self {
16149        let protocol_name =
16150            <UsageWatcher2Marker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
16151        Self { client: fidl::client::Client::new(channel, protocol_name) }
16152    }
16153
16154    /// Get a Stream of events from the remote end of the protocol.
16155    ///
16156    /// # Panics
16157    ///
16158    /// Panics if the event stream was already taken.
16159    pub fn take_event_stream(&self) -> UsageWatcher2EventStream {
16160        UsageWatcher2EventStream { event_receiver: self.client.take_event_receiver() }
16161    }
16162
16163    /// Called on first connection and whenever the watched usage changes. The provided
16164    /// usage will always be the bound usage; it is provided so that an implementation of
16165    /// this protocol may be bound to more than one usage.
16166    ///
16167    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
16168    /// events will eventually be disconnected.
16169    pub fn r#on_state_changed(
16170        &self,
16171        mut usage: &Usage2,
16172        mut state: &UsageState,
16173    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
16174        UsageWatcher2ProxyInterface::r#on_state_changed(self, usage, state)
16175    }
16176}
16177
16178impl UsageWatcher2ProxyInterface for UsageWatcher2Proxy {
16179    type OnStateChangedResponseFut =
16180        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
16181    fn r#on_state_changed(
16182        &self,
16183        mut usage: &Usage2,
16184        mut state: &UsageState,
16185    ) -> Self::OnStateChangedResponseFut {
16186        fn _decode(
16187            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
16188        ) -> Result<(), fidl::Error> {
16189            let _response = fidl::client::decode_transaction_body::<
16190                fidl::encoding::EmptyPayload,
16191                fdomain_client::fidl::FDomainResourceDialect,
16192                0xca31a8b13c324d4,
16193            >(_buf?)?;
16194            Ok(_response)
16195        }
16196        self.client.send_query_and_decode::<UsageWatcher2OnStateChangedRequest, ()>(
16197            (usage, state),
16198            0xca31a8b13c324d4,
16199            fidl::encoding::DynamicFlags::empty(),
16200            _decode,
16201        )
16202    }
16203}
16204
16205pub struct UsageWatcher2EventStream {
16206    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
16207}
16208
16209impl std::marker::Unpin for UsageWatcher2EventStream {}
16210
16211impl futures::stream::FusedStream for UsageWatcher2EventStream {
16212    fn is_terminated(&self) -> bool {
16213        self.event_receiver.is_terminated()
16214    }
16215}
16216
16217impl futures::Stream for UsageWatcher2EventStream {
16218    type Item = Result<UsageWatcher2Event, fidl::Error>;
16219
16220    fn poll_next(
16221        mut self: std::pin::Pin<&mut Self>,
16222        cx: &mut std::task::Context<'_>,
16223    ) -> std::task::Poll<Option<Self::Item>> {
16224        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
16225            &mut self.event_receiver,
16226            cx
16227        )?) {
16228            Some(buf) => std::task::Poll::Ready(Some(UsageWatcher2Event::decode(buf))),
16229            None => std::task::Poll::Ready(None),
16230        }
16231    }
16232}
16233
16234#[derive(Debug)]
16235pub enum UsageWatcher2Event {}
16236
16237impl UsageWatcher2Event {
16238    /// Decodes a message buffer as a [`UsageWatcher2Event`].
16239    fn decode(
16240        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
16241    ) -> Result<UsageWatcher2Event, fidl::Error> {
16242        let (bytes, _handles) = buf.split_mut();
16243        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16244        debug_assert_eq!(tx_header.tx_id, 0);
16245        match tx_header.ordinal {
16246            _ => Err(fidl::Error::UnknownOrdinal {
16247                ordinal: tx_header.ordinal,
16248                protocol_name:
16249                    <UsageWatcher2Marker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
16250            }),
16251        }
16252    }
16253}
16254
16255/// A Stream of incoming requests for fuchsia.media/UsageWatcher2.
16256pub struct UsageWatcher2RequestStream {
16257    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
16258    is_terminated: bool,
16259}
16260
16261impl std::marker::Unpin for UsageWatcher2RequestStream {}
16262
16263impl futures::stream::FusedStream for UsageWatcher2RequestStream {
16264    fn is_terminated(&self) -> bool {
16265        self.is_terminated
16266    }
16267}
16268
16269impl fdomain_client::fidl::RequestStream for UsageWatcher2RequestStream {
16270    type Protocol = UsageWatcher2Marker;
16271    type ControlHandle = UsageWatcher2ControlHandle;
16272
16273    fn from_channel(channel: fdomain_client::Channel) -> Self {
16274        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
16275    }
16276
16277    fn control_handle(&self) -> Self::ControlHandle {
16278        UsageWatcher2ControlHandle { inner: self.inner.clone() }
16279    }
16280
16281    fn into_inner(
16282        self,
16283    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
16284    {
16285        (self.inner, self.is_terminated)
16286    }
16287
16288    fn from_inner(
16289        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
16290        is_terminated: bool,
16291    ) -> Self {
16292        Self { inner, is_terminated }
16293    }
16294}
16295
16296impl futures::Stream for UsageWatcher2RequestStream {
16297    type Item = Result<UsageWatcher2Request, fidl::Error>;
16298
16299    fn poll_next(
16300        mut self: std::pin::Pin<&mut Self>,
16301        cx: &mut std::task::Context<'_>,
16302    ) -> std::task::Poll<Option<Self::Item>> {
16303        let this = &mut *self;
16304        if this.inner.check_shutdown(cx) {
16305            this.is_terminated = true;
16306            return std::task::Poll::Ready(None);
16307        }
16308        if this.is_terminated {
16309            panic!("polled UsageWatcher2RequestStream after completion");
16310        }
16311        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
16312            |bytes, handles| {
16313                match this.inner.channel().read_etc(cx, bytes, handles) {
16314                    std::task::Poll::Ready(Ok(())) => {}
16315                    std::task::Poll::Pending => return std::task::Poll::Pending,
16316                    std::task::Poll::Ready(Err(None)) => {
16317                        this.is_terminated = true;
16318                        return std::task::Poll::Ready(None);
16319                    }
16320                    std::task::Poll::Ready(Err(Some(e))) => {
16321                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
16322                            e.into(),
16323                        ))));
16324                    }
16325                }
16326
16327                // A message has been received from the channel
16328                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16329
16330                std::task::Poll::Ready(Some(match header.ordinal {
16331                0xca31a8b13c324d4 => {
16332                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16333                    let mut req = fidl::new_empty!(UsageWatcher2OnStateChangedRequest, fdomain_client::fidl::FDomainResourceDialect);
16334                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageWatcher2OnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
16335                    let control_handle = UsageWatcher2ControlHandle {
16336                        inner: this.inner.clone(),
16337                    };
16338                    Ok(UsageWatcher2Request::OnStateChanged {usage: req.usage,
16339state: req.state,
16340
16341                        responder: UsageWatcher2OnStateChangedResponder {
16342                            control_handle: std::mem::ManuallyDrop::new(control_handle),
16343                            tx_id: header.tx_id,
16344                        },
16345                    })
16346                }
16347                _ => Err(fidl::Error::UnknownOrdinal {
16348                    ordinal: header.ordinal,
16349                    protocol_name: <UsageWatcher2Marker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
16350                }),
16351            }))
16352            },
16353        )
16354    }
16355}
16356
16357#[derive(Debug)]
16358pub enum UsageWatcher2Request {
16359    /// Called on first connection and whenever the watched usage changes. The provided
16360    /// usage will always be the bound usage; it is provided so that an implementation of
16361    /// this protocol may be bound to more than one usage.
16362    ///
16363    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
16364    /// events will eventually be disconnected.
16365    OnStateChanged {
16366        usage: Usage2,
16367        state: UsageState,
16368        responder: UsageWatcher2OnStateChangedResponder,
16369    },
16370}
16371
16372impl UsageWatcher2Request {
16373    #[allow(irrefutable_let_patterns)]
16374    pub fn into_on_state_changed(
16375        self,
16376    ) -> Option<(Usage2, UsageState, UsageWatcher2OnStateChangedResponder)> {
16377        if let UsageWatcher2Request::OnStateChanged { usage, state, responder } = self {
16378            Some((usage, state, responder))
16379        } else {
16380            None
16381        }
16382    }
16383
16384    /// Name of the method defined in FIDL
16385    pub fn method_name(&self) -> &'static str {
16386        match *self {
16387            UsageWatcher2Request::OnStateChanged { .. } => "on_state_changed",
16388        }
16389    }
16390}
16391
16392#[derive(Debug, Clone)]
16393pub struct UsageWatcher2ControlHandle {
16394    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
16395}
16396
16397impl fdomain_client::fidl::ControlHandle for UsageWatcher2ControlHandle {
16398    fn shutdown(&self) {
16399        self.inner.shutdown()
16400    }
16401
16402    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
16403        self.inner.shutdown_with_epitaph(status)
16404    }
16405
16406    fn is_closed(&self) -> bool {
16407        self.inner.channel().is_closed()
16408    }
16409    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
16410        self.inner.channel().on_closed()
16411    }
16412}
16413
16414impl UsageWatcher2ControlHandle {}
16415
16416#[must_use = "FIDL methods require a response to be sent"]
16417#[derive(Debug)]
16418pub struct UsageWatcher2OnStateChangedResponder {
16419    control_handle: std::mem::ManuallyDrop<UsageWatcher2ControlHandle>,
16420    tx_id: u32,
16421}
16422
16423/// Set the the channel to be shutdown (see [`UsageWatcher2ControlHandle::shutdown`])
16424/// if the responder is dropped without sending a response, so that the client
16425/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
16426impl std::ops::Drop for UsageWatcher2OnStateChangedResponder {
16427    fn drop(&mut self) {
16428        self.control_handle.shutdown();
16429        // Safety: drops once, never accessed again
16430        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16431    }
16432}
16433
16434impl fdomain_client::fidl::Responder for UsageWatcher2OnStateChangedResponder {
16435    type ControlHandle = UsageWatcher2ControlHandle;
16436
16437    fn control_handle(&self) -> &UsageWatcher2ControlHandle {
16438        &self.control_handle
16439    }
16440
16441    fn drop_without_shutdown(mut self) {
16442        // Safety: drops once, never accessed again due to mem::forget
16443        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16444        // Prevent Drop from running (which would shut down the channel)
16445        std::mem::forget(self);
16446    }
16447}
16448
16449impl UsageWatcher2OnStateChangedResponder {
16450    /// Sends a response to the FIDL transaction.
16451    ///
16452    /// Sets the channel to shutdown if an error occurs.
16453    pub fn send(self) -> Result<(), fidl::Error> {
16454        let _result = self.send_raw();
16455        if _result.is_err() {
16456            self.control_handle.shutdown();
16457        }
16458        self.drop_without_shutdown();
16459        _result
16460    }
16461
16462    /// Similar to "send" but does not shutdown the channel if an error occurs.
16463    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
16464        let _result = self.send_raw();
16465        self.drop_without_shutdown();
16466        _result
16467    }
16468
16469    fn send_raw(&self) -> Result<(), fidl::Error> {
16470        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
16471            (),
16472            self.tx_id,
16473            0xca31a8b13c324d4,
16474            fidl::encoding::DynamicFlags::empty(),
16475        )
16476    }
16477}
16478
16479mod internal {
16480    use super::*;
16481
16482    impl fidl::encoding::ResourceTypeMarker for AudioCapturerBindGainControlRequest {
16483        type Borrowed<'a> = &'a mut Self;
16484        fn take_or_borrow<'a>(
16485            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16486        ) -> Self::Borrowed<'a> {
16487            value
16488        }
16489    }
16490
16491    unsafe impl fidl::encoding::TypeMarker for AudioCapturerBindGainControlRequest {
16492        type Owned = Self;
16493
16494        #[inline(always)]
16495        fn inline_align(_context: fidl::encoding::Context) -> usize {
16496            4
16497        }
16498
16499        #[inline(always)]
16500        fn inline_size(_context: fidl::encoding::Context) -> usize {
16501            4
16502        }
16503    }
16504
16505    unsafe impl
16506        fidl::encoding::Encode<
16507            AudioCapturerBindGainControlRequest,
16508            fdomain_client::fidl::FDomainResourceDialect,
16509        > for &mut AudioCapturerBindGainControlRequest
16510    {
16511        #[inline]
16512        unsafe fn encode(
16513            self,
16514            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16515            offset: usize,
16516            _depth: fidl::encoding::Depth,
16517        ) -> fidl::Result<()> {
16518            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
16519            // Delegate to tuple encoding.
16520            fidl::encoding::Encode::<
16521                AudioCapturerBindGainControlRequest,
16522                fdomain_client::fidl::FDomainResourceDialect,
16523            >::encode(
16524                (<fidl::encoding::Endpoint<
16525                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
16526                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
16527                    &mut self.gain_control_request,
16528                ),),
16529                encoder,
16530                offset,
16531                _depth,
16532            )
16533        }
16534    }
16535    unsafe impl<
16536        T0: fidl::encoding::Encode<
16537                fidl::encoding::Endpoint<
16538                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
16539                >,
16540                fdomain_client::fidl::FDomainResourceDialect,
16541            >,
16542    >
16543        fidl::encoding::Encode<
16544            AudioCapturerBindGainControlRequest,
16545            fdomain_client::fidl::FDomainResourceDialect,
16546        > for (T0,)
16547    {
16548        #[inline]
16549        unsafe fn encode(
16550            self,
16551            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16552            offset: usize,
16553            depth: fidl::encoding::Depth,
16554        ) -> fidl::Result<()> {
16555            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
16556            // Zero out padding regions. There's no need to apply masks
16557            // because the unmasked parts will be overwritten by fields.
16558            // Write the fields.
16559            self.0.encode(encoder, offset + 0, depth)?;
16560            Ok(())
16561        }
16562    }
16563
16564    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
16565        for AudioCapturerBindGainControlRequest
16566    {
16567        #[inline(always)]
16568        fn new_empty() -> Self {
16569            Self {
16570                gain_control_request: fidl::new_empty!(
16571                    fidl::encoding::Endpoint<
16572                        fdomain_client::fidl::ServerEnd<
16573                            fdomain_fuchsia_media_audio::GainControlMarker,
16574                        >,
16575                    >,
16576                    fdomain_client::fidl::FDomainResourceDialect
16577                ),
16578            }
16579        }
16580
16581        #[inline]
16582        unsafe fn decode(
16583            &mut self,
16584            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16585            offset: usize,
16586            _depth: fidl::encoding::Depth,
16587        ) -> fidl::Result<()> {
16588            decoder.debug_check_bounds::<Self>(offset);
16589            // Verify that padding bytes are zero.
16590            fidl::decode!(
16591                fidl::encoding::Endpoint<
16592                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
16593                >,
16594                fdomain_client::fidl::FDomainResourceDialect,
16595                &mut self.gain_control_request,
16596                decoder,
16597                offset + 0,
16598                _depth
16599            )?;
16600            Ok(())
16601        }
16602    }
16603
16604    impl fidl::encoding::ResourceTypeMarker for AudioCapturerGetReferenceClockResponse {
16605        type Borrowed<'a> = &'a mut Self;
16606        fn take_or_borrow<'a>(
16607            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16608        ) -> Self::Borrowed<'a> {
16609            value
16610        }
16611    }
16612
16613    unsafe impl fidl::encoding::TypeMarker for AudioCapturerGetReferenceClockResponse {
16614        type Owned = Self;
16615
16616        #[inline(always)]
16617        fn inline_align(_context: fidl::encoding::Context) -> usize {
16618            4
16619        }
16620
16621        #[inline(always)]
16622        fn inline_size(_context: fidl::encoding::Context) -> usize {
16623            4
16624        }
16625    }
16626
16627    unsafe impl
16628        fidl::encoding::Encode<
16629            AudioCapturerGetReferenceClockResponse,
16630            fdomain_client::fidl::FDomainResourceDialect,
16631        > for &mut AudioCapturerGetReferenceClockResponse
16632    {
16633        #[inline]
16634        unsafe fn encode(
16635            self,
16636            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16637            offset: usize,
16638            _depth: fidl::encoding::Depth,
16639        ) -> fidl::Result<()> {
16640            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
16641            // Delegate to tuple encoding.
16642            fidl::encoding::Encode::<
16643                AudioCapturerGetReferenceClockResponse,
16644                fdomain_client::fidl::FDomainResourceDialect,
16645            >::encode(
16646                (<fidl::encoding::HandleType<
16647                    fdomain_client::Clock,
16648                    { fidl::ObjectType::CLOCK.into_raw() },
16649                    2147483648,
16650                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
16651                    &mut self.reference_clock,
16652                ),),
16653                encoder,
16654                offset,
16655                _depth,
16656            )
16657        }
16658    }
16659    unsafe impl<
16660        T0: fidl::encoding::Encode<
16661                fidl::encoding::HandleType<
16662                    fdomain_client::Clock,
16663                    { fidl::ObjectType::CLOCK.into_raw() },
16664                    2147483648,
16665                >,
16666                fdomain_client::fidl::FDomainResourceDialect,
16667            >,
16668    >
16669        fidl::encoding::Encode<
16670            AudioCapturerGetReferenceClockResponse,
16671            fdomain_client::fidl::FDomainResourceDialect,
16672        > for (T0,)
16673    {
16674        #[inline]
16675        unsafe fn encode(
16676            self,
16677            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16678            offset: usize,
16679            depth: fidl::encoding::Depth,
16680        ) -> fidl::Result<()> {
16681            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
16682            // Zero out padding regions. There's no need to apply masks
16683            // because the unmasked parts will be overwritten by fields.
16684            // Write the fields.
16685            self.0.encode(encoder, offset + 0, depth)?;
16686            Ok(())
16687        }
16688    }
16689
16690    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
16691        for AudioCapturerGetReferenceClockResponse
16692    {
16693        #[inline(always)]
16694        fn new_empty() -> Self {
16695            Self {
16696                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
16697            }
16698        }
16699
16700        #[inline]
16701        unsafe fn decode(
16702            &mut self,
16703            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16704            offset: usize,
16705            _depth: fidl::encoding::Depth,
16706        ) -> fidl::Result<()> {
16707            decoder.debug_check_bounds::<Self>(offset);
16708            // Verify that padding bytes are zero.
16709            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
16710            Ok(())
16711        }
16712    }
16713
16714    impl fidl::encoding::ResourceTypeMarker for AudioCapturerSetReferenceClockRequest {
16715        type Borrowed<'a> = &'a mut Self;
16716        fn take_or_borrow<'a>(
16717            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16718        ) -> Self::Borrowed<'a> {
16719            value
16720        }
16721    }
16722
16723    unsafe impl fidl::encoding::TypeMarker for AudioCapturerSetReferenceClockRequest {
16724        type Owned = Self;
16725
16726        #[inline(always)]
16727        fn inline_align(_context: fidl::encoding::Context) -> usize {
16728            4
16729        }
16730
16731        #[inline(always)]
16732        fn inline_size(_context: fidl::encoding::Context) -> usize {
16733            4
16734        }
16735    }
16736
16737    unsafe impl
16738        fidl::encoding::Encode<
16739            AudioCapturerSetReferenceClockRequest,
16740            fdomain_client::fidl::FDomainResourceDialect,
16741        > for &mut AudioCapturerSetReferenceClockRequest
16742    {
16743        #[inline]
16744        unsafe fn encode(
16745            self,
16746            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16747            offset: usize,
16748            _depth: fidl::encoding::Depth,
16749        ) -> fidl::Result<()> {
16750            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
16751            // Delegate to tuple encoding.
16752            fidl::encoding::Encode::<
16753                AudioCapturerSetReferenceClockRequest,
16754                fdomain_client::fidl::FDomainResourceDialect,
16755            >::encode(
16756                (<fidl::encoding::Optional<
16757                    fidl::encoding::HandleType<
16758                        fdomain_client::Clock,
16759                        { fidl::ObjectType::CLOCK.into_raw() },
16760                        2147483648,
16761                    >,
16762                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
16763                    &mut self.reference_clock,
16764                ),),
16765                encoder,
16766                offset,
16767                _depth,
16768            )
16769        }
16770    }
16771    unsafe impl<
16772        T0: fidl::encoding::Encode<
16773                fidl::encoding::Optional<
16774                    fidl::encoding::HandleType<
16775                        fdomain_client::Clock,
16776                        { fidl::ObjectType::CLOCK.into_raw() },
16777                        2147483648,
16778                    >,
16779                >,
16780                fdomain_client::fidl::FDomainResourceDialect,
16781            >,
16782    >
16783        fidl::encoding::Encode<
16784            AudioCapturerSetReferenceClockRequest,
16785            fdomain_client::fidl::FDomainResourceDialect,
16786        > for (T0,)
16787    {
16788        #[inline]
16789        unsafe fn encode(
16790            self,
16791            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16792            offset: usize,
16793            depth: fidl::encoding::Depth,
16794        ) -> fidl::Result<()> {
16795            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
16796            // Zero out padding regions. There's no need to apply masks
16797            // because the unmasked parts will be overwritten by fields.
16798            // Write the fields.
16799            self.0.encode(encoder, offset + 0, depth)?;
16800            Ok(())
16801        }
16802    }
16803
16804    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
16805        for AudioCapturerSetReferenceClockRequest
16806    {
16807        #[inline(always)]
16808        fn new_empty() -> Self {
16809            Self {
16810                reference_clock: fidl::new_empty!(
16811                    fidl::encoding::Optional<
16812                        fidl::encoding::HandleType<
16813                            fdomain_client::Clock,
16814                            { fidl::ObjectType::CLOCK.into_raw() },
16815                            2147483648,
16816                        >,
16817                    >,
16818                    fdomain_client::fidl::FDomainResourceDialect
16819                ),
16820            }
16821        }
16822
16823        #[inline]
16824        unsafe fn decode(
16825            &mut self,
16826            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16827            offset: usize,
16828            _depth: fidl::encoding::Depth,
16829        ) -> fidl::Result<()> {
16830            decoder.debug_check_bounds::<Self>(offset);
16831            // Verify that padding bytes are zero.
16832            fidl::decode!(
16833                fidl::encoding::Optional<
16834                    fidl::encoding::HandleType<
16835                        fdomain_client::Clock,
16836                        { fidl::ObjectType::CLOCK.into_raw() },
16837                        2147483648,
16838                    >,
16839                >,
16840                fdomain_client::fidl::FDomainResourceDialect,
16841                &mut self.reference_clock,
16842                decoder,
16843                offset + 0,
16844                _depth
16845            )?;
16846            Ok(())
16847        }
16848    }
16849
16850    impl fidl::encoding::ResourceTypeMarker for AudioConsumerBindVolumeControlRequest {
16851        type Borrowed<'a> = &'a mut Self;
16852        fn take_or_borrow<'a>(
16853            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16854        ) -> Self::Borrowed<'a> {
16855            value
16856        }
16857    }
16858
16859    unsafe impl fidl::encoding::TypeMarker for AudioConsumerBindVolumeControlRequest {
16860        type Owned = Self;
16861
16862        #[inline(always)]
16863        fn inline_align(_context: fidl::encoding::Context) -> usize {
16864            4
16865        }
16866
16867        #[inline(always)]
16868        fn inline_size(_context: fidl::encoding::Context) -> usize {
16869            4
16870        }
16871    }
16872
16873    unsafe impl
16874        fidl::encoding::Encode<
16875            AudioConsumerBindVolumeControlRequest,
16876            fdomain_client::fidl::FDomainResourceDialect,
16877        > for &mut AudioConsumerBindVolumeControlRequest
16878    {
16879        #[inline]
16880        unsafe fn encode(
16881            self,
16882            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16883            offset: usize,
16884            _depth: fidl::encoding::Depth,
16885        ) -> fidl::Result<()> {
16886            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
16887            // Delegate to tuple encoding.
16888            fidl::encoding::Encode::<
16889                AudioConsumerBindVolumeControlRequest,
16890                fdomain_client::fidl::FDomainResourceDialect,
16891            >::encode(
16892                (<fidl::encoding::Endpoint<
16893                    fdomain_client::fidl::ServerEnd<
16894                        fdomain_fuchsia_media_audio::VolumeControlMarker,
16895                    >,
16896                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
16897                    &mut self.volume_control_request,
16898                ),),
16899                encoder,
16900                offset,
16901                _depth,
16902            )
16903        }
16904    }
16905    unsafe impl<
16906        T0: fidl::encoding::Encode<
16907                fidl::encoding::Endpoint<
16908                    fdomain_client::fidl::ServerEnd<
16909                        fdomain_fuchsia_media_audio::VolumeControlMarker,
16910                    >,
16911                >,
16912                fdomain_client::fidl::FDomainResourceDialect,
16913            >,
16914    >
16915        fidl::encoding::Encode<
16916            AudioConsumerBindVolumeControlRequest,
16917            fdomain_client::fidl::FDomainResourceDialect,
16918        > for (T0,)
16919    {
16920        #[inline]
16921        unsafe fn encode(
16922            self,
16923            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16924            offset: usize,
16925            depth: fidl::encoding::Depth,
16926        ) -> fidl::Result<()> {
16927            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
16928            // Zero out padding regions. There's no need to apply masks
16929            // because the unmasked parts will be overwritten by fields.
16930            // Write the fields.
16931            self.0.encode(encoder, offset + 0, depth)?;
16932            Ok(())
16933        }
16934    }
16935
16936    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
16937        for AudioConsumerBindVolumeControlRequest
16938    {
16939        #[inline(always)]
16940        fn new_empty() -> Self {
16941            Self {
16942                volume_control_request: fidl::new_empty!(
16943                    fidl::encoding::Endpoint<
16944                        fdomain_client::fidl::ServerEnd<
16945                            fdomain_fuchsia_media_audio::VolumeControlMarker,
16946                        >,
16947                    >,
16948                    fdomain_client::fidl::FDomainResourceDialect
16949                ),
16950            }
16951        }
16952
16953        #[inline]
16954        unsafe fn decode(
16955            &mut self,
16956            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16957            offset: usize,
16958            _depth: fidl::encoding::Depth,
16959        ) -> fidl::Result<()> {
16960            decoder.debug_check_bounds::<Self>(offset);
16961            // Verify that padding bytes are zero.
16962            fidl::decode!(
16963                fidl::encoding::Endpoint<
16964                    fdomain_client::fidl::ServerEnd<
16965                        fdomain_fuchsia_media_audio::VolumeControlMarker,
16966                    >,
16967                >,
16968                fdomain_client::fidl::FDomainResourceDialect,
16969                &mut self.volume_control_request,
16970                decoder,
16971                offset + 0,
16972                _depth
16973            )?;
16974            Ok(())
16975        }
16976    }
16977
16978    impl fidl::encoding::ResourceTypeMarker for AudioConsumerCreateStreamSinkRequest {
16979        type Borrowed<'a> = &'a mut Self;
16980        fn take_or_borrow<'a>(
16981            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16982        ) -> Self::Borrowed<'a> {
16983            value
16984        }
16985    }
16986
16987    unsafe impl fidl::encoding::TypeMarker for AudioConsumerCreateStreamSinkRequest {
16988        type Owned = Self;
16989
16990        #[inline(always)]
16991        fn inline_align(_context: fidl::encoding::Context) -> usize {
16992            8
16993        }
16994
16995        #[inline(always)]
16996        fn inline_size(_context: fidl::encoding::Context) -> usize {
16997            48
16998        }
16999    }
17000
17001    unsafe impl
17002        fidl::encoding::Encode<
17003            AudioConsumerCreateStreamSinkRequest,
17004            fdomain_client::fidl::FDomainResourceDialect,
17005        > for &mut AudioConsumerCreateStreamSinkRequest
17006    {
17007        #[inline]
17008        unsafe fn encode(
17009            self,
17010            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17011            offset: usize,
17012            _depth: fidl::encoding::Depth,
17013        ) -> fidl::Result<()> {
17014            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
17015            // Delegate to tuple encoding.
17016            fidl::encoding::Encode::<AudioConsumerCreateStreamSinkRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
17017                (
17018                    <fidl::encoding::Vector<fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, 16> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffers),
17019                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
17020                    <fidl::encoding::Boxed<Compression> as fidl::encoding::ValueTypeMarker>::borrow(&self.compression),
17021                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<StreamSinkMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.stream_sink_request),
17022                ),
17023                encoder, offset, _depth
17024            )
17025        }
17026    }
17027    unsafe impl<
17028        T0: fidl::encoding::Encode<
17029                fidl::encoding::Vector<
17030                    fidl::encoding::HandleType<
17031                        fdomain_client::Vmo,
17032                        { fidl::ObjectType::VMO.into_raw() },
17033                        2147483648,
17034                    >,
17035                    16,
17036                >,
17037                fdomain_client::fidl::FDomainResourceDialect,
17038            >,
17039        T1: fidl::encoding::Encode<AudioStreamType, fdomain_client::fidl::FDomainResourceDialect>,
17040        T2: fidl::encoding::Encode<
17041                fidl::encoding::Boxed<Compression>,
17042                fdomain_client::fidl::FDomainResourceDialect,
17043            >,
17044        T3: fidl::encoding::Encode<
17045                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<StreamSinkMarker>>,
17046                fdomain_client::fidl::FDomainResourceDialect,
17047            >,
17048    >
17049        fidl::encoding::Encode<
17050            AudioConsumerCreateStreamSinkRequest,
17051            fdomain_client::fidl::FDomainResourceDialect,
17052        > for (T0, T1, T2, T3)
17053    {
17054        #[inline]
17055        unsafe fn encode(
17056            self,
17057            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17058            offset: usize,
17059            depth: fidl::encoding::Depth,
17060        ) -> fidl::Result<()> {
17061            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
17062            // Zero out padding regions. There's no need to apply masks
17063            // because the unmasked parts will be overwritten by fields.
17064            unsafe {
17065                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
17066                (ptr as *mut u64).write_unaligned(0);
17067            }
17068            unsafe {
17069                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
17070                (ptr as *mut u64).write_unaligned(0);
17071            }
17072            // Write the fields.
17073            self.0.encode(encoder, offset + 0, depth)?;
17074            self.1.encode(encoder, offset + 16, depth)?;
17075            self.2.encode(encoder, offset + 32, depth)?;
17076            self.3.encode(encoder, offset + 40, depth)?;
17077            Ok(())
17078        }
17079    }
17080
17081    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17082        for AudioConsumerCreateStreamSinkRequest
17083    {
17084        #[inline(always)]
17085        fn new_empty() -> Self {
17086            Self {
17087                buffers: fidl::new_empty!(
17088                    fidl::encoding::Vector<
17089                        fidl::encoding::HandleType<
17090                            fdomain_client::Vmo,
17091                            { fidl::ObjectType::VMO.into_raw() },
17092                            2147483648,
17093                        >,
17094                        16,
17095                    >,
17096                    fdomain_client::fidl::FDomainResourceDialect
17097                ),
17098                stream_type: fidl::new_empty!(
17099                    AudioStreamType,
17100                    fdomain_client::fidl::FDomainResourceDialect
17101                ),
17102                compression: fidl::new_empty!(
17103                    fidl::encoding::Boxed<Compression>,
17104                    fdomain_client::fidl::FDomainResourceDialect
17105                ),
17106                stream_sink_request: fidl::new_empty!(
17107                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<StreamSinkMarker>>,
17108                    fdomain_client::fidl::FDomainResourceDialect
17109                ),
17110            }
17111        }
17112
17113        #[inline]
17114        unsafe fn decode(
17115            &mut self,
17116            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17117            offset: usize,
17118            _depth: fidl::encoding::Depth,
17119        ) -> fidl::Result<()> {
17120            decoder.debug_check_bounds::<Self>(offset);
17121            // Verify that padding bytes are zero.
17122            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
17123            let padval = unsafe { (ptr as *const u64).read_unaligned() };
17124            let mask = 0xffffffff00000000u64;
17125            let maskedval = padval & mask;
17126            if maskedval != 0 {
17127                return Err(fidl::Error::NonZeroPadding {
17128                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
17129                });
17130            }
17131            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
17132            let padval = unsafe { (ptr as *const u64).read_unaligned() };
17133            let mask = 0xffffffff00000000u64;
17134            let maskedval = padval & mask;
17135            if maskedval != 0 {
17136                return Err(fidl::Error::NonZeroPadding {
17137                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
17138                });
17139            }
17140            fidl::decode!(
17141                fidl::encoding::Vector<
17142                    fidl::encoding::HandleType<
17143                        fdomain_client::Vmo,
17144                        { fidl::ObjectType::VMO.into_raw() },
17145                        2147483648,
17146                    >,
17147                    16,
17148                >,
17149                fdomain_client::fidl::FDomainResourceDialect,
17150                &mut self.buffers,
17151                decoder,
17152                offset + 0,
17153                _depth
17154            )?;
17155            fidl::decode!(
17156                AudioStreamType,
17157                fdomain_client::fidl::FDomainResourceDialect,
17158                &mut self.stream_type,
17159                decoder,
17160                offset + 16,
17161                _depth
17162            )?;
17163            fidl::decode!(
17164                fidl::encoding::Boxed<Compression>,
17165                fdomain_client::fidl::FDomainResourceDialect,
17166                &mut self.compression,
17167                decoder,
17168                offset + 32,
17169                _depth
17170            )?;
17171            fidl::decode!(
17172                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<StreamSinkMarker>>,
17173                fdomain_client::fidl::FDomainResourceDialect,
17174                &mut self.stream_sink_request,
17175                decoder,
17176                offset + 40,
17177                _depth
17178            )?;
17179            Ok(())
17180        }
17181    }
17182
17183    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControl2Request {
17184        type Borrowed<'a> = &'a mut Self;
17185        fn take_or_borrow<'a>(
17186            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17187        ) -> Self::Borrowed<'a> {
17188            value
17189        }
17190    }
17191
17192    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControl2Request {
17193        type Owned = Self;
17194
17195        #[inline(always)]
17196        fn inline_align(_context: fidl::encoding::Context) -> usize {
17197            8
17198        }
17199
17200        #[inline(always)]
17201        fn inline_size(_context: fidl::encoding::Context) -> usize {
17202            24
17203        }
17204    }
17205
17206    unsafe impl
17207        fidl::encoding::Encode<
17208            AudioCoreBindUsageVolumeControl2Request,
17209            fdomain_client::fidl::FDomainResourceDialect,
17210        > for &mut AudioCoreBindUsageVolumeControl2Request
17211    {
17212        #[inline]
17213        unsafe fn encode(
17214            self,
17215            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17216            offset: usize,
17217            _depth: fidl::encoding::Depth,
17218        ) -> fidl::Result<()> {
17219            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
17220            // Delegate to tuple encoding.
17221            fidl::encoding::Encode::<
17222                AudioCoreBindUsageVolumeControl2Request,
17223                fdomain_client::fidl::FDomainResourceDialect,
17224            >::encode(
17225                (
17226                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
17227                    <fidl::encoding::Endpoint<
17228                        fdomain_client::fidl::ServerEnd<
17229                            fdomain_fuchsia_media_audio::VolumeControlMarker,
17230                        >,
17231                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
17232                        &mut self.volume_control,
17233                    ),
17234                ),
17235                encoder,
17236                offset,
17237                _depth,
17238            )
17239        }
17240    }
17241    unsafe impl<
17242        T0: fidl::encoding::Encode<Usage2, fdomain_client::fidl::FDomainResourceDialect>,
17243        T1: fidl::encoding::Encode<
17244                fidl::encoding::Endpoint<
17245                    fdomain_client::fidl::ServerEnd<
17246                        fdomain_fuchsia_media_audio::VolumeControlMarker,
17247                    >,
17248                >,
17249                fdomain_client::fidl::FDomainResourceDialect,
17250            >,
17251    >
17252        fidl::encoding::Encode<
17253            AudioCoreBindUsageVolumeControl2Request,
17254            fdomain_client::fidl::FDomainResourceDialect,
17255        > for (T0, T1)
17256    {
17257        #[inline]
17258        unsafe fn encode(
17259            self,
17260            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17261            offset: usize,
17262            depth: fidl::encoding::Depth,
17263        ) -> fidl::Result<()> {
17264            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
17265            // Zero out padding regions. There's no need to apply masks
17266            // because the unmasked parts will be overwritten by fields.
17267            unsafe {
17268                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
17269                (ptr as *mut u64).write_unaligned(0);
17270            }
17271            // Write the fields.
17272            self.0.encode(encoder, offset + 0, depth)?;
17273            self.1.encode(encoder, offset + 16, depth)?;
17274            Ok(())
17275        }
17276    }
17277
17278    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17279        for AudioCoreBindUsageVolumeControl2Request
17280    {
17281        #[inline(always)]
17282        fn new_empty() -> Self {
17283            Self {
17284                usage: fidl::new_empty!(Usage2, fdomain_client::fidl::FDomainResourceDialect),
17285                volume_control: fidl::new_empty!(
17286                    fidl::encoding::Endpoint<
17287                        fdomain_client::fidl::ServerEnd<
17288                            fdomain_fuchsia_media_audio::VolumeControlMarker,
17289                        >,
17290                    >,
17291                    fdomain_client::fidl::FDomainResourceDialect
17292                ),
17293            }
17294        }
17295
17296        #[inline]
17297        unsafe fn decode(
17298            &mut self,
17299            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17300            offset: usize,
17301            _depth: fidl::encoding::Depth,
17302        ) -> fidl::Result<()> {
17303            decoder.debug_check_bounds::<Self>(offset);
17304            // Verify that padding bytes are zero.
17305            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
17306            let padval = unsafe { (ptr as *const u64).read_unaligned() };
17307            let mask = 0xffffffff00000000u64;
17308            let maskedval = padval & mask;
17309            if maskedval != 0 {
17310                return Err(fidl::Error::NonZeroPadding {
17311                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
17312                });
17313            }
17314            fidl::decode!(
17315                Usage2,
17316                fdomain_client::fidl::FDomainResourceDialect,
17317                &mut self.usage,
17318                decoder,
17319                offset + 0,
17320                _depth
17321            )?;
17322            fidl::decode!(
17323                fidl::encoding::Endpoint<
17324                    fdomain_client::fidl::ServerEnd<
17325                        fdomain_fuchsia_media_audio::VolumeControlMarker,
17326                    >,
17327                >,
17328                fdomain_client::fidl::FDomainResourceDialect,
17329                &mut self.volume_control,
17330                decoder,
17331                offset + 16,
17332                _depth
17333            )?;
17334            Ok(())
17335        }
17336    }
17337
17338    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControlRequest {
17339        type Borrowed<'a> = &'a mut Self;
17340        fn take_or_borrow<'a>(
17341            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17342        ) -> Self::Borrowed<'a> {
17343            value
17344        }
17345    }
17346
17347    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControlRequest {
17348        type Owned = Self;
17349
17350        #[inline(always)]
17351        fn inline_align(_context: fidl::encoding::Context) -> usize {
17352            8
17353        }
17354
17355        #[inline(always)]
17356        fn inline_size(_context: fidl::encoding::Context) -> usize {
17357            24
17358        }
17359    }
17360
17361    unsafe impl
17362        fidl::encoding::Encode<
17363            AudioCoreBindUsageVolumeControlRequest,
17364            fdomain_client::fidl::FDomainResourceDialect,
17365        > for &mut AudioCoreBindUsageVolumeControlRequest
17366    {
17367        #[inline]
17368        unsafe fn encode(
17369            self,
17370            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17371            offset: usize,
17372            _depth: fidl::encoding::Depth,
17373        ) -> fidl::Result<()> {
17374            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
17375            // Delegate to tuple encoding.
17376            fidl::encoding::Encode::<
17377                AudioCoreBindUsageVolumeControlRequest,
17378                fdomain_client::fidl::FDomainResourceDialect,
17379            >::encode(
17380                (
17381                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
17382                    <fidl::encoding::Endpoint<
17383                        fdomain_client::fidl::ServerEnd<
17384                            fdomain_fuchsia_media_audio::VolumeControlMarker,
17385                        >,
17386                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
17387                        &mut self.volume_control,
17388                    ),
17389                ),
17390                encoder,
17391                offset,
17392                _depth,
17393            )
17394        }
17395    }
17396    unsafe impl<
17397        T0: fidl::encoding::Encode<Usage, fdomain_client::fidl::FDomainResourceDialect>,
17398        T1: fidl::encoding::Encode<
17399                fidl::encoding::Endpoint<
17400                    fdomain_client::fidl::ServerEnd<
17401                        fdomain_fuchsia_media_audio::VolumeControlMarker,
17402                    >,
17403                >,
17404                fdomain_client::fidl::FDomainResourceDialect,
17405            >,
17406    >
17407        fidl::encoding::Encode<
17408            AudioCoreBindUsageVolumeControlRequest,
17409            fdomain_client::fidl::FDomainResourceDialect,
17410        > for (T0, T1)
17411    {
17412        #[inline]
17413        unsafe fn encode(
17414            self,
17415            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17416            offset: usize,
17417            depth: fidl::encoding::Depth,
17418        ) -> fidl::Result<()> {
17419            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
17420            // Zero out padding regions. There's no need to apply masks
17421            // because the unmasked parts will be overwritten by fields.
17422            unsafe {
17423                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
17424                (ptr as *mut u64).write_unaligned(0);
17425            }
17426            // Write the fields.
17427            self.0.encode(encoder, offset + 0, depth)?;
17428            self.1.encode(encoder, offset + 16, depth)?;
17429            Ok(())
17430        }
17431    }
17432
17433    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17434        for AudioCoreBindUsageVolumeControlRequest
17435    {
17436        #[inline(always)]
17437        fn new_empty() -> Self {
17438            Self {
17439                usage: fidl::new_empty!(Usage, fdomain_client::fidl::FDomainResourceDialect),
17440                volume_control: fidl::new_empty!(
17441                    fidl::encoding::Endpoint<
17442                        fdomain_client::fidl::ServerEnd<
17443                            fdomain_fuchsia_media_audio::VolumeControlMarker,
17444                        >,
17445                    >,
17446                    fdomain_client::fidl::FDomainResourceDialect
17447                ),
17448            }
17449        }
17450
17451        #[inline]
17452        unsafe fn decode(
17453            &mut self,
17454            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17455            offset: usize,
17456            _depth: fidl::encoding::Depth,
17457        ) -> fidl::Result<()> {
17458            decoder.debug_check_bounds::<Self>(offset);
17459            // Verify that padding bytes are zero.
17460            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
17461            let padval = unsafe { (ptr as *const u64).read_unaligned() };
17462            let mask = 0xffffffff00000000u64;
17463            let maskedval = padval & mask;
17464            if maskedval != 0 {
17465                return Err(fidl::Error::NonZeroPadding {
17466                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
17467                });
17468            }
17469            fidl::decode!(
17470                Usage,
17471                fdomain_client::fidl::FDomainResourceDialect,
17472                &mut self.usage,
17473                decoder,
17474                offset + 0,
17475                _depth
17476            )?;
17477            fidl::decode!(
17478                fidl::encoding::Endpoint<
17479                    fdomain_client::fidl::ServerEnd<
17480                        fdomain_fuchsia_media_audio::VolumeControlMarker,
17481                    >,
17482                >,
17483                fdomain_client::fidl::FDomainResourceDialect,
17484                &mut self.volume_control,
17485                decoder,
17486                offset + 16,
17487                _depth
17488            )?;
17489            Ok(())
17490        }
17491    }
17492
17493    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerRequest {
17494        type Borrowed<'a> = &'a mut Self;
17495        fn take_or_borrow<'a>(
17496            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17497        ) -> Self::Borrowed<'a> {
17498            value
17499        }
17500    }
17501
17502    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerRequest {
17503        type Owned = Self;
17504
17505        #[inline(always)]
17506        fn inline_align(_context: fidl::encoding::Context) -> usize {
17507            4
17508        }
17509
17510        #[inline(always)]
17511        fn inline_size(_context: fidl::encoding::Context) -> usize {
17512            8
17513        }
17514    }
17515
17516    unsafe impl
17517        fidl::encoding::Encode<
17518            AudioCoreCreateAudioCapturerRequest,
17519            fdomain_client::fidl::FDomainResourceDialect,
17520        > for &mut AudioCoreCreateAudioCapturerRequest
17521    {
17522        #[inline]
17523        unsafe fn encode(
17524            self,
17525            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17526            offset: usize,
17527            _depth: fidl::encoding::Depth,
17528        ) -> fidl::Result<()> {
17529            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
17530            // Delegate to tuple encoding.
17531            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
17532                (
17533                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
17534                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_in_request),
17535                ),
17536                encoder, offset, _depth
17537            )
17538        }
17539    }
17540    unsafe impl<
17541        T0: fidl::encoding::Encode<bool, fdomain_client::fidl::FDomainResourceDialect>,
17542        T1: fidl::encoding::Encode<
17543                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
17544                fdomain_client::fidl::FDomainResourceDialect,
17545            >,
17546    >
17547        fidl::encoding::Encode<
17548            AudioCoreCreateAudioCapturerRequest,
17549            fdomain_client::fidl::FDomainResourceDialect,
17550        > for (T0, T1)
17551    {
17552        #[inline]
17553        unsafe fn encode(
17554            self,
17555            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17556            offset: usize,
17557            depth: fidl::encoding::Depth,
17558        ) -> fidl::Result<()> {
17559            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
17560            // Zero out padding regions. There's no need to apply masks
17561            // because the unmasked parts will be overwritten by fields.
17562            unsafe {
17563                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
17564                (ptr as *mut u32).write_unaligned(0);
17565            }
17566            // Write the fields.
17567            self.0.encode(encoder, offset + 0, depth)?;
17568            self.1.encode(encoder, offset + 4, depth)?;
17569            Ok(())
17570        }
17571    }
17572
17573    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17574        for AudioCoreCreateAudioCapturerRequest
17575    {
17576        #[inline(always)]
17577        fn new_empty() -> Self {
17578            Self {
17579                loopback: fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect),
17580                audio_in_request: fidl::new_empty!(
17581                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
17582                    fdomain_client::fidl::FDomainResourceDialect
17583                ),
17584            }
17585        }
17586
17587        #[inline]
17588        unsafe fn decode(
17589            &mut self,
17590            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17591            offset: usize,
17592            _depth: fidl::encoding::Depth,
17593        ) -> fidl::Result<()> {
17594            decoder.debug_check_bounds::<Self>(offset);
17595            // Verify that padding bytes are zero.
17596            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
17597            let padval = unsafe { (ptr as *const u32).read_unaligned() };
17598            let mask = 0xffffff00u32;
17599            let maskedval = padval & mask;
17600            if maskedval != 0 {
17601                return Err(fidl::Error::NonZeroPadding {
17602                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
17603                });
17604            }
17605            fidl::decode!(
17606                bool,
17607                fdomain_client::fidl::FDomainResourceDialect,
17608                &mut self.loopback,
17609                decoder,
17610                offset + 0,
17611                _depth
17612            )?;
17613            fidl::decode!(
17614                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
17615                fdomain_client::fidl::FDomainResourceDialect,
17616                &mut self.audio_in_request,
17617                decoder,
17618                offset + 4,
17619                _depth
17620            )?;
17621            Ok(())
17622        }
17623    }
17624
17625    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
17626        type Borrowed<'a> = &'a mut Self;
17627        fn take_or_borrow<'a>(
17628            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17629        ) -> Self::Borrowed<'a> {
17630            value
17631        }
17632    }
17633
17634    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
17635        type Owned = Self;
17636
17637        #[inline(always)]
17638        fn inline_align(_context: fidl::encoding::Context) -> usize {
17639            8
17640        }
17641
17642        #[inline(always)]
17643        fn inline_size(_context: fidl::encoding::Context) -> usize {
17644            40
17645        }
17646    }
17647
17648    unsafe impl
17649        fidl::encoding::Encode<
17650            AudioCoreCreateAudioCapturerWithConfigurationRequest,
17651            fdomain_client::fidl::FDomainResourceDialect,
17652        > for &mut AudioCoreCreateAudioCapturerWithConfigurationRequest
17653    {
17654        #[inline]
17655        unsafe fn encode(
17656            self,
17657            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17658            offset: usize,
17659            _depth: fidl::encoding::Depth,
17660        ) -> fidl::Result<()> {
17661            encoder
17662                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
17663            // Delegate to tuple encoding.
17664            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerWithConfigurationRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
17665                (
17666                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
17667                    <AudioCapturerConfiguration as fidl::encoding::ValueTypeMarker>::borrow(&self.configuration),
17668                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
17669                ),
17670                encoder, offset, _depth
17671            )
17672        }
17673    }
17674    unsafe impl<
17675        T0: fidl::encoding::Encode<AudioStreamType, fdomain_client::fidl::FDomainResourceDialect>,
17676        T1: fidl::encoding::Encode<
17677                AudioCapturerConfiguration,
17678                fdomain_client::fidl::FDomainResourceDialect,
17679            >,
17680        T2: fidl::encoding::Encode<
17681                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
17682                fdomain_client::fidl::FDomainResourceDialect,
17683            >,
17684    >
17685        fidl::encoding::Encode<
17686            AudioCoreCreateAudioCapturerWithConfigurationRequest,
17687            fdomain_client::fidl::FDomainResourceDialect,
17688        > for (T0, T1, T2)
17689    {
17690        #[inline]
17691        unsafe fn encode(
17692            self,
17693            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17694            offset: usize,
17695            depth: fidl::encoding::Depth,
17696        ) -> fidl::Result<()> {
17697            encoder
17698                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
17699            // Zero out padding regions. There's no need to apply masks
17700            // because the unmasked parts will be overwritten by fields.
17701            unsafe {
17702                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
17703                (ptr as *mut u64).write_unaligned(0);
17704            }
17705            unsafe {
17706                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
17707                (ptr as *mut u64).write_unaligned(0);
17708            }
17709            // Write the fields.
17710            self.0.encode(encoder, offset + 0, depth)?;
17711            self.1.encode(encoder, offset + 16, depth)?;
17712            self.2.encode(encoder, offset + 32, depth)?;
17713            Ok(())
17714        }
17715    }
17716
17717    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17718        for AudioCoreCreateAudioCapturerWithConfigurationRequest
17719    {
17720        #[inline(always)]
17721        fn new_empty() -> Self {
17722            Self {
17723                stream_type: fidl::new_empty!(
17724                    AudioStreamType,
17725                    fdomain_client::fidl::FDomainResourceDialect
17726                ),
17727                configuration: fidl::new_empty!(
17728                    AudioCapturerConfiguration,
17729                    fdomain_client::fidl::FDomainResourceDialect
17730                ),
17731                audio_capturer_request: fidl::new_empty!(
17732                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
17733                    fdomain_client::fidl::FDomainResourceDialect
17734                ),
17735            }
17736        }
17737
17738        #[inline]
17739        unsafe fn decode(
17740            &mut self,
17741            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17742            offset: usize,
17743            _depth: fidl::encoding::Depth,
17744        ) -> fidl::Result<()> {
17745            decoder.debug_check_bounds::<Self>(offset);
17746            // Verify that padding bytes are zero.
17747            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
17748            let padval = unsafe { (ptr as *const u64).read_unaligned() };
17749            let mask = 0xffffffff00000000u64;
17750            let maskedval = padval & mask;
17751            if maskedval != 0 {
17752                return Err(fidl::Error::NonZeroPadding {
17753                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
17754                });
17755            }
17756            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
17757            let padval = unsafe { (ptr as *const u64).read_unaligned() };
17758            let mask = 0xffffffff00000000u64;
17759            let maskedval = padval & mask;
17760            if maskedval != 0 {
17761                return Err(fidl::Error::NonZeroPadding {
17762                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
17763                });
17764            }
17765            fidl::decode!(
17766                AudioStreamType,
17767                fdomain_client::fidl::FDomainResourceDialect,
17768                &mut self.stream_type,
17769                decoder,
17770                offset + 0,
17771                _depth
17772            )?;
17773            fidl::decode!(
17774                AudioCapturerConfiguration,
17775                fdomain_client::fidl::FDomainResourceDialect,
17776                &mut self.configuration,
17777                decoder,
17778                offset + 16,
17779                _depth
17780            )?;
17781            fidl::decode!(
17782                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
17783                fdomain_client::fidl::FDomainResourceDialect,
17784                &mut self.audio_capturer_request,
17785                decoder,
17786                offset + 32,
17787                _depth
17788            )?;
17789            Ok(())
17790        }
17791    }
17792
17793    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioRendererRequest {
17794        type Borrowed<'a> = &'a mut Self;
17795        fn take_or_borrow<'a>(
17796            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17797        ) -> Self::Borrowed<'a> {
17798            value
17799        }
17800    }
17801
17802    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioRendererRequest {
17803        type Owned = Self;
17804
17805        #[inline(always)]
17806        fn inline_align(_context: fidl::encoding::Context) -> usize {
17807            4
17808        }
17809
17810        #[inline(always)]
17811        fn inline_size(_context: fidl::encoding::Context) -> usize {
17812            4
17813        }
17814    }
17815
17816    unsafe impl
17817        fidl::encoding::Encode<
17818            AudioCoreCreateAudioRendererRequest,
17819            fdomain_client::fidl::FDomainResourceDialect,
17820        > for &mut AudioCoreCreateAudioRendererRequest
17821    {
17822        #[inline]
17823        unsafe fn encode(
17824            self,
17825            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17826            offset: usize,
17827            _depth: fidl::encoding::Depth,
17828        ) -> fidl::Result<()> {
17829            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
17830            // Delegate to tuple encoding.
17831            fidl::encoding::Encode::<AudioCoreCreateAudioRendererRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
17832                (
17833                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_out_request),
17834                ),
17835                encoder, offset, _depth
17836            )
17837        }
17838    }
17839    unsafe impl<
17840        T0: fidl::encoding::Encode<
17841                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>>,
17842                fdomain_client::fidl::FDomainResourceDialect,
17843            >,
17844    >
17845        fidl::encoding::Encode<
17846            AudioCoreCreateAudioRendererRequest,
17847            fdomain_client::fidl::FDomainResourceDialect,
17848        > for (T0,)
17849    {
17850        #[inline]
17851        unsafe fn encode(
17852            self,
17853            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17854            offset: usize,
17855            depth: fidl::encoding::Depth,
17856        ) -> fidl::Result<()> {
17857            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
17858            // Zero out padding regions. There's no need to apply masks
17859            // because the unmasked parts will be overwritten by fields.
17860            // Write the fields.
17861            self.0.encode(encoder, offset + 0, depth)?;
17862            Ok(())
17863        }
17864    }
17865
17866    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17867        for AudioCoreCreateAudioRendererRequest
17868    {
17869        #[inline(always)]
17870        fn new_empty() -> Self {
17871            Self {
17872                audio_out_request: fidl::new_empty!(
17873                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>>,
17874                    fdomain_client::fidl::FDomainResourceDialect
17875                ),
17876            }
17877        }
17878
17879        #[inline]
17880        unsafe fn decode(
17881            &mut self,
17882            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17883            offset: usize,
17884            _depth: fidl::encoding::Depth,
17885        ) -> fidl::Result<()> {
17886            decoder.debug_check_bounds::<Self>(offset);
17887            // Verify that padding bytes are zero.
17888            fidl::decode!(
17889                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>>,
17890                fdomain_client::fidl::FDomainResourceDialect,
17891                &mut self.audio_out_request,
17892                decoder,
17893                offset + 0,
17894                _depth
17895            )?;
17896            Ok(())
17897        }
17898    }
17899
17900    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioCapturerRequest {
17901        type Borrowed<'a> = &'a mut Self;
17902        fn take_or_borrow<'a>(
17903            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17904        ) -> Self::Borrowed<'a> {
17905            value
17906        }
17907    }
17908
17909    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioCapturerRequest {
17910        type Owned = Self;
17911
17912        #[inline(always)]
17913        fn inline_align(_context: fidl::encoding::Context) -> usize {
17914            4
17915        }
17916
17917        #[inline(always)]
17918        fn inline_size(_context: fidl::encoding::Context) -> usize {
17919            8
17920        }
17921    }
17922
17923    unsafe impl
17924        fidl::encoding::Encode<
17925            AudioCreateAudioCapturerRequest,
17926            fdomain_client::fidl::FDomainResourceDialect,
17927        > for &mut AudioCreateAudioCapturerRequest
17928    {
17929        #[inline]
17930        unsafe fn encode(
17931            self,
17932            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17933            offset: usize,
17934            _depth: fidl::encoding::Depth,
17935        ) -> fidl::Result<()> {
17936            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
17937            // Delegate to tuple encoding.
17938            fidl::encoding::Encode::<AudioCreateAudioCapturerRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
17939                (
17940                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
17941                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
17942                ),
17943                encoder, offset, _depth
17944            )
17945        }
17946    }
17947    unsafe impl<
17948        T0: fidl::encoding::Encode<
17949                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
17950                fdomain_client::fidl::FDomainResourceDialect,
17951            >,
17952        T1: fidl::encoding::Encode<bool, fdomain_client::fidl::FDomainResourceDialect>,
17953    >
17954        fidl::encoding::Encode<
17955            AudioCreateAudioCapturerRequest,
17956            fdomain_client::fidl::FDomainResourceDialect,
17957        > for (T0, T1)
17958    {
17959        #[inline]
17960        unsafe fn encode(
17961            self,
17962            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17963            offset: usize,
17964            depth: fidl::encoding::Depth,
17965        ) -> fidl::Result<()> {
17966            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
17967            // Zero out padding regions. There's no need to apply masks
17968            // because the unmasked parts will be overwritten by fields.
17969            unsafe {
17970                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
17971                (ptr as *mut u32).write_unaligned(0);
17972            }
17973            // Write the fields.
17974            self.0.encode(encoder, offset + 0, depth)?;
17975            self.1.encode(encoder, offset + 4, depth)?;
17976            Ok(())
17977        }
17978    }
17979
17980    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17981        for AudioCreateAudioCapturerRequest
17982    {
17983        #[inline(always)]
17984        fn new_empty() -> Self {
17985            Self {
17986                audio_capturer_request: fidl::new_empty!(
17987                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
17988                    fdomain_client::fidl::FDomainResourceDialect
17989                ),
17990                loopback: fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect),
17991            }
17992        }
17993
17994        #[inline]
17995        unsafe fn decode(
17996            &mut self,
17997            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17998            offset: usize,
17999            _depth: fidl::encoding::Depth,
18000        ) -> fidl::Result<()> {
18001            decoder.debug_check_bounds::<Self>(offset);
18002            // Verify that padding bytes are zero.
18003            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(4) };
18004            let padval = unsafe { (ptr as *const u32).read_unaligned() };
18005            let mask = 0xffffff00u32;
18006            let maskedval = padval & mask;
18007            if maskedval != 0 {
18008                return Err(fidl::Error::NonZeroPadding {
18009                    padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
18010                });
18011            }
18012            fidl::decode!(
18013                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
18014                fdomain_client::fidl::FDomainResourceDialect,
18015                &mut self.audio_capturer_request,
18016                decoder,
18017                offset + 0,
18018                _depth
18019            )?;
18020            fidl::decode!(
18021                bool,
18022                fdomain_client::fidl::FDomainResourceDialect,
18023                &mut self.loopback,
18024                decoder,
18025                offset + 4,
18026                _depth
18027            )?;
18028            Ok(())
18029        }
18030    }
18031
18032    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioRendererRequest {
18033        type Borrowed<'a> = &'a mut Self;
18034        fn take_or_borrow<'a>(
18035            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18036        ) -> Self::Borrowed<'a> {
18037            value
18038        }
18039    }
18040
18041    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioRendererRequest {
18042        type Owned = Self;
18043
18044        #[inline(always)]
18045        fn inline_align(_context: fidl::encoding::Context) -> usize {
18046            4
18047        }
18048
18049        #[inline(always)]
18050        fn inline_size(_context: fidl::encoding::Context) -> usize {
18051            4
18052        }
18053    }
18054
18055    unsafe impl
18056        fidl::encoding::Encode<
18057            AudioCreateAudioRendererRequest,
18058            fdomain_client::fidl::FDomainResourceDialect,
18059        > for &mut AudioCreateAudioRendererRequest
18060    {
18061        #[inline]
18062        unsafe fn encode(
18063            self,
18064            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18065            offset: usize,
18066            _depth: fidl::encoding::Depth,
18067        ) -> fidl::Result<()> {
18068            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
18069            // Delegate to tuple encoding.
18070            fidl::encoding::Encode::<AudioCreateAudioRendererRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
18071                (
18072                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_renderer_request),
18073                ),
18074                encoder, offset, _depth
18075            )
18076        }
18077    }
18078    unsafe impl<
18079        T0: fidl::encoding::Encode<
18080                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>>,
18081                fdomain_client::fidl::FDomainResourceDialect,
18082            >,
18083    >
18084        fidl::encoding::Encode<
18085            AudioCreateAudioRendererRequest,
18086            fdomain_client::fidl::FDomainResourceDialect,
18087        > for (T0,)
18088    {
18089        #[inline]
18090        unsafe fn encode(
18091            self,
18092            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18093            offset: usize,
18094            depth: fidl::encoding::Depth,
18095        ) -> fidl::Result<()> {
18096            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
18097            // Zero out padding regions. There's no need to apply masks
18098            // because the unmasked parts will be overwritten by fields.
18099            // Write the fields.
18100            self.0.encode(encoder, offset + 0, depth)?;
18101            Ok(())
18102        }
18103    }
18104
18105    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18106        for AudioCreateAudioRendererRequest
18107    {
18108        #[inline(always)]
18109        fn new_empty() -> Self {
18110            Self {
18111                audio_renderer_request: fidl::new_empty!(
18112                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>>,
18113                    fdomain_client::fidl::FDomainResourceDialect
18114                ),
18115            }
18116        }
18117
18118        #[inline]
18119        unsafe fn decode(
18120            &mut self,
18121            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18122            offset: usize,
18123            _depth: fidl::encoding::Depth,
18124        ) -> fidl::Result<()> {
18125            decoder.debug_check_bounds::<Self>(offset);
18126            // Verify that padding bytes are zero.
18127            fidl::decode!(
18128                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>>,
18129                fdomain_client::fidl::FDomainResourceDialect,
18130                &mut self.audio_renderer_request,
18131                decoder,
18132                offset + 0,
18133                _depth
18134            )?;
18135            Ok(())
18136        }
18137    }
18138
18139    impl fidl::encoding::ResourceTypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
18140        type Borrowed<'a> = &'a mut Self;
18141        fn take_or_borrow<'a>(
18142            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18143        ) -> Self::Borrowed<'a> {
18144            value
18145        }
18146    }
18147
18148    unsafe impl fidl::encoding::TypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
18149        type Owned = Self;
18150
18151        #[inline(always)]
18152        fn inline_align(_context: fidl::encoding::Context) -> usize {
18153            8
18154        }
18155
18156        #[inline(always)]
18157        fn inline_size(_context: fidl::encoding::Context) -> usize {
18158            24
18159        }
18160    }
18161
18162    unsafe impl
18163        fidl::encoding::Encode<
18164            AudioDeviceEnumeratorAddDeviceByChannelRequest,
18165            fdomain_client::fidl::FDomainResourceDialect,
18166        > for &mut AudioDeviceEnumeratorAddDeviceByChannelRequest
18167    {
18168        #[inline]
18169        unsafe fn encode(
18170            self,
18171            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18172            offset: usize,
18173            _depth: fidl::encoding::Depth,
18174        ) -> fidl::Result<()> {
18175            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
18176            // Delegate to tuple encoding.
18177            fidl::encoding::Encode::<
18178                AudioDeviceEnumeratorAddDeviceByChannelRequest,
18179                fdomain_client::fidl::FDomainResourceDialect,
18180            >::encode(
18181                (
18182                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow(
18183                        &self.device_name,
18184                    ),
18185                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.is_input),
18186                    <fidl::encoding::Endpoint<
18187                        fdomain_client::fidl::ClientEnd<
18188                            fdomain_fuchsia_hardware_audio::StreamConfigMarker,
18189                        >,
18190                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
18191                        &mut self.channel
18192                    ),
18193                ),
18194                encoder,
18195                offset,
18196                _depth,
18197            )
18198        }
18199    }
18200    unsafe impl<
18201        T0: fidl::encoding::Encode<
18202                fidl::encoding::BoundedString<256>,
18203                fdomain_client::fidl::FDomainResourceDialect,
18204            >,
18205        T1: fidl::encoding::Encode<bool, fdomain_client::fidl::FDomainResourceDialect>,
18206        T2: fidl::encoding::Encode<
18207                fidl::encoding::Endpoint<
18208                    fdomain_client::fidl::ClientEnd<
18209                        fdomain_fuchsia_hardware_audio::StreamConfigMarker,
18210                    >,
18211                >,
18212                fdomain_client::fidl::FDomainResourceDialect,
18213            >,
18214    >
18215        fidl::encoding::Encode<
18216            AudioDeviceEnumeratorAddDeviceByChannelRequest,
18217            fdomain_client::fidl::FDomainResourceDialect,
18218        > for (T0, T1, T2)
18219    {
18220        #[inline]
18221        unsafe fn encode(
18222            self,
18223            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18224            offset: usize,
18225            depth: fidl::encoding::Depth,
18226        ) -> fidl::Result<()> {
18227            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
18228            // Zero out padding regions. There's no need to apply masks
18229            // because the unmasked parts will be overwritten by fields.
18230            unsafe {
18231                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
18232                (ptr as *mut u64).write_unaligned(0);
18233            }
18234            // Write the fields.
18235            self.0.encode(encoder, offset + 0, depth)?;
18236            self.1.encode(encoder, offset + 16, depth)?;
18237            self.2.encode(encoder, offset + 20, depth)?;
18238            Ok(())
18239        }
18240    }
18241
18242    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18243        for AudioDeviceEnumeratorAddDeviceByChannelRequest
18244    {
18245        #[inline(always)]
18246        fn new_empty() -> Self {
18247            Self {
18248                device_name: fidl::new_empty!(
18249                    fidl::encoding::BoundedString<256>,
18250                    fdomain_client::fidl::FDomainResourceDialect
18251                ),
18252                is_input: fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect),
18253                channel: fidl::new_empty!(
18254                    fidl::encoding::Endpoint<
18255                        fdomain_client::fidl::ClientEnd<
18256                            fdomain_fuchsia_hardware_audio::StreamConfigMarker,
18257                        >,
18258                    >,
18259                    fdomain_client::fidl::FDomainResourceDialect
18260                ),
18261            }
18262        }
18263
18264        #[inline]
18265        unsafe fn decode(
18266            &mut self,
18267            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18268            offset: usize,
18269            _depth: fidl::encoding::Depth,
18270        ) -> fidl::Result<()> {
18271            decoder.debug_check_bounds::<Self>(offset);
18272            // Verify that padding bytes are zero.
18273            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
18274            let padval = unsafe { (ptr as *const u64).read_unaligned() };
18275            let mask = 0xffffff00u64;
18276            let maskedval = padval & mask;
18277            if maskedval != 0 {
18278                return Err(fidl::Error::NonZeroPadding {
18279                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
18280                });
18281            }
18282            fidl::decode!(
18283                fidl::encoding::BoundedString<256>,
18284                fdomain_client::fidl::FDomainResourceDialect,
18285                &mut self.device_name,
18286                decoder,
18287                offset + 0,
18288                _depth
18289            )?;
18290            fidl::decode!(
18291                bool,
18292                fdomain_client::fidl::FDomainResourceDialect,
18293                &mut self.is_input,
18294                decoder,
18295                offset + 16,
18296                _depth
18297            )?;
18298            fidl::decode!(
18299                fidl::encoding::Endpoint<
18300                    fdomain_client::fidl::ClientEnd<
18301                        fdomain_fuchsia_hardware_audio::StreamConfigMarker,
18302                    >,
18303                >,
18304                fdomain_client::fidl::FDomainResourceDialect,
18305                &mut self.channel,
18306                decoder,
18307                offset + 20,
18308                _depth
18309            )?;
18310            Ok(())
18311        }
18312    }
18313
18314    impl fidl::encoding::ResourceTypeMarker for AudioRendererBindGainControlRequest {
18315        type Borrowed<'a> = &'a mut Self;
18316        fn take_or_borrow<'a>(
18317            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18318        ) -> Self::Borrowed<'a> {
18319            value
18320        }
18321    }
18322
18323    unsafe impl fidl::encoding::TypeMarker for AudioRendererBindGainControlRequest {
18324        type Owned = Self;
18325
18326        #[inline(always)]
18327        fn inline_align(_context: fidl::encoding::Context) -> usize {
18328            4
18329        }
18330
18331        #[inline(always)]
18332        fn inline_size(_context: fidl::encoding::Context) -> usize {
18333            4
18334        }
18335    }
18336
18337    unsafe impl
18338        fidl::encoding::Encode<
18339            AudioRendererBindGainControlRequest,
18340            fdomain_client::fidl::FDomainResourceDialect,
18341        > for &mut AudioRendererBindGainControlRequest
18342    {
18343        #[inline]
18344        unsafe fn encode(
18345            self,
18346            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18347            offset: usize,
18348            _depth: fidl::encoding::Depth,
18349        ) -> fidl::Result<()> {
18350            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
18351            // Delegate to tuple encoding.
18352            fidl::encoding::Encode::<
18353                AudioRendererBindGainControlRequest,
18354                fdomain_client::fidl::FDomainResourceDialect,
18355            >::encode(
18356                (<fidl::encoding::Endpoint<
18357                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
18358                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
18359                    &mut self.gain_control_request,
18360                ),),
18361                encoder,
18362                offset,
18363                _depth,
18364            )
18365        }
18366    }
18367    unsafe impl<
18368        T0: fidl::encoding::Encode<
18369                fidl::encoding::Endpoint<
18370                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
18371                >,
18372                fdomain_client::fidl::FDomainResourceDialect,
18373            >,
18374    >
18375        fidl::encoding::Encode<
18376            AudioRendererBindGainControlRequest,
18377            fdomain_client::fidl::FDomainResourceDialect,
18378        > for (T0,)
18379    {
18380        #[inline]
18381        unsafe fn encode(
18382            self,
18383            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18384            offset: usize,
18385            depth: fidl::encoding::Depth,
18386        ) -> fidl::Result<()> {
18387            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
18388            // Zero out padding regions. There's no need to apply masks
18389            // because the unmasked parts will be overwritten by fields.
18390            // Write the fields.
18391            self.0.encode(encoder, offset + 0, depth)?;
18392            Ok(())
18393        }
18394    }
18395
18396    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18397        for AudioRendererBindGainControlRequest
18398    {
18399        #[inline(always)]
18400        fn new_empty() -> Self {
18401            Self {
18402                gain_control_request: fidl::new_empty!(
18403                    fidl::encoding::Endpoint<
18404                        fdomain_client::fidl::ServerEnd<
18405                            fdomain_fuchsia_media_audio::GainControlMarker,
18406                        >,
18407                    >,
18408                    fdomain_client::fidl::FDomainResourceDialect
18409                ),
18410            }
18411        }
18412
18413        #[inline]
18414        unsafe fn decode(
18415            &mut self,
18416            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18417            offset: usize,
18418            _depth: fidl::encoding::Depth,
18419        ) -> fidl::Result<()> {
18420            decoder.debug_check_bounds::<Self>(offset);
18421            // Verify that padding bytes are zero.
18422            fidl::decode!(
18423                fidl::encoding::Endpoint<
18424                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
18425                >,
18426                fdomain_client::fidl::FDomainResourceDialect,
18427                &mut self.gain_control_request,
18428                decoder,
18429                offset + 0,
18430                _depth
18431            )?;
18432            Ok(())
18433        }
18434    }
18435
18436    impl fidl::encoding::ResourceTypeMarker for AudioRendererGetReferenceClockResponse {
18437        type Borrowed<'a> = &'a mut Self;
18438        fn take_or_borrow<'a>(
18439            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18440        ) -> Self::Borrowed<'a> {
18441            value
18442        }
18443    }
18444
18445    unsafe impl fidl::encoding::TypeMarker for AudioRendererGetReferenceClockResponse {
18446        type Owned = Self;
18447
18448        #[inline(always)]
18449        fn inline_align(_context: fidl::encoding::Context) -> usize {
18450            4
18451        }
18452
18453        #[inline(always)]
18454        fn inline_size(_context: fidl::encoding::Context) -> usize {
18455            4
18456        }
18457    }
18458
18459    unsafe impl
18460        fidl::encoding::Encode<
18461            AudioRendererGetReferenceClockResponse,
18462            fdomain_client::fidl::FDomainResourceDialect,
18463        > for &mut AudioRendererGetReferenceClockResponse
18464    {
18465        #[inline]
18466        unsafe fn encode(
18467            self,
18468            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18469            offset: usize,
18470            _depth: fidl::encoding::Depth,
18471        ) -> fidl::Result<()> {
18472            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
18473            // Delegate to tuple encoding.
18474            fidl::encoding::Encode::<
18475                AudioRendererGetReferenceClockResponse,
18476                fdomain_client::fidl::FDomainResourceDialect,
18477            >::encode(
18478                (<fidl::encoding::HandleType<
18479                    fdomain_client::Clock,
18480                    { fidl::ObjectType::CLOCK.into_raw() },
18481                    2147483648,
18482                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
18483                    &mut self.reference_clock,
18484                ),),
18485                encoder,
18486                offset,
18487                _depth,
18488            )
18489        }
18490    }
18491    unsafe impl<
18492        T0: fidl::encoding::Encode<
18493                fidl::encoding::HandleType<
18494                    fdomain_client::Clock,
18495                    { fidl::ObjectType::CLOCK.into_raw() },
18496                    2147483648,
18497                >,
18498                fdomain_client::fidl::FDomainResourceDialect,
18499            >,
18500    >
18501        fidl::encoding::Encode<
18502            AudioRendererGetReferenceClockResponse,
18503            fdomain_client::fidl::FDomainResourceDialect,
18504        > for (T0,)
18505    {
18506        #[inline]
18507        unsafe fn encode(
18508            self,
18509            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18510            offset: usize,
18511            depth: fidl::encoding::Depth,
18512        ) -> fidl::Result<()> {
18513            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
18514            // Zero out padding regions. There's no need to apply masks
18515            // because the unmasked parts will be overwritten by fields.
18516            // Write the fields.
18517            self.0.encode(encoder, offset + 0, depth)?;
18518            Ok(())
18519        }
18520    }
18521
18522    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18523        for AudioRendererGetReferenceClockResponse
18524    {
18525        #[inline(always)]
18526        fn new_empty() -> Self {
18527            Self {
18528                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
18529            }
18530        }
18531
18532        #[inline]
18533        unsafe fn decode(
18534            &mut self,
18535            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18536            offset: usize,
18537            _depth: fidl::encoding::Depth,
18538        ) -> fidl::Result<()> {
18539            decoder.debug_check_bounds::<Self>(offset);
18540            // Verify that padding bytes are zero.
18541            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
18542            Ok(())
18543        }
18544    }
18545
18546    impl fidl::encoding::ResourceTypeMarker for AudioRendererSetReferenceClockRequest {
18547        type Borrowed<'a> = &'a mut Self;
18548        fn take_or_borrow<'a>(
18549            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18550        ) -> Self::Borrowed<'a> {
18551            value
18552        }
18553    }
18554
18555    unsafe impl fidl::encoding::TypeMarker for AudioRendererSetReferenceClockRequest {
18556        type Owned = Self;
18557
18558        #[inline(always)]
18559        fn inline_align(_context: fidl::encoding::Context) -> usize {
18560            4
18561        }
18562
18563        #[inline(always)]
18564        fn inline_size(_context: fidl::encoding::Context) -> usize {
18565            4
18566        }
18567    }
18568
18569    unsafe impl
18570        fidl::encoding::Encode<
18571            AudioRendererSetReferenceClockRequest,
18572            fdomain_client::fidl::FDomainResourceDialect,
18573        > for &mut AudioRendererSetReferenceClockRequest
18574    {
18575        #[inline]
18576        unsafe fn encode(
18577            self,
18578            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18579            offset: usize,
18580            _depth: fidl::encoding::Depth,
18581        ) -> fidl::Result<()> {
18582            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
18583            // Delegate to tuple encoding.
18584            fidl::encoding::Encode::<
18585                AudioRendererSetReferenceClockRequest,
18586                fdomain_client::fidl::FDomainResourceDialect,
18587            >::encode(
18588                (<fidl::encoding::Optional<
18589                    fidl::encoding::HandleType<
18590                        fdomain_client::Clock,
18591                        { fidl::ObjectType::CLOCK.into_raw() },
18592                        2147483648,
18593                    >,
18594                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
18595                    &mut self.reference_clock,
18596                ),),
18597                encoder,
18598                offset,
18599                _depth,
18600            )
18601        }
18602    }
18603    unsafe impl<
18604        T0: fidl::encoding::Encode<
18605                fidl::encoding::Optional<
18606                    fidl::encoding::HandleType<
18607                        fdomain_client::Clock,
18608                        { fidl::ObjectType::CLOCK.into_raw() },
18609                        2147483648,
18610                    >,
18611                >,
18612                fdomain_client::fidl::FDomainResourceDialect,
18613            >,
18614    >
18615        fidl::encoding::Encode<
18616            AudioRendererSetReferenceClockRequest,
18617            fdomain_client::fidl::FDomainResourceDialect,
18618        > for (T0,)
18619    {
18620        #[inline]
18621        unsafe fn encode(
18622            self,
18623            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18624            offset: usize,
18625            depth: fidl::encoding::Depth,
18626        ) -> fidl::Result<()> {
18627            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
18628            // Zero out padding regions. There's no need to apply masks
18629            // because the unmasked parts will be overwritten by fields.
18630            // Write the fields.
18631            self.0.encode(encoder, offset + 0, depth)?;
18632            Ok(())
18633        }
18634    }
18635
18636    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18637        for AudioRendererSetReferenceClockRequest
18638    {
18639        #[inline(always)]
18640        fn new_empty() -> Self {
18641            Self {
18642                reference_clock: fidl::new_empty!(
18643                    fidl::encoding::Optional<
18644                        fidl::encoding::HandleType<
18645                            fdomain_client::Clock,
18646                            { fidl::ObjectType::CLOCK.into_raw() },
18647                            2147483648,
18648                        >,
18649                    >,
18650                    fdomain_client::fidl::FDomainResourceDialect
18651                ),
18652            }
18653        }
18654
18655        #[inline]
18656        unsafe fn decode(
18657            &mut self,
18658            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18659            offset: usize,
18660            _depth: fidl::encoding::Depth,
18661        ) -> fidl::Result<()> {
18662            decoder.debug_check_bounds::<Self>(offset);
18663            // Verify that padding bytes are zero.
18664            fidl::decode!(
18665                fidl::encoding::Optional<
18666                    fidl::encoding::HandleType<
18667                        fdomain_client::Clock,
18668                        { fidl::ObjectType::CLOCK.into_raw() },
18669                        2147483648,
18670                    >,
18671                >,
18672                fdomain_client::fidl::FDomainResourceDialect,
18673                &mut self.reference_clock,
18674                decoder,
18675                offset + 0,
18676                _depth
18677            )?;
18678            Ok(())
18679        }
18680    }
18681
18682    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
18683        type Borrowed<'a> = &'a mut Self;
18684        fn take_or_borrow<'a>(
18685            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18686        ) -> Self::Borrowed<'a> {
18687            value
18688        }
18689    }
18690
18691    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
18692        type Owned = Self;
18693
18694        #[inline(always)]
18695        fn inline_align(_context: fidl::encoding::Context) -> usize {
18696            8
18697        }
18698
18699        #[inline(always)]
18700        fn inline_size(_context: fidl::encoding::Context) -> usize {
18701            40
18702        }
18703    }
18704
18705    unsafe impl
18706        fidl::encoding::Encode<
18707            ProfileProviderRegisterHandlerWithCapacityRequest,
18708            fdomain_client::fidl::FDomainResourceDialect,
18709        > for &mut ProfileProviderRegisterHandlerWithCapacityRequest
18710    {
18711        #[inline]
18712        unsafe fn encode(
18713            self,
18714            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18715            offset: usize,
18716            _depth: fidl::encoding::Depth,
18717        ) -> fidl::Result<()> {
18718            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
18719            // Delegate to tuple encoding.
18720            fidl::encoding::Encode::<
18721                ProfileProviderRegisterHandlerWithCapacityRequest,
18722                fdomain_client::fidl::FDomainResourceDialect,
18723            >::encode(
18724                (
18725                    <fidl::encoding::HandleType<
18726                        fdomain_client::Thread,
18727                        { fidl::ObjectType::THREAD.into_raw() },
18728                        2147483648,
18729                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
18730                        &mut self.thread_handle,
18731                    ),
18732                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
18733                        &self.name,
18734                    ),
18735                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.period),
18736                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.capacity),
18737                ),
18738                encoder,
18739                offset,
18740                _depth,
18741            )
18742        }
18743    }
18744    unsafe impl<
18745        T0: fidl::encoding::Encode<
18746                fidl::encoding::HandleType<
18747                    fdomain_client::Thread,
18748                    { fidl::ObjectType::THREAD.into_raw() },
18749                    2147483648,
18750                >,
18751                fdomain_client::fidl::FDomainResourceDialect,
18752            >,
18753        T1: fidl::encoding::Encode<
18754                fidl::encoding::BoundedString<64>,
18755                fdomain_client::fidl::FDomainResourceDialect,
18756            >,
18757        T2: fidl::encoding::Encode<i64, fdomain_client::fidl::FDomainResourceDialect>,
18758        T3: fidl::encoding::Encode<f32, fdomain_client::fidl::FDomainResourceDialect>,
18759    >
18760        fidl::encoding::Encode<
18761            ProfileProviderRegisterHandlerWithCapacityRequest,
18762            fdomain_client::fidl::FDomainResourceDialect,
18763        > for (T0, T1, T2, T3)
18764    {
18765        #[inline]
18766        unsafe fn encode(
18767            self,
18768            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18769            offset: usize,
18770            depth: fidl::encoding::Depth,
18771        ) -> fidl::Result<()> {
18772            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
18773            // Zero out padding regions. There's no need to apply masks
18774            // because the unmasked parts will be overwritten by fields.
18775            unsafe {
18776                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
18777                (ptr as *mut u64).write_unaligned(0);
18778            }
18779            unsafe {
18780                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
18781                (ptr as *mut u64).write_unaligned(0);
18782            }
18783            // Write the fields.
18784            self.0.encode(encoder, offset + 0, depth)?;
18785            self.1.encode(encoder, offset + 8, depth)?;
18786            self.2.encode(encoder, offset + 24, depth)?;
18787            self.3.encode(encoder, offset + 32, depth)?;
18788            Ok(())
18789        }
18790    }
18791
18792    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18793        for ProfileProviderRegisterHandlerWithCapacityRequest
18794    {
18795        #[inline(always)]
18796        fn new_empty() -> Self {
18797            Self {
18798                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
18799                name: fidl::new_empty!(
18800                    fidl::encoding::BoundedString<64>,
18801                    fdomain_client::fidl::FDomainResourceDialect
18802                ),
18803                period: fidl::new_empty!(i64, fdomain_client::fidl::FDomainResourceDialect),
18804                capacity: fidl::new_empty!(f32, fdomain_client::fidl::FDomainResourceDialect),
18805            }
18806        }
18807
18808        #[inline]
18809        unsafe fn decode(
18810            &mut self,
18811            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18812            offset: usize,
18813            _depth: fidl::encoding::Depth,
18814        ) -> fidl::Result<()> {
18815            decoder.debug_check_bounds::<Self>(offset);
18816            // Verify that padding bytes are zero.
18817            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
18818            let padval = unsafe { (ptr as *const u64).read_unaligned() };
18819            let mask = 0xffffffff00000000u64;
18820            let maskedval = padval & mask;
18821            if maskedval != 0 {
18822                return Err(fidl::Error::NonZeroPadding {
18823                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
18824                });
18825            }
18826            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
18827            let padval = unsafe { (ptr as *const u64).read_unaligned() };
18828            let mask = 0xffffffff00000000u64;
18829            let maskedval = padval & mask;
18830            if maskedval != 0 {
18831                return Err(fidl::Error::NonZeroPadding {
18832                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
18833                });
18834            }
18835            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
18836            fidl::decode!(
18837                fidl::encoding::BoundedString<64>,
18838                fdomain_client::fidl::FDomainResourceDialect,
18839                &mut self.name,
18840                decoder,
18841                offset + 8,
18842                _depth
18843            )?;
18844            fidl::decode!(
18845                i64,
18846                fdomain_client::fidl::FDomainResourceDialect,
18847                &mut self.period,
18848                decoder,
18849                offset + 24,
18850                _depth
18851            )?;
18852            fidl::decode!(
18853                f32,
18854                fdomain_client::fidl::FDomainResourceDialect,
18855                &mut self.capacity,
18856                decoder,
18857                offset + 32,
18858                _depth
18859            )?;
18860            Ok(())
18861        }
18862    }
18863
18864    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterMemoryRangeRequest {
18865        type Borrowed<'a> = &'a mut Self;
18866        fn take_or_borrow<'a>(
18867            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18868        ) -> Self::Borrowed<'a> {
18869            value
18870        }
18871    }
18872
18873    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterMemoryRangeRequest {
18874        type Owned = Self;
18875
18876        #[inline(always)]
18877        fn inline_align(_context: fidl::encoding::Context) -> usize {
18878            8
18879        }
18880
18881        #[inline(always)]
18882        fn inline_size(_context: fidl::encoding::Context) -> usize {
18883            24
18884        }
18885    }
18886
18887    unsafe impl
18888        fidl::encoding::Encode<
18889            ProfileProviderRegisterMemoryRangeRequest,
18890            fdomain_client::fidl::FDomainResourceDialect,
18891        > for &mut ProfileProviderRegisterMemoryRangeRequest
18892    {
18893        #[inline]
18894        unsafe fn encode(
18895            self,
18896            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18897            offset: usize,
18898            _depth: fidl::encoding::Depth,
18899        ) -> fidl::Result<()> {
18900            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
18901            // Delegate to tuple encoding.
18902            fidl::encoding::Encode::<
18903                ProfileProviderRegisterMemoryRangeRequest,
18904                fdomain_client::fidl::FDomainResourceDialect,
18905            >::encode(
18906                (
18907                    <fidl::encoding::HandleType<
18908                        fdomain_client::Vmar,
18909                        { fidl::ObjectType::VMAR.into_raw() },
18910                        2147483648,
18911                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
18912                        &mut self.vmar_handle
18913                    ),
18914                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
18915                        &self.name,
18916                    ),
18917                ),
18918                encoder,
18919                offset,
18920                _depth,
18921            )
18922        }
18923    }
18924    unsafe impl<
18925        T0: fidl::encoding::Encode<
18926                fidl::encoding::HandleType<
18927                    fdomain_client::Vmar,
18928                    { fidl::ObjectType::VMAR.into_raw() },
18929                    2147483648,
18930                >,
18931                fdomain_client::fidl::FDomainResourceDialect,
18932            >,
18933        T1: fidl::encoding::Encode<
18934                fidl::encoding::BoundedString<64>,
18935                fdomain_client::fidl::FDomainResourceDialect,
18936            >,
18937    >
18938        fidl::encoding::Encode<
18939            ProfileProviderRegisterMemoryRangeRequest,
18940            fdomain_client::fidl::FDomainResourceDialect,
18941        > for (T0, T1)
18942    {
18943        #[inline]
18944        unsafe fn encode(
18945            self,
18946            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18947            offset: usize,
18948            depth: fidl::encoding::Depth,
18949        ) -> fidl::Result<()> {
18950            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
18951            // Zero out padding regions. There's no need to apply masks
18952            // because the unmasked parts will be overwritten by fields.
18953            unsafe {
18954                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
18955                (ptr as *mut u64).write_unaligned(0);
18956            }
18957            // Write the fields.
18958            self.0.encode(encoder, offset + 0, depth)?;
18959            self.1.encode(encoder, offset + 8, depth)?;
18960            Ok(())
18961        }
18962    }
18963
18964    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18965        for ProfileProviderRegisterMemoryRangeRequest
18966    {
18967        #[inline(always)]
18968        fn new_empty() -> Self {
18969            Self {
18970                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
18971                name: fidl::new_empty!(
18972                    fidl::encoding::BoundedString<64>,
18973                    fdomain_client::fidl::FDomainResourceDialect
18974                ),
18975            }
18976        }
18977
18978        #[inline]
18979        unsafe fn decode(
18980            &mut self,
18981            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18982            offset: usize,
18983            _depth: fidl::encoding::Depth,
18984        ) -> fidl::Result<()> {
18985            decoder.debug_check_bounds::<Self>(offset);
18986            // Verify that padding bytes are zero.
18987            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
18988            let padval = unsafe { (ptr as *const u64).read_unaligned() };
18989            let mask = 0xffffffff00000000u64;
18990            let maskedval = padval & mask;
18991            if maskedval != 0 {
18992                return Err(fidl::Error::NonZeroPadding {
18993                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
18994                });
18995            }
18996            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
18997            fidl::decode!(
18998                fidl::encoding::BoundedString<64>,
18999                fdomain_client::fidl::FDomainResourceDialect,
19000                &mut self.name,
19001                decoder,
19002                offset + 8,
19003                _depth
19004            )?;
19005            Ok(())
19006        }
19007    }
19008
19009    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterHandlerRequest {
19010        type Borrowed<'a> = &'a mut Self;
19011        fn take_or_borrow<'a>(
19012            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19013        ) -> Self::Borrowed<'a> {
19014            value
19015        }
19016    }
19017
19018    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterHandlerRequest {
19019        type Owned = Self;
19020
19021        #[inline(always)]
19022        fn inline_align(_context: fidl::encoding::Context) -> usize {
19023            8
19024        }
19025
19026        #[inline(always)]
19027        fn inline_size(_context: fidl::encoding::Context) -> usize {
19028            24
19029        }
19030    }
19031
19032    unsafe impl
19033        fidl::encoding::Encode<
19034            ProfileProviderUnregisterHandlerRequest,
19035            fdomain_client::fidl::FDomainResourceDialect,
19036        > for &mut ProfileProviderUnregisterHandlerRequest
19037    {
19038        #[inline]
19039        unsafe fn encode(
19040            self,
19041            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19042            offset: usize,
19043            _depth: fidl::encoding::Depth,
19044        ) -> fidl::Result<()> {
19045            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
19046            // Delegate to tuple encoding.
19047            fidl::encoding::Encode::<
19048                ProfileProviderUnregisterHandlerRequest,
19049                fdomain_client::fidl::FDomainResourceDialect,
19050            >::encode(
19051                (
19052                    <fidl::encoding::HandleType<
19053                        fdomain_client::Thread,
19054                        { fidl::ObjectType::THREAD.into_raw() },
19055                        2147483648,
19056                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
19057                        &mut self.thread_handle,
19058                    ),
19059                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
19060                        &self.name,
19061                    ),
19062                ),
19063                encoder,
19064                offset,
19065                _depth,
19066            )
19067        }
19068    }
19069    unsafe impl<
19070        T0: fidl::encoding::Encode<
19071                fidl::encoding::HandleType<
19072                    fdomain_client::Thread,
19073                    { fidl::ObjectType::THREAD.into_raw() },
19074                    2147483648,
19075                >,
19076                fdomain_client::fidl::FDomainResourceDialect,
19077            >,
19078        T1: fidl::encoding::Encode<
19079                fidl::encoding::BoundedString<64>,
19080                fdomain_client::fidl::FDomainResourceDialect,
19081            >,
19082    >
19083        fidl::encoding::Encode<
19084            ProfileProviderUnregisterHandlerRequest,
19085            fdomain_client::fidl::FDomainResourceDialect,
19086        > for (T0, T1)
19087    {
19088        #[inline]
19089        unsafe fn encode(
19090            self,
19091            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19092            offset: usize,
19093            depth: fidl::encoding::Depth,
19094        ) -> fidl::Result<()> {
19095            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
19096            // Zero out padding regions. There's no need to apply masks
19097            // because the unmasked parts will be overwritten by fields.
19098            unsafe {
19099                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
19100                (ptr as *mut u64).write_unaligned(0);
19101            }
19102            // Write the fields.
19103            self.0.encode(encoder, offset + 0, depth)?;
19104            self.1.encode(encoder, offset + 8, depth)?;
19105            Ok(())
19106        }
19107    }
19108
19109    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19110        for ProfileProviderUnregisterHandlerRequest
19111    {
19112        #[inline(always)]
19113        fn new_empty() -> Self {
19114            Self {
19115                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
19116                name: fidl::new_empty!(
19117                    fidl::encoding::BoundedString<64>,
19118                    fdomain_client::fidl::FDomainResourceDialect
19119                ),
19120            }
19121        }
19122
19123        #[inline]
19124        unsafe fn decode(
19125            &mut self,
19126            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19127            offset: usize,
19128            _depth: fidl::encoding::Depth,
19129        ) -> fidl::Result<()> {
19130            decoder.debug_check_bounds::<Self>(offset);
19131            // Verify that padding bytes are zero.
19132            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
19133            let padval = unsafe { (ptr as *const u64).read_unaligned() };
19134            let mask = 0xffffffff00000000u64;
19135            let maskedval = padval & mask;
19136            if maskedval != 0 {
19137                return Err(fidl::Error::NonZeroPadding {
19138                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
19139                });
19140            }
19141            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
19142            fidl::decode!(
19143                fidl::encoding::BoundedString<64>,
19144                fdomain_client::fidl::FDomainResourceDialect,
19145                &mut self.name,
19146                decoder,
19147                offset + 8,
19148                _depth
19149            )?;
19150            Ok(())
19151        }
19152    }
19153
19154    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
19155        type Borrowed<'a> = &'a mut Self;
19156        fn take_or_borrow<'a>(
19157            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19158        ) -> Self::Borrowed<'a> {
19159            value
19160        }
19161    }
19162
19163    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
19164        type Owned = Self;
19165
19166        #[inline(always)]
19167        fn inline_align(_context: fidl::encoding::Context) -> usize {
19168            4
19169        }
19170
19171        #[inline(always)]
19172        fn inline_size(_context: fidl::encoding::Context) -> usize {
19173            4
19174        }
19175    }
19176
19177    unsafe impl
19178        fidl::encoding::Encode<
19179            ProfileProviderUnregisterMemoryRangeRequest,
19180            fdomain_client::fidl::FDomainResourceDialect,
19181        > for &mut ProfileProviderUnregisterMemoryRangeRequest
19182    {
19183        #[inline]
19184        unsafe fn encode(
19185            self,
19186            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19187            offset: usize,
19188            _depth: fidl::encoding::Depth,
19189        ) -> fidl::Result<()> {
19190            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
19191            // Delegate to tuple encoding.
19192            fidl::encoding::Encode::<
19193                ProfileProviderUnregisterMemoryRangeRequest,
19194                fdomain_client::fidl::FDomainResourceDialect,
19195            >::encode(
19196                (<fidl::encoding::HandleType<
19197                    fdomain_client::Vmar,
19198                    { fidl::ObjectType::VMAR.into_raw() },
19199                    2147483648,
19200                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
19201                    &mut self.vmar_handle
19202                ),),
19203                encoder,
19204                offset,
19205                _depth,
19206            )
19207        }
19208    }
19209    unsafe impl<
19210        T0: fidl::encoding::Encode<
19211                fidl::encoding::HandleType<
19212                    fdomain_client::Vmar,
19213                    { fidl::ObjectType::VMAR.into_raw() },
19214                    2147483648,
19215                >,
19216                fdomain_client::fidl::FDomainResourceDialect,
19217            >,
19218    >
19219        fidl::encoding::Encode<
19220            ProfileProviderUnregisterMemoryRangeRequest,
19221            fdomain_client::fidl::FDomainResourceDialect,
19222        > for (T0,)
19223    {
19224        #[inline]
19225        unsafe fn encode(
19226            self,
19227            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19228            offset: usize,
19229            depth: fidl::encoding::Depth,
19230        ) -> fidl::Result<()> {
19231            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
19232            // Zero out padding regions. There's no need to apply masks
19233            // because the unmasked parts will be overwritten by fields.
19234            // Write the fields.
19235            self.0.encode(encoder, offset + 0, depth)?;
19236            Ok(())
19237        }
19238    }
19239
19240    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19241        for ProfileProviderUnregisterMemoryRangeRequest
19242    {
19243        #[inline(always)]
19244        fn new_empty() -> Self {
19245            Self {
19246                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
19247            }
19248        }
19249
19250        #[inline]
19251        unsafe fn decode(
19252            &mut self,
19253            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19254            offset: usize,
19255            _depth: fidl::encoding::Depth,
19256        ) -> fidl::Result<()> {
19257            decoder.debug_check_bounds::<Self>(offset);
19258            // Verify that padding bytes are zero.
19259            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
19260            Ok(())
19261        }
19262    }
19263
19264    impl fidl::encoding::ResourceTypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
19265        type Borrowed<'a> = &'a mut Self;
19266        fn take_or_borrow<'a>(
19267            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19268        ) -> Self::Borrowed<'a> {
19269            value
19270        }
19271    }
19272
19273    unsafe impl fidl::encoding::TypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
19274        type Owned = Self;
19275
19276        #[inline(always)]
19277        fn inline_align(_context: fidl::encoding::Context) -> usize {
19278            8
19279        }
19280
19281        #[inline(always)]
19282        fn inline_size(_context: fidl::encoding::Context) -> usize {
19283            16
19284        }
19285    }
19286
19287    unsafe impl
19288        fidl::encoding::Encode<
19289            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
19290            fdomain_client::fidl::FDomainResourceDialect,
19291        > for &mut SessionAudioConsumerFactoryCreateAudioConsumerRequest
19292    {
19293        #[inline]
19294        unsafe fn encode(
19295            self,
19296            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19297            offset: usize,
19298            _depth: fidl::encoding::Depth,
19299        ) -> fidl::Result<()> {
19300            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
19301                offset,
19302            );
19303            // Delegate to tuple encoding.
19304            fidl::encoding::Encode::<SessionAudioConsumerFactoryCreateAudioConsumerRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
19305                (
19306                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.session_id),
19307                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
19308                ),
19309                encoder, offset, _depth
19310            )
19311        }
19312    }
19313    unsafe impl<
19314        T0: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
19315        T1: fidl::encoding::Encode<
19316                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
19317                fdomain_client::fidl::FDomainResourceDialect,
19318            >,
19319    >
19320        fidl::encoding::Encode<
19321            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
19322            fdomain_client::fidl::FDomainResourceDialect,
19323        > for (T0, T1)
19324    {
19325        #[inline]
19326        unsafe fn encode(
19327            self,
19328            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19329            offset: usize,
19330            depth: fidl::encoding::Depth,
19331        ) -> fidl::Result<()> {
19332            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
19333                offset,
19334            );
19335            // Zero out padding regions. There's no need to apply masks
19336            // because the unmasked parts will be overwritten by fields.
19337            unsafe {
19338                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
19339                (ptr as *mut u64).write_unaligned(0);
19340            }
19341            // Write the fields.
19342            self.0.encode(encoder, offset + 0, depth)?;
19343            self.1.encode(encoder, offset + 8, depth)?;
19344            Ok(())
19345        }
19346    }
19347
19348    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19349        for SessionAudioConsumerFactoryCreateAudioConsumerRequest
19350    {
19351        #[inline(always)]
19352        fn new_empty() -> Self {
19353            Self {
19354                session_id: fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect),
19355                audio_consumer_request: fidl::new_empty!(
19356                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
19357                    fdomain_client::fidl::FDomainResourceDialect
19358                ),
19359            }
19360        }
19361
19362        #[inline]
19363        unsafe fn decode(
19364            &mut self,
19365            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19366            offset: usize,
19367            _depth: fidl::encoding::Depth,
19368        ) -> fidl::Result<()> {
19369            decoder.debug_check_bounds::<Self>(offset);
19370            // Verify that padding bytes are zero.
19371            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
19372            let padval = unsafe { (ptr as *const u64).read_unaligned() };
19373            let mask = 0xffffffff00000000u64;
19374            let maskedval = padval & mask;
19375            if maskedval != 0 {
19376                return Err(fidl::Error::NonZeroPadding {
19377                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
19378                });
19379            }
19380            fidl::decode!(
19381                u64,
19382                fdomain_client::fidl::FDomainResourceDialect,
19383                &mut self.session_id,
19384                decoder,
19385                offset + 0,
19386                _depth
19387            )?;
19388            fidl::decode!(
19389                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
19390                fdomain_client::fidl::FDomainResourceDialect,
19391                &mut self.audio_consumer_request,
19392                decoder,
19393                offset + 8,
19394                _depth
19395            )?;
19396            Ok(())
19397        }
19398    }
19399
19400    impl fidl::encoding::ResourceTypeMarker for StreamBufferSetAddPayloadBufferRequest {
19401        type Borrowed<'a> = &'a mut Self;
19402        fn take_or_borrow<'a>(
19403            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19404        ) -> Self::Borrowed<'a> {
19405            value
19406        }
19407    }
19408
19409    unsafe impl fidl::encoding::TypeMarker for StreamBufferSetAddPayloadBufferRequest {
19410        type Owned = Self;
19411
19412        #[inline(always)]
19413        fn inline_align(_context: fidl::encoding::Context) -> usize {
19414            4
19415        }
19416
19417        #[inline(always)]
19418        fn inline_size(_context: fidl::encoding::Context) -> usize {
19419            8
19420        }
19421    }
19422
19423    unsafe impl
19424        fidl::encoding::Encode<
19425            StreamBufferSetAddPayloadBufferRequest,
19426            fdomain_client::fidl::FDomainResourceDialect,
19427        > for &mut StreamBufferSetAddPayloadBufferRequest
19428    {
19429        #[inline]
19430        unsafe fn encode(
19431            self,
19432            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19433            offset: usize,
19434            _depth: fidl::encoding::Depth,
19435        ) -> fidl::Result<()> {
19436            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
19437            // Delegate to tuple encoding.
19438            fidl::encoding::Encode::<
19439                StreamBufferSetAddPayloadBufferRequest,
19440                fdomain_client::fidl::FDomainResourceDialect,
19441            >::encode(
19442                (
19443                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
19444                    <fidl::encoding::HandleType<
19445                        fdomain_client::Vmo,
19446                        { fidl::ObjectType::VMO.into_raw() },
19447                        2147483648,
19448                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
19449                        &mut self.payload_buffer,
19450                    ),
19451                ),
19452                encoder,
19453                offset,
19454                _depth,
19455            )
19456        }
19457    }
19458    unsafe impl<
19459        T0: fidl::encoding::Encode<u32, fdomain_client::fidl::FDomainResourceDialect>,
19460        T1: fidl::encoding::Encode<
19461                fidl::encoding::HandleType<
19462                    fdomain_client::Vmo,
19463                    { fidl::ObjectType::VMO.into_raw() },
19464                    2147483648,
19465                >,
19466                fdomain_client::fidl::FDomainResourceDialect,
19467            >,
19468    >
19469        fidl::encoding::Encode<
19470            StreamBufferSetAddPayloadBufferRequest,
19471            fdomain_client::fidl::FDomainResourceDialect,
19472        > for (T0, T1)
19473    {
19474        #[inline]
19475        unsafe fn encode(
19476            self,
19477            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19478            offset: usize,
19479            depth: fidl::encoding::Depth,
19480        ) -> fidl::Result<()> {
19481            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
19482            // Zero out padding regions. There's no need to apply masks
19483            // because the unmasked parts will be overwritten by fields.
19484            // Write the fields.
19485            self.0.encode(encoder, offset + 0, depth)?;
19486            self.1.encode(encoder, offset + 4, depth)?;
19487            Ok(())
19488        }
19489    }
19490
19491    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19492        for StreamBufferSetAddPayloadBufferRequest
19493    {
19494        #[inline(always)]
19495        fn new_empty() -> Self {
19496            Self {
19497                id: fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect),
19498                payload_buffer: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
19499            }
19500        }
19501
19502        #[inline]
19503        unsafe fn decode(
19504            &mut self,
19505            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19506            offset: usize,
19507            _depth: fidl::encoding::Depth,
19508        ) -> fidl::Result<()> {
19509            decoder.debug_check_bounds::<Self>(offset);
19510            // Verify that padding bytes are zero.
19511            fidl::decode!(
19512                u32,
19513                fdomain_client::fidl::FDomainResourceDialect,
19514                &mut self.id,
19515                decoder,
19516                offset + 0,
19517                _depth
19518            )?;
19519            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.payload_buffer, decoder, offset + 4, _depth)?;
19520            Ok(())
19521        }
19522    }
19523
19524    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
19525        type Borrowed<'a> = &'a mut Self;
19526        fn take_or_borrow<'a>(
19527            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19528        ) -> Self::Borrowed<'a> {
19529            value
19530        }
19531    }
19532
19533    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
19534        type Owned = Self;
19535
19536        #[inline(always)]
19537        fn inline_align(_context: fidl::encoding::Context) -> usize {
19538            8
19539        }
19540
19541        #[inline(always)]
19542        fn inline_size(_context: fidl::encoding::Context) -> usize {
19543            16
19544        }
19545    }
19546
19547    unsafe impl
19548        fidl::encoding::Encode<
19549            StreamProcessorSetInputBufferPartialSettingsRequest,
19550            fdomain_client::fidl::FDomainResourceDialect,
19551        > for &mut StreamProcessorSetInputBufferPartialSettingsRequest
19552    {
19553        #[inline]
19554        unsafe fn encode(
19555            self,
19556            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19557            offset: usize,
19558            _depth: fidl::encoding::Depth,
19559        ) -> fidl::Result<()> {
19560            encoder
19561                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
19562            // Delegate to tuple encoding.
19563            fidl::encoding::Encode::<StreamProcessorSetInputBufferPartialSettingsRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
19564                (
19565                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.input_settings),
19566                ),
19567                encoder, offset, _depth
19568            )
19569        }
19570    }
19571    unsafe impl<
19572        T0: fidl::encoding::Encode<
19573                StreamBufferPartialSettings,
19574                fdomain_client::fidl::FDomainResourceDialect,
19575            >,
19576    >
19577        fidl::encoding::Encode<
19578            StreamProcessorSetInputBufferPartialSettingsRequest,
19579            fdomain_client::fidl::FDomainResourceDialect,
19580        > for (T0,)
19581    {
19582        #[inline]
19583        unsafe fn encode(
19584            self,
19585            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19586            offset: usize,
19587            depth: fidl::encoding::Depth,
19588        ) -> fidl::Result<()> {
19589            encoder
19590                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
19591            // Zero out padding regions. There's no need to apply masks
19592            // because the unmasked parts will be overwritten by fields.
19593            // Write the fields.
19594            self.0.encode(encoder, offset + 0, depth)?;
19595            Ok(())
19596        }
19597    }
19598
19599    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19600        for StreamProcessorSetInputBufferPartialSettingsRequest
19601    {
19602        #[inline(always)]
19603        fn new_empty() -> Self {
19604            Self {
19605                input_settings: fidl::new_empty!(
19606                    StreamBufferPartialSettings,
19607                    fdomain_client::fidl::FDomainResourceDialect
19608                ),
19609            }
19610        }
19611
19612        #[inline]
19613        unsafe fn decode(
19614            &mut self,
19615            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19616            offset: usize,
19617            _depth: fidl::encoding::Depth,
19618        ) -> fidl::Result<()> {
19619            decoder.debug_check_bounds::<Self>(offset);
19620            // Verify that padding bytes are zero.
19621            fidl::decode!(
19622                StreamBufferPartialSettings,
19623                fdomain_client::fidl::FDomainResourceDialect,
19624                &mut self.input_settings,
19625                decoder,
19626                offset + 0,
19627                _depth
19628            )?;
19629            Ok(())
19630        }
19631    }
19632
19633    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
19634        type Borrowed<'a> = &'a mut Self;
19635        fn take_or_borrow<'a>(
19636            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19637        ) -> Self::Borrowed<'a> {
19638            value
19639        }
19640    }
19641
19642    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
19643        type Owned = Self;
19644
19645        #[inline(always)]
19646        fn inline_align(_context: fidl::encoding::Context) -> usize {
19647            8
19648        }
19649
19650        #[inline(always)]
19651        fn inline_size(_context: fidl::encoding::Context) -> usize {
19652            16
19653        }
19654    }
19655
19656    unsafe impl
19657        fidl::encoding::Encode<
19658            StreamProcessorSetOutputBufferPartialSettingsRequest,
19659            fdomain_client::fidl::FDomainResourceDialect,
19660        > for &mut StreamProcessorSetOutputBufferPartialSettingsRequest
19661    {
19662        #[inline]
19663        unsafe fn encode(
19664            self,
19665            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19666            offset: usize,
19667            _depth: fidl::encoding::Depth,
19668        ) -> fidl::Result<()> {
19669            encoder
19670                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
19671            // Delegate to tuple encoding.
19672            fidl::encoding::Encode::<StreamProcessorSetOutputBufferPartialSettingsRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
19673                (
19674                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.output_settings),
19675                ),
19676                encoder, offset, _depth
19677            )
19678        }
19679    }
19680    unsafe impl<
19681        T0: fidl::encoding::Encode<
19682                StreamBufferPartialSettings,
19683                fdomain_client::fidl::FDomainResourceDialect,
19684            >,
19685    >
19686        fidl::encoding::Encode<
19687            StreamProcessorSetOutputBufferPartialSettingsRequest,
19688            fdomain_client::fidl::FDomainResourceDialect,
19689        > for (T0,)
19690    {
19691        #[inline]
19692        unsafe fn encode(
19693            self,
19694            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19695            offset: usize,
19696            depth: fidl::encoding::Depth,
19697        ) -> fidl::Result<()> {
19698            encoder
19699                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
19700            // Zero out padding regions. There's no need to apply masks
19701            // because the unmasked parts will be overwritten by fields.
19702            // Write the fields.
19703            self.0.encode(encoder, offset + 0, depth)?;
19704            Ok(())
19705        }
19706    }
19707
19708    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19709        for StreamProcessorSetOutputBufferPartialSettingsRequest
19710    {
19711        #[inline(always)]
19712        fn new_empty() -> Self {
19713            Self {
19714                output_settings: fidl::new_empty!(
19715                    StreamBufferPartialSettings,
19716                    fdomain_client::fidl::FDomainResourceDialect
19717                ),
19718            }
19719        }
19720
19721        #[inline]
19722        unsafe fn decode(
19723            &mut self,
19724            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19725            offset: usize,
19726            _depth: fidl::encoding::Depth,
19727        ) -> fidl::Result<()> {
19728            decoder.debug_check_bounds::<Self>(offset);
19729            // Verify that padding bytes are zero.
19730            fidl::decode!(
19731                StreamBufferPartialSettings,
19732                fdomain_client::fidl::FDomainResourceDialect,
19733                &mut self.output_settings,
19734                decoder,
19735                offset + 0,
19736                _depth
19737            )?;
19738            Ok(())
19739        }
19740    }
19741
19742    impl fidl::encoding::ResourceTypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
19743        type Borrowed<'a> = &'a mut Self;
19744        fn take_or_borrow<'a>(
19745            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19746        ) -> Self::Borrowed<'a> {
19747            value
19748        }
19749    }
19750
19751    unsafe impl fidl::encoding::TypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
19752        type Owned = Self;
19753
19754        #[inline(always)]
19755        fn inline_align(_context: fidl::encoding::Context) -> usize {
19756            4
19757        }
19758
19759        #[inline(always)]
19760        fn inline_size(_context: fidl::encoding::Context) -> usize {
19761            8
19762        }
19763    }
19764
19765    unsafe impl
19766        fidl::encoding::Encode<
19767            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
19768            fdomain_client::fidl::FDomainResourceDialect,
19769        > for &mut Usage2AudioConsumerFactoryCreateAudioConsumerRequest
19770    {
19771        #[inline]
19772        unsafe fn encode(
19773            self,
19774            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19775            offset: usize,
19776            _depth: fidl::encoding::Depth,
19777        ) -> fidl::Result<()> {
19778            encoder
19779                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
19780            // Delegate to tuple encoding.
19781            fidl::encoding::Encode::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
19782                (
19783                    <AudioRenderUsage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
19784                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
19785                ),
19786                encoder, offset, _depth
19787            )
19788        }
19789    }
19790    unsafe impl<
19791        T0: fidl::encoding::Encode<AudioRenderUsage2, fdomain_client::fidl::FDomainResourceDialect>,
19792        T1: fidl::encoding::Encode<
19793                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
19794                fdomain_client::fidl::FDomainResourceDialect,
19795            >,
19796    >
19797        fidl::encoding::Encode<
19798            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
19799            fdomain_client::fidl::FDomainResourceDialect,
19800        > for (T0, T1)
19801    {
19802        #[inline]
19803        unsafe fn encode(
19804            self,
19805            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19806            offset: usize,
19807            depth: fidl::encoding::Depth,
19808        ) -> fidl::Result<()> {
19809            encoder
19810                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
19811            // Zero out padding regions. There's no need to apply masks
19812            // because the unmasked parts will be overwritten by fields.
19813            // Write the fields.
19814            self.0.encode(encoder, offset + 0, depth)?;
19815            self.1.encode(encoder, offset + 4, depth)?;
19816            Ok(())
19817        }
19818    }
19819
19820    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19821        for Usage2AudioConsumerFactoryCreateAudioConsumerRequest
19822    {
19823        #[inline(always)]
19824        fn new_empty() -> Self {
19825            Self {
19826                usage: fidl::new_empty!(
19827                    AudioRenderUsage2,
19828                    fdomain_client::fidl::FDomainResourceDialect
19829                ),
19830                audio_consumer_request: fidl::new_empty!(
19831                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
19832                    fdomain_client::fidl::FDomainResourceDialect
19833                ),
19834            }
19835        }
19836
19837        #[inline]
19838        unsafe fn decode(
19839            &mut self,
19840            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19841            offset: usize,
19842            _depth: fidl::encoding::Depth,
19843        ) -> fidl::Result<()> {
19844            decoder.debug_check_bounds::<Self>(offset);
19845            // Verify that padding bytes are zero.
19846            fidl::decode!(
19847                AudioRenderUsage2,
19848                fdomain_client::fidl::FDomainResourceDialect,
19849                &mut self.usage,
19850                decoder,
19851                offset + 0,
19852                _depth
19853            )?;
19854            fidl::decode!(
19855                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
19856                fdomain_client::fidl::FDomainResourceDialect,
19857                &mut self.audio_consumer_request,
19858                decoder,
19859                offset + 4,
19860                _depth
19861            )?;
19862            Ok(())
19863        }
19864    }
19865
19866    impl fidl::encoding::ResourceTypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
19867        type Borrowed<'a> = &'a mut Self;
19868        fn take_or_borrow<'a>(
19869            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19870        ) -> Self::Borrowed<'a> {
19871            value
19872        }
19873    }
19874
19875    unsafe impl fidl::encoding::TypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
19876        type Owned = Self;
19877
19878        #[inline(always)]
19879        fn inline_align(_context: fidl::encoding::Context) -> usize {
19880            4
19881        }
19882
19883        #[inline(always)]
19884        fn inline_size(_context: fidl::encoding::Context) -> usize {
19885            8
19886        }
19887    }
19888
19889    unsafe impl
19890        fidl::encoding::Encode<
19891            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
19892            fdomain_client::fidl::FDomainResourceDialect,
19893        > for &mut UsageAudioConsumerFactoryCreateAudioConsumerRequest
19894    {
19895        #[inline]
19896        unsafe fn encode(
19897            self,
19898            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19899            offset: usize,
19900            _depth: fidl::encoding::Depth,
19901        ) -> fidl::Result<()> {
19902            encoder
19903                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
19904            // Delegate to tuple encoding.
19905            fidl::encoding::Encode::<UsageAudioConsumerFactoryCreateAudioConsumerRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
19906                (
19907                    <AudioRenderUsage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
19908                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
19909                ),
19910                encoder, offset, _depth
19911            )
19912        }
19913    }
19914    unsafe impl<
19915        T0: fidl::encoding::Encode<AudioRenderUsage, fdomain_client::fidl::FDomainResourceDialect>,
19916        T1: fidl::encoding::Encode<
19917                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
19918                fdomain_client::fidl::FDomainResourceDialect,
19919            >,
19920    >
19921        fidl::encoding::Encode<
19922            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
19923            fdomain_client::fidl::FDomainResourceDialect,
19924        > for (T0, T1)
19925    {
19926        #[inline]
19927        unsafe fn encode(
19928            self,
19929            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19930            offset: usize,
19931            depth: fidl::encoding::Depth,
19932        ) -> fidl::Result<()> {
19933            encoder
19934                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
19935            // Zero out padding regions. There's no need to apply masks
19936            // because the unmasked parts will be overwritten by fields.
19937            // Write the fields.
19938            self.0.encode(encoder, offset + 0, depth)?;
19939            self.1.encode(encoder, offset + 4, depth)?;
19940            Ok(())
19941        }
19942    }
19943
19944    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19945        for UsageAudioConsumerFactoryCreateAudioConsumerRequest
19946    {
19947        #[inline(always)]
19948        fn new_empty() -> Self {
19949            Self {
19950                usage: fidl::new_empty!(
19951                    AudioRenderUsage,
19952                    fdomain_client::fidl::FDomainResourceDialect
19953                ),
19954                audio_consumer_request: fidl::new_empty!(
19955                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
19956                    fdomain_client::fidl::FDomainResourceDialect
19957                ),
19958            }
19959        }
19960
19961        #[inline]
19962        unsafe fn decode(
19963            &mut self,
19964            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19965            offset: usize,
19966            _depth: fidl::encoding::Depth,
19967        ) -> fidl::Result<()> {
19968            decoder.debug_check_bounds::<Self>(offset);
19969            // Verify that padding bytes are zero.
19970            fidl::decode!(
19971                AudioRenderUsage,
19972                fdomain_client::fidl::FDomainResourceDialect,
19973                &mut self.usage,
19974                decoder,
19975                offset + 0,
19976                _depth
19977            )?;
19978            fidl::decode!(
19979                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
19980                fdomain_client::fidl::FDomainResourceDialect,
19981                &mut self.audio_consumer_request,
19982                decoder,
19983                offset + 4,
19984                _depth
19985            )?;
19986            Ok(())
19987        }
19988    }
19989
19990    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListener2Request {
19991        type Borrowed<'a> = &'a mut Self;
19992        fn take_or_borrow<'a>(
19993            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19994        ) -> Self::Borrowed<'a> {
19995            value
19996        }
19997    }
19998
19999    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListener2Request {
20000        type Owned = Self;
20001
20002        #[inline(always)]
20003        fn inline_align(_context: fidl::encoding::Context) -> usize {
20004            8
20005        }
20006
20007        #[inline(always)]
20008        fn inline_size(_context: fidl::encoding::Context) -> usize {
20009            40
20010        }
20011    }
20012
20013    unsafe impl
20014        fidl::encoding::Encode<
20015            UsageGainReporterRegisterListener2Request,
20016            fdomain_client::fidl::FDomainResourceDialect,
20017        > for &mut UsageGainReporterRegisterListener2Request
20018    {
20019        #[inline]
20020        unsafe fn encode(
20021            self,
20022            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20023            offset: usize,
20024            _depth: fidl::encoding::Depth,
20025        ) -> fidl::Result<()> {
20026            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
20027            // Delegate to tuple encoding.
20028            fidl::encoding::Encode::<
20029                UsageGainReporterRegisterListener2Request,
20030                fdomain_client::fidl::FDomainResourceDialect,
20031            >::encode(
20032                (
20033                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(
20034                        &self.device_unique_id,
20035                    ),
20036                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
20037                    <fidl::encoding::Endpoint<
20038                        fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
20039                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20040                        &mut self.usage_gain_listener,
20041                    ),
20042                ),
20043                encoder,
20044                offset,
20045                _depth,
20046            )
20047        }
20048    }
20049    unsafe impl<
20050        T0: fidl::encoding::Encode<
20051                fidl::encoding::BoundedString<36>,
20052                fdomain_client::fidl::FDomainResourceDialect,
20053            >,
20054        T1: fidl::encoding::Encode<Usage2, fdomain_client::fidl::FDomainResourceDialect>,
20055        T2: fidl::encoding::Encode<
20056                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>>,
20057                fdomain_client::fidl::FDomainResourceDialect,
20058            >,
20059    >
20060        fidl::encoding::Encode<
20061            UsageGainReporterRegisterListener2Request,
20062            fdomain_client::fidl::FDomainResourceDialect,
20063        > for (T0, T1, T2)
20064    {
20065        #[inline]
20066        unsafe fn encode(
20067            self,
20068            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20069            offset: usize,
20070            depth: fidl::encoding::Depth,
20071        ) -> fidl::Result<()> {
20072            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
20073            // Zero out padding regions. There's no need to apply masks
20074            // because the unmasked parts will be overwritten by fields.
20075            unsafe {
20076                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
20077                (ptr as *mut u64).write_unaligned(0);
20078            }
20079            // Write the fields.
20080            self.0.encode(encoder, offset + 0, depth)?;
20081            self.1.encode(encoder, offset + 16, depth)?;
20082            self.2.encode(encoder, offset + 32, depth)?;
20083            Ok(())
20084        }
20085    }
20086
20087    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20088        for UsageGainReporterRegisterListener2Request
20089    {
20090        #[inline(always)]
20091        fn new_empty() -> Self {
20092            Self {
20093                device_unique_id: fidl::new_empty!(
20094                    fidl::encoding::BoundedString<36>,
20095                    fdomain_client::fidl::FDomainResourceDialect
20096                ),
20097                usage: fidl::new_empty!(Usage2, fdomain_client::fidl::FDomainResourceDialect),
20098                usage_gain_listener: fidl::new_empty!(
20099                    fidl::encoding::Endpoint<
20100                        fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
20101                    >,
20102                    fdomain_client::fidl::FDomainResourceDialect
20103                ),
20104            }
20105        }
20106
20107        #[inline]
20108        unsafe fn decode(
20109            &mut self,
20110            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20111            offset: usize,
20112            _depth: fidl::encoding::Depth,
20113        ) -> fidl::Result<()> {
20114            decoder.debug_check_bounds::<Self>(offset);
20115            // Verify that padding bytes are zero.
20116            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
20117            let padval = unsafe { (ptr as *const u64).read_unaligned() };
20118            let mask = 0xffffffff00000000u64;
20119            let maskedval = padval & mask;
20120            if maskedval != 0 {
20121                return Err(fidl::Error::NonZeroPadding {
20122                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
20123                });
20124            }
20125            fidl::decode!(
20126                fidl::encoding::BoundedString<36>,
20127                fdomain_client::fidl::FDomainResourceDialect,
20128                &mut self.device_unique_id,
20129                decoder,
20130                offset + 0,
20131                _depth
20132            )?;
20133            fidl::decode!(
20134                Usage2,
20135                fdomain_client::fidl::FDomainResourceDialect,
20136                &mut self.usage,
20137                decoder,
20138                offset + 16,
20139                _depth
20140            )?;
20141            fidl::decode!(
20142                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>>,
20143                fdomain_client::fidl::FDomainResourceDialect,
20144                &mut self.usage_gain_listener,
20145                decoder,
20146                offset + 32,
20147                _depth
20148            )?;
20149            Ok(())
20150        }
20151    }
20152
20153    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListenerRequest {
20154        type Borrowed<'a> = &'a mut Self;
20155        fn take_or_borrow<'a>(
20156            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20157        ) -> Self::Borrowed<'a> {
20158            value
20159        }
20160    }
20161
20162    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListenerRequest {
20163        type Owned = Self;
20164
20165        #[inline(always)]
20166        fn inline_align(_context: fidl::encoding::Context) -> usize {
20167            8
20168        }
20169
20170        #[inline(always)]
20171        fn inline_size(_context: fidl::encoding::Context) -> usize {
20172            40
20173        }
20174    }
20175
20176    unsafe impl
20177        fidl::encoding::Encode<
20178            UsageGainReporterRegisterListenerRequest,
20179            fdomain_client::fidl::FDomainResourceDialect,
20180        > for &mut UsageGainReporterRegisterListenerRequest
20181    {
20182        #[inline]
20183        unsafe fn encode(
20184            self,
20185            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20186            offset: usize,
20187            _depth: fidl::encoding::Depth,
20188        ) -> fidl::Result<()> {
20189            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
20190            // Delegate to tuple encoding.
20191            fidl::encoding::Encode::<
20192                UsageGainReporterRegisterListenerRequest,
20193                fdomain_client::fidl::FDomainResourceDialect,
20194            >::encode(
20195                (
20196                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(
20197                        &self.device_unique_id,
20198                    ),
20199                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
20200                    <fidl::encoding::Endpoint<
20201                        fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
20202                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20203                        &mut self.usage_gain_listener,
20204                    ),
20205                ),
20206                encoder,
20207                offset,
20208                _depth,
20209            )
20210        }
20211    }
20212    unsafe impl<
20213        T0: fidl::encoding::Encode<
20214                fidl::encoding::BoundedString<36>,
20215                fdomain_client::fidl::FDomainResourceDialect,
20216            >,
20217        T1: fidl::encoding::Encode<Usage, fdomain_client::fidl::FDomainResourceDialect>,
20218        T2: fidl::encoding::Encode<
20219                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>>,
20220                fdomain_client::fidl::FDomainResourceDialect,
20221            >,
20222    >
20223        fidl::encoding::Encode<
20224            UsageGainReporterRegisterListenerRequest,
20225            fdomain_client::fidl::FDomainResourceDialect,
20226        > for (T0, T1, T2)
20227    {
20228        #[inline]
20229        unsafe fn encode(
20230            self,
20231            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20232            offset: usize,
20233            depth: fidl::encoding::Depth,
20234        ) -> fidl::Result<()> {
20235            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
20236            // Zero out padding regions. There's no need to apply masks
20237            // because the unmasked parts will be overwritten by fields.
20238            unsafe {
20239                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
20240                (ptr as *mut u64).write_unaligned(0);
20241            }
20242            // Write the fields.
20243            self.0.encode(encoder, offset + 0, depth)?;
20244            self.1.encode(encoder, offset + 16, depth)?;
20245            self.2.encode(encoder, offset + 32, depth)?;
20246            Ok(())
20247        }
20248    }
20249
20250    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20251        for UsageGainReporterRegisterListenerRequest
20252    {
20253        #[inline(always)]
20254        fn new_empty() -> Self {
20255            Self {
20256                device_unique_id: fidl::new_empty!(
20257                    fidl::encoding::BoundedString<36>,
20258                    fdomain_client::fidl::FDomainResourceDialect
20259                ),
20260                usage: fidl::new_empty!(Usage, fdomain_client::fidl::FDomainResourceDialect),
20261                usage_gain_listener: fidl::new_empty!(
20262                    fidl::encoding::Endpoint<
20263                        fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
20264                    >,
20265                    fdomain_client::fidl::FDomainResourceDialect
20266                ),
20267            }
20268        }
20269
20270        #[inline]
20271        unsafe fn decode(
20272            &mut self,
20273            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20274            offset: usize,
20275            _depth: fidl::encoding::Depth,
20276        ) -> fidl::Result<()> {
20277            decoder.debug_check_bounds::<Self>(offset);
20278            // Verify that padding bytes are zero.
20279            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
20280            let padval = unsafe { (ptr as *const u64).read_unaligned() };
20281            let mask = 0xffffffff00000000u64;
20282            let maskedval = padval & mask;
20283            if maskedval != 0 {
20284                return Err(fidl::Error::NonZeroPadding {
20285                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
20286                });
20287            }
20288            fidl::decode!(
20289                fidl::encoding::BoundedString<36>,
20290                fdomain_client::fidl::FDomainResourceDialect,
20291                &mut self.device_unique_id,
20292                decoder,
20293                offset + 0,
20294                _depth
20295            )?;
20296            fidl::decode!(
20297                Usage,
20298                fdomain_client::fidl::FDomainResourceDialect,
20299                &mut self.usage,
20300                decoder,
20301                offset + 16,
20302                _depth
20303            )?;
20304            fidl::decode!(
20305                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>>,
20306                fdomain_client::fidl::FDomainResourceDialect,
20307                &mut self.usage_gain_listener,
20308                decoder,
20309                offset + 32,
20310                _depth
20311            )?;
20312            Ok(())
20313        }
20314    }
20315
20316    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatch2Request {
20317        type Borrowed<'a> = &'a mut Self;
20318        fn take_or_borrow<'a>(
20319            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20320        ) -> Self::Borrowed<'a> {
20321            value
20322        }
20323    }
20324
20325    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatch2Request {
20326        type Owned = Self;
20327
20328        #[inline(always)]
20329        fn inline_align(_context: fidl::encoding::Context) -> usize {
20330            8
20331        }
20332
20333        #[inline(always)]
20334        fn inline_size(_context: fidl::encoding::Context) -> usize {
20335            24
20336        }
20337    }
20338
20339    unsafe impl
20340        fidl::encoding::Encode<
20341            UsageReporterWatch2Request,
20342            fdomain_client::fidl::FDomainResourceDialect,
20343        > for &mut UsageReporterWatch2Request
20344    {
20345        #[inline]
20346        unsafe fn encode(
20347            self,
20348            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20349            offset: usize,
20350            _depth: fidl::encoding::Depth,
20351        ) -> fidl::Result<()> {
20352            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
20353            // Delegate to tuple encoding.
20354            fidl::encoding::Encode::<UsageReporterWatch2Request, fdomain_client::fidl::FDomainResourceDialect>::encode(
20355                (
20356                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
20357                    <fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
20358                ),
20359                encoder, offset, _depth
20360            )
20361        }
20362    }
20363    unsafe impl<
20364        T0: fidl::encoding::Encode<Usage2, fdomain_client::fidl::FDomainResourceDialect>,
20365        T1: fidl::encoding::Encode<
20366                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>>,
20367                fdomain_client::fidl::FDomainResourceDialect,
20368            >,
20369    >
20370        fidl::encoding::Encode<
20371            UsageReporterWatch2Request,
20372            fdomain_client::fidl::FDomainResourceDialect,
20373        > for (T0, T1)
20374    {
20375        #[inline]
20376        unsafe fn encode(
20377            self,
20378            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20379            offset: usize,
20380            depth: fidl::encoding::Depth,
20381        ) -> fidl::Result<()> {
20382            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
20383            // Zero out padding regions. There's no need to apply masks
20384            // because the unmasked parts will be overwritten by fields.
20385            unsafe {
20386                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
20387                (ptr as *mut u64).write_unaligned(0);
20388            }
20389            // Write the fields.
20390            self.0.encode(encoder, offset + 0, depth)?;
20391            self.1.encode(encoder, offset + 16, depth)?;
20392            Ok(())
20393        }
20394    }
20395
20396    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20397        for UsageReporterWatch2Request
20398    {
20399        #[inline(always)]
20400        fn new_empty() -> Self {
20401            Self {
20402                usage: fidl::new_empty!(Usage2, fdomain_client::fidl::FDomainResourceDialect),
20403                usage_watcher: fidl::new_empty!(
20404                    fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>>,
20405                    fdomain_client::fidl::FDomainResourceDialect
20406                ),
20407            }
20408        }
20409
20410        #[inline]
20411        unsafe fn decode(
20412            &mut self,
20413            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20414            offset: usize,
20415            _depth: fidl::encoding::Depth,
20416        ) -> fidl::Result<()> {
20417            decoder.debug_check_bounds::<Self>(offset);
20418            // Verify that padding bytes are zero.
20419            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
20420            let padval = unsafe { (ptr as *const u64).read_unaligned() };
20421            let mask = 0xffffffff00000000u64;
20422            let maskedval = padval & mask;
20423            if maskedval != 0 {
20424                return Err(fidl::Error::NonZeroPadding {
20425                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
20426                });
20427            }
20428            fidl::decode!(
20429                Usage2,
20430                fdomain_client::fidl::FDomainResourceDialect,
20431                &mut self.usage,
20432                decoder,
20433                offset + 0,
20434                _depth
20435            )?;
20436            fidl::decode!(
20437                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>>,
20438                fdomain_client::fidl::FDomainResourceDialect,
20439                &mut self.usage_watcher,
20440                decoder,
20441                offset + 16,
20442                _depth
20443            )?;
20444            Ok(())
20445        }
20446    }
20447
20448    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatchRequest {
20449        type Borrowed<'a> = &'a mut Self;
20450        fn take_or_borrow<'a>(
20451            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20452        ) -> Self::Borrowed<'a> {
20453            value
20454        }
20455    }
20456
20457    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatchRequest {
20458        type Owned = Self;
20459
20460        #[inline(always)]
20461        fn inline_align(_context: fidl::encoding::Context) -> usize {
20462            8
20463        }
20464
20465        #[inline(always)]
20466        fn inline_size(_context: fidl::encoding::Context) -> usize {
20467            24
20468        }
20469    }
20470
20471    unsafe impl
20472        fidl::encoding::Encode<
20473            UsageReporterWatchRequest,
20474            fdomain_client::fidl::FDomainResourceDialect,
20475        > for &mut UsageReporterWatchRequest
20476    {
20477        #[inline]
20478        unsafe fn encode(
20479            self,
20480            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20481            offset: usize,
20482            _depth: fidl::encoding::Depth,
20483        ) -> fidl::Result<()> {
20484            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
20485            // Delegate to tuple encoding.
20486            fidl::encoding::Encode::<UsageReporterWatchRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
20487                (
20488                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
20489                    <fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
20490                ),
20491                encoder, offset, _depth
20492            )
20493        }
20494    }
20495    unsafe impl<
20496        T0: fidl::encoding::Encode<Usage, fdomain_client::fidl::FDomainResourceDialect>,
20497        T1: fidl::encoding::Encode<
20498                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcherMarker>>,
20499                fdomain_client::fidl::FDomainResourceDialect,
20500            >,
20501    >
20502        fidl::encoding::Encode<
20503            UsageReporterWatchRequest,
20504            fdomain_client::fidl::FDomainResourceDialect,
20505        > for (T0, T1)
20506    {
20507        #[inline]
20508        unsafe fn encode(
20509            self,
20510            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20511            offset: usize,
20512            depth: fidl::encoding::Depth,
20513        ) -> fidl::Result<()> {
20514            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
20515            // Zero out padding regions. There's no need to apply masks
20516            // because the unmasked parts will be overwritten by fields.
20517            unsafe {
20518                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
20519                (ptr as *mut u64).write_unaligned(0);
20520            }
20521            // Write the fields.
20522            self.0.encode(encoder, offset + 0, depth)?;
20523            self.1.encode(encoder, offset + 16, depth)?;
20524            Ok(())
20525        }
20526    }
20527
20528    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20529        for UsageReporterWatchRequest
20530    {
20531        #[inline(always)]
20532        fn new_empty() -> Self {
20533            Self {
20534                usage: fidl::new_empty!(Usage, fdomain_client::fidl::FDomainResourceDialect),
20535                usage_watcher: fidl::new_empty!(
20536                    fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcherMarker>>,
20537                    fdomain_client::fidl::FDomainResourceDialect
20538                ),
20539            }
20540        }
20541
20542        #[inline]
20543        unsafe fn decode(
20544            &mut self,
20545            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20546            offset: usize,
20547            _depth: fidl::encoding::Depth,
20548        ) -> fidl::Result<()> {
20549            decoder.debug_check_bounds::<Self>(offset);
20550            // Verify that padding bytes are zero.
20551            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
20552            let padval = unsafe { (ptr as *const u64).read_unaligned() };
20553            let mask = 0xffffffff00000000u64;
20554            let maskedval = padval & mask;
20555            if maskedval != 0 {
20556                return Err(fidl::Error::NonZeroPadding {
20557                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
20558                });
20559            }
20560            fidl::decode!(
20561                Usage,
20562                fdomain_client::fidl::FDomainResourceDialect,
20563                &mut self.usage,
20564                decoder,
20565                offset + 0,
20566                _depth
20567            )?;
20568            fidl::decode!(
20569                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcherMarker>>,
20570                fdomain_client::fidl::FDomainResourceDialect,
20571                &mut self.usage_watcher,
20572                decoder,
20573                offset + 16,
20574                _depth
20575            )?;
20576            Ok(())
20577        }
20578    }
20579
20580    impl StreamBufferPartialSettings {
20581        #[inline(always)]
20582        fn max_ordinal_present(&self) -> u64 {
20583            if let Some(_) = self.sysmem2_token {
20584                return 7;
20585            }
20586            if let Some(_) = self.sysmem_token {
20587                return 6;
20588            }
20589            if let Some(_) = self.packet_count_for_client {
20590                return 5;
20591            }
20592            if let Some(_) = self.packet_count_for_server {
20593                return 4;
20594            }
20595            if let Some(_) = self.single_buffer_mode {
20596                return 3;
20597            }
20598            if let Some(_) = self.buffer_constraints_version_ordinal {
20599                return 2;
20600            }
20601            if let Some(_) = self.buffer_lifetime_ordinal {
20602                return 1;
20603            }
20604            0
20605        }
20606    }
20607
20608    impl fidl::encoding::ResourceTypeMarker for StreamBufferPartialSettings {
20609        type Borrowed<'a> = &'a mut Self;
20610        fn take_or_borrow<'a>(
20611            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20612        ) -> Self::Borrowed<'a> {
20613            value
20614        }
20615    }
20616
20617    unsafe impl fidl::encoding::TypeMarker for StreamBufferPartialSettings {
20618        type Owned = Self;
20619
20620        #[inline(always)]
20621        fn inline_align(_context: fidl::encoding::Context) -> usize {
20622            8
20623        }
20624
20625        #[inline(always)]
20626        fn inline_size(_context: fidl::encoding::Context) -> usize {
20627            16
20628        }
20629    }
20630
20631    unsafe impl
20632        fidl::encoding::Encode<
20633            StreamBufferPartialSettings,
20634            fdomain_client::fidl::FDomainResourceDialect,
20635        > for &mut StreamBufferPartialSettings
20636    {
20637        unsafe fn encode(
20638            self,
20639            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20640            offset: usize,
20641            mut depth: fidl::encoding::Depth,
20642        ) -> fidl::Result<()> {
20643            encoder.debug_check_bounds::<StreamBufferPartialSettings>(offset);
20644            // Vector header
20645            let max_ordinal: u64 = self.max_ordinal_present();
20646            encoder.write_num(max_ordinal, offset);
20647            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
20648            // Calling encoder.out_of_line_offset(0) is not allowed.
20649            if max_ordinal == 0 {
20650                return Ok(());
20651            }
20652            depth.increment()?;
20653            let envelope_size = 8;
20654            let bytes_len = max_ordinal as usize * envelope_size;
20655            #[allow(unused_variables)]
20656            let offset = encoder.out_of_line_offset(bytes_len);
20657            let mut _prev_end_offset: usize = 0;
20658            if 1 > max_ordinal {
20659                return Ok(());
20660            }
20661
20662            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
20663            // are envelope_size bytes.
20664            let cur_offset: usize = (1 - 1) * envelope_size;
20665
20666            // Zero reserved fields.
20667            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
20668
20669            // Safety:
20670            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
20671            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
20672            //   envelope_size bytes, there is always sufficient room.
20673            fidl::encoding::encode_in_envelope_optional::<
20674                u64,
20675                fdomain_client::fidl::FDomainResourceDialect,
20676            >(
20677                self.buffer_lifetime_ordinal
20678                    .as_ref()
20679                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
20680                encoder,
20681                offset + cur_offset,
20682                depth,
20683            )?;
20684
20685            _prev_end_offset = cur_offset + envelope_size;
20686            if 2 > max_ordinal {
20687                return Ok(());
20688            }
20689
20690            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
20691            // are envelope_size bytes.
20692            let cur_offset: usize = (2 - 1) * envelope_size;
20693
20694            // Zero reserved fields.
20695            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
20696
20697            // Safety:
20698            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
20699            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
20700            //   envelope_size bytes, there is always sufficient room.
20701            fidl::encoding::encode_in_envelope_optional::<
20702                u64,
20703                fdomain_client::fidl::FDomainResourceDialect,
20704            >(
20705                self.buffer_constraints_version_ordinal
20706                    .as_ref()
20707                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
20708                encoder,
20709                offset + cur_offset,
20710                depth,
20711            )?;
20712
20713            _prev_end_offset = cur_offset + envelope_size;
20714            if 3 > max_ordinal {
20715                return Ok(());
20716            }
20717
20718            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
20719            // are envelope_size bytes.
20720            let cur_offset: usize = (3 - 1) * envelope_size;
20721
20722            // Zero reserved fields.
20723            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
20724
20725            // Safety:
20726            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
20727            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
20728            //   envelope_size bytes, there is always sufficient room.
20729            fidl::encoding::encode_in_envelope_optional::<
20730                bool,
20731                fdomain_client::fidl::FDomainResourceDialect,
20732            >(
20733                self.single_buffer_mode
20734                    .as_ref()
20735                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
20736                encoder,
20737                offset + cur_offset,
20738                depth,
20739            )?;
20740
20741            _prev_end_offset = cur_offset + envelope_size;
20742            if 4 > max_ordinal {
20743                return Ok(());
20744            }
20745
20746            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
20747            // are envelope_size bytes.
20748            let cur_offset: usize = (4 - 1) * envelope_size;
20749
20750            // Zero reserved fields.
20751            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
20752
20753            // Safety:
20754            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
20755            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
20756            //   envelope_size bytes, there is always sufficient room.
20757            fidl::encoding::encode_in_envelope_optional::<
20758                u32,
20759                fdomain_client::fidl::FDomainResourceDialect,
20760            >(
20761                self.packet_count_for_server
20762                    .as_ref()
20763                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
20764                encoder,
20765                offset + cur_offset,
20766                depth,
20767            )?;
20768
20769            _prev_end_offset = cur_offset + envelope_size;
20770            if 5 > max_ordinal {
20771                return Ok(());
20772            }
20773
20774            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
20775            // are envelope_size bytes.
20776            let cur_offset: usize = (5 - 1) * envelope_size;
20777
20778            // Zero reserved fields.
20779            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
20780
20781            // Safety:
20782            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
20783            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
20784            //   envelope_size bytes, there is always sufficient room.
20785            fidl::encoding::encode_in_envelope_optional::<
20786                u32,
20787                fdomain_client::fidl::FDomainResourceDialect,
20788            >(
20789                self.packet_count_for_client
20790                    .as_ref()
20791                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
20792                encoder,
20793                offset + cur_offset,
20794                depth,
20795            )?;
20796
20797            _prev_end_offset = cur_offset + envelope_size;
20798            if 6 > max_ordinal {
20799                return Ok(());
20800            }
20801
20802            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
20803            // are envelope_size bytes.
20804            let cur_offset: usize = (6 - 1) * envelope_size;
20805
20806            // Zero reserved fields.
20807            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
20808
20809            // Safety:
20810            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
20811            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
20812            //   envelope_size bytes, there is always sufficient room.
20813            fidl::encoding::encode_in_envelope_optional::<
20814                fidl::encoding::Endpoint<
20815                    fdomain_client::fidl::ClientEnd<
20816                        fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
20817                    >,
20818                >,
20819                fdomain_client::fidl::FDomainResourceDialect,
20820            >(
20821                self.sysmem_token.as_mut().map(
20822                    <fidl::encoding::Endpoint<
20823                        fdomain_client::fidl::ClientEnd<
20824                            fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
20825                        >,
20826                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
20827                ),
20828                encoder,
20829                offset + cur_offset,
20830                depth,
20831            )?;
20832
20833            _prev_end_offset = cur_offset + envelope_size;
20834            if 7 > max_ordinal {
20835                return Ok(());
20836            }
20837
20838            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
20839            // are envelope_size bytes.
20840            let cur_offset: usize = (7 - 1) * envelope_size;
20841
20842            // Zero reserved fields.
20843            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
20844
20845            // Safety:
20846            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
20847            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
20848            //   envelope_size bytes, there is always sufficient room.
20849            fidl::encoding::encode_in_envelope_optional::<
20850                fidl::encoding::Endpoint<
20851                    fdomain_client::fidl::ClientEnd<
20852                        fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
20853                    >,
20854                >,
20855                fdomain_client::fidl::FDomainResourceDialect,
20856            >(
20857                self.sysmem2_token.as_mut().map(
20858                    <fidl::encoding::Endpoint<
20859                        fdomain_client::fidl::ClientEnd<
20860                            fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
20861                        >,
20862                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
20863                ),
20864                encoder,
20865                offset + cur_offset,
20866                depth,
20867            )?;
20868
20869            _prev_end_offset = cur_offset + envelope_size;
20870
20871            Ok(())
20872        }
20873    }
20874
20875    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20876        for StreamBufferPartialSettings
20877    {
20878        #[inline(always)]
20879        fn new_empty() -> Self {
20880            Self::default()
20881        }
20882
20883        unsafe fn decode(
20884            &mut self,
20885            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20886            offset: usize,
20887            mut depth: fidl::encoding::Depth,
20888        ) -> fidl::Result<()> {
20889            decoder.debug_check_bounds::<Self>(offset);
20890            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
20891                None => return Err(fidl::Error::NotNullable),
20892                Some(len) => len,
20893            };
20894            // Calling decoder.out_of_line_offset(0) is not allowed.
20895            if len == 0 {
20896                return Ok(());
20897            };
20898            depth.increment()?;
20899            let envelope_size = 8;
20900            let bytes_len = len * envelope_size;
20901            let offset = decoder.out_of_line_offset(bytes_len)?;
20902            // Decode the envelope for each type.
20903            let mut _next_ordinal_to_read = 0;
20904            let mut next_offset = offset;
20905            let end_offset = offset + bytes_len;
20906            _next_ordinal_to_read += 1;
20907            if next_offset >= end_offset {
20908                return Ok(());
20909            }
20910
20911            // Decode unknown envelopes for gaps in ordinals.
20912            while _next_ordinal_to_read < 1 {
20913                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
20914                _next_ordinal_to_read += 1;
20915                next_offset += envelope_size;
20916            }
20917
20918            let next_out_of_line = decoder.next_out_of_line();
20919            let handles_before = decoder.remaining_handles();
20920            if let Some((inlined, num_bytes, num_handles)) =
20921                fidl::encoding::decode_envelope_header(decoder, next_offset)?
20922            {
20923                let member_inline_size =
20924                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
20925                if inlined != (member_inline_size <= 4) {
20926                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
20927                }
20928                let inner_offset;
20929                let mut inner_depth = depth.clone();
20930                if inlined {
20931                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
20932                    inner_offset = next_offset;
20933                } else {
20934                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
20935                    inner_depth.increment()?;
20936                }
20937                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
20938                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
20939                });
20940                fidl::decode!(
20941                    u64,
20942                    fdomain_client::fidl::FDomainResourceDialect,
20943                    val_ref,
20944                    decoder,
20945                    inner_offset,
20946                    inner_depth
20947                )?;
20948                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
20949                {
20950                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
20951                }
20952                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
20953                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
20954                }
20955            }
20956
20957            next_offset += envelope_size;
20958            _next_ordinal_to_read += 1;
20959            if next_offset >= end_offset {
20960                return Ok(());
20961            }
20962
20963            // Decode unknown envelopes for gaps in ordinals.
20964            while _next_ordinal_to_read < 2 {
20965                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
20966                _next_ordinal_to_read += 1;
20967                next_offset += envelope_size;
20968            }
20969
20970            let next_out_of_line = decoder.next_out_of_line();
20971            let handles_before = decoder.remaining_handles();
20972            if let Some((inlined, num_bytes, num_handles)) =
20973                fidl::encoding::decode_envelope_header(decoder, next_offset)?
20974            {
20975                let member_inline_size =
20976                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
20977                if inlined != (member_inline_size <= 4) {
20978                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
20979                }
20980                let inner_offset;
20981                let mut inner_depth = depth.clone();
20982                if inlined {
20983                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
20984                    inner_offset = next_offset;
20985                } else {
20986                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
20987                    inner_depth.increment()?;
20988                }
20989                let val_ref = self.buffer_constraints_version_ordinal.get_or_insert_with(|| {
20990                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
20991                });
20992                fidl::decode!(
20993                    u64,
20994                    fdomain_client::fidl::FDomainResourceDialect,
20995                    val_ref,
20996                    decoder,
20997                    inner_offset,
20998                    inner_depth
20999                )?;
21000                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
21001                {
21002                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
21003                }
21004                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
21005                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
21006                }
21007            }
21008
21009            next_offset += envelope_size;
21010            _next_ordinal_to_read += 1;
21011            if next_offset >= end_offset {
21012                return Ok(());
21013            }
21014
21015            // Decode unknown envelopes for gaps in ordinals.
21016            while _next_ordinal_to_read < 3 {
21017                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
21018                _next_ordinal_to_read += 1;
21019                next_offset += envelope_size;
21020            }
21021
21022            let next_out_of_line = decoder.next_out_of_line();
21023            let handles_before = decoder.remaining_handles();
21024            if let Some((inlined, num_bytes, num_handles)) =
21025                fidl::encoding::decode_envelope_header(decoder, next_offset)?
21026            {
21027                let member_inline_size =
21028                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
21029                if inlined != (member_inline_size <= 4) {
21030                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
21031                }
21032                let inner_offset;
21033                let mut inner_depth = depth.clone();
21034                if inlined {
21035                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
21036                    inner_offset = next_offset;
21037                } else {
21038                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
21039                    inner_depth.increment()?;
21040                }
21041                let val_ref = self.single_buffer_mode.get_or_insert_with(|| {
21042                    fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect)
21043                });
21044                fidl::decode!(
21045                    bool,
21046                    fdomain_client::fidl::FDomainResourceDialect,
21047                    val_ref,
21048                    decoder,
21049                    inner_offset,
21050                    inner_depth
21051                )?;
21052                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
21053                {
21054                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
21055                }
21056                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
21057                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
21058                }
21059            }
21060
21061            next_offset += envelope_size;
21062            _next_ordinal_to_read += 1;
21063            if next_offset >= end_offset {
21064                return Ok(());
21065            }
21066
21067            // Decode unknown envelopes for gaps in ordinals.
21068            while _next_ordinal_to_read < 4 {
21069                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
21070                _next_ordinal_to_read += 1;
21071                next_offset += envelope_size;
21072            }
21073
21074            let next_out_of_line = decoder.next_out_of_line();
21075            let handles_before = decoder.remaining_handles();
21076            if let Some((inlined, num_bytes, num_handles)) =
21077                fidl::encoding::decode_envelope_header(decoder, next_offset)?
21078            {
21079                let member_inline_size =
21080                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
21081                if inlined != (member_inline_size <= 4) {
21082                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
21083                }
21084                let inner_offset;
21085                let mut inner_depth = depth.clone();
21086                if inlined {
21087                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
21088                    inner_offset = next_offset;
21089                } else {
21090                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
21091                    inner_depth.increment()?;
21092                }
21093                let val_ref = self.packet_count_for_server.get_or_insert_with(|| {
21094                    fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect)
21095                });
21096                fidl::decode!(
21097                    u32,
21098                    fdomain_client::fidl::FDomainResourceDialect,
21099                    val_ref,
21100                    decoder,
21101                    inner_offset,
21102                    inner_depth
21103                )?;
21104                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
21105                {
21106                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
21107                }
21108                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
21109                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
21110                }
21111            }
21112
21113            next_offset += envelope_size;
21114            _next_ordinal_to_read += 1;
21115            if next_offset >= end_offset {
21116                return Ok(());
21117            }
21118
21119            // Decode unknown envelopes for gaps in ordinals.
21120            while _next_ordinal_to_read < 5 {
21121                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
21122                _next_ordinal_to_read += 1;
21123                next_offset += envelope_size;
21124            }
21125
21126            let next_out_of_line = decoder.next_out_of_line();
21127            let handles_before = decoder.remaining_handles();
21128            if let Some((inlined, num_bytes, num_handles)) =
21129                fidl::encoding::decode_envelope_header(decoder, next_offset)?
21130            {
21131                let member_inline_size =
21132                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
21133                if inlined != (member_inline_size <= 4) {
21134                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
21135                }
21136                let inner_offset;
21137                let mut inner_depth = depth.clone();
21138                if inlined {
21139                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
21140                    inner_offset = next_offset;
21141                } else {
21142                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
21143                    inner_depth.increment()?;
21144                }
21145                let val_ref = self.packet_count_for_client.get_or_insert_with(|| {
21146                    fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect)
21147                });
21148                fidl::decode!(
21149                    u32,
21150                    fdomain_client::fidl::FDomainResourceDialect,
21151                    val_ref,
21152                    decoder,
21153                    inner_offset,
21154                    inner_depth
21155                )?;
21156                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
21157                {
21158                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
21159                }
21160                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
21161                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
21162                }
21163            }
21164
21165            next_offset += envelope_size;
21166            _next_ordinal_to_read += 1;
21167            if next_offset >= end_offset {
21168                return Ok(());
21169            }
21170
21171            // Decode unknown envelopes for gaps in ordinals.
21172            while _next_ordinal_to_read < 6 {
21173                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
21174                _next_ordinal_to_read += 1;
21175                next_offset += envelope_size;
21176            }
21177
21178            let next_out_of_line = decoder.next_out_of_line();
21179            let handles_before = decoder.remaining_handles();
21180            if let Some((inlined, num_bytes, num_handles)) =
21181                fidl::encoding::decode_envelope_header(decoder, next_offset)?
21182            {
21183                let member_inline_size = <fidl::encoding::Endpoint<
21184                    fdomain_client::fidl::ClientEnd<
21185                        fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
21186                    >,
21187                > as fidl::encoding::TypeMarker>::inline_size(
21188                    decoder.context
21189                );
21190                if inlined != (member_inline_size <= 4) {
21191                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
21192                }
21193                let inner_offset;
21194                let mut inner_depth = depth.clone();
21195                if inlined {
21196                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
21197                    inner_offset = next_offset;
21198                } else {
21199                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
21200                    inner_depth.increment()?;
21201                }
21202                let val_ref = self.sysmem_token.get_or_insert_with(|| {
21203                    fidl::new_empty!(
21204                        fidl::encoding::Endpoint<
21205                            fdomain_client::fidl::ClientEnd<
21206                                fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
21207                            >,
21208                        >,
21209                        fdomain_client::fidl::FDomainResourceDialect
21210                    )
21211                });
21212                fidl::decode!(
21213                    fidl::encoding::Endpoint<
21214                        fdomain_client::fidl::ClientEnd<
21215                            fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
21216                        >,
21217                    >,
21218                    fdomain_client::fidl::FDomainResourceDialect,
21219                    val_ref,
21220                    decoder,
21221                    inner_offset,
21222                    inner_depth
21223                )?;
21224                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
21225                {
21226                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
21227                }
21228                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
21229                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
21230                }
21231            }
21232
21233            next_offset += envelope_size;
21234            _next_ordinal_to_read += 1;
21235            if next_offset >= end_offset {
21236                return Ok(());
21237            }
21238
21239            // Decode unknown envelopes for gaps in ordinals.
21240            while _next_ordinal_to_read < 7 {
21241                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
21242                _next_ordinal_to_read += 1;
21243                next_offset += envelope_size;
21244            }
21245
21246            let next_out_of_line = decoder.next_out_of_line();
21247            let handles_before = decoder.remaining_handles();
21248            if let Some((inlined, num_bytes, num_handles)) =
21249                fidl::encoding::decode_envelope_header(decoder, next_offset)?
21250            {
21251                let member_inline_size = <fidl::encoding::Endpoint<
21252                    fdomain_client::fidl::ClientEnd<
21253                        fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
21254                    >,
21255                > as fidl::encoding::TypeMarker>::inline_size(
21256                    decoder.context
21257                );
21258                if inlined != (member_inline_size <= 4) {
21259                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
21260                }
21261                let inner_offset;
21262                let mut inner_depth = depth.clone();
21263                if inlined {
21264                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
21265                    inner_offset = next_offset;
21266                } else {
21267                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
21268                    inner_depth.increment()?;
21269                }
21270                let val_ref = self.sysmem2_token.get_or_insert_with(|| {
21271                    fidl::new_empty!(
21272                        fidl::encoding::Endpoint<
21273                            fdomain_client::fidl::ClientEnd<
21274                                fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
21275                            >,
21276                        >,
21277                        fdomain_client::fidl::FDomainResourceDialect
21278                    )
21279                });
21280                fidl::decode!(
21281                    fidl::encoding::Endpoint<
21282                        fdomain_client::fidl::ClientEnd<
21283                            fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
21284                        >,
21285                    >,
21286                    fdomain_client::fidl::FDomainResourceDialect,
21287                    val_ref,
21288                    decoder,
21289                    inner_offset,
21290                    inner_depth
21291                )?;
21292                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
21293                {
21294                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
21295                }
21296                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
21297                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
21298                }
21299            }
21300
21301            next_offset += envelope_size;
21302
21303            // Decode the remaining unknown envelopes.
21304            while next_offset < end_offset {
21305                _next_ordinal_to_read += 1;
21306                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
21307                next_offset += envelope_size;
21308            }
21309
21310            Ok(())
21311        }
21312    }
21313}