Skip to main content

fidl_fuchsia_media/
fidl_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 fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_media__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct AudioCapturerBindGainControlRequest {
16    pub gain_control_request:
17        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for AudioCapturerBindGainControlRequest
22{
23}
24
25#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub struct AudioCapturerGetReferenceClockResponse {
27    pub reference_clock: fidl::Clock,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
31    for AudioCapturerGetReferenceClockResponse
32{
33}
34
35#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
36pub struct AudioCapturerSetReferenceClockRequest {
37    pub reference_clock: Option<fidl::Clock>,
38}
39
40impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
41    for AudioCapturerSetReferenceClockRequest
42{
43}
44
45#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
46pub struct AudioConsumerBindVolumeControlRequest {
47    pub volume_control_request:
48        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
49}
50
51impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
52    for AudioConsumerBindVolumeControlRequest
53{
54}
55
56#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
57pub struct AudioConsumerCreateStreamSinkRequest {
58    pub buffers: Vec<fidl::Vmo>,
59    pub stream_type: AudioStreamType,
60    pub compression: Option<Box<Compression>>,
61    pub stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
62}
63
64impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
65    for AudioConsumerCreateStreamSinkRequest
66{
67}
68
69#[derive(Debug, PartialEq)]
70pub struct AudioCoreBindUsageVolumeControl2Request {
71    pub usage: Usage2,
72    pub volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
73}
74
75impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
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: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
84}
85
86impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
87    for AudioCoreBindUsageVolumeControlRequest
88{
89}
90
91#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
92pub struct AudioCoreCreateAudioCapturerRequest {
93    pub loopback: bool,
94    pub audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
95}
96
97impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
98    for AudioCoreCreateAudioCapturerRequest
99{
100}
101
102#[derive(Debug, PartialEq)]
103pub struct AudioCoreCreateAudioCapturerWithConfigurationRequest {
104    pub stream_type: AudioStreamType,
105    pub configuration: AudioCapturerConfiguration,
106    pub audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
107}
108
109impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
110    for AudioCoreCreateAudioCapturerWithConfigurationRequest
111{
112}
113
114#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
115pub struct AudioCoreCreateAudioRendererRequest {
116    pub audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
117}
118
119impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
120    for AudioCoreCreateAudioRendererRequest
121{
122}
123
124#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
125pub struct AudioCreateAudioCapturerRequest {
126    pub audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
127    pub loopback: bool,
128}
129
130impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
131    for AudioCreateAudioCapturerRequest
132{
133}
134
135#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
136pub struct AudioCreateAudioRendererRequest {
137    pub audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
138}
139
140impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
141    for AudioCreateAudioRendererRequest
142{
143}
144
145#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
146pub struct AudioDeviceEnumeratorAddDeviceByChannelRequest {
147    pub device_name: String,
148    pub is_input: bool,
149    pub channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
150}
151
152impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
153    for AudioDeviceEnumeratorAddDeviceByChannelRequest
154{
155}
156
157#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
158pub struct AudioRendererBindGainControlRequest {
159    pub gain_control_request:
160        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
161}
162
163impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
164    for AudioRendererBindGainControlRequest
165{
166}
167
168#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
169pub struct AudioRendererGetReferenceClockResponse {
170    pub reference_clock: fidl::Clock,
171}
172
173impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
174    for AudioRendererGetReferenceClockResponse
175{
176}
177
178#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
179pub struct AudioRendererSetReferenceClockRequest {
180    pub reference_clock: Option<fidl::Clock>,
181}
182
183impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
184    for AudioRendererSetReferenceClockRequest
185{
186}
187
188#[derive(Debug, PartialEq, PartialOrd)]
189pub struct ProfileProviderRegisterHandlerWithCapacityRequest {
190    pub thread_handle: fidl::Thread,
191    pub name: String,
192    pub period: i64,
193    pub capacity: f32,
194}
195
196impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
197    for ProfileProviderRegisterHandlerWithCapacityRequest
198{
199}
200
201#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
202pub struct ProfileProviderRegisterMemoryRangeRequest {
203    pub vmar_handle: fidl::Vmar,
204    pub name: String,
205}
206
207impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
208    for ProfileProviderRegisterMemoryRangeRequest
209{
210}
211
212#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
213pub struct ProfileProviderUnregisterHandlerRequest {
214    pub thread_handle: fidl::Thread,
215    pub name: String,
216}
217
218impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
219    for ProfileProviderUnregisterHandlerRequest
220{
221}
222
223#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
224pub struct ProfileProviderUnregisterMemoryRangeRequest {
225    pub vmar_handle: fidl::Vmar,
226}
227
228impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
229    for ProfileProviderUnregisterMemoryRangeRequest
230{
231}
232
233#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
234pub struct SessionAudioConsumerFactoryCreateAudioConsumerRequest {
235    pub session_id: u64,
236    pub audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
237}
238
239impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
240    for SessionAudioConsumerFactoryCreateAudioConsumerRequest
241{
242}
243
244#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
245pub struct StreamBufferSetAddPayloadBufferRequest {
246    pub id: u32,
247    pub payload_buffer: fidl::Vmo,
248}
249
250impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
251    for StreamBufferSetAddPayloadBufferRequest
252{
253}
254
255#[derive(Debug, PartialEq)]
256pub struct StreamProcessorSetInputBufferPartialSettingsRequest {
257    pub input_settings: StreamBufferPartialSettings,
258}
259
260impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
261    for StreamProcessorSetInputBufferPartialSettingsRequest
262{
263}
264
265#[derive(Debug, PartialEq)]
266pub struct StreamProcessorSetOutputBufferPartialSettingsRequest {
267    pub output_settings: StreamBufferPartialSettings,
268}
269
270impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
271    for StreamProcessorSetOutputBufferPartialSettingsRequest
272{
273}
274
275#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
276pub struct Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
277    pub usage: AudioRenderUsage2,
278    pub audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
279}
280
281impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
282    for Usage2AudioConsumerFactoryCreateAudioConsumerRequest
283{
284}
285
286#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
287pub struct UsageAudioConsumerFactoryCreateAudioConsumerRequest {
288    pub usage: AudioRenderUsage,
289    pub audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
290}
291
292impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
293    for UsageAudioConsumerFactoryCreateAudioConsumerRequest
294{
295}
296
297#[derive(Debug, PartialEq)]
298pub struct UsageGainReporterRegisterListener2Request {
299    pub device_unique_id: String,
300    pub usage: Usage2,
301    pub usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
302}
303
304impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
305    for UsageGainReporterRegisterListener2Request
306{
307}
308
309#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
310pub struct UsageGainReporterRegisterListenerRequest {
311    pub device_unique_id: String,
312    pub usage: Usage,
313    pub usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
314}
315
316impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
317    for UsageGainReporterRegisterListenerRequest
318{
319}
320
321#[derive(Debug, PartialEq)]
322pub struct UsageReporterWatch2Request {
323    pub usage: Usage2,
324    pub usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
325}
326
327impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
328    for UsageReporterWatch2Request
329{
330}
331
332#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
333pub struct UsageReporterWatchRequest {
334    pub usage: Usage,
335    pub usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
336}
337
338impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for UsageReporterWatchRequest {}
339
340#[derive(Debug, Default, PartialEq)]
341pub struct StreamBufferPartialSettings {
342    /// The containing message starts a new buffer_lifetime_ordinal.
343    ///
344    /// There is a separate buffer_lifetime_ordinal for input vs. output.
345    ///
346    /// Re-use of the same value is not allowed.  Values must be odd.  Values
347    /// must only increase (increasing by more than 2 is permitted).
348    ///
349    /// A buffer_lifetime_ordinal lifetime starts at SetInputBufferSettings() or
350    /// SetOutputBufferSettings(), and ends at the earlier of
351    /// CloseCurrentStream() with release_input_buffers/release_output_buffers
352    /// set or SetOutputBufferSettings() with new buffer_lifetime_ordinal in the
353    /// case of mid-stream output config change.
354    pub buffer_lifetime_ordinal: Option<u64>,
355    /// This value indicates which version of constraints the client is/was aware
356    /// of so far.
357    ///
358    /// For input, this must always be 0 because constraints don't change for
359    /// input (settings can change, but there's no settings vs current
360    /// constraints synchronization issue on input).
361    ///
362    /// For output, this allows the server to know when the client is
363    /// sufficiently caught up before the server will generate any more output.
364    ///
365    /// When there is no active stream, a client is permitted to re-configure
366    /// buffers again using the same buffer_constraints_version_ordinal.
367    pub buffer_constraints_version_ordinal: Option<u64>,
368    pub single_buffer_mode: Option<bool>,
369    pub packet_count_for_server: Option<u32>,
370    pub packet_count_for_client: Option<u32>,
371    pub sysmem_token:
372        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>>,
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:
381        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>>,
382    #[doc(hidden)]
383    pub __source_breaking: fidl::marker::SourceBreaking,
384}
385
386impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
387    for StreamBufferPartialSettings
388{
389}
390
391#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
392pub struct ActivityReporterMarker;
393
394impl fidl::endpoints::ProtocolMarker for ActivityReporterMarker {
395    type Proxy = ActivityReporterProxy;
396    type RequestStream = ActivityReporterRequestStream;
397    #[cfg(target_os = "fuchsia")]
398    type SynchronousProxy = ActivityReporterSynchronousProxy;
399
400    const DEBUG_NAME: &'static str = "fuchsia.media.ActivityReporter";
401}
402impl fidl::endpoints::DiscoverableProtocolMarker for ActivityReporterMarker {}
403
404pub trait ActivityReporterProxyInterface: Send + Sync {
405    type WatchRenderActivityResponseFut: std::future::Future<Output = Result<Vec<AudioRenderUsage>, fidl::Error>>
406        + Send;
407    fn r#watch_render_activity(&self) -> Self::WatchRenderActivityResponseFut;
408    type WatchRenderActivity2ResponseFut: std::future::Future<Output = Result<Vec<AudioRenderUsage2>, fidl::Error>>
409        + Send;
410    fn r#watch_render_activity2(&self) -> Self::WatchRenderActivity2ResponseFut;
411    type WatchCaptureActivityResponseFut: std::future::Future<Output = Result<Vec<AudioCaptureUsage>, fidl::Error>>
412        + Send;
413    fn r#watch_capture_activity(&self) -> Self::WatchCaptureActivityResponseFut;
414    type WatchCaptureActivity2ResponseFut: std::future::Future<Output = Result<Vec<AudioCaptureUsage2>, fidl::Error>>
415        + Send;
416    fn r#watch_capture_activity2(&self) -> Self::WatchCaptureActivity2ResponseFut;
417}
418#[derive(Debug)]
419#[cfg(target_os = "fuchsia")]
420pub struct ActivityReporterSynchronousProxy {
421    client: fidl::client::sync::Client,
422}
423
424#[cfg(target_os = "fuchsia")]
425impl fidl::endpoints::SynchronousProxy for ActivityReporterSynchronousProxy {
426    type Proxy = ActivityReporterProxy;
427    type Protocol = ActivityReporterMarker;
428
429    fn from_channel(inner: fidl::Channel) -> Self {
430        Self::new(inner)
431    }
432
433    fn into_channel(self) -> fidl::Channel {
434        self.client.into_channel()
435    }
436
437    fn as_channel(&self) -> &fidl::Channel {
438        self.client.as_channel()
439    }
440}
441
442#[cfg(target_os = "fuchsia")]
443impl ActivityReporterSynchronousProxy {
444    pub fn new(channel: fidl::Channel) -> Self {
445        Self { client: fidl::client::sync::Client::new(channel) }
446    }
447
448    pub fn into_channel(self) -> fidl::Channel {
449        self.client.into_channel()
450    }
451
452    /// Waits until an event arrives and returns it. It is safe for other
453    /// threads to make concurrent requests while waiting for an event.
454    pub fn wait_for_event(
455        &self,
456        deadline: zx::MonotonicInstant,
457    ) -> Result<ActivityReporterEvent, fidl::Error> {
458        ActivityReporterEvent::decode(
459            self.client.wait_for_event::<ActivityReporterMarker>(deadline)?,
460        )
461    }
462
463    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
464    /// It returns immediately the first time that it is called.
465    pub fn r#watch_render_activity(
466        &self,
467        ___deadline: zx::MonotonicInstant,
468    ) -> Result<Vec<AudioRenderUsage>, fidl::Error> {
469        let _response = self.client.send_query::<
470            fidl::encoding::EmptyPayload,
471            ActivityReporterWatchRenderActivityResponse,
472            ActivityReporterMarker,
473        >(
474            (),
475            0x2974e9f5880b2f1f,
476            fidl::encoding::DynamicFlags::empty(),
477            ___deadline,
478        )?;
479        Ok(_response.active_usages)
480    }
481
482    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
483    /// It returns immediately the first time that it is called.
484    pub fn r#watch_render_activity2(
485        &self,
486        ___deadline: zx::MonotonicInstant,
487    ) -> Result<Vec<AudioRenderUsage2>, fidl::Error> {
488        let _response = self.client.send_query::<
489            fidl::encoding::EmptyPayload,
490            fidl::encoding::FlexibleType<ActivityReporterWatchRenderActivity2Response>,
491            ActivityReporterMarker,
492        >(
493            (),
494            0x484236fc11b363e6,
495            fidl::encoding::DynamicFlags::FLEXIBLE,
496            ___deadline,
497        )?
498        .into_result::<ActivityReporterMarker>("watch_render_activity2")?;
499        Ok(_response.active_usages)
500    }
501
502    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
503    /// It returns immediately the first time that it is called.
504    pub fn r#watch_capture_activity(
505        &self,
506        ___deadline: zx::MonotonicInstant,
507    ) -> Result<Vec<AudioCaptureUsage>, fidl::Error> {
508        let _response = self.client.send_query::<
509            fidl::encoding::EmptyPayload,
510            ActivityReporterWatchCaptureActivityResponse,
511            ActivityReporterMarker,
512        >(
513            (),
514            0x70e7038e9658e128,
515            fidl::encoding::DynamicFlags::empty(),
516            ___deadline,
517        )?;
518        Ok(_response.active_usages)
519    }
520
521    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
522    /// It returns immediately the first time that it is called.
523    pub fn r#watch_capture_activity2(
524        &self,
525        ___deadline: zx::MonotonicInstant,
526    ) -> Result<Vec<AudioCaptureUsage2>, fidl::Error> {
527        let _response = self.client.send_query::<
528            fidl::encoding::EmptyPayload,
529            fidl::encoding::FlexibleType<ActivityReporterWatchCaptureActivity2Response>,
530            ActivityReporterMarker,
531        >(
532            (),
533            0x3d137e0364f9d550,
534            fidl::encoding::DynamicFlags::FLEXIBLE,
535            ___deadline,
536        )?
537        .into_result::<ActivityReporterMarker>("watch_capture_activity2")?;
538        Ok(_response.active_usages)
539    }
540}
541
542#[cfg(target_os = "fuchsia")]
543impl From<ActivityReporterSynchronousProxy> for zx::NullableHandle {
544    fn from(value: ActivityReporterSynchronousProxy) -> Self {
545        value.into_channel().into()
546    }
547}
548
549#[cfg(target_os = "fuchsia")]
550impl From<fidl::Channel> for ActivityReporterSynchronousProxy {
551    fn from(value: fidl::Channel) -> Self {
552        Self::new(value)
553    }
554}
555
556#[cfg(target_os = "fuchsia")]
557impl fidl::endpoints::FromClient for ActivityReporterSynchronousProxy {
558    type Protocol = ActivityReporterMarker;
559
560    fn from_client(value: fidl::endpoints::ClientEnd<ActivityReporterMarker>) -> Self {
561        Self::new(value.into_channel())
562    }
563}
564
565#[derive(Debug, Clone)]
566pub struct ActivityReporterProxy {
567    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
568}
569
570impl fidl::endpoints::Proxy for ActivityReporterProxy {
571    type Protocol = ActivityReporterMarker;
572
573    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
574        Self::new(inner)
575    }
576
577    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
578        self.client.into_channel().map_err(|client| Self { client })
579    }
580
581    fn as_channel(&self) -> &::fidl::AsyncChannel {
582        self.client.as_channel()
583    }
584}
585
586impl ActivityReporterProxy {
587    /// Create a new Proxy for fuchsia.media/ActivityReporter.
588    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
589        let protocol_name = <ActivityReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
590        Self { client: fidl::client::Client::new(channel, protocol_name) }
591    }
592
593    /// Get a Stream of events from the remote end of the protocol.
594    ///
595    /// # Panics
596    ///
597    /// Panics if the event stream was already taken.
598    pub fn take_event_stream(&self) -> ActivityReporterEventStream {
599        ActivityReporterEventStream { event_receiver: self.client.take_event_receiver() }
600    }
601
602    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
603    /// It returns immediately the first time that it is called.
604    pub fn r#watch_render_activity(
605        &self,
606    ) -> fidl::client::QueryResponseFut<
607        Vec<AudioRenderUsage>,
608        fidl::encoding::DefaultFuchsiaResourceDialect,
609    > {
610        ActivityReporterProxyInterface::r#watch_render_activity(self)
611    }
612
613    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
614    /// It returns immediately the first time that it is called.
615    pub fn r#watch_render_activity2(
616        &self,
617    ) -> fidl::client::QueryResponseFut<
618        Vec<AudioRenderUsage2>,
619        fidl::encoding::DefaultFuchsiaResourceDialect,
620    > {
621        ActivityReporterProxyInterface::r#watch_render_activity2(self)
622    }
623
624    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
625    /// It returns immediately the first time that it is called.
626    pub fn r#watch_capture_activity(
627        &self,
628    ) -> fidl::client::QueryResponseFut<
629        Vec<AudioCaptureUsage>,
630        fidl::encoding::DefaultFuchsiaResourceDialect,
631    > {
632        ActivityReporterProxyInterface::r#watch_capture_activity(self)
633    }
634
635    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
636    /// It returns immediately the first time that it is called.
637    pub fn r#watch_capture_activity2(
638        &self,
639    ) -> fidl::client::QueryResponseFut<
640        Vec<AudioCaptureUsage2>,
641        fidl::encoding::DefaultFuchsiaResourceDialect,
642    > {
643        ActivityReporterProxyInterface::r#watch_capture_activity2(self)
644    }
645}
646
647impl ActivityReporterProxyInterface for ActivityReporterProxy {
648    type WatchRenderActivityResponseFut = fidl::client::QueryResponseFut<
649        Vec<AudioRenderUsage>,
650        fidl::encoding::DefaultFuchsiaResourceDialect,
651    >;
652    fn r#watch_render_activity(&self) -> Self::WatchRenderActivityResponseFut {
653        fn _decode(
654            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
655        ) -> Result<Vec<AudioRenderUsage>, fidl::Error> {
656            let _response = fidl::client::decode_transaction_body::<
657                ActivityReporterWatchRenderActivityResponse,
658                fidl::encoding::DefaultFuchsiaResourceDialect,
659                0x2974e9f5880b2f1f,
660            >(_buf?)?;
661            Ok(_response.active_usages)
662        }
663        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioRenderUsage>>(
664            (),
665            0x2974e9f5880b2f1f,
666            fidl::encoding::DynamicFlags::empty(),
667            _decode,
668        )
669    }
670
671    type WatchRenderActivity2ResponseFut = fidl::client::QueryResponseFut<
672        Vec<AudioRenderUsage2>,
673        fidl::encoding::DefaultFuchsiaResourceDialect,
674    >;
675    fn r#watch_render_activity2(&self) -> Self::WatchRenderActivity2ResponseFut {
676        fn _decode(
677            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
678        ) -> Result<Vec<AudioRenderUsage2>, fidl::Error> {
679            let _response = fidl::client::decode_transaction_body::<
680                fidl::encoding::FlexibleType<ActivityReporterWatchRenderActivity2Response>,
681                fidl::encoding::DefaultFuchsiaResourceDialect,
682                0x484236fc11b363e6,
683            >(_buf?)?
684            .into_result::<ActivityReporterMarker>("watch_render_activity2")?;
685            Ok(_response.active_usages)
686        }
687        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioRenderUsage2>>(
688            (),
689            0x484236fc11b363e6,
690            fidl::encoding::DynamicFlags::FLEXIBLE,
691            _decode,
692        )
693    }
694
695    type WatchCaptureActivityResponseFut = fidl::client::QueryResponseFut<
696        Vec<AudioCaptureUsage>,
697        fidl::encoding::DefaultFuchsiaResourceDialect,
698    >;
699    fn r#watch_capture_activity(&self) -> Self::WatchCaptureActivityResponseFut {
700        fn _decode(
701            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
702        ) -> Result<Vec<AudioCaptureUsage>, fidl::Error> {
703            let _response = fidl::client::decode_transaction_body::<
704                ActivityReporterWatchCaptureActivityResponse,
705                fidl::encoding::DefaultFuchsiaResourceDialect,
706                0x70e7038e9658e128,
707            >(_buf?)?;
708            Ok(_response.active_usages)
709        }
710        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioCaptureUsage>>(
711            (),
712            0x70e7038e9658e128,
713            fidl::encoding::DynamicFlags::empty(),
714            _decode,
715        )
716    }
717
718    type WatchCaptureActivity2ResponseFut = fidl::client::QueryResponseFut<
719        Vec<AudioCaptureUsage2>,
720        fidl::encoding::DefaultFuchsiaResourceDialect,
721    >;
722    fn r#watch_capture_activity2(&self) -> Self::WatchCaptureActivity2ResponseFut {
723        fn _decode(
724            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
725        ) -> Result<Vec<AudioCaptureUsage2>, fidl::Error> {
726            let _response = fidl::client::decode_transaction_body::<
727                fidl::encoding::FlexibleType<ActivityReporterWatchCaptureActivity2Response>,
728                fidl::encoding::DefaultFuchsiaResourceDialect,
729                0x3d137e0364f9d550,
730            >(_buf?)?
731            .into_result::<ActivityReporterMarker>("watch_capture_activity2")?;
732            Ok(_response.active_usages)
733        }
734        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioCaptureUsage2>>(
735            (),
736            0x3d137e0364f9d550,
737            fidl::encoding::DynamicFlags::FLEXIBLE,
738            _decode,
739        )
740    }
741}
742
743pub struct ActivityReporterEventStream {
744    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
745}
746
747impl std::marker::Unpin for ActivityReporterEventStream {}
748
749impl futures::stream::FusedStream for ActivityReporterEventStream {
750    fn is_terminated(&self) -> bool {
751        self.event_receiver.is_terminated()
752    }
753}
754
755impl futures::Stream for ActivityReporterEventStream {
756    type Item = Result<ActivityReporterEvent, fidl::Error>;
757
758    fn poll_next(
759        mut self: std::pin::Pin<&mut Self>,
760        cx: &mut std::task::Context<'_>,
761    ) -> std::task::Poll<Option<Self::Item>> {
762        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
763            &mut self.event_receiver,
764            cx
765        )?) {
766            Some(buf) => std::task::Poll::Ready(Some(ActivityReporterEvent::decode(buf))),
767            None => std::task::Poll::Ready(None),
768        }
769    }
770}
771
772#[derive(Debug)]
773pub enum ActivityReporterEvent {
774    #[non_exhaustive]
775    _UnknownEvent {
776        /// Ordinal of the event that was sent.
777        ordinal: u64,
778    },
779}
780
781impl ActivityReporterEvent {
782    /// Decodes a message buffer as a [`ActivityReporterEvent`].
783    fn decode(
784        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
785    ) -> Result<ActivityReporterEvent, fidl::Error> {
786        let (bytes, _handles) = buf.split_mut();
787        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
788        debug_assert_eq!(tx_header.tx_id, 0);
789        match tx_header.ordinal {
790            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
791                Ok(ActivityReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
792            }
793            _ => Err(fidl::Error::UnknownOrdinal {
794                ordinal: tx_header.ordinal,
795                protocol_name:
796                    <ActivityReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
797            }),
798        }
799    }
800}
801
802/// A Stream of incoming requests for fuchsia.media/ActivityReporter.
803pub struct ActivityReporterRequestStream {
804    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
805    is_terminated: bool,
806}
807
808impl std::marker::Unpin for ActivityReporterRequestStream {}
809
810impl futures::stream::FusedStream for ActivityReporterRequestStream {
811    fn is_terminated(&self) -> bool {
812        self.is_terminated
813    }
814}
815
816impl fidl::endpoints::RequestStream for ActivityReporterRequestStream {
817    type Protocol = ActivityReporterMarker;
818    type ControlHandle = ActivityReporterControlHandle;
819
820    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
821        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
822    }
823
824    fn control_handle(&self) -> Self::ControlHandle {
825        ActivityReporterControlHandle { inner: self.inner.clone() }
826    }
827
828    fn into_inner(
829        self,
830    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
831    {
832        (self.inner, self.is_terminated)
833    }
834
835    fn from_inner(
836        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
837        is_terminated: bool,
838    ) -> Self {
839        Self { inner, is_terminated }
840    }
841}
842
843impl futures::Stream for ActivityReporterRequestStream {
844    type Item = Result<ActivityReporterRequest, fidl::Error>;
845
846    fn poll_next(
847        mut self: std::pin::Pin<&mut Self>,
848        cx: &mut std::task::Context<'_>,
849    ) -> std::task::Poll<Option<Self::Item>> {
850        let this = &mut *self;
851        if this.inner.check_shutdown(cx) {
852            this.is_terminated = true;
853            return std::task::Poll::Ready(None);
854        }
855        if this.is_terminated {
856            panic!("polled ActivityReporterRequestStream after completion");
857        }
858        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
859            |bytes, handles| {
860                match this.inner.channel().read_etc(cx, bytes, handles) {
861                    std::task::Poll::Ready(Ok(())) => {}
862                    std::task::Poll::Pending => return std::task::Poll::Pending,
863                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
864                        this.is_terminated = true;
865                        return std::task::Poll::Ready(None);
866                    }
867                    std::task::Poll::Ready(Err(e)) => {
868                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
869                            e.into(),
870                        ))));
871                    }
872                }
873
874                // A message has been received from the channel
875                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
876
877                std::task::Poll::Ready(Some(match header.ordinal {
878                    0x2974e9f5880b2f1f => {
879                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
880                        let mut req = fidl::new_empty!(
881                            fidl::encoding::EmptyPayload,
882                            fidl::encoding::DefaultFuchsiaResourceDialect
883                        );
884                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
885                        let control_handle =
886                            ActivityReporterControlHandle { inner: this.inner.clone() };
887                        Ok(ActivityReporterRequest::WatchRenderActivity {
888                            responder: ActivityReporterWatchRenderActivityResponder {
889                                control_handle: std::mem::ManuallyDrop::new(control_handle),
890                                tx_id: header.tx_id,
891                            },
892                        })
893                    }
894                    0x484236fc11b363e6 => {
895                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
896                        let mut req = fidl::new_empty!(
897                            fidl::encoding::EmptyPayload,
898                            fidl::encoding::DefaultFuchsiaResourceDialect
899                        );
900                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
901                        let control_handle =
902                            ActivityReporterControlHandle { inner: this.inner.clone() };
903                        Ok(ActivityReporterRequest::WatchRenderActivity2 {
904                            responder: ActivityReporterWatchRenderActivity2Responder {
905                                control_handle: std::mem::ManuallyDrop::new(control_handle),
906                                tx_id: header.tx_id,
907                            },
908                        })
909                    }
910                    0x70e7038e9658e128 => {
911                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
912                        let mut req = fidl::new_empty!(
913                            fidl::encoding::EmptyPayload,
914                            fidl::encoding::DefaultFuchsiaResourceDialect
915                        );
916                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
917                        let control_handle =
918                            ActivityReporterControlHandle { inner: this.inner.clone() };
919                        Ok(ActivityReporterRequest::WatchCaptureActivity {
920                            responder: ActivityReporterWatchCaptureActivityResponder {
921                                control_handle: std::mem::ManuallyDrop::new(control_handle),
922                                tx_id: header.tx_id,
923                            },
924                        })
925                    }
926                    0x3d137e0364f9d550 => {
927                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
928                        let mut req = fidl::new_empty!(
929                            fidl::encoding::EmptyPayload,
930                            fidl::encoding::DefaultFuchsiaResourceDialect
931                        );
932                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
933                        let control_handle =
934                            ActivityReporterControlHandle { inner: this.inner.clone() };
935                        Ok(ActivityReporterRequest::WatchCaptureActivity2 {
936                            responder: ActivityReporterWatchCaptureActivity2Responder {
937                                control_handle: std::mem::ManuallyDrop::new(control_handle),
938                                tx_id: header.tx_id,
939                            },
940                        })
941                    }
942                    _ if header.tx_id == 0
943                        && header
944                            .dynamic_flags()
945                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
946                    {
947                        Ok(ActivityReporterRequest::_UnknownMethod {
948                            ordinal: header.ordinal,
949                            control_handle: ActivityReporterControlHandle {
950                                inner: this.inner.clone(),
951                            },
952                            method_type: fidl::MethodType::OneWay,
953                        })
954                    }
955                    _ if header
956                        .dynamic_flags()
957                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
958                    {
959                        this.inner.send_framework_err(
960                            fidl::encoding::FrameworkErr::UnknownMethod,
961                            header.tx_id,
962                            header.ordinal,
963                            header.dynamic_flags(),
964                            (bytes, handles),
965                        )?;
966                        Ok(ActivityReporterRequest::_UnknownMethod {
967                            ordinal: header.ordinal,
968                            control_handle: ActivityReporterControlHandle {
969                                inner: this.inner.clone(),
970                            },
971                            method_type: fidl::MethodType::TwoWay,
972                        })
973                    }
974                    _ => Err(fidl::Error::UnknownOrdinal {
975                        ordinal: header.ordinal,
976                        protocol_name:
977                            <ActivityReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
978                    }),
979                }))
980            },
981        )
982    }
983}
984
985/// A protocol for monitoring the usage activity of the AudioRenderers and AudioCapturers.
986#[derive(Debug)]
987pub enum ActivityReporterRequest {
988    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
989    /// It returns immediately the first time that it is called.
990    WatchRenderActivity { responder: ActivityReporterWatchRenderActivityResponder },
991    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
992    /// It returns immediately the first time that it is called.
993    WatchRenderActivity2 { responder: ActivityReporterWatchRenderActivity2Responder },
994    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
995    /// It returns immediately the first time that it is called.
996    WatchCaptureActivity { responder: ActivityReporterWatchCaptureActivityResponder },
997    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
998    /// It returns immediately the first time that it is called.
999    WatchCaptureActivity2 { responder: ActivityReporterWatchCaptureActivity2Responder },
1000    /// An interaction was received which does not match any known method.
1001    #[non_exhaustive]
1002    _UnknownMethod {
1003        /// Ordinal of the method that was called.
1004        ordinal: u64,
1005        control_handle: ActivityReporterControlHandle,
1006        method_type: fidl::MethodType,
1007    },
1008}
1009
1010impl ActivityReporterRequest {
1011    #[allow(irrefutable_let_patterns)]
1012    pub fn into_watch_render_activity(
1013        self,
1014    ) -> Option<(ActivityReporterWatchRenderActivityResponder)> {
1015        if let ActivityReporterRequest::WatchRenderActivity { responder } = self {
1016            Some((responder))
1017        } else {
1018            None
1019        }
1020    }
1021
1022    #[allow(irrefutable_let_patterns)]
1023    pub fn into_watch_render_activity2(
1024        self,
1025    ) -> Option<(ActivityReporterWatchRenderActivity2Responder)> {
1026        if let ActivityReporterRequest::WatchRenderActivity2 { responder } = self {
1027            Some((responder))
1028        } else {
1029            None
1030        }
1031    }
1032
1033    #[allow(irrefutable_let_patterns)]
1034    pub fn into_watch_capture_activity(
1035        self,
1036    ) -> Option<(ActivityReporterWatchCaptureActivityResponder)> {
1037        if let ActivityReporterRequest::WatchCaptureActivity { responder } = self {
1038            Some((responder))
1039        } else {
1040            None
1041        }
1042    }
1043
1044    #[allow(irrefutable_let_patterns)]
1045    pub fn into_watch_capture_activity2(
1046        self,
1047    ) -> Option<(ActivityReporterWatchCaptureActivity2Responder)> {
1048        if let ActivityReporterRequest::WatchCaptureActivity2 { responder } = self {
1049            Some((responder))
1050        } else {
1051            None
1052        }
1053    }
1054
1055    /// Name of the method defined in FIDL
1056    pub fn method_name(&self) -> &'static str {
1057        match *self {
1058            ActivityReporterRequest::WatchRenderActivity { .. } => "watch_render_activity",
1059            ActivityReporterRequest::WatchRenderActivity2 { .. } => "watch_render_activity2",
1060            ActivityReporterRequest::WatchCaptureActivity { .. } => "watch_capture_activity",
1061            ActivityReporterRequest::WatchCaptureActivity2 { .. } => "watch_capture_activity2",
1062            ActivityReporterRequest::_UnknownMethod {
1063                method_type: fidl::MethodType::OneWay,
1064                ..
1065            } => "unknown one-way method",
1066            ActivityReporterRequest::_UnknownMethod {
1067                method_type: fidl::MethodType::TwoWay,
1068                ..
1069            } => "unknown two-way method",
1070        }
1071    }
1072}
1073
1074#[derive(Debug, Clone)]
1075pub struct ActivityReporterControlHandle {
1076    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1077}
1078
1079impl fidl::endpoints::ControlHandle for ActivityReporterControlHandle {
1080    fn shutdown(&self) {
1081        self.inner.shutdown()
1082    }
1083
1084    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1085        self.inner.shutdown_with_epitaph(status)
1086    }
1087
1088    fn is_closed(&self) -> bool {
1089        self.inner.channel().is_closed()
1090    }
1091    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1092        self.inner.channel().on_closed()
1093    }
1094
1095    #[cfg(target_os = "fuchsia")]
1096    fn signal_peer(
1097        &self,
1098        clear_mask: zx::Signals,
1099        set_mask: zx::Signals,
1100    ) -> Result<(), zx_status::Status> {
1101        use fidl::Peered;
1102        self.inner.channel().signal_peer(clear_mask, set_mask)
1103    }
1104}
1105
1106impl ActivityReporterControlHandle {}
1107
1108#[must_use = "FIDL methods require a response to be sent"]
1109#[derive(Debug)]
1110pub struct ActivityReporterWatchRenderActivityResponder {
1111    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1112    tx_id: u32,
1113}
1114
1115/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1116/// if the responder is dropped without sending a response, so that the client
1117/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1118impl std::ops::Drop for ActivityReporterWatchRenderActivityResponder {
1119    fn drop(&mut self) {
1120        self.control_handle.shutdown();
1121        // Safety: drops once, never accessed again
1122        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1123    }
1124}
1125
1126impl fidl::endpoints::Responder for ActivityReporterWatchRenderActivityResponder {
1127    type ControlHandle = ActivityReporterControlHandle;
1128
1129    fn control_handle(&self) -> &ActivityReporterControlHandle {
1130        &self.control_handle
1131    }
1132
1133    fn drop_without_shutdown(mut self) {
1134        // Safety: drops once, never accessed again due to mem::forget
1135        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1136        // Prevent Drop from running (which would shut down the channel)
1137        std::mem::forget(self);
1138    }
1139}
1140
1141impl ActivityReporterWatchRenderActivityResponder {
1142    /// Sends a response to the FIDL transaction.
1143    ///
1144    /// Sets the channel to shutdown if an error occurs.
1145    pub fn send(self, mut active_usages: &[AudioRenderUsage]) -> Result<(), fidl::Error> {
1146        let _result = self.send_raw(active_usages);
1147        if _result.is_err() {
1148            self.control_handle.shutdown();
1149        }
1150        self.drop_without_shutdown();
1151        _result
1152    }
1153
1154    /// Similar to "send" but does not shutdown the channel if an error occurs.
1155    pub fn send_no_shutdown_on_err(
1156        self,
1157        mut active_usages: &[AudioRenderUsage],
1158    ) -> Result<(), fidl::Error> {
1159        let _result = self.send_raw(active_usages);
1160        self.drop_without_shutdown();
1161        _result
1162    }
1163
1164    fn send_raw(&self, mut active_usages: &[AudioRenderUsage]) -> Result<(), fidl::Error> {
1165        self.control_handle.inner.send::<ActivityReporterWatchRenderActivityResponse>(
1166            (active_usages,),
1167            self.tx_id,
1168            0x2974e9f5880b2f1f,
1169            fidl::encoding::DynamicFlags::empty(),
1170        )
1171    }
1172}
1173
1174#[must_use = "FIDL methods require a response to be sent"]
1175#[derive(Debug)]
1176pub struct ActivityReporterWatchRenderActivity2Responder {
1177    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1178    tx_id: u32,
1179}
1180
1181/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1182/// if the responder is dropped without sending a response, so that the client
1183/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1184impl std::ops::Drop for ActivityReporterWatchRenderActivity2Responder {
1185    fn drop(&mut self) {
1186        self.control_handle.shutdown();
1187        // Safety: drops once, never accessed again
1188        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1189    }
1190}
1191
1192impl fidl::endpoints::Responder for ActivityReporterWatchRenderActivity2Responder {
1193    type ControlHandle = ActivityReporterControlHandle;
1194
1195    fn control_handle(&self) -> &ActivityReporterControlHandle {
1196        &self.control_handle
1197    }
1198
1199    fn drop_without_shutdown(mut self) {
1200        // Safety: drops once, never accessed again due to mem::forget
1201        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1202        // Prevent Drop from running (which would shut down the channel)
1203        std::mem::forget(self);
1204    }
1205}
1206
1207impl ActivityReporterWatchRenderActivity2Responder {
1208    /// Sends a response to the FIDL transaction.
1209    ///
1210    /// Sets the channel to shutdown if an error occurs.
1211    pub fn send(self, mut active_usages: &[AudioRenderUsage2]) -> Result<(), fidl::Error> {
1212        let _result = self.send_raw(active_usages);
1213        if _result.is_err() {
1214            self.control_handle.shutdown();
1215        }
1216        self.drop_without_shutdown();
1217        _result
1218    }
1219
1220    /// Similar to "send" but does not shutdown the channel if an error occurs.
1221    pub fn send_no_shutdown_on_err(
1222        self,
1223        mut active_usages: &[AudioRenderUsage2],
1224    ) -> Result<(), fidl::Error> {
1225        let _result = self.send_raw(active_usages);
1226        self.drop_without_shutdown();
1227        _result
1228    }
1229
1230    fn send_raw(&self, mut active_usages: &[AudioRenderUsage2]) -> Result<(), fidl::Error> {
1231        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1232            ActivityReporterWatchRenderActivity2Response,
1233        >>(
1234            fidl::encoding::Flexible::new((active_usages,)),
1235            self.tx_id,
1236            0x484236fc11b363e6,
1237            fidl::encoding::DynamicFlags::FLEXIBLE,
1238        )
1239    }
1240}
1241
1242#[must_use = "FIDL methods require a response to be sent"]
1243#[derive(Debug)]
1244pub struct ActivityReporterWatchCaptureActivityResponder {
1245    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1246    tx_id: u32,
1247}
1248
1249/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1250/// if the responder is dropped without sending a response, so that the client
1251/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1252impl std::ops::Drop for ActivityReporterWatchCaptureActivityResponder {
1253    fn drop(&mut self) {
1254        self.control_handle.shutdown();
1255        // Safety: drops once, never accessed again
1256        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1257    }
1258}
1259
1260impl fidl::endpoints::Responder for ActivityReporterWatchCaptureActivityResponder {
1261    type ControlHandle = ActivityReporterControlHandle;
1262
1263    fn control_handle(&self) -> &ActivityReporterControlHandle {
1264        &self.control_handle
1265    }
1266
1267    fn drop_without_shutdown(mut self) {
1268        // Safety: drops once, never accessed again due to mem::forget
1269        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1270        // Prevent Drop from running (which would shut down the channel)
1271        std::mem::forget(self);
1272    }
1273}
1274
1275impl ActivityReporterWatchCaptureActivityResponder {
1276    /// Sends a response to the FIDL transaction.
1277    ///
1278    /// Sets the channel to shutdown if an error occurs.
1279    pub fn send(self, mut active_usages: &[AudioCaptureUsage]) -> Result<(), fidl::Error> {
1280        let _result = self.send_raw(active_usages);
1281        if _result.is_err() {
1282            self.control_handle.shutdown();
1283        }
1284        self.drop_without_shutdown();
1285        _result
1286    }
1287
1288    /// Similar to "send" but does not shutdown the channel if an error occurs.
1289    pub fn send_no_shutdown_on_err(
1290        self,
1291        mut active_usages: &[AudioCaptureUsage],
1292    ) -> Result<(), fidl::Error> {
1293        let _result = self.send_raw(active_usages);
1294        self.drop_without_shutdown();
1295        _result
1296    }
1297
1298    fn send_raw(&self, mut active_usages: &[AudioCaptureUsage]) -> Result<(), fidl::Error> {
1299        self.control_handle.inner.send::<ActivityReporterWatchCaptureActivityResponse>(
1300            (active_usages,),
1301            self.tx_id,
1302            0x70e7038e9658e128,
1303            fidl::encoding::DynamicFlags::empty(),
1304        )
1305    }
1306}
1307
1308#[must_use = "FIDL methods require a response to be sent"]
1309#[derive(Debug)]
1310pub struct ActivityReporterWatchCaptureActivity2Responder {
1311    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1312    tx_id: u32,
1313}
1314
1315/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1316/// if the responder is dropped without sending a response, so that the client
1317/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1318impl std::ops::Drop for ActivityReporterWatchCaptureActivity2Responder {
1319    fn drop(&mut self) {
1320        self.control_handle.shutdown();
1321        // Safety: drops once, never accessed again
1322        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1323    }
1324}
1325
1326impl fidl::endpoints::Responder for ActivityReporterWatchCaptureActivity2Responder {
1327    type ControlHandle = ActivityReporterControlHandle;
1328
1329    fn control_handle(&self) -> &ActivityReporterControlHandle {
1330        &self.control_handle
1331    }
1332
1333    fn drop_without_shutdown(mut self) {
1334        // Safety: drops once, never accessed again due to mem::forget
1335        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1336        // Prevent Drop from running (which would shut down the channel)
1337        std::mem::forget(self);
1338    }
1339}
1340
1341impl ActivityReporterWatchCaptureActivity2Responder {
1342    /// Sends a response to the FIDL transaction.
1343    ///
1344    /// Sets the channel to shutdown if an error occurs.
1345    pub fn send(self, mut active_usages: &[AudioCaptureUsage2]) -> Result<(), fidl::Error> {
1346        let _result = self.send_raw(active_usages);
1347        if _result.is_err() {
1348            self.control_handle.shutdown();
1349        }
1350        self.drop_without_shutdown();
1351        _result
1352    }
1353
1354    /// Similar to "send" but does not shutdown the channel if an error occurs.
1355    pub fn send_no_shutdown_on_err(
1356        self,
1357        mut active_usages: &[AudioCaptureUsage2],
1358    ) -> Result<(), fidl::Error> {
1359        let _result = self.send_raw(active_usages);
1360        self.drop_without_shutdown();
1361        _result
1362    }
1363
1364    fn send_raw(&self, mut active_usages: &[AudioCaptureUsage2]) -> Result<(), fidl::Error> {
1365        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1366            ActivityReporterWatchCaptureActivity2Response,
1367        >>(
1368            fidl::encoding::Flexible::new((active_usages,)),
1369            self.tx_id,
1370            0x3d137e0364f9d550,
1371            fidl::encoding::DynamicFlags::FLEXIBLE,
1372        )
1373    }
1374}
1375
1376#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1377pub struct AudioMarker;
1378
1379impl fidl::endpoints::ProtocolMarker for AudioMarker {
1380    type Proxy = AudioProxy;
1381    type RequestStream = AudioRequestStream;
1382    #[cfg(target_os = "fuchsia")]
1383    type SynchronousProxy = AudioSynchronousProxy;
1384
1385    const DEBUG_NAME: &'static str = "fuchsia.media.Audio";
1386}
1387impl fidl::endpoints::DiscoverableProtocolMarker for AudioMarker {}
1388
1389pub trait AudioProxyInterface: Send + Sync {
1390    fn r#create_audio_renderer(
1391        &self,
1392        audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1393    ) -> Result<(), fidl::Error>;
1394    fn r#create_audio_capturer(
1395        &self,
1396        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1397        loopback: bool,
1398    ) -> Result<(), fidl::Error>;
1399}
1400#[derive(Debug)]
1401#[cfg(target_os = "fuchsia")]
1402pub struct AudioSynchronousProxy {
1403    client: fidl::client::sync::Client,
1404}
1405
1406#[cfg(target_os = "fuchsia")]
1407impl fidl::endpoints::SynchronousProxy for AudioSynchronousProxy {
1408    type Proxy = AudioProxy;
1409    type Protocol = AudioMarker;
1410
1411    fn from_channel(inner: fidl::Channel) -> Self {
1412        Self::new(inner)
1413    }
1414
1415    fn into_channel(self) -> fidl::Channel {
1416        self.client.into_channel()
1417    }
1418
1419    fn as_channel(&self) -> &fidl::Channel {
1420        self.client.as_channel()
1421    }
1422}
1423
1424#[cfg(target_os = "fuchsia")]
1425impl AudioSynchronousProxy {
1426    pub fn new(channel: fidl::Channel) -> Self {
1427        Self { client: fidl::client::sync::Client::new(channel) }
1428    }
1429
1430    pub fn into_channel(self) -> fidl::Channel {
1431        self.client.into_channel()
1432    }
1433
1434    /// Waits until an event arrives and returns it. It is safe for other
1435    /// threads to make concurrent requests while waiting for an event.
1436    pub fn wait_for_event(
1437        &self,
1438        deadline: zx::MonotonicInstant,
1439    ) -> Result<AudioEvent, fidl::Error> {
1440        AudioEvent::decode(self.client.wait_for_event::<AudioMarker>(deadline)?)
1441    }
1442
1443    pub fn r#create_audio_renderer(
1444        &self,
1445        mut audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1446    ) -> Result<(), fidl::Error> {
1447        self.client.send::<AudioCreateAudioRendererRequest>(
1448            (audio_renderer_request,),
1449            0x572f413566fd58f1,
1450            fidl::encoding::DynamicFlags::empty(),
1451        )
1452    }
1453
1454    /// Creates an AudioCapturer which either captures from the current default
1455    /// audio input device, or loops-back from the current default audio output
1456    /// device based on value passed for the loopback flag.
1457    pub fn r#create_audio_capturer(
1458        &self,
1459        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1460        mut loopback: bool,
1461    ) -> Result<(), fidl::Error> {
1462        self.client.send::<AudioCreateAudioCapturerRequest>(
1463            (audio_capturer_request, loopback),
1464            0x44660fc63a6202f,
1465            fidl::encoding::DynamicFlags::empty(),
1466        )
1467    }
1468}
1469
1470#[cfg(target_os = "fuchsia")]
1471impl From<AudioSynchronousProxy> for zx::NullableHandle {
1472    fn from(value: AudioSynchronousProxy) -> Self {
1473        value.into_channel().into()
1474    }
1475}
1476
1477#[cfg(target_os = "fuchsia")]
1478impl From<fidl::Channel> for AudioSynchronousProxy {
1479    fn from(value: fidl::Channel) -> Self {
1480        Self::new(value)
1481    }
1482}
1483
1484#[cfg(target_os = "fuchsia")]
1485impl fidl::endpoints::FromClient for AudioSynchronousProxy {
1486    type Protocol = AudioMarker;
1487
1488    fn from_client(value: fidl::endpoints::ClientEnd<AudioMarker>) -> Self {
1489        Self::new(value.into_channel())
1490    }
1491}
1492
1493#[derive(Debug, Clone)]
1494pub struct AudioProxy {
1495    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1496}
1497
1498impl fidl::endpoints::Proxy for AudioProxy {
1499    type Protocol = AudioMarker;
1500
1501    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1502        Self::new(inner)
1503    }
1504
1505    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1506        self.client.into_channel().map_err(|client| Self { client })
1507    }
1508
1509    fn as_channel(&self) -> &::fidl::AsyncChannel {
1510        self.client.as_channel()
1511    }
1512}
1513
1514impl AudioProxy {
1515    /// Create a new Proxy for fuchsia.media/Audio.
1516    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1517        let protocol_name = <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1518        Self { client: fidl::client::Client::new(channel, protocol_name) }
1519    }
1520
1521    /// Get a Stream of events from the remote end of the protocol.
1522    ///
1523    /// # Panics
1524    ///
1525    /// Panics if the event stream was already taken.
1526    pub fn take_event_stream(&self) -> AudioEventStream {
1527        AudioEventStream { event_receiver: self.client.take_event_receiver() }
1528    }
1529
1530    pub fn r#create_audio_renderer(
1531        &self,
1532        mut audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1533    ) -> Result<(), fidl::Error> {
1534        AudioProxyInterface::r#create_audio_renderer(self, audio_renderer_request)
1535    }
1536
1537    /// Creates an AudioCapturer which either captures from the current default
1538    /// audio input device, or loops-back from the current default audio output
1539    /// device based on value passed for the loopback flag.
1540    pub fn r#create_audio_capturer(
1541        &self,
1542        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1543        mut loopback: bool,
1544    ) -> Result<(), fidl::Error> {
1545        AudioProxyInterface::r#create_audio_capturer(self, audio_capturer_request, loopback)
1546    }
1547}
1548
1549impl AudioProxyInterface for AudioProxy {
1550    fn r#create_audio_renderer(
1551        &self,
1552        mut audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1553    ) -> Result<(), fidl::Error> {
1554        self.client.send::<AudioCreateAudioRendererRequest>(
1555            (audio_renderer_request,),
1556            0x572f413566fd58f1,
1557            fidl::encoding::DynamicFlags::empty(),
1558        )
1559    }
1560
1561    fn r#create_audio_capturer(
1562        &self,
1563        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1564        mut loopback: bool,
1565    ) -> Result<(), fidl::Error> {
1566        self.client.send::<AudioCreateAudioCapturerRequest>(
1567            (audio_capturer_request, loopback),
1568            0x44660fc63a6202f,
1569            fidl::encoding::DynamicFlags::empty(),
1570        )
1571    }
1572}
1573
1574pub struct AudioEventStream {
1575    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1576}
1577
1578impl std::marker::Unpin for AudioEventStream {}
1579
1580impl futures::stream::FusedStream for AudioEventStream {
1581    fn is_terminated(&self) -> bool {
1582        self.event_receiver.is_terminated()
1583    }
1584}
1585
1586impl futures::Stream for AudioEventStream {
1587    type Item = Result<AudioEvent, fidl::Error>;
1588
1589    fn poll_next(
1590        mut self: std::pin::Pin<&mut Self>,
1591        cx: &mut std::task::Context<'_>,
1592    ) -> std::task::Poll<Option<Self::Item>> {
1593        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1594            &mut self.event_receiver,
1595            cx
1596        )?) {
1597            Some(buf) => std::task::Poll::Ready(Some(AudioEvent::decode(buf))),
1598            None => std::task::Poll::Ready(None),
1599        }
1600    }
1601}
1602
1603#[derive(Debug)]
1604pub enum AudioEvent {}
1605
1606impl AudioEvent {
1607    /// Decodes a message buffer as a [`AudioEvent`].
1608    fn decode(
1609        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1610    ) -> Result<AudioEvent, fidl::Error> {
1611        let (bytes, _handles) = buf.split_mut();
1612        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1613        debug_assert_eq!(tx_header.tx_id, 0);
1614        match tx_header.ordinal {
1615            _ => Err(fidl::Error::UnknownOrdinal {
1616                ordinal: tx_header.ordinal,
1617                protocol_name: <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1618            }),
1619        }
1620    }
1621}
1622
1623/// A Stream of incoming requests for fuchsia.media/Audio.
1624pub struct AudioRequestStream {
1625    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1626    is_terminated: bool,
1627}
1628
1629impl std::marker::Unpin for AudioRequestStream {}
1630
1631impl futures::stream::FusedStream for AudioRequestStream {
1632    fn is_terminated(&self) -> bool {
1633        self.is_terminated
1634    }
1635}
1636
1637impl fidl::endpoints::RequestStream for AudioRequestStream {
1638    type Protocol = AudioMarker;
1639    type ControlHandle = AudioControlHandle;
1640
1641    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1642        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1643    }
1644
1645    fn control_handle(&self) -> Self::ControlHandle {
1646        AudioControlHandle { inner: self.inner.clone() }
1647    }
1648
1649    fn into_inner(
1650        self,
1651    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1652    {
1653        (self.inner, self.is_terminated)
1654    }
1655
1656    fn from_inner(
1657        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1658        is_terminated: bool,
1659    ) -> Self {
1660        Self { inner, is_terminated }
1661    }
1662}
1663
1664impl futures::Stream for AudioRequestStream {
1665    type Item = Result<AudioRequest, fidl::Error>;
1666
1667    fn poll_next(
1668        mut self: std::pin::Pin<&mut Self>,
1669        cx: &mut std::task::Context<'_>,
1670    ) -> std::task::Poll<Option<Self::Item>> {
1671        let this = &mut *self;
1672        if this.inner.check_shutdown(cx) {
1673            this.is_terminated = true;
1674            return std::task::Poll::Ready(None);
1675        }
1676        if this.is_terminated {
1677            panic!("polled AudioRequestStream after completion");
1678        }
1679        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1680            |bytes, handles| {
1681                match this.inner.channel().read_etc(cx, bytes, handles) {
1682                    std::task::Poll::Ready(Ok(())) => {}
1683                    std::task::Poll::Pending => return std::task::Poll::Pending,
1684                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1685                        this.is_terminated = true;
1686                        return std::task::Poll::Ready(None);
1687                    }
1688                    std::task::Poll::Ready(Err(e)) => {
1689                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1690                            e.into(),
1691                        ))));
1692                    }
1693                }
1694
1695                // A message has been received from the channel
1696                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1697
1698                std::task::Poll::Ready(Some(match header.ordinal {
1699                    0x572f413566fd58f1 => {
1700                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1701                        let mut req = fidl::new_empty!(
1702                            AudioCreateAudioRendererRequest,
1703                            fidl::encoding::DefaultFuchsiaResourceDialect
1704                        );
1705                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCreateAudioRendererRequest>(&header, _body_bytes, handles, &mut req)?;
1706                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
1707                        Ok(AudioRequest::CreateAudioRenderer {
1708                            audio_renderer_request: req.audio_renderer_request,
1709
1710                            control_handle,
1711                        })
1712                    }
1713                    0x44660fc63a6202f => {
1714                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1715                        let mut req = fidl::new_empty!(
1716                            AudioCreateAudioCapturerRequest,
1717                            fidl::encoding::DefaultFuchsiaResourceDialect
1718                        );
1719                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCreateAudioCapturerRequest>(&header, _body_bytes, handles, &mut req)?;
1720                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
1721                        Ok(AudioRequest::CreateAudioCapturer {
1722                            audio_capturer_request: req.audio_capturer_request,
1723                            loopback: req.loopback,
1724
1725                            control_handle,
1726                        })
1727                    }
1728                    _ => Err(fidl::Error::UnknownOrdinal {
1729                        ordinal: header.ordinal,
1730                        protocol_name: <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1731                    }),
1732                }))
1733            },
1734        )
1735    }
1736}
1737
1738#[derive(Debug)]
1739pub enum AudioRequest {
1740    CreateAudioRenderer {
1741        audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1742        control_handle: AudioControlHandle,
1743    },
1744    /// Creates an AudioCapturer which either captures from the current default
1745    /// audio input device, or loops-back from the current default audio output
1746    /// device based on value passed for the loopback flag.
1747    CreateAudioCapturer {
1748        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1749        loopback: bool,
1750        control_handle: AudioControlHandle,
1751    },
1752}
1753
1754impl AudioRequest {
1755    #[allow(irrefutable_let_patterns)]
1756    pub fn into_create_audio_renderer(
1757        self,
1758    ) -> Option<(fidl::endpoints::ServerEnd<AudioRendererMarker>, AudioControlHandle)> {
1759        if let AudioRequest::CreateAudioRenderer { audio_renderer_request, control_handle } = self {
1760            Some((audio_renderer_request, control_handle))
1761        } else {
1762            None
1763        }
1764    }
1765
1766    #[allow(irrefutable_let_patterns)]
1767    pub fn into_create_audio_capturer(
1768        self,
1769    ) -> Option<(fidl::endpoints::ServerEnd<AudioCapturerMarker>, bool, AudioControlHandle)> {
1770        if let AudioRequest::CreateAudioCapturer {
1771            audio_capturer_request,
1772            loopback,
1773            control_handle,
1774        } = self
1775        {
1776            Some((audio_capturer_request, loopback, control_handle))
1777        } else {
1778            None
1779        }
1780    }
1781
1782    /// Name of the method defined in FIDL
1783    pub fn method_name(&self) -> &'static str {
1784        match *self {
1785            AudioRequest::CreateAudioRenderer { .. } => "create_audio_renderer",
1786            AudioRequest::CreateAudioCapturer { .. } => "create_audio_capturer",
1787        }
1788    }
1789}
1790
1791#[derive(Debug, Clone)]
1792pub struct AudioControlHandle {
1793    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1794}
1795
1796impl fidl::endpoints::ControlHandle for AudioControlHandle {
1797    fn shutdown(&self) {
1798        self.inner.shutdown()
1799    }
1800
1801    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1802        self.inner.shutdown_with_epitaph(status)
1803    }
1804
1805    fn is_closed(&self) -> bool {
1806        self.inner.channel().is_closed()
1807    }
1808    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1809        self.inner.channel().on_closed()
1810    }
1811
1812    #[cfg(target_os = "fuchsia")]
1813    fn signal_peer(
1814        &self,
1815        clear_mask: zx::Signals,
1816        set_mask: zx::Signals,
1817    ) -> Result<(), zx_status::Status> {
1818        use fidl::Peered;
1819        self.inner.channel().signal_peer(clear_mask, set_mask)
1820    }
1821}
1822
1823impl AudioControlHandle {}
1824
1825#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1826pub struct AudioCapturerMarker;
1827
1828impl fidl::endpoints::ProtocolMarker for AudioCapturerMarker {
1829    type Proxy = AudioCapturerProxy;
1830    type RequestStream = AudioCapturerRequestStream;
1831    #[cfg(target_os = "fuchsia")]
1832    type SynchronousProxy = AudioCapturerSynchronousProxy;
1833
1834    const DEBUG_NAME: &'static str = "fuchsia.media.AudioCapturer";
1835}
1836impl fidl::endpoints::DiscoverableProtocolMarker for AudioCapturerMarker {}
1837
1838pub trait AudioCapturerProxyInterface: Send + Sync {
1839    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
1840    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
1841    fn r#release_packet(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
1842    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1843    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
1844    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
1845    fn r#set_pcm_stream_type(&self, stream_type: &AudioStreamType) -> Result<(), fidl::Error>;
1846    type CaptureAtResponseFut: std::future::Future<Output = Result<StreamPacket, fidl::Error>>
1847        + Send;
1848    fn r#capture_at(
1849        &self,
1850        payload_buffer_id: u32,
1851        payload_offset: u32,
1852        frames: u32,
1853    ) -> Self::CaptureAtResponseFut;
1854    fn r#start_async_capture(&self, frames_per_packet: u32) -> Result<(), fidl::Error>;
1855    type StopAsyncCaptureResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1856    fn r#stop_async_capture(&self) -> Self::StopAsyncCaptureResponseFut;
1857    fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error>;
1858    fn r#bind_gain_control(
1859        &self,
1860        gain_control_request: fidl::endpoints::ServerEnd<
1861            fidl_fuchsia_media_audio::GainControlMarker,
1862        >,
1863    ) -> Result<(), fidl::Error>;
1864    type GetReferenceClockResponseFut: std::future::Future<Output = Result<fidl::Clock, fidl::Error>>
1865        + Send;
1866    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
1867    fn r#set_reference_clock(
1868        &self,
1869        reference_clock: Option<fidl::Clock>,
1870    ) -> Result<(), fidl::Error>;
1871    fn r#set_usage(&self, usage: AudioCaptureUsage) -> Result<(), fidl::Error>;
1872    fn r#set_usage2(&self, usage: AudioCaptureUsage2) -> Result<(), fidl::Error>;
1873    type GetStreamTypeResponseFut: std::future::Future<Output = Result<StreamType, fidl::Error>>
1874        + Send;
1875    fn r#get_stream_type(&self) -> Self::GetStreamTypeResponseFut;
1876}
1877#[derive(Debug)]
1878#[cfg(target_os = "fuchsia")]
1879pub struct AudioCapturerSynchronousProxy {
1880    client: fidl::client::sync::Client,
1881}
1882
1883#[cfg(target_os = "fuchsia")]
1884impl fidl::endpoints::SynchronousProxy for AudioCapturerSynchronousProxy {
1885    type Proxy = AudioCapturerProxy;
1886    type Protocol = AudioCapturerMarker;
1887
1888    fn from_channel(inner: fidl::Channel) -> Self {
1889        Self::new(inner)
1890    }
1891
1892    fn into_channel(self) -> fidl::Channel {
1893        self.client.into_channel()
1894    }
1895
1896    fn as_channel(&self) -> &fidl::Channel {
1897        self.client.as_channel()
1898    }
1899}
1900
1901#[cfg(target_os = "fuchsia")]
1902impl AudioCapturerSynchronousProxy {
1903    pub fn new(channel: fidl::Channel) -> Self {
1904        Self { client: fidl::client::sync::Client::new(channel) }
1905    }
1906
1907    pub fn into_channel(self) -> fidl::Channel {
1908        self.client.into_channel()
1909    }
1910
1911    /// Waits until an event arrives and returns it. It is safe for other
1912    /// threads to make concurrent requests while waiting for an event.
1913    pub fn wait_for_event(
1914        &self,
1915        deadline: zx::MonotonicInstant,
1916    ) -> Result<AudioCapturerEvent, fidl::Error> {
1917        AudioCapturerEvent::decode(self.client.wait_for_event::<AudioCapturerMarker>(deadline)?)
1918    }
1919
1920    /// Adds a payload buffer to the current buffer set associated with the
1921    /// connection. A `StreamPacket` struct reference a payload buffer in the
1922    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
1923    ///
1924    /// A buffer with ID `id` must not be in the current set when this method is
1925    /// invoked, otherwise the service will close the connection.
1926    pub fn r#add_payload_buffer(
1927        &self,
1928        mut id: u32,
1929        mut payload_buffer: fidl::Vmo,
1930    ) -> Result<(), fidl::Error> {
1931        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
1932            (id, payload_buffer),
1933            0x3b3a37fc34fe5b56,
1934            fidl::encoding::DynamicFlags::empty(),
1935        )
1936    }
1937
1938    /// Removes a payload buffer from the current buffer set associated with the
1939    /// connection.
1940    ///
1941    /// A buffer with ID `id` must exist in the current set when this method is
1942    /// invoked, otherwise the service will will close the connection.
1943    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
1944        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
1945            (id,),
1946            0x5d1e4f74c3658262,
1947            fidl::encoding::DynamicFlags::empty(),
1948        )
1949    }
1950
1951    /// Releases payload memory associated with a packet previously delivered
1952    /// via `OnPacketProduced`.
1953    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
1954        self.client.send::<StreamSourceReleasePacketRequest>(
1955            (packet,),
1956            0x7a7b57f0f7d9e4bb,
1957            fidl::encoding::DynamicFlags::empty(),
1958        )
1959    }
1960
1961    pub fn r#discard_all_packets(
1962        &self,
1963        ___deadline: zx::MonotonicInstant,
1964    ) -> Result<(), fidl::Error> {
1965        let _response = self.client.send_query::<
1966            fidl::encoding::EmptyPayload,
1967            fidl::encoding::EmptyPayload,
1968            AudioCapturerMarker,
1969        >(
1970            (),
1971            0x27afd605e97b09d2,
1972            fidl::encoding::DynamicFlags::empty(),
1973            ___deadline,
1974        )?;
1975        Ok(_response)
1976    }
1977
1978    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
1979        self.client.send::<fidl::encoding::EmptyPayload>(
1980            (),
1981            0x35f9d721e905b831,
1982            fidl::encoding::DynamicFlags::empty(),
1983        )
1984    }
1985
1986    /// Sets the stream type of the stream to be delivered. Causes the source
1987    /// material to be reformatted/resampled if needed in order to produce the
1988    /// requested stream type. Must be called before the payload buffer is
1989    /// established.
1990    pub fn r#set_pcm_stream_type(
1991        &self,
1992        mut stream_type: &AudioStreamType,
1993    ) -> Result<(), fidl::Error> {
1994        self.client.send::<AudioCapturerSetPcmStreamTypeRequest>(
1995            (stream_type,),
1996            0x1531ea9ea2c852cd,
1997            fidl::encoding::DynamicFlags::empty(),
1998        )
1999    }
2000
2001    /// Explicitly specifies a region of the shared payload buffer for the audio
2002    /// input to capture into.
2003    pub fn r#capture_at(
2004        &self,
2005        mut payload_buffer_id: u32,
2006        mut payload_offset: u32,
2007        mut frames: u32,
2008        ___deadline: zx::MonotonicInstant,
2009    ) -> Result<StreamPacket, fidl::Error> {
2010        let _response = self.client.send_query::<
2011            AudioCapturerCaptureAtRequest,
2012            AudioCapturerCaptureAtResponse,
2013            AudioCapturerMarker,
2014        >(
2015            (payload_buffer_id, payload_offset, frames,),
2016            0x784e25df72cea780,
2017            fidl::encoding::DynamicFlags::empty(),
2018            ___deadline,
2019        )?;
2020        Ok(_response.captured_packet)
2021    }
2022
2023    /// Places the AudioCapturer into 'async' capture mode and begin to produce
2024    /// packets of exactly 'frames_per_packet' number of frames each. The
2025    /// OnPacketProduced event (of StreamSink) will be used to inform the client
2026    /// of produced packets.
2027    pub fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
2028        self.client.send::<AudioCapturerStartAsyncCaptureRequest>(
2029            (frames_per_packet,),
2030            0x7768adbb1ccfd7a6,
2031            fidl::encoding::DynamicFlags::empty(),
2032        )
2033    }
2034
2035    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
2036    /// that may be used by the client if explicit synchronization is needed.
2037    pub fn r#stop_async_capture(
2038        &self,
2039        ___deadline: zx::MonotonicInstant,
2040    ) -> Result<(), fidl::Error> {
2041        let _response = self.client.send_query::<
2042            fidl::encoding::EmptyPayload,
2043            fidl::encoding::EmptyPayload,
2044            AudioCapturerMarker,
2045        >(
2046            (),
2047            0x5bfc8790a8cef8cb,
2048            fidl::encoding::DynamicFlags::empty(),
2049            ___deadline,
2050        )?;
2051        Ok(_response)
2052    }
2053
2054    pub fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
2055        self.client.send::<fidl::encoding::EmptyPayload>(
2056            (),
2057            0x33223cb2962c95e3,
2058            fidl::encoding::DynamicFlags::empty(),
2059        )
2060    }
2061
2062    /// Binds to the gain control for this AudioCapturer.
2063    pub fn r#bind_gain_control(
2064        &self,
2065        mut gain_control_request: fidl::endpoints::ServerEnd<
2066            fidl_fuchsia_media_audio::GainControlMarker,
2067        >,
2068    ) -> Result<(), fidl::Error> {
2069        self.client.send::<AudioCapturerBindGainControlRequest>(
2070            (gain_control_request,),
2071            0x658a6a17ddb3a8e0,
2072            fidl::encoding::DynamicFlags::empty(),
2073        )
2074    }
2075
2076    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
2077    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
2078    pub fn r#get_reference_clock(
2079        &self,
2080        ___deadline: zx::MonotonicInstant,
2081    ) -> Result<fidl::Clock, fidl::Error> {
2082        let _response = self.client.send_query::<
2083            fidl::encoding::EmptyPayload,
2084            AudioCapturerGetReferenceClockResponse,
2085            AudioCapturerMarker,
2086        >(
2087            (),
2088            0x50d037aa5a4b4d71,
2089            fidl::encoding::DynamicFlags::empty(),
2090            ___deadline,
2091        )?;
2092        Ok(_response.reference_clock)
2093    }
2094
2095    /// Sets the reference clock that controls this capturer's playback rate. If the input
2096    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
2097    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
2098    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
2099    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
2100    ///
2101    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
2102    /// added. It also cannot be called a second time (even before capture).
2103    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
2104    /// diverge at some later time, they should create a clone of the monotonic clock, set
2105    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
2106    pub fn r#set_reference_clock(
2107        &self,
2108        mut reference_clock: Option<fidl::Clock>,
2109    ) -> Result<(), fidl::Error> {
2110        self.client.send::<AudioCapturerSetReferenceClockRequest>(
2111            (reference_clock,),
2112            0x732b2c496d521bcf,
2113            fidl::encoding::DynamicFlags::empty(),
2114        )
2115    }
2116
2117    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
2118    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
2119    pub fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2120        self.client.send::<AudioCapturerSetUsageRequest>(
2121            (usage,),
2122            0x42a16f392bd21b25,
2123            fidl::encoding::DynamicFlags::empty(),
2124        )
2125    }
2126
2127    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
2128    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
2129    pub fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2130        self.client.send::<AudioCapturerSetUsage2Request>(
2131            (usage,),
2132            0x7a73e251b8d2382b,
2133            fidl::encoding::DynamicFlags::FLEXIBLE,
2134        )
2135    }
2136
2137    /// Gets the currently configured stream type. Note: for an AudioCapturer
2138    /// which was just created and has not yet had its stream type explicitly
2139    /// set, this will retrieve the stream type -- at the time the AudioCapturer
2140    /// was created -- of the source (input or looped-back output) to which the
2141    /// AudioCapturer is bound. Even if this matches the client's desired format,
2142    /// `SetPcmStreamType` must still be called.
2143    pub fn r#get_stream_type(
2144        &self,
2145        ___deadline: zx::MonotonicInstant,
2146    ) -> Result<StreamType, fidl::Error> {
2147        let _response = self.client.send_query::<
2148            fidl::encoding::EmptyPayload,
2149            AudioCapturerGetStreamTypeResponse,
2150            AudioCapturerMarker,
2151        >(
2152            (),
2153            0x5dcaaa670b433088,
2154            fidl::encoding::DynamicFlags::empty(),
2155            ___deadline,
2156        )?;
2157        Ok(_response.stream_type)
2158    }
2159}
2160
2161#[cfg(target_os = "fuchsia")]
2162impl From<AudioCapturerSynchronousProxy> for zx::NullableHandle {
2163    fn from(value: AudioCapturerSynchronousProxy) -> Self {
2164        value.into_channel().into()
2165    }
2166}
2167
2168#[cfg(target_os = "fuchsia")]
2169impl From<fidl::Channel> for AudioCapturerSynchronousProxy {
2170    fn from(value: fidl::Channel) -> Self {
2171        Self::new(value)
2172    }
2173}
2174
2175#[cfg(target_os = "fuchsia")]
2176impl fidl::endpoints::FromClient for AudioCapturerSynchronousProxy {
2177    type Protocol = AudioCapturerMarker;
2178
2179    fn from_client(value: fidl::endpoints::ClientEnd<AudioCapturerMarker>) -> Self {
2180        Self::new(value.into_channel())
2181    }
2182}
2183
2184#[derive(Debug, Clone)]
2185pub struct AudioCapturerProxy {
2186    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2187}
2188
2189impl fidl::endpoints::Proxy for AudioCapturerProxy {
2190    type Protocol = AudioCapturerMarker;
2191
2192    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2193        Self::new(inner)
2194    }
2195
2196    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2197        self.client.into_channel().map_err(|client| Self { client })
2198    }
2199
2200    fn as_channel(&self) -> &::fidl::AsyncChannel {
2201        self.client.as_channel()
2202    }
2203}
2204
2205impl AudioCapturerProxy {
2206    /// Create a new Proxy for fuchsia.media/AudioCapturer.
2207    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2208        let protocol_name = <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2209        Self { client: fidl::client::Client::new(channel, protocol_name) }
2210    }
2211
2212    /// Get a Stream of events from the remote end of the protocol.
2213    ///
2214    /// # Panics
2215    ///
2216    /// Panics if the event stream was already taken.
2217    pub fn take_event_stream(&self) -> AudioCapturerEventStream {
2218        AudioCapturerEventStream { event_receiver: self.client.take_event_receiver() }
2219    }
2220
2221    /// Adds a payload buffer to the current buffer set associated with the
2222    /// connection. A `StreamPacket` struct reference a payload buffer in the
2223    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
2224    ///
2225    /// A buffer with ID `id` must not be in the current set when this method is
2226    /// invoked, otherwise the service will close the connection.
2227    pub fn r#add_payload_buffer(
2228        &self,
2229        mut id: u32,
2230        mut payload_buffer: fidl::Vmo,
2231    ) -> Result<(), fidl::Error> {
2232        AudioCapturerProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
2233    }
2234
2235    /// Removes a payload buffer from the current buffer set associated with the
2236    /// connection.
2237    ///
2238    /// A buffer with ID `id` must exist in the current set when this method is
2239    /// invoked, otherwise the service will will close the connection.
2240    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
2241        AudioCapturerProxyInterface::r#remove_payload_buffer(self, id)
2242    }
2243
2244    /// Releases payload memory associated with a packet previously delivered
2245    /// via `OnPacketProduced`.
2246    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
2247        AudioCapturerProxyInterface::r#release_packet(self, packet)
2248    }
2249
2250    pub fn r#discard_all_packets(
2251        &self,
2252    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2253        AudioCapturerProxyInterface::r#discard_all_packets(self)
2254    }
2255
2256    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
2257        AudioCapturerProxyInterface::r#discard_all_packets_no_reply(self)
2258    }
2259
2260    /// Sets the stream type of the stream to be delivered. Causes the source
2261    /// material to be reformatted/resampled if needed in order to produce the
2262    /// requested stream type. Must be called before the payload buffer is
2263    /// established.
2264    pub fn r#set_pcm_stream_type(
2265        &self,
2266        mut stream_type: &AudioStreamType,
2267    ) -> Result<(), fidl::Error> {
2268        AudioCapturerProxyInterface::r#set_pcm_stream_type(self, stream_type)
2269    }
2270
2271    /// Explicitly specifies a region of the shared payload buffer for the audio
2272    /// input to capture into.
2273    pub fn r#capture_at(
2274        &self,
2275        mut payload_buffer_id: u32,
2276        mut payload_offset: u32,
2277        mut frames: u32,
2278    ) -> fidl::client::QueryResponseFut<StreamPacket, fidl::encoding::DefaultFuchsiaResourceDialect>
2279    {
2280        AudioCapturerProxyInterface::r#capture_at(self, payload_buffer_id, payload_offset, frames)
2281    }
2282
2283    /// Places the AudioCapturer into 'async' capture mode and begin to produce
2284    /// packets of exactly 'frames_per_packet' number of frames each. The
2285    /// OnPacketProduced event (of StreamSink) will be used to inform the client
2286    /// of produced packets.
2287    pub fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
2288        AudioCapturerProxyInterface::r#start_async_capture(self, frames_per_packet)
2289    }
2290
2291    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
2292    /// that may be used by the client if explicit synchronization is needed.
2293    pub fn r#stop_async_capture(
2294        &self,
2295    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2296        AudioCapturerProxyInterface::r#stop_async_capture(self)
2297    }
2298
2299    pub fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
2300        AudioCapturerProxyInterface::r#stop_async_capture_no_reply(self)
2301    }
2302
2303    /// Binds to the gain control for this AudioCapturer.
2304    pub fn r#bind_gain_control(
2305        &self,
2306        mut gain_control_request: fidl::endpoints::ServerEnd<
2307            fidl_fuchsia_media_audio::GainControlMarker,
2308        >,
2309    ) -> Result<(), fidl::Error> {
2310        AudioCapturerProxyInterface::r#bind_gain_control(self, gain_control_request)
2311    }
2312
2313    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
2314    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
2315    pub fn r#get_reference_clock(
2316        &self,
2317    ) -> fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>
2318    {
2319        AudioCapturerProxyInterface::r#get_reference_clock(self)
2320    }
2321
2322    /// Sets the reference clock that controls this capturer's playback rate. If the input
2323    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
2324    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
2325    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
2326    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
2327    ///
2328    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
2329    /// added. It also cannot be called a second time (even before capture).
2330    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
2331    /// diverge at some later time, they should create a clone of the monotonic clock, set
2332    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
2333    pub fn r#set_reference_clock(
2334        &self,
2335        mut reference_clock: Option<fidl::Clock>,
2336    ) -> Result<(), fidl::Error> {
2337        AudioCapturerProxyInterface::r#set_reference_clock(self, reference_clock)
2338    }
2339
2340    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
2341    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
2342    pub fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2343        AudioCapturerProxyInterface::r#set_usage(self, usage)
2344    }
2345
2346    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
2347    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
2348    pub fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2349        AudioCapturerProxyInterface::r#set_usage2(self, usage)
2350    }
2351
2352    /// Gets the currently configured stream type. Note: for an AudioCapturer
2353    /// which was just created and has not yet had its stream type explicitly
2354    /// set, this will retrieve the stream type -- at the time the AudioCapturer
2355    /// was created -- of the source (input or looped-back output) to which the
2356    /// AudioCapturer is bound. Even if this matches the client's desired format,
2357    /// `SetPcmStreamType` must still be called.
2358    pub fn r#get_stream_type(
2359        &self,
2360    ) -> fidl::client::QueryResponseFut<StreamType, fidl::encoding::DefaultFuchsiaResourceDialect>
2361    {
2362        AudioCapturerProxyInterface::r#get_stream_type(self)
2363    }
2364}
2365
2366impl AudioCapturerProxyInterface for AudioCapturerProxy {
2367    fn r#add_payload_buffer(
2368        &self,
2369        mut id: u32,
2370        mut payload_buffer: fidl::Vmo,
2371    ) -> Result<(), fidl::Error> {
2372        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
2373            (id, payload_buffer),
2374            0x3b3a37fc34fe5b56,
2375            fidl::encoding::DynamicFlags::empty(),
2376        )
2377    }
2378
2379    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
2380        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
2381            (id,),
2382            0x5d1e4f74c3658262,
2383            fidl::encoding::DynamicFlags::empty(),
2384        )
2385    }
2386
2387    fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
2388        self.client.send::<StreamSourceReleasePacketRequest>(
2389            (packet,),
2390            0x7a7b57f0f7d9e4bb,
2391            fidl::encoding::DynamicFlags::empty(),
2392        )
2393    }
2394
2395    type DiscardAllPacketsResponseFut =
2396        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2397    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
2398        fn _decode(
2399            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2400        ) -> Result<(), fidl::Error> {
2401            let _response = fidl::client::decode_transaction_body::<
2402                fidl::encoding::EmptyPayload,
2403                fidl::encoding::DefaultFuchsiaResourceDialect,
2404                0x27afd605e97b09d2,
2405            >(_buf?)?;
2406            Ok(_response)
2407        }
2408        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2409            (),
2410            0x27afd605e97b09d2,
2411            fidl::encoding::DynamicFlags::empty(),
2412            _decode,
2413        )
2414    }
2415
2416    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
2417        self.client.send::<fidl::encoding::EmptyPayload>(
2418            (),
2419            0x35f9d721e905b831,
2420            fidl::encoding::DynamicFlags::empty(),
2421        )
2422    }
2423
2424    fn r#set_pcm_stream_type(&self, mut stream_type: &AudioStreamType) -> Result<(), fidl::Error> {
2425        self.client.send::<AudioCapturerSetPcmStreamTypeRequest>(
2426            (stream_type,),
2427            0x1531ea9ea2c852cd,
2428            fidl::encoding::DynamicFlags::empty(),
2429        )
2430    }
2431
2432    type CaptureAtResponseFut =
2433        fidl::client::QueryResponseFut<StreamPacket, fidl::encoding::DefaultFuchsiaResourceDialect>;
2434    fn r#capture_at(
2435        &self,
2436        mut payload_buffer_id: u32,
2437        mut payload_offset: u32,
2438        mut frames: u32,
2439    ) -> Self::CaptureAtResponseFut {
2440        fn _decode(
2441            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2442        ) -> Result<StreamPacket, fidl::Error> {
2443            let _response = fidl::client::decode_transaction_body::<
2444                AudioCapturerCaptureAtResponse,
2445                fidl::encoding::DefaultFuchsiaResourceDialect,
2446                0x784e25df72cea780,
2447            >(_buf?)?;
2448            Ok(_response.captured_packet)
2449        }
2450        self.client.send_query_and_decode::<AudioCapturerCaptureAtRequest, StreamPacket>(
2451            (payload_buffer_id, payload_offset, frames),
2452            0x784e25df72cea780,
2453            fidl::encoding::DynamicFlags::empty(),
2454            _decode,
2455        )
2456    }
2457
2458    fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
2459        self.client.send::<AudioCapturerStartAsyncCaptureRequest>(
2460            (frames_per_packet,),
2461            0x7768adbb1ccfd7a6,
2462            fidl::encoding::DynamicFlags::empty(),
2463        )
2464    }
2465
2466    type StopAsyncCaptureResponseFut =
2467        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2468    fn r#stop_async_capture(&self) -> Self::StopAsyncCaptureResponseFut {
2469        fn _decode(
2470            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2471        ) -> Result<(), fidl::Error> {
2472            let _response = fidl::client::decode_transaction_body::<
2473                fidl::encoding::EmptyPayload,
2474                fidl::encoding::DefaultFuchsiaResourceDialect,
2475                0x5bfc8790a8cef8cb,
2476            >(_buf?)?;
2477            Ok(_response)
2478        }
2479        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2480            (),
2481            0x5bfc8790a8cef8cb,
2482            fidl::encoding::DynamicFlags::empty(),
2483            _decode,
2484        )
2485    }
2486
2487    fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
2488        self.client.send::<fidl::encoding::EmptyPayload>(
2489            (),
2490            0x33223cb2962c95e3,
2491            fidl::encoding::DynamicFlags::empty(),
2492        )
2493    }
2494
2495    fn r#bind_gain_control(
2496        &self,
2497        mut gain_control_request: fidl::endpoints::ServerEnd<
2498            fidl_fuchsia_media_audio::GainControlMarker,
2499        >,
2500    ) -> Result<(), fidl::Error> {
2501        self.client.send::<AudioCapturerBindGainControlRequest>(
2502            (gain_control_request,),
2503            0x658a6a17ddb3a8e0,
2504            fidl::encoding::DynamicFlags::empty(),
2505        )
2506    }
2507
2508    type GetReferenceClockResponseFut =
2509        fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>;
2510    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
2511        fn _decode(
2512            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2513        ) -> Result<fidl::Clock, fidl::Error> {
2514            let _response = fidl::client::decode_transaction_body::<
2515                AudioCapturerGetReferenceClockResponse,
2516                fidl::encoding::DefaultFuchsiaResourceDialect,
2517                0x50d037aa5a4b4d71,
2518            >(_buf?)?;
2519            Ok(_response.reference_clock)
2520        }
2521        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Clock>(
2522            (),
2523            0x50d037aa5a4b4d71,
2524            fidl::encoding::DynamicFlags::empty(),
2525            _decode,
2526        )
2527    }
2528
2529    fn r#set_reference_clock(
2530        &self,
2531        mut reference_clock: Option<fidl::Clock>,
2532    ) -> Result<(), fidl::Error> {
2533        self.client.send::<AudioCapturerSetReferenceClockRequest>(
2534            (reference_clock,),
2535            0x732b2c496d521bcf,
2536            fidl::encoding::DynamicFlags::empty(),
2537        )
2538    }
2539
2540    fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2541        self.client.send::<AudioCapturerSetUsageRequest>(
2542            (usage,),
2543            0x42a16f392bd21b25,
2544            fidl::encoding::DynamicFlags::empty(),
2545        )
2546    }
2547
2548    fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2549        self.client.send::<AudioCapturerSetUsage2Request>(
2550            (usage,),
2551            0x7a73e251b8d2382b,
2552            fidl::encoding::DynamicFlags::FLEXIBLE,
2553        )
2554    }
2555
2556    type GetStreamTypeResponseFut =
2557        fidl::client::QueryResponseFut<StreamType, fidl::encoding::DefaultFuchsiaResourceDialect>;
2558    fn r#get_stream_type(&self) -> Self::GetStreamTypeResponseFut {
2559        fn _decode(
2560            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2561        ) -> Result<StreamType, fidl::Error> {
2562            let _response = fidl::client::decode_transaction_body::<
2563                AudioCapturerGetStreamTypeResponse,
2564                fidl::encoding::DefaultFuchsiaResourceDialect,
2565                0x5dcaaa670b433088,
2566            >(_buf?)?;
2567            Ok(_response.stream_type)
2568        }
2569        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, StreamType>(
2570            (),
2571            0x5dcaaa670b433088,
2572            fidl::encoding::DynamicFlags::empty(),
2573            _decode,
2574        )
2575    }
2576}
2577
2578pub struct AudioCapturerEventStream {
2579    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2580}
2581
2582impl std::marker::Unpin for AudioCapturerEventStream {}
2583
2584impl futures::stream::FusedStream for AudioCapturerEventStream {
2585    fn is_terminated(&self) -> bool {
2586        self.event_receiver.is_terminated()
2587    }
2588}
2589
2590impl futures::Stream for AudioCapturerEventStream {
2591    type Item = Result<AudioCapturerEvent, fidl::Error>;
2592
2593    fn poll_next(
2594        mut self: std::pin::Pin<&mut Self>,
2595        cx: &mut std::task::Context<'_>,
2596    ) -> std::task::Poll<Option<Self::Item>> {
2597        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2598            &mut self.event_receiver,
2599            cx
2600        )?) {
2601            Some(buf) => std::task::Poll::Ready(Some(AudioCapturerEvent::decode(buf))),
2602            None => std::task::Poll::Ready(None),
2603        }
2604    }
2605}
2606
2607#[derive(Debug)]
2608pub enum AudioCapturerEvent {
2609    OnPacketProduced {
2610        packet: StreamPacket,
2611    },
2612    OnEndOfStream {},
2613    #[non_exhaustive]
2614    _UnknownEvent {
2615        /// Ordinal of the event that was sent.
2616        ordinal: u64,
2617    },
2618}
2619
2620impl AudioCapturerEvent {
2621    #[allow(irrefutable_let_patterns)]
2622    pub fn into_on_packet_produced(self) -> Option<StreamPacket> {
2623        if let AudioCapturerEvent::OnPacketProduced { packet } = self {
2624            Some((packet))
2625        } else {
2626            None
2627        }
2628    }
2629    #[allow(irrefutable_let_patterns)]
2630    pub fn into_on_end_of_stream(self) -> Option<()> {
2631        if let AudioCapturerEvent::OnEndOfStream {} = self { Some(()) } else { None }
2632    }
2633
2634    /// Decodes a message buffer as a [`AudioCapturerEvent`].
2635    fn decode(
2636        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2637    ) -> Result<AudioCapturerEvent, fidl::Error> {
2638        let (bytes, _handles) = buf.split_mut();
2639        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2640        debug_assert_eq!(tx_header.tx_id, 0);
2641        match tx_header.ordinal {
2642            0x6bbe69746a3c8bd9 => {
2643                let mut out = fidl::new_empty!(
2644                    StreamSourceOnPacketProducedRequest,
2645                    fidl::encoding::DefaultFuchsiaResourceDialect
2646                );
2647                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2648                Ok((AudioCapturerEvent::OnPacketProduced { packet: out.packet }))
2649            }
2650            0x550e69b41d03e2c2 => {
2651                let mut out = fidl::new_empty!(
2652                    fidl::encoding::EmptyPayload,
2653                    fidl::encoding::DefaultFuchsiaResourceDialect
2654                );
2655                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
2656                Ok((AudioCapturerEvent::OnEndOfStream {}))
2657            }
2658            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2659                Ok(AudioCapturerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2660            }
2661            _ => Err(fidl::Error::UnknownOrdinal {
2662                ordinal: tx_header.ordinal,
2663                protocol_name: <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2664            }),
2665        }
2666    }
2667}
2668
2669/// A Stream of incoming requests for fuchsia.media/AudioCapturer.
2670pub struct AudioCapturerRequestStream {
2671    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2672    is_terminated: bool,
2673}
2674
2675impl std::marker::Unpin for AudioCapturerRequestStream {}
2676
2677impl futures::stream::FusedStream for AudioCapturerRequestStream {
2678    fn is_terminated(&self) -> bool {
2679        self.is_terminated
2680    }
2681}
2682
2683impl fidl::endpoints::RequestStream for AudioCapturerRequestStream {
2684    type Protocol = AudioCapturerMarker;
2685    type ControlHandle = AudioCapturerControlHandle;
2686
2687    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2688        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2689    }
2690
2691    fn control_handle(&self) -> Self::ControlHandle {
2692        AudioCapturerControlHandle { inner: self.inner.clone() }
2693    }
2694
2695    fn into_inner(
2696        self,
2697    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2698    {
2699        (self.inner, self.is_terminated)
2700    }
2701
2702    fn from_inner(
2703        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2704        is_terminated: bool,
2705    ) -> Self {
2706        Self { inner, is_terminated }
2707    }
2708}
2709
2710impl futures::Stream for AudioCapturerRequestStream {
2711    type Item = Result<AudioCapturerRequest, fidl::Error>;
2712
2713    fn poll_next(
2714        mut self: std::pin::Pin<&mut Self>,
2715        cx: &mut std::task::Context<'_>,
2716    ) -> std::task::Poll<Option<Self::Item>> {
2717        let this = &mut *self;
2718        if this.inner.check_shutdown(cx) {
2719            this.is_terminated = true;
2720            return std::task::Poll::Ready(None);
2721        }
2722        if this.is_terminated {
2723            panic!("polled AudioCapturerRequestStream after completion");
2724        }
2725        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2726            |bytes, handles| {
2727                match this.inner.channel().read_etc(cx, bytes, handles) {
2728                    std::task::Poll::Ready(Ok(())) => {}
2729                    std::task::Poll::Pending => return std::task::Poll::Pending,
2730                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2731                        this.is_terminated = true;
2732                        return std::task::Poll::Ready(None);
2733                    }
2734                    std::task::Poll::Ready(Err(e)) => {
2735                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2736                            e.into(),
2737                        ))));
2738                    }
2739                }
2740
2741                // A message has been received from the channel
2742                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2743
2744                std::task::Poll::Ready(Some(match header.ordinal {
2745                    0x3b3a37fc34fe5b56 => {
2746                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2747                        let mut req = fidl::new_empty!(
2748                            StreamBufferSetAddPayloadBufferRequest,
2749                            fidl::encoding::DefaultFuchsiaResourceDialect
2750                        );
2751                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
2752                        let control_handle =
2753                            AudioCapturerControlHandle { inner: this.inner.clone() };
2754                        Ok(AudioCapturerRequest::AddPayloadBuffer {
2755                            id: req.id,
2756                            payload_buffer: req.payload_buffer,
2757
2758                            control_handle,
2759                        })
2760                    }
2761                    0x5d1e4f74c3658262 => {
2762                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2763                        let mut req = fidl::new_empty!(
2764                            StreamBufferSetRemovePayloadBufferRequest,
2765                            fidl::encoding::DefaultFuchsiaResourceDialect
2766                        );
2767                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
2768                        let control_handle =
2769                            AudioCapturerControlHandle { inner: this.inner.clone() };
2770                        Ok(AudioCapturerRequest::RemovePayloadBuffer { id: req.id, control_handle })
2771                    }
2772                    0x7a7b57f0f7d9e4bb => {
2773                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2774                        let mut req = fidl::new_empty!(
2775                            StreamSourceReleasePacketRequest,
2776                            fidl::encoding::DefaultFuchsiaResourceDialect
2777                        );
2778                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
2779                        let control_handle =
2780                            AudioCapturerControlHandle { inner: this.inner.clone() };
2781                        Ok(AudioCapturerRequest::ReleasePacket {
2782                            packet: req.packet,
2783
2784                            control_handle,
2785                        })
2786                    }
2787                    0x27afd605e97b09d2 => {
2788                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2789                        let mut req = fidl::new_empty!(
2790                            fidl::encoding::EmptyPayload,
2791                            fidl::encoding::DefaultFuchsiaResourceDialect
2792                        );
2793                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2794                        let control_handle =
2795                            AudioCapturerControlHandle { inner: this.inner.clone() };
2796                        Ok(AudioCapturerRequest::DiscardAllPackets {
2797                            responder: AudioCapturerDiscardAllPacketsResponder {
2798                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2799                                tx_id: header.tx_id,
2800                            },
2801                        })
2802                    }
2803                    0x35f9d721e905b831 => {
2804                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2805                        let mut req = fidl::new_empty!(
2806                            fidl::encoding::EmptyPayload,
2807                            fidl::encoding::DefaultFuchsiaResourceDialect
2808                        );
2809                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2810                        let control_handle =
2811                            AudioCapturerControlHandle { inner: this.inner.clone() };
2812                        Ok(AudioCapturerRequest::DiscardAllPacketsNoReply { control_handle })
2813                    }
2814                    0x1531ea9ea2c852cd => {
2815                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2816                        let mut req = fidl::new_empty!(
2817                            AudioCapturerSetPcmStreamTypeRequest,
2818                            fidl::encoding::DefaultFuchsiaResourceDialect
2819                        );
2820                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetPcmStreamTypeRequest>(&header, _body_bytes, handles, &mut req)?;
2821                        let control_handle =
2822                            AudioCapturerControlHandle { inner: this.inner.clone() };
2823                        Ok(AudioCapturerRequest::SetPcmStreamType {
2824                            stream_type: req.stream_type,
2825
2826                            control_handle,
2827                        })
2828                    }
2829                    0x784e25df72cea780 => {
2830                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2831                        let mut req = fidl::new_empty!(
2832                            AudioCapturerCaptureAtRequest,
2833                            fidl::encoding::DefaultFuchsiaResourceDialect
2834                        );
2835                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerCaptureAtRequest>(&header, _body_bytes, handles, &mut req)?;
2836                        let control_handle =
2837                            AudioCapturerControlHandle { inner: this.inner.clone() };
2838                        Ok(AudioCapturerRequest::CaptureAt {
2839                            payload_buffer_id: req.payload_buffer_id,
2840                            payload_offset: req.payload_offset,
2841                            frames: req.frames,
2842
2843                            responder: AudioCapturerCaptureAtResponder {
2844                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2845                                tx_id: header.tx_id,
2846                            },
2847                        })
2848                    }
2849                    0x7768adbb1ccfd7a6 => {
2850                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2851                        let mut req = fidl::new_empty!(
2852                            AudioCapturerStartAsyncCaptureRequest,
2853                            fidl::encoding::DefaultFuchsiaResourceDialect
2854                        );
2855                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerStartAsyncCaptureRequest>(&header, _body_bytes, handles, &mut req)?;
2856                        let control_handle =
2857                            AudioCapturerControlHandle { inner: this.inner.clone() };
2858                        Ok(AudioCapturerRequest::StartAsyncCapture {
2859                            frames_per_packet: req.frames_per_packet,
2860
2861                            control_handle,
2862                        })
2863                    }
2864                    0x5bfc8790a8cef8cb => {
2865                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2866                        let mut req = fidl::new_empty!(
2867                            fidl::encoding::EmptyPayload,
2868                            fidl::encoding::DefaultFuchsiaResourceDialect
2869                        );
2870                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2871                        let control_handle =
2872                            AudioCapturerControlHandle { inner: this.inner.clone() };
2873                        Ok(AudioCapturerRequest::StopAsyncCapture {
2874                            responder: AudioCapturerStopAsyncCaptureResponder {
2875                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2876                                tx_id: header.tx_id,
2877                            },
2878                        })
2879                    }
2880                    0x33223cb2962c95e3 => {
2881                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2882                        let mut req = fidl::new_empty!(
2883                            fidl::encoding::EmptyPayload,
2884                            fidl::encoding::DefaultFuchsiaResourceDialect
2885                        );
2886                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2887                        let control_handle =
2888                            AudioCapturerControlHandle { inner: this.inner.clone() };
2889                        Ok(AudioCapturerRequest::StopAsyncCaptureNoReply { control_handle })
2890                    }
2891                    0x658a6a17ddb3a8e0 => {
2892                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2893                        let mut req = fidl::new_empty!(
2894                            AudioCapturerBindGainControlRequest,
2895                            fidl::encoding::DefaultFuchsiaResourceDialect
2896                        );
2897                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerBindGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
2898                        let control_handle =
2899                            AudioCapturerControlHandle { inner: this.inner.clone() };
2900                        Ok(AudioCapturerRequest::BindGainControl {
2901                            gain_control_request: req.gain_control_request,
2902
2903                            control_handle,
2904                        })
2905                    }
2906                    0x50d037aa5a4b4d71 => {
2907                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2908                        let mut req = fidl::new_empty!(
2909                            fidl::encoding::EmptyPayload,
2910                            fidl::encoding::DefaultFuchsiaResourceDialect
2911                        );
2912                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2913                        let control_handle =
2914                            AudioCapturerControlHandle { inner: this.inner.clone() };
2915                        Ok(AudioCapturerRequest::GetReferenceClock {
2916                            responder: AudioCapturerGetReferenceClockResponder {
2917                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2918                                tx_id: header.tx_id,
2919                            },
2920                        })
2921                    }
2922                    0x732b2c496d521bcf => {
2923                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2924                        let mut req = fidl::new_empty!(
2925                            AudioCapturerSetReferenceClockRequest,
2926                            fidl::encoding::DefaultFuchsiaResourceDialect
2927                        );
2928                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetReferenceClockRequest>(&header, _body_bytes, handles, &mut req)?;
2929                        let control_handle =
2930                            AudioCapturerControlHandle { inner: this.inner.clone() };
2931                        Ok(AudioCapturerRequest::SetReferenceClock {
2932                            reference_clock: req.reference_clock,
2933
2934                            control_handle,
2935                        })
2936                    }
2937                    0x42a16f392bd21b25 => {
2938                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2939                        let mut req = fidl::new_empty!(
2940                            AudioCapturerSetUsageRequest,
2941                            fidl::encoding::DefaultFuchsiaResourceDialect
2942                        );
2943                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetUsageRequest>(&header, _body_bytes, handles, &mut req)?;
2944                        let control_handle =
2945                            AudioCapturerControlHandle { inner: this.inner.clone() };
2946                        Ok(AudioCapturerRequest::SetUsage { usage: req.usage, control_handle })
2947                    }
2948                    0x7a73e251b8d2382b => {
2949                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2950                        let mut req = fidl::new_empty!(
2951                            AudioCapturerSetUsage2Request,
2952                            fidl::encoding::DefaultFuchsiaResourceDialect
2953                        );
2954                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetUsage2Request>(&header, _body_bytes, handles, &mut req)?;
2955                        let control_handle =
2956                            AudioCapturerControlHandle { inner: this.inner.clone() };
2957                        Ok(AudioCapturerRequest::SetUsage2 { usage: req.usage, control_handle })
2958                    }
2959                    0x5dcaaa670b433088 => {
2960                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2961                        let mut req = fidl::new_empty!(
2962                            fidl::encoding::EmptyPayload,
2963                            fidl::encoding::DefaultFuchsiaResourceDialect
2964                        );
2965                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2966                        let control_handle =
2967                            AudioCapturerControlHandle { inner: this.inner.clone() };
2968                        Ok(AudioCapturerRequest::GetStreamType {
2969                            responder: AudioCapturerGetStreamTypeResponder {
2970                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2971                                tx_id: header.tx_id,
2972                            },
2973                        })
2974                    }
2975                    _ if header.tx_id == 0
2976                        && header
2977                            .dynamic_flags()
2978                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2979                    {
2980                        Ok(AudioCapturerRequest::_UnknownMethod {
2981                            ordinal: header.ordinal,
2982                            control_handle: AudioCapturerControlHandle {
2983                                inner: this.inner.clone(),
2984                            },
2985                            method_type: fidl::MethodType::OneWay,
2986                        })
2987                    }
2988                    _ if header
2989                        .dynamic_flags()
2990                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2991                    {
2992                        this.inner.send_framework_err(
2993                            fidl::encoding::FrameworkErr::UnknownMethod,
2994                            header.tx_id,
2995                            header.ordinal,
2996                            header.dynamic_flags(),
2997                            (bytes, handles),
2998                        )?;
2999                        Ok(AudioCapturerRequest::_UnknownMethod {
3000                            ordinal: header.ordinal,
3001                            control_handle: AudioCapturerControlHandle {
3002                                inner: this.inner.clone(),
3003                            },
3004                            method_type: fidl::MethodType::TwoWay,
3005                        })
3006                    }
3007                    _ => Err(fidl::Error::UnknownOrdinal {
3008                        ordinal: header.ordinal,
3009                        protocol_name:
3010                            <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3011                    }),
3012                }))
3013            },
3014        )
3015    }
3016}
3017
3018/// AudioCapturer
3019///
3020/// An AudioCapturer is an interface returned from an fuchsia.media.Audio's
3021/// CreateAudioCapturer method, which may be used by clients to capture audio
3022/// from either the current default audio input device, or the current default
3023/// audio output device depending on the flags passed during creation.
3024///
3025/// **Format support**
3026///
3027/// See (Get|Set)StreamType below. By default, the captured stream type will be
3028/// initially determined by the currently configured stream type of the source
3029/// that the AudioCapturer was bound to at creation time. Users may either fetch
3030/// this type using GetStreamType, or they may choose to have the media
3031/// resampled or converted to a type of their choosing by calling SetStreamType.
3032/// Note: the stream type may only be set while the system is not running,
3033/// meaning that there are no pending capture regions (specified using CaptureAt)
3034/// and that the system is not currently running in 'async' capture mode.
3035///
3036/// **Buffers and memory management**
3037///
3038/// Audio data is captured into a shared memory buffer (a VMO) supplied by the
3039/// user to the AudioCapturer during the AddPayloadBuffer call. Please note the
3040/// following requirements related to the management of the payload buffer.
3041///
3042/// + The payload buffer must be supplied before any capture operation may
3043///   start. Any attempt to start capture (via either CaptureAt or
3044///   StartAsyncCapture) before a payload buffer has been established is an
3045///   error.
3046/// + The payload buffer may not be changed while there are any capture
3047///   operations pending.
3048/// + The stream type may not be changed after the payload buffer has been set.
3049/// + The payload buffer must be an integral number of audio frame sizes (in
3050///   bytes)
3051/// + When running in 'async' mode (see below), the payload buffer must be at
3052///   least as large as twice the frames_per_packet size specified during
3053///   StartAsyncCapture.
3054/// + The handle to the payload buffer supplied by the user must be readable,
3055///   writable, mappable and transferable.
3056/// + Users should always treat the payload buffer as read-only.
3057///
3058/// **Synchronous vs. Asynchronous capture mode**
3059///
3060/// The AudioCapturer interface can be used in one of two mutually exclusive
3061/// modes: Synchronous and Asynchronous. A description of each mode and their
3062/// tradeoffs is given below.
3063///
3064/// **Synchronous mode**
3065///
3066/// By default, AudioCapturer instances are running in 'sync' mode. They will
3067/// only capture data when a user supplies at least one region to capture into
3068/// using the CaptureAt method. Regions supplied in this way will be filled in
3069/// the order that they are received and returned to the client as StreamPackets
3070/// via the return value of the CaptureAt method. If an AudioCapturer instance
3071/// has data to capture, but no place to put it (because there are no more
3072/// pending regions to fill), the next payload generated will indicate that their
3073/// has been an overflow by setting the Discontinuity flag on the next produced
3074/// StreamPacket. Synchronous mode may not be used in conjunction with
3075/// Asynchronous mode. It is an error to attempt to call StartAsyncCapture while
3076/// the system still regions supplied by CaptureAt waiting to be filled.
3077///
3078/// If a user has supplied regions to be filled by the AudioCapturer instance in
3079/// the past, but wishes to reclaim those regions, they may do so using the
3080/// DiscardAllPackets method. Calling the DiscardAllPackets method will cause
3081/// all pending regions to be returned, but with `NO_TIMESTAMP` as their
3082/// StreamPacket's PTS. See "Timing and Overflows", below, for a discussion of
3083/// timestamps and discontinuity flags. After a DiscardAllPackets operation,
3084/// an OnEndOfStream event will be produced. While an AudioCapturer will never
3085/// overwrite any region of the payload buffer after a completed region is
3086/// returned, it may overwrite the unfilled portions of a partially filled
3087/// buffer which has been returned as a result of a DiscardAllPackets operation.
3088///
3089/// **Asynchronous mode**
3090///
3091/// While running in 'async' mode, clients do not need to explicitly supply
3092/// shared buffer regions to be filled by the AudioCapturer instance. Instead, a
3093/// client enters into 'async' mode by calling StartAsyncCapture and supplying a
3094/// callback interface and the number of frames to capture per-callback. Once
3095/// running in async mode, the AudioCapturer instance will identify which
3096/// payload buffer regions to capture into, capture the specified number of
3097/// frames, then deliver those frames as StreamPackets using the OnPacketCapture
3098/// FIDL event. Users may stop capturing and return the AudioCapturer instance to
3099/// 'sync' mode using the StopAsyncCapture method.
3100///
3101/// It is considered an error to attempt any of the following operations.
3102///
3103/// + To attempt to enter 'async' capture mode when no payload buffer has been
3104///   established.
3105/// + To specify a number of frames to capture per payload which does not permit
3106///   at least two contiguous capture payloads to exist in the established
3107///   shared payload buffer simultaneously.
3108/// + To send a region to capture into using the CaptureAt method while the
3109///   AudioCapturer instance is running in 'async' mode.
3110/// + To attempt to call DiscardAllPackets while the AudioCapturer instance is
3111///   running in 'async' mode.
3112/// + To attempt to re-start 'async' mode capturing without having first
3113///   stopped.
3114/// + To attempt any operation except for SetGain while in the process of
3115///   stopping.
3116///
3117/// **Synchronizing with a StopAsyncCapture operation**
3118///
3119/// Stopping asynchronous capture mode and returning to synchronous capture mode
3120/// is an operation which takes time. Aside from SetGain, users may not call any
3121/// other methods on the AudioCapturer interface after calling StopAsyncCapture
3122/// (including calling StopAsyncCapture again) until after the stop operation has
3123/// completed. Because of this, it is important for users to be able to
3124/// synchronize with the stop operation. Two mechanisms are provided for doing
3125/// so.
3126///
3127/// The first is to use StopAsyncCapture (not the NoReply variant). When the user's
3128/// callback has been called, they can be certain that stop operation is complete
3129/// and that the AudioCapturer instance has returned to synchronous operation
3130/// mode.
3131///
3132/// The second way to determine that a stop operation has completed is to use the
3133/// flags on the packets which get delivered via the user-supplied
3134/// AudioCapturerCallback interface after calling StopAsyncCapture. When
3135/// asked to stop, any partially filled packet will be returned to the user, and
3136/// the final packet returned will always have the end-of-stream flag (kFlagsEos)
3137/// set on it to indicate that this is the final frame in the sequence. If
3138/// there is no partially filled packet to return, the AudioCapturer will
3139/// synthesize an empty packet with no timestamp, and offset/length set to zero,
3140/// in order to deliver a packet with the end-of-stream flag set on it. Once
3141/// users have seen the end-of-stream flag after calling stop, the AudioCapturer
3142/// has finished the stop operation and returned to synchronous operating mode.
3143///
3144/// **Timing and Overflows**
3145///
3146/// All media packets produced by an AudioCapturer instance will have their PTS
3147/// field filled out with the capture time of the audio expressed as a timestamp
3148/// given by the reference clock timeline. Note: this timestamp is actually a
3149/// capture timestamp, not a presentation timestamp (it is more of a CTS than a
3150/// PTS) and is meant to represent the underlying system's best estimate of the
3151/// capture time of the first frame of audio, including all outboard and hardware
3152/// introduced buffering delay. As a result, all timestamps produced by an
3153/// AudioCapturer should be expected to be in the past relative to 'now' on the
3154/// stream's reference clock timeline.
3155///
3156/// The one exception to the "everything has an explicit timestamp" rule is when
3157/// discarding submitted regions while operating in synchronous mode. Discarded
3158/// packets have no data in them, but FIDL demands that all pending
3159/// method-return-value callbacks be executed. Because of this, the regions will
3160/// be returned to the user, but their timestamps will be set to
3161/// `NO_TIMESTAMP`, and their payload sizes will be set to zero. Any
3162/// partially filled payload will have a valid timestamp, but a payload size
3163/// smaller than originally requested. The final discarded payload (if there
3164/// were any to discard) will be followed by an OnEndOfStream event.
3165///
3166/// Two StreamPackets delivered by an AudioCapturer instance are 'continuous' if
3167/// the first frame of audio contained in the second packet was captured exactly
3168/// one nominal frame time after the final frame of audio in the first packet.
3169/// If this relationship does not hold, the second StreamPacket will have the
3170/// `STREAM_PACKET_FLAG_DISCONTINUITY` bit set in its `flags` field.
3171///
3172/// Even though explicit timestamps are provided on every StreamPacket produced,
3173/// users who have very precise timing requirements are encouraged to always
3174/// reason about time by counting frames delivered since the last discontinuity,
3175/// rather than simply using the raw capture timestamps. This is because the
3176/// explicit timestamps written on continuous packets may have a small amount of
3177/// rounding error based on whether or not the units of the capture timeline
3178/// reference clock are divisible by the chosen audio frame rate.
3179///
3180/// Users should always expect the first StreamPacket produced by an
3181/// AudioCapturer to have the discontinuous flag set on it (as there is no
3182/// previous packet to be continuous with). Similarly, the first StreamPacket
3183/// after a DiscardAllPackets or a Stop/Start cycle will always be
3184/// discontinuous. After that, there are only two reasons that a StreamPacket
3185/// will ever be discontinuous:
3186///
3187/// 1. The user is operating in synchronous mode and does not supply regions to
3188///    be filled quickly enough. If the next continuous frame of data has not
3189///    been captured by the time it needs to be purged from the source buffers,
3190///    an overflow has occurred and the AudioCapturer will flag the next captured
3191///    region as discontinuous.
3192/// 2. The user is operating in asynchronous mode and some internal error
3193///    prevents the AudioCapturer instance from capturing the next frame of audio
3194///    in a continuous fashion. This might be high system load or a hardware
3195///    error, but in general it is something which should never normally happen.
3196///    In practice, however, if it does, the next produced packet will be flagged
3197///    as being discontinuous.
3198///
3199/// **Synchronous vs. Asynchronous Trade-offs**
3200///
3201/// The choice of operating in synchronous vs. asynchronous mode is up to the
3202/// user, and depending on the user's requirements, there are some advantages and
3203/// disadvantages to each choice.
3204///
3205/// Synchronous mode requires only a single Zircon channel under the hood and can
3206/// achieve some small savings because of this. In addition, the user has
3207/// complete control over the buffer management. Users specify exactly where
3208/// audio will be captured to and in what order. Because of this, if users do
3209/// not need to always be capturing, it is simple to stop and restart the capture
3210/// later (just by ceasing to supply packets, then resuming later on). Payloads
3211/// do not need to be uniform in size either, clients may specify payloads of
3212/// whatever granularity is appropriate.
3213///
3214/// The primary downside of operating in synchronous mode is that two messages
3215/// will need to be sent for every packet to be captured. One to inform the
3216/// AudioCapturer of the instance to capture into, and one to inform the user
3217/// that the packet has been captured. This may end up increasing overhead and
3218/// potentially complicating client designs.
3219///
3220/// Asynchronous mode has the advantage requiring only 1/2 of the messages,
3221/// however, when operating in 'async' mode, AudioCapturer instances have no way
3222/// of knowing if a user is processing the StreamPackets being sent in a timely
3223/// fashion, and no way of automatically detecting an overflow condition. Users
3224/// of 'async' mode should be careful to use a buffer large enough to ensure that
3225/// they will be able to process their data before an AudioCapturer will be
3226/// forced to overwrite it.
3227#[derive(Debug)]
3228pub enum AudioCapturerRequest {
3229    /// Adds a payload buffer to the current buffer set associated with the
3230    /// connection. A `StreamPacket` struct reference a payload buffer in the
3231    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
3232    ///
3233    /// A buffer with ID `id` must not be in the current set when this method is
3234    /// invoked, otherwise the service will close the connection.
3235    AddPayloadBuffer {
3236        id: u32,
3237        payload_buffer: fidl::Vmo,
3238        control_handle: AudioCapturerControlHandle,
3239    },
3240    /// Removes a payload buffer from the current buffer set associated with the
3241    /// connection.
3242    ///
3243    /// A buffer with ID `id` must exist in the current set when this method is
3244    /// invoked, otherwise the service will will close the connection.
3245    RemovePayloadBuffer {
3246        id: u32,
3247        control_handle: AudioCapturerControlHandle,
3248    },
3249    /// Releases payload memory associated with a packet previously delivered
3250    /// via `OnPacketProduced`.
3251    ReleasePacket {
3252        packet: StreamPacket,
3253        control_handle: AudioCapturerControlHandle,
3254    },
3255    DiscardAllPackets {
3256        responder: AudioCapturerDiscardAllPacketsResponder,
3257    },
3258    DiscardAllPacketsNoReply {
3259        control_handle: AudioCapturerControlHandle,
3260    },
3261    /// Sets the stream type of the stream to be delivered. Causes the source
3262    /// material to be reformatted/resampled if needed in order to produce the
3263    /// requested stream type. Must be called before the payload buffer is
3264    /// established.
3265    SetPcmStreamType {
3266        stream_type: AudioStreamType,
3267        control_handle: AudioCapturerControlHandle,
3268    },
3269    /// Explicitly specifies a region of the shared payload buffer for the audio
3270    /// input to capture into.
3271    CaptureAt {
3272        payload_buffer_id: u32,
3273        payload_offset: u32,
3274        frames: u32,
3275        responder: AudioCapturerCaptureAtResponder,
3276    },
3277    /// Places the AudioCapturer into 'async' capture mode and begin to produce
3278    /// packets of exactly 'frames_per_packet' number of frames each. The
3279    /// OnPacketProduced event (of StreamSink) will be used to inform the client
3280    /// of produced packets.
3281    StartAsyncCapture {
3282        frames_per_packet: u32,
3283        control_handle: AudioCapturerControlHandle,
3284    },
3285    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
3286    /// that may be used by the client if explicit synchronization is needed.
3287    StopAsyncCapture {
3288        responder: AudioCapturerStopAsyncCaptureResponder,
3289    },
3290    StopAsyncCaptureNoReply {
3291        control_handle: AudioCapturerControlHandle,
3292    },
3293    /// Binds to the gain control for this AudioCapturer.
3294    BindGainControl {
3295        gain_control_request:
3296            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
3297        control_handle: AudioCapturerControlHandle,
3298    },
3299    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
3300    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
3301    GetReferenceClock {
3302        responder: AudioCapturerGetReferenceClockResponder,
3303    },
3304    /// Sets the reference clock that controls this capturer's playback rate. If the input
3305    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
3306    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
3307    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
3308    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
3309    ///
3310    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
3311    /// added. It also cannot be called a second time (even before capture).
3312    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
3313    /// diverge at some later time, they should create a clone of the monotonic clock, set
3314    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
3315    SetReferenceClock {
3316        reference_clock: Option<fidl::Clock>,
3317        control_handle: AudioCapturerControlHandle,
3318    },
3319    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
3320    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
3321    SetUsage {
3322        usage: AudioCaptureUsage,
3323        control_handle: AudioCapturerControlHandle,
3324    },
3325    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
3326    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
3327    SetUsage2 {
3328        usage: AudioCaptureUsage2,
3329        control_handle: AudioCapturerControlHandle,
3330    },
3331    /// Gets the currently configured stream type. Note: for an AudioCapturer
3332    /// which was just created and has not yet had its stream type explicitly
3333    /// set, this will retrieve the stream type -- at the time the AudioCapturer
3334    /// was created -- of the source (input or looped-back output) to which the
3335    /// AudioCapturer is bound. Even if this matches the client's desired format,
3336    /// `SetPcmStreamType` must still be called.
3337    GetStreamType {
3338        responder: AudioCapturerGetStreamTypeResponder,
3339    },
3340    /// An interaction was received which does not match any known method.
3341    #[non_exhaustive]
3342    _UnknownMethod {
3343        /// Ordinal of the method that was called.
3344        ordinal: u64,
3345        control_handle: AudioCapturerControlHandle,
3346        method_type: fidl::MethodType,
3347    },
3348}
3349
3350impl AudioCapturerRequest {
3351    #[allow(irrefutable_let_patterns)]
3352    pub fn into_add_payload_buffer(self) -> Option<(u32, fidl::Vmo, AudioCapturerControlHandle)> {
3353        if let AudioCapturerRequest::AddPayloadBuffer { id, payload_buffer, control_handle } = self
3354        {
3355            Some((id, payload_buffer, control_handle))
3356        } else {
3357            None
3358        }
3359    }
3360
3361    #[allow(irrefutable_let_patterns)]
3362    pub fn into_remove_payload_buffer(self) -> Option<(u32, AudioCapturerControlHandle)> {
3363        if let AudioCapturerRequest::RemovePayloadBuffer { id, control_handle } = self {
3364            Some((id, control_handle))
3365        } else {
3366            None
3367        }
3368    }
3369
3370    #[allow(irrefutable_let_patterns)]
3371    pub fn into_release_packet(self) -> Option<(StreamPacket, AudioCapturerControlHandle)> {
3372        if let AudioCapturerRequest::ReleasePacket { packet, control_handle } = self {
3373            Some((packet, control_handle))
3374        } else {
3375            None
3376        }
3377    }
3378
3379    #[allow(irrefutable_let_patterns)]
3380    pub fn into_discard_all_packets(self) -> Option<(AudioCapturerDiscardAllPacketsResponder)> {
3381        if let AudioCapturerRequest::DiscardAllPackets { responder } = self {
3382            Some((responder))
3383        } else {
3384            None
3385        }
3386    }
3387
3388    #[allow(irrefutable_let_patterns)]
3389    pub fn into_discard_all_packets_no_reply(self) -> Option<(AudioCapturerControlHandle)> {
3390        if let AudioCapturerRequest::DiscardAllPacketsNoReply { control_handle } = self {
3391            Some((control_handle))
3392        } else {
3393            None
3394        }
3395    }
3396
3397    #[allow(irrefutable_let_patterns)]
3398    pub fn into_set_pcm_stream_type(self) -> Option<(AudioStreamType, AudioCapturerControlHandle)> {
3399        if let AudioCapturerRequest::SetPcmStreamType { stream_type, control_handle } = self {
3400            Some((stream_type, control_handle))
3401        } else {
3402            None
3403        }
3404    }
3405
3406    #[allow(irrefutable_let_patterns)]
3407    pub fn into_capture_at(self) -> Option<(u32, u32, u32, AudioCapturerCaptureAtResponder)> {
3408        if let AudioCapturerRequest::CaptureAt {
3409            payload_buffer_id,
3410            payload_offset,
3411            frames,
3412            responder,
3413        } = self
3414        {
3415            Some((payload_buffer_id, payload_offset, frames, responder))
3416        } else {
3417            None
3418        }
3419    }
3420
3421    #[allow(irrefutable_let_patterns)]
3422    pub fn into_start_async_capture(self) -> Option<(u32, AudioCapturerControlHandle)> {
3423        if let AudioCapturerRequest::StartAsyncCapture { frames_per_packet, control_handle } = self
3424        {
3425            Some((frames_per_packet, control_handle))
3426        } else {
3427            None
3428        }
3429    }
3430
3431    #[allow(irrefutable_let_patterns)]
3432    pub fn into_stop_async_capture(self) -> Option<(AudioCapturerStopAsyncCaptureResponder)> {
3433        if let AudioCapturerRequest::StopAsyncCapture { responder } = self {
3434            Some((responder))
3435        } else {
3436            None
3437        }
3438    }
3439
3440    #[allow(irrefutable_let_patterns)]
3441    pub fn into_stop_async_capture_no_reply(self) -> Option<(AudioCapturerControlHandle)> {
3442        if let AudioCapturerRequest::StopAsyncCaptureNoReply { control_handle } = self {
3443            Some((control_handle))
3444        } else {
3445            None
3446        }
3447    }
3448
3449    #[allow(irrefutable_let_patterns)]
3450    pub fn into_bind_gain_control(
3451        self,
3452    ) -> Option<(
3453        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
3454        AudioCapturerControlHandle,
3455    )> {
3456        if let AudioCapturerRequest::BindGainControl { gain_control_request, control_handle } = self
3457        {
3458            Some((gain_control_request, control_handle))
3459        } else {
3460            None
3461        }
3462    }
3463
3464    #[allow(irrefutable_let_patterns)]
3465    pub fn into_get_reference_clock(self) -> Option<(AudioCapturerGetReferenceClockResponder)> {
3466        if let AudioCapturerRequest::GetReferenceClock { responder } = self {
3467            Some((responder))
3468        } else {
3469            None
3470        }
3471    }
3472
3473    #[allow(irrefutable_let_patterns)]
3474    pub fn into_set_reference_clock(
3475        self,
3476    ) -> Option<(Option<fidl::Clock>, AudioCapturerControlHandle)> {
3477        if let AudioCapturerRequest::SetReferenceClock { reference_clock, control_handle } = self {
3478            Some((reference_clock, control_handle))
3479        } else {
3480            None
3481        }
3482    }
3483
3484    #[allow(irrefutable_let_patterns)]
3485    pub fn into_set_usage(self) -> Option<(AudioCaptureUsage, AudioCapturerControlHandle)> {
3486        if let AudioCapturerRequest::SetUsage { usage, control_handle } = self {
3487            Some((usage, control_handle))
3488        } else {
3489            None
3490        }
3491    }
3492
3493    #[allow(irrefutable_let_patterns)]
3494    pub fn into_set_usage2(self) -> Option<(AudioCaptureUsage2, AudioCapturerControlHandle)> {
3495        if let AudioCapturerRequest::SetUsage2 { usage, control_handle } = self {
3496            Some((usage, control_handle))
3497        } else {
3498            None
3499        }
3500    }
3501
3502    #[allow(irrefutable_let_patterns)]
3503    pub fn into_get_stream_type(self) -> Option<(AudioCapturerGetStreamTypeResponder)> {
3504        if let AudioCapturerRequest::GetStreamType { responder } = self {
3505            Some((responder))
3506        } else {
3507            None
3508        }
3509    }
3510
3511    /// Name of the method defined in FIDL
3512    pub fn method_name(&self) -> &'static str {
3513        match *self {
3514            AudioCapturerRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
3515            AudioCapturerRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
3516            AudioCapturerRequest::ReleasePacket { .. } => "release_packet",
3517            AudioCapturerRequest::DiscardAllPackets { .. } => "discard_all_packets",
3518            AudioCapturerRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
3519            AudioCapturerRequest::SetPcmStreamType { .. } => "set_pcm_stream_type",
3520            AudioCapturerRequest::CaptureAt { .. } => "capture_at",
3521            AudioCapturerRequest::StartAsyncCapture { .. } => "start_async_capture",
3522            AudioCapturerRequest::StopAsyncCapture { .. } => "stop_async_capture",
3523            AudioCapturerRequest::StopAsyncCaptureNoReply { .. } => "stop_async_capture_no_reply",
3524            AudioCapturerRequest::BindGainControl { .. } => "bind_gain_control",
3525            AudioCapturerRequest::GetReferenceClock { .. } => "get_reference_clock",
3526            AudioCapturerRequest::SetReferenceClock { .. } => "set_reference_clock",
3527            AudioCapturerRequest::SetUsage { .. } => "set_usage",
3528            AudioCapturerRequest::SetUsage2 { .. } => "set_usage2",
3529            AudioCapturerRequest::GetStreamType { .. } => "get_stream_type",
3530            AudioCapturerRequest::_UnknownMethod {
3531                method_type: fidl::MethodType::OneWay, ..
3532            } => "unknown one-way method",
3533            AudioCapturerRequest::_UnknownMethod {
3534                method_type: fidl::MethodType::TwoWay, ..
3535            } => "unknown two-way method",
3536        }
3537    }
3538}
3539
3540#[derive(Debug, Clone)]
3541pub struct AudioCapturerControlHandle {
3542    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3543}
3544
3545impl fidl::endpoints::ControlHandle for AudioCapturerControlHandle {
3546    fn shutdown(&self) {
3547        self.inner.shutdown()
3548    }
3549
3550    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3551        self.inner.shutdown_with_epitaph(status)
3552    }
3553
3554    fn is_closed(&self) -> bool {
3555        self.inner.channel().is_closed()
3556    }
3557    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3558        self.inner.channel().on_closed()
3559    }
3560
3561    #[cfg(target_os = "fuchsia")]
3562    fn signal_peer(
3563        &self,
3564        clear_mask: zx::Signals,
3565        set_mask: zx::Signals,
3566    ) -> Result<(), zx_status::Status> {
3567        use fidl::Peered;
3568        self.inner.channel().signal_peer(clear_mask, set_mask)
3569    }
3570}
3571
3572impl AudioCapturerControlHandle {
3573    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
3574        self.inner.send::<StreamSourceOnPacketProducedRequest>(
3575            (packet,),
3576            0,
3577            0x6bbe69746a3c8bd9,
3578            fidl::encoding::DynamicFlags::empty(),
3579        )
3580    }
3581
3582    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
3583        self.inner.send::<fidl::encoding::EmptyPayload>(
3584            (),
3585            0,
3586            0x550e69b41d03e2c2,
3587            fidl::encoding::DynamicFlags::empty(),
3588        )
3589    }
3590}
3591
3592#[must_use = "FIDL methods require a response to be sent"]
3593#[derive(Debug)]
3594pub struct AudioCapturerDiscardAllPacketsResponder {
3595    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3596    tx_id: u32,
3597}
3598
3599/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3600/// if the responder is dropped without sending a response, so that the client
3601/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3602impl std::ops::Drop for AudioCapturerDiscardAllPacketsResponder {
3603    fn drop(&mut self) {
3604        self.control_handle.shutdown();
3605        // Safety: drops once, never accessed again
3606        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3607    }
3608}
3609
3610impl fidl::endpoints::Responder for AudioCapturerDiscardAllPacketsResponder {
3611    type ControlHandle = AudioCapturerControlHandle;
3612
3613    fn control_handle(&self) -> &AudioCapturerControlHandle {
3614        &self.control_handle
3615    }
3616
3617    fn drop_without_shutdown(mut self) {
3618        // Safety: drops once, never accessed again due to mem::forget
3619        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3620        // Prevent Drop from running (which would shut down the channel)
3621        std::mem::forget(self);
3622    }
3623}
3624
3625impl AudioCapturerDiscardAllPacketsResponder {
3626    /// Sends a response to the FIDL transaction.
3627    ///
3628    /// Sets the channel to shutdown if an error occurs.
3629    pub fn send(self) -> Result<(), fidl::Error> {
3630        let _result = self.send_raw();
3631        if _result.is_err() {
3632            self.control_handle.shutdown();
3633        }
3634        self.drop_without_shutdown();
3635        _result
3636    }
3637
3638    /// Similar to "send" but does not shutdown the channel if an error occurs.
3639    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3640        let _result = self.send_raw();
3641        self.drop_without_shutdown();
3642        _result
3643    }
3644
3645    fn send_raw(&self) -> Result<(), fidl::Error> {
3646        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3647            (),
3648            self.tx_id,
3649            0x27afd605e97b09d2,
3650            fidl::encoding::DynamicFlags::empty(),
3651        )
3652    }
3653}
3654
3655#[must_use = "FIDL methods require a response to be sent"]
3656#[derive(Debug)]
3657pub struct AudioCapturerCaptureAtResponder {
3658    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3659    tx_id: u32,
3660}
3661
3662/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3663/// if the responder is dropped without sending a response, so that the client
3664/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3665impl std::ops::Drop for AudioCapturerCaptureAtResponder {
3666    fn drop(&mut self) {
3667        self.control_handle.shutdown();
3668        // Safety: drops once, never accessed again
3669        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3670    }
3671}
3672
3673impl fidl::endpoints::Responder for AudioCapturerCaptureAtResponder {
3674    type ControlHandle = AudioCapturerControlHandle;
3675
3676    fn control_handle(&self) -> &AudioCapturerControlHandle {
3677        &self.control_handle
3678    }
3679
3680    fn drop_without_shutdown(mut self) {
3681        // Safety: drops once, never accessed again due to mem::forget
3682        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3683        // Prevent Drop from running (which would shut down the channel)
3684        std::mem::forget(self);
3685    }
3686}
3687
3688impl AudioCapturerCaptureAtResponder {
3689    /// Sends a response to the FIDL transaction.
3690    ///
3691    /// Sets the channel to shutdown if an error occurs.
3692    pub fn send(self, mut captured_packet: &StreamPacket) -> Result<(), fidl::Error> {
3693        let _result = self.send_raw(captured_packet);
3694        if _result.is_err() {
3695            self.control_handle.shutdown();
3696        }
3697        self.drop_without_shutdown();
3698        _result
3699    }
3700
3701    /// Similar to "send" but does not shutdown the channel if an error occurs.
3702    pub fn send_no_shutdown_on_err(
3703        self,
3704        mut captured_packet: &StreamPacket,
3705    ) -> Result<(), fidl::Error> {
3706        let _result = self.send_raw(captured_packet);
3707        self.drop_without_shutdown();
3708        _result
3709    }
3710
3711    fn send_raw(&self, mut captured_packet: &StreamPacket) -> Result<(), fidl::Error> {
3712        self.control_handle.inner.send::<AudioCapturerCaptureAtResponse>(
3713            (captured_packet,),
3714            self.tx_id,
3715            0x784e25df72cea780,
3716            fidl::encoding::DynamicFlags::empty(),
3717        )
3718    }
3719}
3720
3721#[must_use = "FIDL methods require a response to be sent"]
3722#[derive(Debug)]
3723pub struct AudioCapturerStopAsyncCaptureResponder {
3724    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3725    tx_id: u32,
3726}
3727
3728/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3729/// if the responder is dropped without sending a response, so that the client
3730/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3731impl std::ops::Drop for AudioCapturerStopAsyncCaptureResponder {
3732    fn drop(&mut self) {
3733        self.control_handle.shutdown();
3734        // Safety: drops once, never accessed again
3735        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3736    }
3737}
3738
3739impl fidl::endpoints::Responder for AudioCapturerStopAsyncCaptureResponder {
3740    type ControlHandle = AudioCapturerControlHandle;
3741
3742    fn control_handle(&self) -> &AudioCapturerControlHandle {
3743        &self.control_handle
3744    }
3745
3746    fn drop_without_shutdown(mut self) {
3747        // Safety: drops once, never accessed again due to mem::forget
3748        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3749        // Prevent Drop from running (which would shut down the channel)
3750        std::mem::forget(self);
3751    }
3752}
3753
3754impl AudioCapturerStopAsyncCaptureResponder {
3755    /// Sends a response to the FIDL transaction.
3756    ///
3757    /// Sets the channel to shutdown if an error occurs.
3758    pub fn send(self) -> Result<(), fidl::Error> {
3759        let _result = self.send_raw();
3760        if _result.is_err() {
3761            self.control_handle.shutdown();
3762        }
3763        self.drop_without_shutdown();
3764        _result
3765    }
3766
3767    /// Similar to "send" but does not shutdown the channel if an error occurs.
3768    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3769        let _result = self.send_raw();
3770        self.drop_without_shutdown();
3771        _result
3772    }
3773
3774    fn send_raw(&self) -> Result<(), fidl::Error> {
3775        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3776            (),
3777            self.tx_id,
3778            0x5bfc8790a8cef8cb,
3779            fidl::encoding::DynamicFlags::empty(),
3780        )
3781    }
3782}
3783
3784#[must_use = "FIDL methods require a response to be sent"]
3785#[derive(Debug)]
3786pub struct AudioCapturerGetReferenceClockResponder {
3787    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3788    tx_id: u32,
3789}
3790
3791/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3792/// if the responder is dropped without sending a response, so that the client
3793/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3794impl std::ops::Drop for AudioCapturerGetReferenceClockResponder {
3795    fn drop(&mut self) {
3796        self.control_handle.shutdown();
3797        // Safety: drops once, never accessed again
3798        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3799    }
3800}
3801
3802impl fidl::endpoints::Responder for AudioCapturerGetReferenceClockResponder {
3803    type ControlHandle = AudioCapturerControlHandle;
3804
3805    fn control_handle(&self) -> &AudioCapturerControlHandle {
3806        &self.control_handle
3807    }
3808
3809    fn drop_without_shutdown(mut self) {
3810        // Safety: drops once, never accessed again due to mem::forget
3811        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3812        // Prevent Drop from running (which would shut down the channel)
3813        std::mem::forget(self);
3814    }
3815}
3816
3817impl AudioCapturerGetReferenceClockResponder {
3818    /// Sends a response to the FIDL transaction.
3819    ///
3820    /// Sets the channel to shutdown if an error occurs.
3821    pub fn send(self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
3822        let _result = self.send_raw(reference_clock);
3823        if _result.is_err() {
3824            self.control_handle.shutdown();
3825        }
3826        self.drop_without_shutdown();
3827        _result
3828    }
3829
3830    /// Similar to "send" but does not shutdown the channel if an error occurs.
3831    pub fn send_no_shutdown_on_err(
3832        self,
3833        mut reference_clock: fidl::Clock,
3834    ) -> Result<(), fidl::Error> {
3835        let _result = self.send_raw(reference_clock);
3836        self.drop_without_shutdown();
3837        _result
3838    }
3839
3840    fn send_raw(&self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
3841        self.control_handle.inner.send::<AudioCapturerGetReferenceClockResponse>(
3842            (reference_clock,),
3843            self.tx_id,
3844            0x50d037aa5a4b4d71,
3845            fidl::encoding::DynamicFlags::empty(),
3846        )
3847    }
3848}
3849
3850#[must_use = "FIDL methods require a response to be sent"]
3851#[derive(Debug)]
3852pub struct AudioCapturerGetStreamTypeResponder {
3853    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3854    tx_id: u32,
3855}
3856
3857/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3858/// if the responder is dropped without sending a response, so that the client
3859/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3860impl std::ops::Drop for AudioCapturerGetStreamTypeResponder {
3861    fn drop(&mut self) {
3862        self.control_handle.shutdown();
3863        // Safety: drops once, never accessed again
3864        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3865    }
3866}
3867
3868impl fidl::endpoints::Responder for AudioCapturerGetStreamTypeResponder {
3869    type ControlHandle = AudioCapturerControlHandle;
3870
3871    fn control_handle(&self) -> &AudioCapturerControlHandle {
3872        &self.control_handle
3873    }
3874
3875    fn drop_without_shutdown(mut self) {
3876        // Safety: drops once, never accessed again due to mem::forget
3877        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3878        // Prevent Drop from running (which would shut down the channel)
3879        std::mem::forget(self);
3880    }
3881}
3882
3883impl AudioCapturerGetStreamTypeResponder {
3884    /// Sends a response to the FIDL transaction.
3885    ///
3886    /// Sets the channel to shutdown if an error occurs.
3887    pub fn send(self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3888        let _result = self.send_raw(stream_type);
3889        if _result.is_err() {
3890            self.control_handle.shutdown();
3891        }
3892        self.drop_without_shutdown();
3893        _result
3894    }
3895
3896    /// Similar to "send" but does not shutdown the channel if an error occurs.
3897    pub fn send_no_shutdown_on_err(self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3898        let _result = self.send_raw(stream_type);
3899        self.drop_without_shutdown();
3900        _result
3901    }
3902
3903    fn send_raw(&self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3904        self.control_handle.inner.send::<AudioCapturerGetStreamTypeResponse>(
3905            (stream_type,),
3906            self.tx_id,
3907            0x5dcaaa670b433088,
3908            fidl::encoding::DynamicFlags::empty(),
3909        )
3910    }
3911}
3912
3913#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3914pub struct AudioConsumerMarker;
3915
3916impl fidl::endpoints::ProtocolMarker for AudioConsumerMarker {
3917    type Proxy = AudioConsumerProxy;
3918    type RequestStream = AudioConsumerRequestStream;
3919    #[cfg(target_os = "fuchsia")]
3920    type SynchronousProxy = AudioConsumerSynchronousProxy;
3921
3922    const DEBUG_NAME: &'static str = "(anonymous) AudioConsumer";
3923}
3924
3925pub trait AudioConsumerProxyInterface: Send + Sync {
3926    fn r#create_stream_sink(
3927        &self,
3928        buffers: Vec<fidl::Vmo>,
3929        stream_type: &AudioStreamType,
3930        compression: Option<&Compression>,
3931        stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
3932    ) -> Result<(), fidl::Error>;
3933    fn r#start(
3934        &self,
3935        flags: AudioConsumerStartFlags,
3936        reference_time: i64,
3937        media_time: i64,
3938    ) -> Result<(), fidl::Error>;
3939    fn r#stop(&self) -> Result<(), fidl::Error>;
3940    fn r#set_rate(&self, rate: f32) -> Result<(), fidl::Error>;
3941    fn r#bind_volume_control(
3942        &self,
3943        volume_control_request: fidl::endpoints::ServerEnd<
3944            fidl_fuchsia_media_audio::VolumeControlMarker,
3945        >,
3946    ) -> Result<(), fidl::Error>;
3947    type WatchStatusResponseFut: std::future::Future<Output = Result<AudioConsumerStatus, fidl::Error>>
3948        + Send;
3949    fn r#watch_status(&self) -> Self::WatchStatusResponseFut;
3950}
3951#[derive(Debug)]
3952#[cfg(target_os = "fuchsia")]
3953pub struct AudioConsumerSynchronousProxy {
3954    client: fidl::client::sync::Client,
3955}
3956
3957#[cfg(target_os = "fuchsia")]
3958impl fidl::endpoints::SynchronousProxy for AudioConsumerSynchronousProxy {
3959    type Proxy = AudioConsumerProxy;
3960    type Protocol = AudioConsumerMarker;
3961
3962    fn from_channel(inner: fidl::Channel) -> Self {
3963        Self::new(inner)
3964    }
3965
3966    fn into_channel(self) -> fidl::Channel {
3967        self.client.into_channel()
3968    }
3969
3970    fn as_channel(&self) -> &fidl::Channel {
3971        self.client.as_channel()
3972    }
3973}
3974
3975#[cfg(target_os = "fuchsia")]
3976impl AudioConsumerSynchronousProxy {
3977    pub fn new(channel: fidl::Channel) -> Self {
3978        Self { client: fidl::client::sync::Client::new(channel) }
3979    }
3980
3981    pub fn into_channel(self) -> fidl::Channel {
3982        self.client.into_channel()
3983    }
3984
3985    /// Waits until an event arrives and returns it. It is safe for other
3986    /// threads to make concurrent requests while waiting for an event.
3987    pub fn wait_for_event(
3988        &self,
3989        deadline: zx::MonotonicInstant,
3990    ) -> Result<AudioConsumerEvent, fidl::Error> {
3991        AudioConsumerEvent::decode(self.client.wait_for_event::<AudioConsumerMarker>(deadline)?)
3992    }
3993
3994    /// Creates a `StreamSink` for the consumer with the indicated properties.
3995    ///
3996    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
3997    /// sequentially rather than concurrently. The first stream sink that's created using this
3998    /// method is used as the sole source of packets incoming to the logical consumer until that
3999    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
4000    /// the second stream sink is used, and so on.
4001    ///
4002    /// If an unsupported compression type is supplied, the
4003    /// `stream_sink_request` request will be closed with an epitaph value of
4004    /// `ZX_ERR_INVALID_ARGS`.
4005    pub fn r#create_stream_sink(
4006        &self,
4007        mut buffers: Vec<fidl::Vmo>,
4008        mut stream_type: &AudioStreamType,
4009        mut compression: Option<&Compression>,
4010        mut stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4011    ) -> Result<(), fidl::Error> {
4012        self.client.send::<AudioConsumerCreateStreamSinkRequest>(
4013            (buffers.as_mut(), stream_type, compression, stream_sink_request),
4014            0x525b3b97fdf7d884,
4015            fidl::encoding::DynamicFlags::empty(),
4016        )
4017    }
4018
4019    /// Starts rendering as indicated by `flags`.
4020    ///
4021    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4022    /// Typically, this is the timestamp of the first packet that will be
4023    /// rendered. If packets will be supplied with no timestamps, this value
4024    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4025    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4026    ///     1. When starting for the first time, the default media time is the
4027    ///        timestamp on the first packet sent to the stream sink.
4028    ///     2. When resuming after stop, the default media time is the media
4029    ///        time at which the stream stopped.
4030    ///
4031    /// `reference_time` is the monotonic system time at which rendering should
4032    /// be started. For supply-driven sources, this must be the time at which
4033    /// the first packet was (or will be) sent plus a lead time, which must be
4034    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4035    /// sources, the client must ensure that the lead time requirement is met at
4036    /// the start time.  Passing the default value of 0 for `reference_time`
4037    /// causes the consumer to choose a start time based on the availability of
4038    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4039    /// specified.
4040    ///
4041    /// The actual start time will be reflected in the updated status.
4042    pub fn r#start(
4043        &self,
4044        mut flags: AudioConsumerStartFlags,
4045        mut reference_time: i64,
4046        mut media_time: i64,
4047    ) -> Result<(), fidl::Error> {
4048        self.client.send::<AudioConsumerStartRequest>(
4049            (flags, reference_time, media_time),
4050            0x4fdbd44b3f2a3a3c,
4051            fidl::encoding::DynamicFlags::empty(),
4052        )
4053    }
4054
4055    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4056    /// be reflected in the updated status.
4057    pub fn r#stop(&self) -> Result<(), fidl::Error> {
4058        self.client.send::<fidl::encoding::EmptyPayload>(
4059            (),
4060            0x3d46c3741686c40d,
4061            fidl::encoding::DynamicFlags::empty(),
4062        )
4063    }
4064
4065    /// Requests to change the playback rate of the renderer. 1.0 means normal
4066    /// playback. Negative rates are not supported. The new rate will be
4067    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4068    pub fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
4069        self.client.send::<AudioConsumerSetRateRequest>(
4070            (rate,),
4071            0x45342b73968bfafe,
4072            fidl::encoding::DynamicFlags::empty(),
4073        )
4074    }
4075
4076    /// Binds to this `AudioConsumer` volume control for control and notifications.
4077    pub fn r#bind_volume_control(
4078        &self,
4079        mut volume_control_request: fidl::endpoints::ServerEnd<
4080            fidl_fuchsia_media_audio::VolumeControlMarker,
4081        >,
4082    ) -> Result<(), fidl::Error> {
4083        self.client.send::<AudioConsumerBindVolumeControlRequest>(
4084            (volume_control_request,),
4085            0x6f1b01fd887f5748,
4086            fidl::encoding::DynamicFlags::empty(),
4087        )
4088    }
4089
4090    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4091    /// to this method when the status changes - initially with respect to the initial status value
4092    /// and thereafter with respect to the previously-reported status value.
4093    pub fn r#watch_status(
4094        &self,
4095        ___deadline: zx::MonotonicInstant,
4096    ) -> Result<AudioConsumerStatus, fidl::Error> {
4097        let _response = self.client.send_query::<
4098            fidl::encoding::EmptyPayload,
4099            AudioConsumerWatchStatusResponse,
4100            AudioConsumerMarker,
4101        >(
4102            (),
4103            0x35cf702c721e2cc6,
4104            fidl::encoding::DynamicFlags::empty(),
4105            ___deadline,
4106        )?;
4107        Ok(_response.status)
4108    }
4109}
4110
4111#[cfg(target_os = "fuchsia")]
4112impl From<AudioConsumerSynchronousProxy> for zx::NullableHandle {
4113    fn from(value: AudioConsumerSynchronousProxy) -> Self {
4114        value.into_channel().into()
4115    }
4116}
4117
4118#[cfg(target_os = "fuchsia")]
4119impl From<fidl::Channel> for AudioConsumerSynchronousProxy {
4120    fn from(value: fidl::Channel) -> Self {
4121        Self::new(value)
4122    }
4123}
4124
4125#[cfg(target_os = "fuchsia")]
4126impl fidl::endpoints::FromClient for AudioConsumerSynchronousProxy {
4127    type Protocol = AudioConsumerMarker;
4128
4129    fn from_client(value: fidl::endpoints::ClientEnd<AudioConsumerMarker>) -> Self {
4130        Self::new(value.into_channel())
4131    }
4132}
4133
4134#[derive(Debug, Clone)]
4135pub struct AudioConsumerProxy {
4136    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4137}
4138
4139impl fidl::endpoints::Proxy for AudioConsumerProxy {
4140    type Protocol = AudioConsumerMarker;
4141
4142    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4143        Self::new(inner)
4144    }
4145
4146    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4147        self.client.into_channel().map_err(|client| Self { client })
4148    }
4149
4150    fn as_channel(&self) -> &::fidl::AsyncChannel {
4151        self.client.as_channel()
4152    }
4153}
4154
4155impl AudioConsumerProxy {
4156    /// Create a new Proxy for fuchsia.media/AudioConsumer.
4157    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4158        let protocol_name = <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4159        Self { client: fidl::client::Client::new(channel, protocol_name) }
4160    }
4161
4162    /// Get a Stream of events from the remote end of the protocol.
4163    ///
4164    /// # Panics
4165    ///
4166    /// Panics if the event stream was already taken.
4167    pub fn take_event_stream(&self) -> AudioConsumerEventStream {
4168        AudioConsumerEventStream { event_receiver: self.client.take_event_receiver() }
4169    }
4170
4171    /// Creates a `StreamSink` for the consumer with the indicated properties.
4172    ///
4173    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
4174    /// sequentially rather than concurrently. The first stream sink that's created using this
4175    /// method is used as the sole source of packets incoming to the logical consumer until that
4176    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
4177    /// the second stream sink is used, and so on.
4178    ///
4179    /// If an unsupported compression type is supplied, the
4180    /// `stream_sink_request` request will be closed with an epitaph value of
4181    /// `ZX_ERR_INVALID_ARGS`.
4182    pub fn r#create_stream_sink(
4183        &self,
4184        mut buffers: Vec<fidl::Vmo>,
4185        mut stream_type: &AudioStreamType,
4186        mut compression: Option<&Compression>,
4187        mut stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4188    ) -> Result<(), fidl::Error> {
4189        AudioConsumerProxyInterface::r#create_stream_sink(
4190            self,
4191            buffers,
4192            stream_type,
4193            compression,
4194            stream_sink_request,
4195        )
4196    }
4197
4198    /// Starts rendering as indicated by `flags`.
4199    ///
4200    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4201    /// Typically, this is the timestamp of the first packet that will be
4202    /// rendered. If packets will be supplied with no timestamps, this value
4203    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4204    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4205    ///     1. When starting for the first time, the default media time is the
4206    ///        timestamp on the first packet sent to the stream sink.
4207    ///     2. When resuming after stop, the default media time is the media
4208    ///        time at which the stream stopped.
4209    ///
4210    /// `reference_time` is the monotonic system time at which rendering should
4211    /// be started. For supply-driven sources, this must be the time at which
4212    /// the first packet was (or will be) sent plus a lead time, which must be
4213    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4214    /// sources, the client must ensure that the lead time requirement is met at
4215    /// the start time.  Passing the default value of 0 for `reference_time`
4216    /// causes the consumer to choose a start time based on the availability of
4217    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4218    /// specified.
4219    ///
4220    /// The actual start time will be reflected in the updated status.
4221    pub fn r#start(
4222        &self,
4223        mut flags: AudioConsumerStartFlags,
4224        mut reference_time: i64,
4225        mut media_time: i64,
4226    ) -> Result<(), fidl::Error> {
4227        AudioConsumerProxyInterface::r#start(self, flags, reference_time, media_time)
4228    }
4229
4230    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4231    /// be reflected in the updated status.
4232    pub fn r#stop(&self) -> Result<(), fidl::Error> {
4233        AudioConsumerProxyInterface::r#stop(self)
4234    }
4235
4236    /// Requests to change the playback rate of the renderer. 1.0 means normal
4237    /// playback. Negative rates are not supported. The new rate will be
4238    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4239    pub fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
4240        AudioConsumerProxyInterface::r#set_rate(self, rate)
4241    }
4242
4243    /// Binds to this `AudioConsumer` volume control for control and notifications.
4244    pub fn r#bind_volume_control(
4245        &self,
4246        mut volume_control_request: fidl::endpoints::ServerEnd<
4247            fidl_fuchsia_media_audio::VolumeControlMarker,
4248        >,
4249    ) -> Result<(), fidl::Error> {
4250        AudioConsumerProxyInterface::r#bind_volume_control(self, volume_control_request)
4251    }
4252
4253    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4254    /// to this method when the status changes - initially with respect to the initial status value
4255    /// and thereafter with respect to the previously-reported status value.
4256    pub fn r#watch_status(
4257        &self,
4258    ) -> fidl::client::QueryResponseFut<
4259        AudioConsumerStatus,
4260        fidl::encoding::DefaultFuchsiaResourceDialect,
4261    > {
4262        AudioConsumerProxyInterface::r#watch_status(self)
4263    }
4264}
4265
4266impl AudioConsumerProxyInterface for AudioConsumerProxy {
4267    fn r#create_stream_sink(
4268        &self,
4269        mut buffers: Vec<fidl::Vmo>,
4270        mut stream_type: &AudioStreamType,
4271        mut compression: Option<&Compression>,
4272        mut stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4273    ) -> Result<(), fidl::Error> {
4274        self.client.send::<AudioConsumerCreateStreamSinkRequest>(
4275            (buffers.as_mut(), stream_type, compression, stream_sink_request),
4276            0x525b3b97fdf7d884,
4277            fidl::encoding::DynamicFlags::empty(),
4278        )
4279    }
4280
4281    fn r#start(
4282        &self,
4283        mut flags: AudioConsumerStartFlags,
4284        mut reference_time: i64,
4285        mut media_time: i64,
4286    ) -> Result<(), fidl::Error> {
4287        self.client.send::<AudioConsumerStartRequest>(
4288            (flags, reference_time, media_time),
4289            0x4fdbd44b3f2a3a3c,
4290            fidl::encoding::DynamicFlags::empty(),
4291        )
4292    }
4293
4294    fn r#stop(&self) -> Result<(), fidl::Error> {
4295        self.client.send::<fidl::encoding::EmptyPayload>(
4296            (),
4297            0x3d46c3741686c40d,
4298            fidl::encoding::DynamicFlags::empty(),
4299        )
4300    }
4301
4302    fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
4303        self.client.send::<AudioConsumerSetRateRequest>(
4304            (rate,),
4305            0x45342b73968bfafe,
4306            fidl::encoding::DynamicFlags::empty(),
4307        )
4308    }
4309
4310    fn r#bind_volume_control(
4311        &self,
4312        mut volume_control_request: fidl::endpoints::ServerEnd<
4313            fidl_fuchsia_media_audio::VolumeControlMarker,
4314        >,
4315    ) -> Result<(), fidl::Error> {
4316        self.client.send::<AudioConsumerBindVolumeControlRequest>(
4317            (volume_control_request,),
4318            0x6f1b01fd887f5748,
4319            fidl::encoding::DynamicFlags::empty(),
4320        )
4321    }
4322
4323    type WatchStatusResponseFut = fidl::client::QueryResponseFut<
4324        AudioConsumerStatus,
4325        fidl::encoding::DefaultFuchsiaResourceDialect,
4326    >;
4327    fn r#watch_status(&self) -> Self::WatchStatusResponseFut {
4328        fn _decode(
4329            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4330        ) -> Result<AudioConsumerStatus, fidl::Error> {
4331            let _response = fidl::client::decode_transaction_body::<
4332                AudioConsumerWatchStatusResponse,
4333                fidl::encoding::DefaultFuchsiaResourceDialect,
4334                0x35cf702c721e2cc6,
4335            >(_buf?)?;
4336            Ok(_response.status)
4337        }
4338        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, AudioConsumerStatus>(
4339            (),
4340            0x35cf702c721e2cc6,
4341            fidl::encoding::DynamicFlags::empty(),
4342            _decode,
4343        )
4344    }
4345}
4346
4347pub struct AudioConsumerEventStream {
4348    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4349}
4350
4351impl std::marker::Unpin for AudioConsumerEventStream {}
4352
4353impl futures::stream::FusedStream for AudioConsumerEventStream {
4354    fn is_terminated(&self) -> bool {
4355        self.event_receiver.is_terminated()
4356    }
4357}
4358
4359impl futures::Stream for AudioConsumerEventStream {
4360    type Item = Result<AudioConsumerEvent, fidl::Error>;
4361
4362    fn poll_next(
4363        mut self: std::pin::Pin<&mut Self>,
4364        cx: &mut std::task::Context<'_>,
4365    ) -> std::task::Poll<Option<Self::Item>> {
4366        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4367            &mut self.event_receiver,
4368            cx
4369        )?) {
4370            Some(buf) => std::task::Poll::Ready(Some(AudioConsumerEvent::decode(buf))),
4371            None => std::task::Poll::Ready(None),
4372        }
4373    }
4374}
4375
4376#[derive(Debug)]
4377pub enum AudioConsumerEvent {
4378    OnEndOfStream {},
4379}
4380
4381impl AudioConsumerEvent {
4382    #[allow(irrefutable_let_patterns)]
4383    pub fn into_on_end_of_stream(self) -> Option<()> {
4384        if let AudioConsumerEvent::OnEndOfStream {} = self { Some(()) } else { None }
4385    }
4386
4387    /// Decodes a message buffer as a [`AudioConsumerEvent`].
4388    fn decode(
4389        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4390    ) -> Result<AudioConsumerEvent, fidl::Error> {
4391        let (bytes, _handles) = buf.split_mut();
4392        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4393        debug_assert_eq!(tx_header.tx_id, 0);
4394        match tx_header.ordinal {
4395            0x53a64e6d0e8f8a20 => {
4396                let mut out = fidl::new_empty!(
4397                    fidl::encoding::EmptyPayload,
4398                    fidl::encoding::DefaultFuchsiaResourceDialect
4399                );
4400                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
4401                Ok((AudioConsumerEvent::OnEndOfStream {}))
4402            }
4403            _ => Err(fidl::Error::UnknownOrdinal {
4404                ordinal: tx_header.ordinal,
4405                protocol_name: <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4406            }),
4407        }
4408    }
4409}
4410
4411/// A Stream of incoming requests for fuchsia.media/AudioConsumer.
4412pub struct AudioConsumerRequestStream {
4413    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4414    is_terminated: bool,
4415}
4416
4417impl std::marker::Unpin for AudioConsumerRequestStream {}
4418
4419impl futures::stream::FusedStream for AudioConsumerRequestStream {
4420    fn is_terminated(&self) -> bool {
4421        self.is_terminated
4422    }
4423}
4424
4425impl fidl::endpoints::RequestStream for AudioConsumerRequestStream {
4426    type Protocol = AudioConsumerMarker;
4427    type ControlHandle = AudioConsumerControlHandle;
4428
4429    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4430        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4431    }
4432
4433    fn control_handle(&self) -> Self::ControlHandle {
4434        AudioConsumerControlHandle { inner: self.inner.clone() }
4435    }
4436
4437    fn into_inner(
4438        self,
4439    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4440    {
4441        (self.inner, self.is_terminated)
4442    }
4443
4444    fn from_inner(
4445        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4446        is_terminated: bool,
4447    ) -> Self {
4448        Self { inner, is_terminated }
4449    }
4450}
4451
4452impl futures::Stream for AudioConsumerRequestStream {
4453    type Item = Result<AudioConsumerRequest, fidl::Error>;
4454
4455    fn poll_next(
4456        mut self: std::pin::Pin<&mut Self>,
4457        cx: &mut std::task::Context<'_>,
4458    ) -> std::task::Poll<Option<Self::Item>> {
4459        let this = &mut *self;
4460        if this.inner.check_shutdown(cx) {
4461            this.is_terminated = true;
4462            return std::task::Poll::Ready(None);
4463        }
4464        if this.is_terminated {
4465            panic!("polled AudioConsumerRequestStream after completion");
4466        }
4467        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4468            |bytes, handles| {
4469                match this.inner.channel().read_etc(cx, bytes, handles) {
4470                    std::task::Poll::Ready(Ok(())) => {}
4471                    std::task::Poll::Pending => return std::task::Poll::Pending,
4472                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4473                        this.is_terminated = true;
4474                        return std::task::Poll::Ready(None);
4475                    }
4476                    std::task::Poll::Ready(Err(e)) => {
4477                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4478                            e.into(),
4479                        ))));
4480                    }
4481                }
4482
4483                // A message has been received from the channel
4484                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4485
4486                std::task::Poll::Ready(Some(match header.ordinal {
4487                    0x525b3b97fdf7d884 => {
4488                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4489                        let mut req = fidl::new_empty!(
4490                            AudioConsumerCreateStreamSinkRequest,
4491                            fidl::encoding::DefaultFuchsiaResourceDialect
4492                        );
4493                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerCreateStreamSinkRequest>(&header, _body_bytes, handles, &mut req)?;
4494                        let control_handle =
4495                            AudioConsumerControlHandle { inner: this.inner.clone() };
4496                        Ok(AudioConsumerRequest::CreateStreamSink {
4497                            buffers: req.buffers,
4498                            stream_type: req.stream_type,
4499                            compression: req.compression,
4500                            stream_sink_request: req.stream_sink_request,
4501
4502                            control_handle,
4503                        })
4504                    }
4505                    0x4fdbd44b3f2a3a3c => {
4506                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4507                        let mut req = fidl::new_empty!(
4508                            AudioConsumerStartRequest,
4509                            fidl::encoding::DefaultFuchsiaResourceDialect
4510                        );
4511                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerStartRequest>(&header, _body_bytes, handles, &mut req)?;
4512                        let control_handle =
4513                            AudioConsumerControlHandle { inner: this.inner.clone() };
4514                        Ok(AudioConsumerRequest::Start {
4515                            flags: req.flags,
4516                            reference_time: req.reference_time,
4517                            media_time: req.media_time,
4518
4519                            control_handle,
4520                        })
4521                    }
4522                    0x3d46c3741686c40d => {
4523                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4524                        let mut req = fidl::new_empty!(
4525                            fidl::encoding::EmptyPayload,
4526                            fidl::encoding::DefaultFuchsiaResourceDialect
4527                        );
4528                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4529                        let control_handle =
4530                            AudioConsumerControlHandle { inner: this.inner.clone() };
4531                        Ok(AudioConsumerRequest::Stop { control_handle })
4532                    }
4533                    0x45342b73968bfafe => {
4534                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4535                        let mut req = fidl::new_empty!(
4536                            AudioConsumerSetRateRequest,
4537                            fidl::encoding::DefaultFuchsiaResourceDialect
4538                        );
4539                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerSetRateRequest>(&header, _body_bytes, handles, &mut req)?;
4540                        let control_handle =
4541                            AudioConsumerControlHandle { inner: this.inner.clone() };
4542                        Ok(AudioConsumerRequest::SetRate { rate: req.rate, control_handle })
4543                    }
4544                    0x6f1b01fd887f5748 => {
4545                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4546                        let mut req = fidl::new_empty!(
4547                            AudioConsumerBindVolumeControlRequest,
4548                            fidl::encoding::DefaultFuchsiaResourceDialect
4549                        );
4550                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerBindVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
4551                        let control_handle =
4552                            AudioConsumerControlHandle { inner: this.inner.clone() };
4553                        Ok(AudioConsumerRequest::BindVolumeControl {
4554                            volume_control_request: req.volume_control_request,
4555
4556                            control_handle,
4557                        })
4558                    }
4559                    0x35cf702c721e2cc6 => {
4560                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4561                        let mut req = fidl::new_empty!(
4562                            fidl::encoding::EmptyPayload,
4563                            fidl::encoding::DefaultFuchsiaResourceDialect
4564                        );
4565                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4566                        let control_handle =
4567                            AudioConsumerControlHandle { inner: this.inner.clone() };
4568                        Ok(AudioConsumerRequest::WatchStatus {
4569                            responder: AudioConsumerWatchStatusResponder {
4570                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4571                                tx_id: header.tx_id,
4572                            },
4573                        })
4574                    }
4575                    _ => Err(fidl::Error::UnknownOrdinal {
4576                        ordinal: header.ordinal,
4577                        protocol_name:
4578                            <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4579                    }),
4580                }))
4581            },
4582        )
4583    }
4584}
4585
4586/// Interface for playing and controlling audio.
4587#[derive(Debug)]
4588pub enum AudioConsumerRequest {
4589    /// Creates a `StreamSink` for the consumer with the indicated properties.
4590    ///
4591    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
4592    /// sequentially rather than concurrently. The first stream sink that's created using this
4593    /// method is used as the sole source of packets incoming to the logical consumer until that
4594    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
4595    /// the second stream sink is used, and so on.
4596    ///
4597    /// If an unsupported compression type is supplied, the
4598    /// `stream_sink_request` request will be closed with an epitaph value of
4599    /// `ZX_ERR_INVALID_ARGS`.
4600    CreateStreamSink {
4601        buffers: Vec<fidl::Vmo>,
4602        stream_type: AudioStreamType,
4603        compression: Option<Box<Compression>>,
4604        stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4605        control_handle: AudioConsumerControlHandle,
4606    },
4607    /// Starts rendering as indicated by `flags`.
4608    ///
4609    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4610    /// Typically, this is the timestamp of the first packet that will be
4611    /// rendered. If packets will be supplied with no timestamps, this value
4612    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4613    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4614    ///     1. When starting for the first time, the default media time is the
4615    ///        timestamp on the first packet sent to the stream sink.
4616    ///     2. When resuming after stop, the default media time is the media
4617    ///        time at which the stream stopped.
4618    ///
4619    /// `reference_time` is the monotonic system time at which rendering should
4620    /// be started. For supply-driven sources, this must be the time at which
4621    /// the first packet was (or will be) sent plus a lead time, which must be
4622    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4623    /// sources, the client must ensure that the lead time requirement is met at
4624    /// the start time.  Passing the default value of 0 for `reference_time`
4625    /// causes the consumer to choose a start time based on the availability of
4626    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4627    /// specified.
4628    ///
4629    /// The actual start time will be reflected in the updated status.
4630    Start {
4631        flags: AudioConsumerStartFlags,
4632        reference_time: i64,
4633        media_time: i64,
4634        control_handle: AudioConsumerControlHandle,
4635    },
4636    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4637    /// be reflected in the updated status.
4638    Stop { control_handle: AudioConsumerControlHandle },
4639    /// Requests to change the playback rate of the renderer. 1.0 means normal
4640    /// playback. Negative rates are not supported. The new rate will be
4641    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4642    SetRate { rate: f32, control_handle: AudioConsumerControlHandle },
4643    /// Binds to this `AudioConsumer` volume control for control and notifications.
4644    BindVolumeControl {
4645        volume_control_request:
4646            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4647        control_handle: AudioConsumerControlHandle,
4648    },
4649    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4650    /// to this method when the status changes - initially with respect to the initial status value
4651    /// and thereafter with respect to the previously-reported status value.
4652    WatchStatus { responder: AudioConsumerWatchStatusResponder },
4653}
4654
4655impl AudioConsumerRequest {
4656    #[allow(irrefutable_let_patterns)]
4657    pub fn into_create_stream_sink(
4658        self,
4659    ) -> Option<(
4660        Vec<fidl::Vmo>,
4661        AudioStreamType,
4662        Option<Box<Compression>>,
4663        fidl::endpoints::ServerEnd<StreamSinkMarker>,
4664        AudioConsumerControlHandle,
4665    )> {
4666        if let AudioConsumerRequest::CreateStreamSink {
4667            buffers,
4668            stream_type,
4669            compression,
4670            stream_sink_request,
4671            control_handle,
4672        } = self
4673        {
4674            Some((buffers, stream_type, compression, stream_sink_request, control_handle))
4675        } else {
4676            None
4677        }
4678    }
4679
4680    #[allow(irrefutable_let_patterns)]
4681    pub fn into_start(
4682        self,
4683    ) -> Option<(AudioConsumerStartFlags, i64, i64, AudioConsumerControlHandle)> {
4684        if let AudioConsumerRequest::Start { flags, reference_time, media_time, control_handle } =
4685            self
4686        {
4687            Some((flags, reference_time, media_time, control_handle))
4688        } else {
4689            None
4690        }
4691    }
4692
4693    #[allow(irrefutable_let_patterns)]
4694    pub fn into_stop(self) -> Option<(AudioConsumerControlHandle)> {
4695        if let AudioConsumerRequest::Stop { control_handle } = self {
4696            Some((control_handle))
4697        } else {
4698            None
4699        }
4700    }
4701
4702    #[allow(irrefutable_let_patterns)]
4703    pub fn into_set_rate(self) -> Option<(f32, AudioConsumerControlHandle)> {
4704        if let AudioConsumerRequest::SetRate { rate, control_handle } = self {
4705            Some((rate, control_handle))
4706        } else {
4707            None
4708        }
4709    }
4710
4711    #[allow(irrefutable_let_patterns)]
4712    pub fn into_bind_volume_control(
4713        self,
4714    ) -> Option<(
4715        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4716        AudioConsumerControlHandle,
4717    )> {
4718        if let AudioConsumerRequest::BindVolumeControl { volume_control_request, control_handle } =
4719            self
4720        {
4721            Some((volume_control_request, control_handle))
4722        } else {
4723            None
4724        }
4725    }
4726
4727    #[allow(irrefutable_let_patterns)]
4728    pub fn into_watch_status(self) -> Option<(AudioConsumerWatchStatusResponder)> {
4729        if let AudioConsumerRequest::WatchStatus { responder } = self {
4730            Some((responder))
4731        } else {
4732            None
4733        }
4734    }
4735
4736    /// Name of the method defined in FIDL
4737    pub fn method_name(&self) -> &'static str {
4738        match *self {
4739            AudioConsumerRequest::CreateStreamSink { .. } => "create_stream_sink",
4740            AudioConsumerRequest::Start { .. } => "start",
4741            AudioConsumerRequest::Stop { .. } => "stop",
4742            AudioConsumerRequest::SetRate { .. } => "set_rate",
4743            AudioConsumerRequest::BindVolumeControl { .. } => "bind_volume_control",
4744            AudioConsumerRequest::WatchStatus { .. } => "watch_status",
4745        }
4746    }
4747}
4748
4749#[derive(Debug, Clone)]
4750pub struct AudioConsumerControlHandle {
4751    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4752}
4753
4754impl fidl::endpoints::ControlHandle for AudioConsumerControlHandle {
4755    fn shutdown(&self) {
4756        self.inner.shutdown()
4757    }
4758
4759    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4760        self.inner.shutdown_with_epitaph(status)
4761    }
4762
4763    fn is_closed(&self) -> bool {
4764        self.inner.channel().is_closed()
4765    }
4766    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4767        self.inner.channel().on_closed()
4768    }
4769
4770    #[cfg(target_os = "fuchsia")]
4771    fn signal_peer(
4772        &self,
4773        clear_mask: zx::Signals,
4774        set_mask: zx::Signals,
4775    ) -> Result<(), zx_status::Status> {
4776        use fidl::Peered;
4777        self.inner.channel().signal_peer(clear_mask, set_mask)
4778    }
4779}
4780
4781impl AudioConsumerControlHandle {
4782    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
4783        self.inner.send::<fidl::encoding::EmptyPayload>(
4784            (),
4785            0,
4786            0x53a64e6d0e8f8a20,
4787            fidl::encoding::DynamicFlags::empty(),
4788        )
4789    }
4790}
4791
4792#[must_use = "FIDL methods require a response to be sent"]
4793#[derive(Debug)]
4794pub struct AudioConsumerWatchStatusResponder {
4795    control_handle: std::mem::ManuallyDrop<AudioConsumerControlHandle>,
4796    tx_id: u32,
4797}
4798
4799/// Set the the channel to be shutdown (see [`AudioConsumerControlHandle::shutdown`])
4800/// if the responder is dropped without sending a response, so that the client
4801/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4802impl std::ops::Drop for AudioConsumerWatchStatusResponder {
4803    fn drop(&mut self) {
4804        self.control_handle.shutdown();
4805        // Safety: drops once, never accessed again
4806        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4807    }
4808}
4809
4810impl fidl::endpoints::Responder for AudioConsumerWatchStatusResponder {
4811    type ControlHandle = AudioConsumerControlHandle;
4812
4813    fn control_handle(&self) -> &AudioConsumerControlHandle {
4814        &self.control_handle
4815    }
4816
4817    fn drop_without_shutdown(mut self) {
4818        // Safety: drops once, never accessed again due to mem::forget
4819        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4820        // Prevent Drop from running (which would shut down the channel)
4821        std::mem::forget(self);
4822    }
4823}
4824
4825impl AudioConsumerWatchStatusResponder {
4826    /// Sends a response to the FIDL transaction.
4827    ///
4828    /// Sets the channel to shutdown if an error occurs.
4829    pub fn send(self, mut status: &AudioConsumerStatus) -> Result<(), fidl::Error> {
4830        let _result = self.send_raw(status);
4831        if _result.is_err() {
4832            self.control_handle.shutdown();
4833        }
4834        self.drop_without_shutdown();
4835        _result
4836    }
4837
4838    /// Similar to "send" but does not shutdown the channel if an error occurs.
4839    pub fn send_no_shutdown_on_err(
4840        self,
4841        mut status: &AudioConsumerStatus,
4842    ) -> Result<(), fidl::Error> {
4843        let _result = self.send_raw(status);
4844        self.drop_without_shutdown();
4845        _result
4846    }
4847
4848    fn send_raw(&self, mut status: &AudioConsumerStatus) -> Result<(), fidl::Error> {
4849        self.control_handle.inner.send::<AudioConsumerWatchStatusResponse>(
4850            (status,),
4851            self.tx_id,
4852            0x35cf702c721e2cc6,
4853            fidl::encoding::DynamicFlags::empty(),
4854        )
4855    }
4856}
4857
4858#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4859pub struct AudioCoreMarker;
4860
4861impl fidl::endpoints::ProtocolMarker for AudioCoreMarker {
4862    type Proxy = AudioCoreProxy;
4863    type RequestStream = AudioCoreRequestStream;
4864    #[cfg(target_os = "fuchsia")]
4865    type SynchronousProxy = AudioCoreSynchronousProxy;
4866
4867    const DEBUG_NAME: &'static str = "fuchsia.media.AudioCore";
4868}
4869impl fidl::endpoints::DiscoverableProtocolMarker for AudioCoreMarker {}
4870
4871pub trait AudioCoreProxyInterface: Send + Sync {
4872    fn r#create_audio_renderer(
4873        &self,
4874        audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
4875    ) -> Result<(), fidl::Error>;
4876    fn r#create_audio_capturer_with_configuration(
4877        &self,
4878        stream_type: &AudioStreamType,
4879        configuration: &AudioCapturerConfiguration,
4880        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
4881    ) -> Result<(), fidl::Error>;
4882    fn r#create_audio_capturer(
4883        &self,
4884        loopback: bool,
4885        audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
4886    ) -> Result<(), fidl::Error>;
4887    fn r#set_render_usage_gain(
4888        &self,
4889        usage: AudioRenderUsage,
4890        gain_db: f32,
4891    ) -> Result<(), fidl::Error>;
4892    fn r#set_render_usage_gain2(
4893        &self,
4894        usage: AudioRenderUsage2,
4895        gain_db: f32,
4896    ) -> Result<(), fidl::Error>;
4897    fn r#set_capture_usage_gain(
4898        &self,
4899        usage: AudioCaptureUsage,
4900        gain_db: f32,
4901    ) -> Result<(), fidl::Error>;
4902    fn r#set_capture_usage_gain2(
4903        &self,
4904        usage: AudioCaptureUsage2,
4905        gain_db: f32,
4906    ) -> Result<(), fidl::Error>;
4907    fn r#bind_usage_volume_control(
4908        &self,
4909        usage: &Usage,
4910        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4911    ) -> Result<(), fidl::Error>;
4912    fn r#bind_usage_volume_control2(
4913        &self,
4914        usage: &Usage2,
4915        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4916    ) -> Result<(), fidl::Error>;
4917    type GetVolumeFromDbResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4918    fn r#get_volume_from_db(&self, usage: &Usage, gain_db: f32)
4919    -> Self::GetVolumeFromDbResponseFut;
4920    type GetVolumeFromDb2ResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4921    fn r#get_volume_from_db2(
4922        &self,
4923        usage: &Usage2,
4924        gain_db: f32,
4925    ) -> Self::GetVolumeFromDb2ResponseFut;
4926    type GetDbFromVolumeResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4927    fn r#get_db_from_volume(&self, usage: &Usage, volume: f32) -> Self::GetDbFromVolumeResponseFut;
4928    type GetDbFromVolume2ResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4929    fn r#get_db_from_volume2(
4930        &self,
4931        usage: &Usage2,
4932        volume: f32,
4933    ) -> Self::GetDbFromVolume2ResponseFut;
4934    fn r#set_interaction(
4935        &self,
4936        active: &Usage,
4937        affected: &Usage,
4938        behavior: Behavior,
4939    ) -> Result<(), fidl::Error>;
4940    fn r#set_interaction2(
4941        &self,
4942        active: &Usage2,
4943        affected: &Usage2,
4944        behavior: Behavior,
4945    ) -> Result<(), fidl::Error>;
4946    fn r#reset_interactions(&self) -> Result<(), fidl::Error>;
4947    fn r#load_defaults(&self) -> Result<(), fidl::Error>;
4948}
4949#[derive(Debug)]
4950#[cfg(target_os = "fuchsia")]
4951pub struct AudioCoreSynchronousProxy {
4952    client: fidl::client::sync::Client,
4953}
4954
4955#[cfg(target_os = "fuchsia")]
4956impl fidl::endpoints::SynchronousProxy for AudioCoreSynchronousProxy {
4957    type Proxy = AudioCoreProxy;
4958    type Protocol = AudioCoreMarker;
4959
4960    fn from_channel(inner: fidl::Channel) -> Self {
4961        Self::new(inner)
4962    }
4963
4964    fn into_channel(self) -> fidl::Channel {
4965        self.client.into_channel()
4966    }
4967
4968    fn as_channel(&self) -> &fidl::Channel {
4969        self.client.as_channel()
4970    }
4971}
4972
4973#[cfg(target_os = "fuchsia")]
4974impl AudioCoreSynchronousProxy {
4975    pub fn new(channel: fidl::Channel) -> Self {
4976        Self { client: fidl::client::sync::Client::new(channel) }
4977    }
4978
4979    pub fn into_channel(self) -> fidl::Channel {
4980        self.client.into_channel()
4981    }
4982
4983    /// Waits until an event arrives and returns it. It is safe for other
4984    /// threads to make concurrent requests while waiting for an event.
4985    pub fn wait_for_event(
4986        &self,
4987        deadline: zx::MonotonicInstant,
4988    ) -> Result<AudioCoreEvent, fidl::Error> {
4989        AudioCoreEvent::decode(self.client.wait_for_event::<AudioCoreMarker>(deadline)?)
4990    }
4991
4992    /// Creates an AudioRenderer which outputs audio to the default device.
4993    pub fn r#create_audio_renderer(
4994        &self,
4995        mut audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
4996    ) -> Result<(), fidl::Error> {
4997        self.client.send::<AudioCoreCreateAudioRendererRequest>(
4998            (audio_out_request,),
4999            0x2ac9beba47f83435,
5000            fidl::encoding::DynamicFlags::empty(),
5001        )
5002    }
5003
5004    /// Creates an AudioCapturer according to the given requirements.
5005    ///
5006    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
5007    /// It causes the source material to be reformatted/resampled if needed
5008    /// in order to produce the requested stream type.
5009    ///
5010    /// `usage` is used by Fuchsia to make decisions about user experience.
5011    /// See `AudioCaptureUsage` for more details.
5012    ///
5013    /// `configuration` must be initialized to a variant, or no capturer
5014    /// can be created.
5015    pub fn r#create_audio_capturer_with_configuration(
5016        &self,
5017        mut stream_type: &AudioStreamType,
5018        mut configuration: &AudioCapturerConfiguration,
5019        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5020    ) -> Result<(), fidl::Error> {
5021        self.client.send::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(
5022            (stream_type, configuration, audio_capturer_request),
5023            0x459de383b0d76d97,
5024            fidl::encoding::DynamicFlags::empty(),
5025        )
5026    }
5027
5028    /// Creates an AudioCapturer which either captures from the current default
5029    /// audio input device, or loops-back from the current default audio output
5030    /// device based on value passed for the loopback flag.
5031    pub fn r#create_audio_capturer(
5032        &self,
5033        mut loopback: bool,
5034        mut audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5035    ) -> Result<(), fidl::Error> {
5036        self.client.send::<AudioCoreCreateAudioCapturerRequest>(
5037            (loopback, audio_in_request),
5038            0x787db169df99aed0,
5039            fidl::encoding::DynamicFlags::empty(),
5040        )
5041    }
5042
5043    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5044    pub fn r#set_render_usage_gain(
5045        &self,
5046        mut usage: AudioRenderUsage,
5047        mut gain_db: f32,
5048    ) -> Result<(), fidl::Error> {
5049        self.client.send::<AudioCoreSetRenderUsageGainRequest>(
5050            (usage, gain_db),
5051            0x48097f45f6e2b8e7,
5052            fidl::encoding::DynamicFlags::empty(),
5053        )
5054    }
5055
5056    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5057    pub fn r#set_render_usage_gain2(
5058        &self,
5059        mut usage: AudioRenderUsage2,
5060        mut gain_db: f32,
5061    ) -> Result<(), fidl::Error> {
5062        self.client.send::<AudioCoreSetRenderUsageGain2Request>(
5063            (usage, gain_db),
5064            0x779b1531dc9e64f4,
5065            fidl::encoding::DynamicFlags::FLEXIBLE,
5066        )
5067    }
5068
5069    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5070    pub fn r#set_capture_usage_gain(
5071        &self,
5072        mut usage: AudioCaptureUsage,
5073        mut gain_db: f32,
5074    ) -> Result<(), fidl::Error> {
5075        self.client.send::<AudioCoreSetCaptureUsageGainRequest>(
5076            (usage, gain_db),
5077            0x457d29217d4ea248,
5078            fidl::encoding::DynamicFlags::empty(),
5079        )
5080    }
5081
5082    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5083    pub fn r#set_capture_usage_gain2(
5084        &self,
5085        mut usage: AudioCaptureUsage2,
5086        mut gain_db: f32,
5087    ) -> Result<(), fidl::Error> {
5088        self.client.send::<AudioCoreSetCaptureUsageGain2Request>(
5089            (usage, gain_db),
5090            0x15065ee308f44af0,
5091            fidl::encoding::DynamicFlags::FLEXIBLE,
5092        )
5093    }
5094
5095    /// Binds to a volume control protocol for the given usage.
5096    pub fn r#bind_usage_volume_control(
5097        &self,
5098        mut usage: &Usage,
5099        mut volume_control: fidl::endpoints::ServerEnd<
5100            fidl_fuchsia_media_audio::VolumeControlMarker,
5101        >,
5102    ) -> Result<(), fidl::Error> {
5103        self.client.send::<AudioCoreBindUsageVolumeControlRequest>(
5104            (usage, volume_control),
5105            0x7225be116aadc137,
5106            fidl::encoding::DynamicFlags::empty(),
5107        )
5108    }
5109
5110    /// Binds to a volume control protocol for the given usage.
5111    pub fn r#bind_usage_volume_control2(
5112        &self,
5113        mut usage: &Usage2,
5114        mut volume_control: fidl::endpoints::ServerEnd<
5115            fidl_fuchsia_media_audio::VolumeControlMarker,
5116        >,
5117    ) -> Result<(), fidl::Error> {
5118        self.client.send::<AudioCoreBindUsageVolumeControl2Request>(
5119            (usage, volume_control),
5120            0x729dff93019d055,
5121            fidl::encoding::DynamicFlags::FLEXIBLE,
5122        )
5123    }
5124
5125    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5126    /// `usage`. This is the same mapping as used by the VolumeControl from
5127    /// `BindUsageVolumeControl`.
5128    pub fn r#get_volume_from_db(
5129        &self,
5130        mut usage: &Usage,
5131        mut gain_db: f32,
5132        ___deadline: zx::MonotonicInstant,
5133    ) -> Result<f32, fidl::Error> {
5134        let _response = self.client.send_query::<
5135            AudioCoreGetVolumeFromDbRequest,
5136            AudioCoreGetVolumeFromDbResponse,
5137            AudioCoreMarker,
5138        >(
5139            (usage, gain_db,),
5140            0x50e3ca45509770bf,
5141            fidl::encoding::DynamicFlags::empty(),
5142            ___deadline,
5143        )?;
5144        Ok(_response.volume)
5145    }
5146
5147    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5148    /// `usage`. This is the same mapping as used by the VolumeControl from
5149    /// `BindUsageVolumeControl`.
5150    pub fn r#get_volume_from_db2(
5151        &self,
5152        mut usage: &Usage2,
5153        mut gain_db: f32,
5154        ___deadline: zx::MonotonicInstant,
5155    ) -> Result<f32, fidl::Error> {
5156        let _response = self.client.send_query::<
5157            AudioCoreGetVolumeFromDb2Request,
5158            fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>,
5159            AudioCoreMarker,
5160        >(
5161            (usage, gain_db,),
5162            0x165c811091ef99da,
5163            fidl::encoding::DynamicFlags::FLEXIBLE,
5164            ___deadline,
5165        )?
5166        .into_result::<AudioCoreMarker>("get_volume_from_db2")?;
5167        Ok(_response.volume)
5168    }
5169
5170    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5171    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5172    pub fn r#get_db_from_volume(
5173        &self,
5174        mut usage: &Usage,
5175        mut volume: f32,
5176        ___deadline: zx::MonotonicInstant,
5177    ) -> Result<f32, fidl::Error> {
5178        let _response = self.client.send_query::<
5179            AudioCoreGetDbFromVolumeRequest,
5180            AudioCoreGetDbFromVolumeResponse,
5181            AudioCoreMarker,
5182        >(
5183            (usage, volume,),
5184            0x3e8eec27dd5a8bda,
5185            fidl::encoding::DynamicFlags::empty(),
5186            ___deadline,
5187        )?;
5188        Ok(_response.gain_db)
5189    }
5190
5191    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5192    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5193    pub fn r#get_db_from_volume2(
5194        &self,
5195        mut usage: &Usage2,
5196        mut volume: f32,
5197        ___deadline: zx::MonotonicInstant,
5198    ) -> Result<f32, fidl::Error> {
5199        let _response = self.client.send_query::<
5200            AudioCoreGetDbFromVolume2Request,
5201            fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>,
5202            AudioCoreMarker,
5203        >(
5204            (usage, volume,),
5205            0x5f421a8ebf265bf3,
5206            fidl::encoding::DynamicFlags::FLEXIBLE,
5207            ___deadline,
5208        )?
5209        .into_result::<AudioCoreMarker>("get_db_from_volume2")?;
5210        Ok(_response.gain_db)
5211    }
5212
5213    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5214    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5215    /// the Behavior specified will be applied to the streams of Usage `affected`.
5216    pub fn r#set_interaction(
5217        &self,
5218        mut active: &Usage,
5219        mut affected: &Usage,
5220        mut behavior: Behavior,
5221    ) -> Result<(), fidl::Error> {
5222        self.client.send::<AudioCoreSetInteractionRequest>(
5223            (active, affected, behavior),
5224            0x7bfed14345ece7b7,
5225            fidl::encoding::DynamicFlags::empty(),
5226        )
5227    }
5228
5229    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5230    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5231    /// the Behavior specified will be applied to the streams of Usage `affected`.
5232    pub fn r#set_interaction2(
5233        &self,
5234        mut active: &Usage2,
5235        mut affected: &Usage2,
5236        mut behavior: Behavior,
5237    ) -> Result<(), fidl::Error> {
5238        self.client.send::<AudioCoreSetInteraction2Request>(
5239            (active, affected, behavior),
5240            0x7226c7c6e6edc62f,
5241            fidl::encoding::DynamicFlags::FLEXIBLE,
5242        )
5243    }
5244
5245    /// Re-initializes the set of rules that are currently governing the interaction of streams in
5246    /// audio_core. The default behavior is 'NONE'.
5247    pub fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
5248        self.client.send::<fidl::encoding::EmptyPayload>(
5249            (),
5250            0x65bd94d9d0a28b5e,
5251            fidl::encoding::DynamicFlags::empty(),
5252        )
5253    }
5254
5255    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
5256    /// does not provide a config.
5257    pub fn r#load_defaults(&self) -> Result<(), fidl::Error> {
5258        self.client.send::<fidl::encoding::EmptyPayload>(
5259            (),
5260            0x54a0bebca85f6b31,
5261            fidl::encoding::DynamicFlags::empty(),
5262        )
5263    }
5264}
5265
5266#[cfg(target_os = "fuchsia")]
5267impl From<AudioCoreSynchronousProxy> for zx::NullableHandle {
5268    fn from(value: AudioCoreSynchronousProxy) -> Self {
5269        value.into_channel().into()
5270    }
5271}
5272
5273#[cfg(target_os = "fuchsia")]
5274impl From<fidl::Channel> for AudioCoreSynchronousProxy {
5275    fn from(value: fidl::Channel) -> Self {
5276        Self::new(value)
5277    }
5278}
5279
5280#[cfg(target_os = "fuchsia")]
5281impl fidl::endpoints::FromClient for AudioCoreSynchronousProxy {
5282    type Protocol = AudioCoreMarker;
5283
5284    fn from_client(value: fidl::endpoints::ClientEnd<AudioCoreMarker>) -> Self {
5285        Self::new(value.into_channel())
5286    }
5287}
5288
5289#[derive(Debug, Clone)]
5290pub struct AudioCoreProxy {
5291    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5292}
5293
5294impl fidl::endpoints::Proxy for AudioCoreProxy {
5295    type Protocol = AudioCoreMarker;
5296
5297    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5298        Self::new(inner)
5299    }
5300
5301    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5302        self.client.into_channel().map_err(|client| Self { client })
5303    }
5304
5305    fn as_channel(&self) -> &::fidl::AsyncChannel {
5306        self.client.as_channel()
5307    }
5308}
5309
5310impl AudioCoreProxy {
5311    /// Create a new Proxy for fuchsia.media/AudioCore.
5312    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5313        let protocol_name = <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5314        Self { client: fidl::client::Client::new(channel, protocol_name) }
5315    }
5316
5317    /// Get a Stream of events from the remote end of the protocol.
5318    ///
5319    /// # Panics
5320    ///
5321    /// Panics if the event stream was already taken.
5322    pub fn take_event_stream(&self) -> AudioCoreEventStream {
5323        AudioCoreEventStream { event_receiver: self.client.take_event_receiver() }
5324    }
5325
5326    /// Creates an AudioRenderer which outputs audio to the default device.
5327    pub fn r#create_audio_renderer(
5328        &self,
5329        mut audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
5330    ) -> Result<(), fidl::Error> {
5331        AudioCoreProxyInterface::r#create_audio_renderer(self, audio_out_request)
5332    }
5333
5334    /// Creates an AudioCapturer according to the given requirements.
5335    ///
5336    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
5337    /// It causes the source material to be reformatted/resampled if needed
5338    /// in order to produce the requested stream type.
5339    ///
5340    /// `usage` is used by Fuchsia to make decisions about user experience.
5341    /// See `AudioCaptureUsage` for more details.
5342    ///
5343    /// `configuration` must be initialized to a variant, or no capturer
5344    /// can be created.
5345    pub fn r#create_audio_capturer_with_configuration(
5346        &self,
5347        mut stream_type: &AudioStreamType,
5348        mut configuration: &AudioCapturerConfiguration,
5349        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5350    ) -> Result<(), fidl::Error> {
5351        AudioCoreProxyInterface::r#create_audio_capturer_with_configuration(
5352            self,
5353            stream_type,
5354            configuration,
5355            audio_capturer_request,
5356        )
5357    }
5358
5359    /// Creates an AudioCapturer which either captures from the current default
5360    /// audio input device, or loops-back from the current default audio output
5361    /// device based on value passed for the loopback flag.
5362    pub fn r#create_audio_capturer(
5363        &self,
5364        mut loopback: bool,
5365        mut audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5366    ) -> Result<(), fidl::Error> {
5367        AudioCoreProxyInterface::r#create_audio_capturer(self, loopback, audio_in_request)
5368    }
5369
5370    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5371    pub fn r#set_render_usage_gain(
5372        &self,
5373        mut usage: AudioRenderUsage,
5374        mut gain_db: f32,
5375    ) -> Result<(), fidl::Error> {
5376        AudioCoreProxyInterface::r#set_render_usage_gain(self, usage, gain_db)
5377    }
5378
5379    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5380    pub fn r#set_render_usage_gain2(
5381        &self,
5382        mut usage: AudioRenderUsage2,
5383        mut gain_db: f32,
5384    ) -> Result<(), fidl::Error> {
5385        AudioCoreProxyInterface::r#set_render_usage_gain2(self, usage, gain_db)
5386    }
5387
5388    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5389    pub fn r#set_capture_usage_gain(
5390        &self,
5391        mut usage: AudioCaptureUsage,
5392        mut gain_db: f32,
5393    ) -> Result<(), fidl::Error> {
5394        AudioCoreProxyInterface::r#set_capture_usage_gain(self, usage, gain_db)
5395    }
5396
5397    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5398    pub fn r#set_capture_usage_gain2(
5399        &self,
5400        mut usage: AudioCaptureUsage2,
5401        mut gain_db: f32,
5402    ) -> Result<(), fidl::Error> {
5403        AudioCoreProxyInterface::r#set_capture_usage_gain2(self, usage, gain_db)
5404    }
5405
5406    /// Binds to a volume control protocol for the given usage.
5407    pub fn r#bind_usage_volume_control(
5408        &self,
5409        mut usage: &Usage,
5410        mut volume_control: fidl::endpoints::ServerEnd<
5411            fidl_fuchsia_media_audio::VolumeControlMarker,
5412        >,
5413    ) -> Result<(), fidl::Error> {
5414        AudioCoreProxyInterface::r#bind_usage_volume_control(self, usage, volume_control)
5415    }
5416
5417    /// Binds to a volume control protocol for the given usage.
5418    pub fn r#bind_usage_volume_control2(
5419        &self,
5420        mut usage: &Usage2,
5421        mut volume_control: fidl::endpoints::ServerEnd<
5422            fidl_fuchsia_media_audio::VolumeControlMarker,
5423        >,
5424    ) -> Result<(), fidl::Error> {
5425        AudioCoreProxyInterface::r#bind_usage_volume_control2(self, usage, volume_control)
5426    }
5427
5428    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5429    /// `usage`. This is the same mapping as used by the VolumeControl from
5430    /// `BindUsageVolumeControl`.
5431    pub fn r#get_volume_from_db(
5432        &self,
5433        mut usage: &Usage,
5434        mut gain_db: f32,
5435    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5436        AudioCoreProxyInterface::r#get_volume_from_db(self, usage, gain_db)
5437    }
5438
5439    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5440    /// `usage`. This is the same mapping as used by the VolumeControl from
5441    /// `BindUsageVolumeControl`.
5442    pub fn r#get_volume_from_db2(
5443        &self,
5444        mut usage: &Usage2,
5445        mut gain_db: f32,
5446    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5447        AudioCoreProxyInterface::r#get_volume_from_db2(self, usage, gain_db)
5448    }
5449
5450    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5451    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5452    pub fn r#get_db_from_volume(
5453        &self,
5454        mut usage: &Usage,
5455        mut volume: f32,
5456    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5457        AudioCoreProxyInterface::r#get_db_from_volume(self, usage, volume)
5458    }
5459
5460    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5461    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5462    pub fn r#get_db_from_volume2(
5463        &self,
5464        mut usage: &Usage2,
5465        mut volume: f32,
5466    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5467        AudioCoreProxyInterface::r#get_db_from_volume2(self, usage, volume)
5468    }
5469
5470    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5471    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5472    /// the Behavior specified will be applied to the streams of Usage `affected`.
5473    pub fn r#set_interaction(
5474        &self,
5475        mut active: &Usage,
5476        mut affected: &Usage,
5477        mut behavior: Behavior,
5478    ) -> Result<(), fidl::Error> {
5479        AudioCoreProxyInterface::r#set_interaction(self, active, affected, behavior)
5480    }
5481
5482    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5483    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5484    /// the Behavior specified will be applied to the streams of Usage `affected`.
5485    pub fn r#set_interaction2(
5486        &self,
5487        mut active: &Usage2,
5488        mut affected: &Usage2,
5489        mut behavior: Behavior,
5490    ) -> Result<(), fidl::Error> {
5491        AudioCoreProxyInterface::r#set_interaction2(self, active, affected, behavior)
5492    }
5493
5494    /// Re-initializes the set of rules that are currently governing the interaction of streams in
5495    /// audio_core. The default behavior is 'NONE'.
5496    pub fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
5497        AudioCoreProxyInterface::r#reset_interactions(self)
5498    }
5499
5500    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
5501    /// does not provide a config.
5502    pub fn r#load_defaults(&self) -> Result<(), fidl::Error> {
5503        AudioCoreProxyInterface::r#load_defaults(self)
5504    }
5505}
5506
5507impl AudioCoreProxyInterface for AudioCoreProxy {
5508    fn r#create_audio_renderer(
5509        &self,
5510        mut audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
5511    ) -> Result<(), fidl::Error> {
5512        self.client.send::<AudioCoreCreateAudioRendererRequest>(
5513            (audio_out_request,),
5514            0x2ac9beba47f83435,
5515            fidl::encoding::DynamicFlags::empty(),
5516        )
5517    }
5518
5519    fn r#create_audio_capturer_with_configuration(
5520        &self,
5521        mut stream_type: &AudioStreamType,
5522        mut configuration: &AudioCapturerConfiguration,
5523        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5524    ) -> Result<(), fidl::Error> {
5525        self.client.send::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(
5526            (stream_type, configuration, audio_capturer_request),
5527            0x459de383b0d76d97,
5528            fidl::encoding::DynamicFlags::empty(),
5529        )
5530    }
5531
5532    fn r#create_audio_capturer(
5533        &self,
5534        mut loopback: bool,
5535        mut audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5536    ) -> Result<(), fidl::Error> {
5537        self.client.send::<AudioCoreCreateAudioCapturerRequest>(
5538            (loopback, audio_in_request),
5539            0x787db169df99aed0,
5540            fidl::encoding::DynamicFlags::empty(),
5541        )
5542    }
5543
5544    fn r#set_render_usage_gain(
5545        &self,
5546        mut usage: AudioRenderUsage,
5547        mut gain_db: f32,
5548    ) -> Result<(), fidl::Error> {
5549        self.client.send::<AudioCoreSetRenderUsageGainRequest>(
5550            (usage, gain_db),
5551            0x48097f45f6e2b8e7,
5552            fidl::encoding::DynamicFlags::empty(),
5553        )
5554    }
5555
5556    fn r#set_render_usage_gain2(
5557        &self,
5558        mut usage: AudioRenderUsage2,
5559        mut gain_db: f32,
5560    ) -> Result<(), fidl::Error> {
5561        self.client.send::<AudioCoreSetRenderUsageGain2Request>(
5562            (usage, gain_db),
5563            0x779b1531dc9e64f4,
5564            fidl::encoding::DynamicFlags::FLEXIBLE,
5565        )
5566    }
5567
5568    fn r#set_capture_usage_gain(
5569        &self,
5570        mut usage: AudioCaptureUsage,
5571        mut gain_db: f32,
5572    ) -> Result<(), fidl::Error> {
5573        self.client.send::<AudioCoreSetCaptureUsageGainRequest>(
5574            (usage, gain_db),
5575            0x457d29217d4ea248,
5576            fidl::encoding::DynamicFlags::empty(),
5577        )
5578    }
5579
5580    fn r#set_capture_usage_gain2(
5581        &self,
5582        mut usage: AudioCaptureUsage2,
5583        mut gain_db: f32,
5584    ) -> Result<(), fidl::Error> {
5585        self.client.send::<AudioCoreSetCaptureUsageGain2Request>(
5586            (usage, gain_db),
5587            0x15065ee308f44af0,
5588            fidl::encoding::DynamicFlags::FLEXIBLE,
5589        )
5590    }
5591
5592    fn r#bind_usage_volume_control(
5593        &self,
5594        mut usage: &Usage,
5595        mut volume_control: fidl::endpoints::ServerEnd<
5596            fidl_fuchsia_media_audio::VolumeControlMarker,
5597        >,
5598    ) -> Result<(), fidl::Error> {
5599        self.client.send::<AudioCoreBindUsageVolumeControlRequest>(
5600            (usage, volume_control),
5601            0x7225be116aadc137,
5602            fidl::encoding::DynamicFlags::empty(),
5603        )
5604    }
5605
5606    fn r#bind_usage_volume_control2(
5607        &self,
5608        mut usage: &Usage2,
5609        mut volume_control: fidl::endpoints::ServerEnd<
5610            fidl_fuchsia_media_audio::VolumeControlMarker,
5611        >,
5612    ) -> Result<(), fidl::Error> {
5613        self.client.send::<AudioCoreBindUsageVolumeControl2Request>(
5614            (usage, volume_control),
5615            0x729dff93019d055,
5616            fidl::encoding::DynamicFlags::FLEXIBLE,
5617        )
5618    }
5619
5620    type GetVolumeFromDbResponseFut =
5621        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5622    fn r#get_volume_from_db(
5623        &self,
5624        mut usage: &Usage,
5625        mut gain_db: f32,
5626    ) -> Self::GetVolumeFromDbResponseFut {
5627        fn _decode(
5628            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5629        ) -> Result<f32, fidl::Error> {
5630            let _response = fidl::client::decode_transaction_body::<
5631                AudioCoreGetVolumeFromDbResponse,
5632                fidl::encoding::DefaultFuchsiaResourceDialect,
5633                0x50e3ca45509770bf,
5634            >(_buf?)?;
5635            Ok(_response.volume)
5636        }
5637        self.client.send_query_and_decode::<AudioCoreGetVolumeFromDbRequest, f32>(
5638            (usage, gain_db),
5639            0x50e3ca45509770bf,
5640            fidl::encoding::DynamicFlags::empty(),
5641            _decode,
5642        )
5643    }
5644
5645    type GetVolumeFromDb2ResponseFut =
5646        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5647    fn r#get_volume_from_db2(
5648        &self,
5649        mut usage: &Usage2,
5650        mut gain_db: f32,
5651    ) -> Self::GetVolumeFromDb2ResponseFut {
5652        fn _decode(
5653            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5654        ) -> Result<f32, fidl::Error> {
5655            let _response = fidl::client::decode_transaction_body::<
5656                fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>,
5657                fidl::encoding::DefaultFuchsiaResourceDialect,
5658                0x165c811091ef99da,
5659            >(_buf?)?
5660            .into_result::<AudioCoreMarker>("get_volume_from_db2")?;
5661            Ok(_response.volume)
5662        }
5663        self.client.send_query_and_decode::<AudioCoreGetVolumeFromDb2Request, f32>(
5664            (usage, gain_db),
5665            0x165c811091ef99da,
5666            fidl::encoding::DynamicFlags::FLEXIBLE,
5667            _decode,
5668        )
5669    }
5670
5671    type GetDbFromVolumeResponseFut =
5672        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5673    fn r#get_db_from_volume(
5674        &self,
5675        mut usage: &Usage,
5676        mut volume: f32,
5677    ) -> Self::GetDbFromVolumeResponseFut {
5678        fn _decode(
5679            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5680        ) -> Result<f32, fidl::Error> {
5681            let _response = fidl::client::decode_transaction_body::<
5682                AudioCoreGetDbFromVolumeResponse,
5683                fidl::encoding::DefaultFuchsiaResourceDialect,
5684                0x3e8eec27dd5a8bda,
5685            >(_buf?)?;
5686            Ok(_response.gain_db)
5687        }
5688        self.client.send_query_and_decode::<AudioCoreGetDbFromVolumeRequest, f32>(
5689            (usage, volume),
5690            0x3e8eec27dd5a8bda,
5691            fidl::encoding::DynamicFlags::empty(),
5692            _decode,
5693        )
5694    }
5695
5696    type GetDbFromVolume2ResponseFut =
5697        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5698    fn r#get_db_from_volume2(
5699        &self,
5700        mut usage: &Usage2,
5701        mut volume: f32,
5702    ) -> Self::GetDbFromVolume2ResponseFut {
5703        fn _decode(
5704            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5705        ) -> Result<f32, fidl::Error> {
5706            let _response = fidl::client::decode_transaction_body::<
5707                fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>,
5708                fidl::encoding::DefaultFuchsiaResourceDialect,
5709                0x5f421a8ebf265bf3,
5710            >(_buf?)?
5711            .into_result::<AudioCoreMarker>("get_db_from_volume2")?;
5712            Ok(_response.gain_db)
5713        }
5714        self.client.send_query_and_decode::<AudioCoreGetDbFromVolume2Request, f32>(
5715            (usage, volume),
5716            0x5f421a8ebf265bf3,
5717            fidl::encoding::DynamicFlags::FLEXIBLE,
5718            _decode,
5719        )
5720    }
5721
5722    fn r#set_interaction(
5723        &self,
5724        mut active: &Usage,
5725        mut affected: &Usage,
5726        mut behavior: Behavior,
5727    ) -> Result<(), fidl::Error> {
5728        self.client.send::<AudioCoreSetInteractionRequest>(
5729            (active, affected, behavior),
5730            0x7bfed14345ece7b7,
5731            fidl::encoding::DynamicFlags::empty(),
5732        )
5733    }
5734
5735    fn r#set_interaction2(
5736        &self,
5737        mut active: &Usage2,
5738        mut affected: &Usage2,
5739        mut behavior: Behavior,
5740    ) -> Result<(), fidl::Error> {
5741        self.client.send::<AudioCoreSetInteraction2Request>(
5742            (active, affected, behavior),
5743            0x7226c7c6e6edc62f,
5744            fidl::encoding::DynamicFlags::FLEXIBLE,
5745        )
5746    }
5747
5748    fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
5749        self.client.send::<fidl::encoding::EmptyPayload>(
5750            (),
5751            0x65bd94d9d0a28b5e,
5752            fidl::encoding::DynamicFlags::empty(),
5753        )
5754    }
5755
5756    fn r#load_defaults(&self) -> Result<(), fidl::Error> {
5757        self.client.send::<fidl::encoding::EmptyPayload>(
5758            (),
5759            0x54a0bebca85f6b31,
5760            fidl::encoding::DynamicFlags::empty(),
5761        )
5762    }
5763}
5764
5765pub struct AudioCoreEventStream {
5766    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5767}
5768
5769impl std::marker::Unpin for AudioCoreEventStream {}
5770
5771impl futures::stream::FusedStream for AudioCoreEventStream {
5772    fn is_terminated(&self) -> bool {
5773        self.event_receiver.is_terminated()
5774    }
5775}
5776
5777impl futures::Stream for AudioCoreEventStream {
5778    type Item = Result<AudioCoreEvent, fidl::Error>;
5779
5780    fn poll_next(
5781        mut self: std::pin::Pin<&mut Self>,
5782        cx: &mut std::task::Context<'_>,
5783    ) -> std::task::Poll<Option<Self::Item>> {
5784        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5785            &mut self.event_receiver,
5786            cx
5787        )?) {
5788            Some(buf) => std::task::Poll::Ready(Some(AudioCoreEvent::decode(buf))),
5789            None => std::task::Poll::Ready(None),
5790        }
5791    }
5792}
5793
5794#[derive(Debug)]
5795pub enum AudioCoreEvent {
5796    #[non_exhaustive]
5797    _UnknownEvent {
5798        /// Ordinal of the event that was sent.
5799        ordinal: u64,
5800    },
5801}
5802
5803impl AudioCoreEvent {
5804    /// Decodes a message buffer as a [`AudioCoreEvent`].
5805    fn decode(
5806        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5807    ) -> Result<AudioCoreEvent, fidl::Error> {
5808        let (bytes, _handles) = buf.split_mut();
5809        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5810        debug_assert_eq!(tx_header.tx_id, 0);
5811        match tx_header.ordinal {
5812            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5813                Ok(AudioCoreEvent::_UnknownEvent { ordinal: tx_header.ordinal })
5814            }
5815            _ => Err(fidl::Error::UnknownOrdinal {
5816                ordinal: tx_header.ordinal,
5817                protocol_name: <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5818            }),
5819        }
5820    }
5821}
5822
5823/// A Stream of incoming requests for fuchsia.media/AudioCore.
5824pub struct AudioCoreRequestStream {
5825    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5826    is_terminated: bool,
5827}
5828
5829impl std::marker::Unpin for AudioCoreRequestStream {}
5830
5831impl futures::stream::FusedStream for AudioCoreRequestStream {
5832    fn is_terminated(&self) -> bool {
5833        self.is_terminated
5834    }
5835}
5836
5837impl fidl::endpoints::RequestStream for AudioCoreRequestStream {
5838    type Protocol = AudioCoreMarker;
5839    type ControlHandle = AudioCoreControlHandle;
5840
5841    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5842        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5843    }
5844
5845    fn control_handle(&self) -> Self::ControlHandle {
5846        AudioCoreControlHandle { inner: self.inner.clone() }
5847    }
5848
5849    fn into_inner(
5850        self,
5851    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5852    {
5853        (self.inner, self.is_terminated)
5854    }
5855
5856    fn from_inner(
5857        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5858        is_terminated: bool,
5859    ) -> Self {
5860        Self { inner, is_terminated }
5861    }
5862}
5863
5864impl futures::Stream for AudioCoreRequestStream {
5865    type Item = Result<AudioCoreRequest, fidl::Error>;
5866
5867    fn poll_next(
5868        mut self: std::pin::Pin<&mut Self>,
5869        cx: &mut std::task::Context<'_>,
5870    ) -> std::task::Poll<Option<Self::Item>> {
5871        let this = &mut *self;
5872        if this.inner.check_shutdown(cx) {
5873            this.is_terminated = true;
5874            return std::task::Poll::Ready(None);
5875        }
5876        if this.is_terminated {
5877            panic!("polled AudioCoreRequestStream after completion");
5878        }
5879        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5880            |bytes, handles| {
5881                match this.inner.channel().read_etc(cx, bytes, handles) {
5882                    std::task::Poll::Ready(Ok(())) => {}
5883                    std::task::Poll::Pending => return std::task::Poll::Pending,
5884                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5885                        this.is_terminated = true;
5886                        return std::task::Poll::Ready(None);
5887                    }
5888                    std::task::Poll::Ready(Err(e)) => {
5889                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5890                            e.into(),
5891                        ))));
5892                    }
5893                }
5894
5895                // A message has been received from the channel
5896                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5897
5898                std::task::Poll::Ready(Some(match header.ordinal {
5899                    0x2ac9beba47f83435 => {
5900                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5901                        let mut req = fidl::new_empty!(
5902                            AudioCoreCreateAudioRendererRequest,
5903                            fidl::encoding::DefaultFuchsiaResourceDialect
5904                        );
5905                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreCreateAudioRendererRequest>(&header, _body_bytes, handles, &mut req)?;
5906                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5907                        Ok(AudioCoreRequest::CreateAudioRenderer {
5908                            audio_out_request: req.audio_out_request,
5909
5910                            control_handle,
5911                        })
5912                    }
5913                    0x459de383b0d76d97 => {
5914                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5915                        let mut req = fidl::new_empty!(
5916                            AudioCoreCreateAudioCapturerWithConfigurationRequest,
5917                            fidl::encoding::DefaultFuchsiaResourceDialect
5918                        );
5919                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(&header, _body_bytes, handles, &mut req)?;
5920                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5921                        Ok(AudioCoreRequest::CreateAudioCapturerWithConfiguration {
5922                            stream_type: req.stream_type,
5923                            configuration: req.configuration,
5924                            audio_capturer_request: req.audio_capturer_request,
5925
5926                            control_handle,
5927                        })
5928                    }
5929                    0x787db169df99aed0 => {
5930                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5931                        let mut req = fidl::new_empty!(
5932                            AudioCoreCreateAudioCapturerRequest,
5933                            fidl::encoding::DefaultFuchsiaResourceDialect
5934                        );
5935                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreCreateAudioCapturerRequest>(&header, _body_bytes, handles, &mut req)?;
5936                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5937                        Ok(AudioCoreRequest::CreateAudioCapturer {
5938                            loopback: req.loopback,
5939                            audio_in_request: req.audio_in_request,
5940
5941                            control_handle,
5942                        })
5943                    }
5944                    0x48097f45f6e2b8e7 => {
5945                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5946                        let mut req = fidl::new_empty!(
5947                            AudioCoreSetRenderUsageGainRequest,
5948                            fidl::encoding::DefaultFuchsiaResourceDialect
5949                        );
5950                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetRenderUsageGainRequest>(&header, _body_bytes, handles, &mut req)?;
5951                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5952                        Ok(AudioCoreRequest::SetRenderUsageGain {
5953                            usage: req.usage,
5954                            gain_db: req.gain_db,
5955
5956                            control_handle,
5957                        })
5958                    }
5959                    0x779b1531dc9e64f4 => {
5960                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5961                        let mut req = fidl::new_empty!(
5962                            AudioCoreSetRenderUsageGain2Request,
5963                            fidl::encoding::DefaultFuchsiaResourceDialect
5964                        );
5965                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetRenderUsageGain2Request>(&header, _body_bytes, handles, &mut req)?;
5966                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5967                        Ok(AudioCoreRequest::SetRenderUsageGain2 {
5968                            usage: req.usage,
5969                            gain_db: req.gain_db,
5970
5971                            control_handle,
5972                        })
5973                    }
5974                    0x457d29217d4ea248 => {
5975                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5976                        let mut req = fidl::new_empty!(
5977                            AudioCoreSetCaptureUsageGainRequest,
5978                            fidl::encoding::DefaultFuchsiaResourceDialect
5979                        );
5980                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetCaptureUsageGainRequest>(&header, _body_bytes, handles, &mut req)?;
5981                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5982                        Ok(AudioCoreRequest::SetCaptureUsageGain {
5983                            usage: req.usage,
5984                            gain_db: req.gain_db,
5985
5986                            control_handle,
5987                        })
5988                    }
5989                    0x15065ee308f44af0 => {
5990                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5991                        let mut req = fidl::new_empty!(
5992                            AudioCoreSetCaptureUsageGain2Request,
5993                            fidl::encoding::DefaultFuchsiaResourceDialect
5994                        );
5995                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetCaptureUsageGain2Request>(&header, _body_bytes, handles, &mut req)?;
5996                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5997                        Ok(AudioCoreRequest::SetCaptureUsageGain2 {
5998                            usage: req.usage,
5999                            gain_db: req.gain_db,
6000
6001                            control_handle,
6002                        })
6003                    }
6004                    0x7225be116aadc137 => {
6005                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6006                        let mut req = fidl::new_empty!(
6007                            AudioCoreBindUsageVolumeControlRequest,
6008                            fidl::encoding::DefaultFuchsiaResourceDialect
6009                        );
6010                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreBindUsageVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
6011                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6012                        Ok(AudioCoreRequest::BindUsageVolumeControl {
6013                            usage: req.usage,
6014                            volume_control: req.volume_control,
6015
6016                            control_handle,
6017                        })
6018                    }
6019                    0x729dff93019d055 => {
6020                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6021                        let mut req = fidl::new_empty!(
6022                            AudioCoreBindUsageVolumeControl2Request,
6023                            fidl::encoding::DefaultFuchsiaResourceDialect
6024                        );
6025                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreBindUsageVolumeControl2Request>(&header, _body_bytes, handles, &mut req)?;
6026                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6027                        Ok(AudioCoreRequest::BindUsageVolumeControl2 {
6028                            usage: req.usage,
6029                            volume_control: req.volume_control,
6030
6031                            control_handle,
6032                        })
6033                    }
6034                    0x50e3ca45509770bf => {
6035                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6036                        let mut req = fidl::new_empty!(
6037                            AudioCoreGetVolumeFromDbRequest,
6038                            fidl::encoding::DefaultFuchsiaResourceDialect
6039                        );
6040                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetVolumeFromDbRequest>(&header, _body_bytes, handles, &mut req)?;
6041                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6042                        Ok(AudioCoreRequest::GetVolumeFromDb {
6043                            usage: req.usage,
6044                            gain_db: req.gain_db,
6045
6046                            responder: AudioCoreGetVolumeFromDbResponder {
6047                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6048                                tx_id: header.tx_id,
6049                            },
6050                        })
6051                    }
6052                    0x165c811091ef99da => {
6053                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6054                        let mut req = fidl::new_empty!(
6055                            AudioCoreGetVolumeFromDb2Request,
6056                            fidl::encoding::DefaultFuchsiaResourceDialect
6057                        );
6058                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetVolumeFromDb2Request>(&header, _body_bytes, handles, &mut req)?;
6059                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6060                        Ok(AudioCoreRequest::GetVolumeFromDb2 {
6061                            usage: req.usage,
6062                            gain_db: req.gain_db,
6063
6064                            responder: AudioCoreGetVolumeFromDb2Responder {
6065                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6066                                tx_id: header.tx_id,
6067                            },
6068                        })
6069                    }
6070                    0x3e8eec27dd5a8bda => {
6071                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6072                        let mut req = fidl::new_empty!(
6073                            AudioCoreGetDbFromVolumeRequest,
6074                            fidl::encoding::DefaultFuchsiaResourceDialect
6075                        );
6076                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetDbFromVolumeRequest>(&header, _body_bytes, handles, &mut req)?;
6077                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6078                        Ok(AudioCoreRequest::GetDbFromVolume {
6079                            usage: req.usage,
6080                            volume: req.volume,
6081
6082                            responder: AudioCoreGetDbFromVolumeResponder {
6083                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6084                                tx_id: header.tx_id,
6085                            },
6086                        })
6087                    }
6088                    0x5f421a8ebf265bf3 => {
6089                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6090                        let mut req = fidl::new_empty!(
6091                            AudioCoreGetDbFromVolume2Request,
6092                            fidl::encoding::DefaultFuchsiaResourceDialect
6093                        );
6094                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetDbFromVolume2Request>(&header, _body_bytes, handles, &mut req)?;
6095                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6096                        Ok(AudioCoreRequest::GetDbFromVolume2 {
6097                            usage: req.usage,
6098                            volume: req.volume,
6099
6100                            responder: AudioCoreGetDbFromVolume2Responder {
6101                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6102                                tx_id: header.tx_id,
6103                            },
6104                        })
6105                    }
6106                    0x7bfed14345ece7b7 => {
6107                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6108                        let mut req = fidl::new_empty!(
6109                            AudioCoreSetInteractionRequest,
6110                            fidl::encoding::DefaultFuchsiaResourceDialect
6111                        );
6112                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetInteractionRequest>(&header, _body_bytes, handles, &mut req)?;
6113                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6114                        Ok(AudioCoreRequest::SetInteraction {
6115                            active: req.active,
6116                            affected: req.affected,
6117                            behavior: req.behavior,
6118
6119                            control_handle,
6120                        })
6121                    }
6122                    0x7226c7c6e6edc62f => {
6123                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6124                        let mut req = fidl::new_empty!(
6125                            AudioCoreSetInteraction2Request,
6126                            fidl::encoding::DefaultFuchsiaResourceDialect
6127                        );
6128                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetInteraction2Request>(&header, _body_bytes, handles, &mut req)?;
6129                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6130                        Ok(AudioCoreRequest::SetInteraction2 {
6131                            active: req.active,
6132                            affected: req.affected,
6133                            behavior: req.behavior,
6134
6135                            control_handle,
6136                        })
6137                    }
6138                    0x65bd94d9d0a28b5e => {
6139                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6140                        let mut req = fidl::new_empty!(
6141                            fidl::encoding::EmptyPayload,
6142                            fidl::encoding::DefaultFuchsiaResourceDialect
6143                        );
6144                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6145                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6146                        Ok(AudioCoreRequest::ResetInteractions { control_handle })
6147                    }
6148                    0x54a0bebca85f6b31 => {
6149                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6150                        let mut req = fidl::new_empty!(
6151                            fidl::encoding::EmptyPayload,
6152                            fidl::encoding::DefaultFuchsiaResourceDialect
6153                        );
6154                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6155                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6156                        Ok(AudioCoreRequest::LoadDefaults { control_handle })
6157                    }
6158                    _ if header.tx_id == 0
6159                        && header
6160                            .dynamic_flags()
6161                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6162                    {
6163                        Ok(AudioCoreRequest::_UnknownMethod {
6164                            ordinal: header.ordinal,
6165                            control_handle: AudioCoreControlHandle { inner: this.inner.clone() },
6166                            method_type: fidl::MethodType::OneWay,
6167                        })
6168                    }
6169                    _ if header
6170                        .dynamic_flags()
6171                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6172                    {
6173                        this.inner.send_framework_err(
6174                            fidl::encoding::FrameworkErr::UnknownMethod,
6175                            header.tx_id,
6176                            header.ordinal,
6177                            header.dynamic_flags(),
6178                            (bytes, handles),
6179                        )?;
6180                        Ok(AudioCoreRequest::_UnknownMethod {
6181                            ordinal: header.ordinal,
6182                            control_handle: AudioCoreControlHandle { inner: this.inner.clone() },
6183                            method_type: fidl::MethodType::TwoWay,
6184                        })
6185                    }
6186                    _ => Err(fidl::Error::UnknownOrdinal {
6187                        ordinal: header.ordinal,
6188                        protocol_name:
6189                            <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6190                    }),
6191                }))
6192            },
6193        )
6194    }
6195}
6196
6197#[derive(Debug)]
6198pub enum AudioCoreRequest {
6199    /// Creates an AudioRenderer which outputs audio to the default device.
6200    CreateAudioRenderer {
6201        audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
6202        control_handle: AudioCoreControlHandle,
6203    },
6204    /// Creates an AudioCapturer according to the given requirements.
6205    ///
6206    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
6207    /// It causes the source material to be reformatted/resampled if needed
6208    /// in order to produce the requested stream type.
6209    ///
6210    /// `usage` is used by Fuchsia to make decisions about user experience.
6211    /// See `AudioCaptureUsage` for more details.
6212    ///
6213    /// `configuration` must be initialized to a variant, or no capturer
6214    /// can be created.
6215    CreateAudioCapturerWithConfiguration {
6216        stream_type: AudioStreamType,
6217        configuration: AudioCapturerConfiguration,
6218        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
6219        control_handle: AudioCoreControlHandle,
6220    },
6221    /// Creates an AudioCapturer which either captures from the current default
6222    /// audio input device, or loops-back from the current default audio output
6223    /// device based on value passed for the loopback flag.
6224    CreateAudioCapturer {
6225        loopback: bool,
6226        audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
6227        control_handle: AudioCoreControlHandle,
6228    },
6229    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
6230    SetRenderUsageGain {
6231        usage: AudioRenderUsage,
6232        gain_db: f32,
6233        control_handle: AudioCoreControlHandle,
6234    },
6235    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
6236    SetRenderUsageGain2 {
6237        usage: AudioRenderUsage2,
6238        gain_db: f32,
6239        control_handle: AudioCoreControlHandle,
6240    },
6241    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
6242    SetCaptureUsageGain {
6243        usage: AudioCaptureUsage,
6244        gain_db: f32,
6245        control_handle: AudioCoreControlHandle,
6246    },
6247    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
6248    SetCaptureUsageGain2 {
6249        usage: AudioCaptureUsage2,
6250        gain_db: f32,
6251        control_handle: AudioCoreControlHandle,
6252    },
6253    /// Binds to a volume control protocol for the given usage.
6254    BindUsageVolumeControl {
6255        usage: Usage,
6256        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6257        control_handle: AudioCoreControlHandle,
6258    },
6259    /// Binds to a volume control protocol for the given usage.
6260    BindUsageVolumeControl2 {
6261        usage: Usage2,
6262        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6263        control_handle: AudioCoreControlHandle,
6264    },
6265    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
6266    /// `usage`. This is the same mapping as used by the VolumeControl from
6267    /// `BindUsageVolumeControl`.
6268    GetVolumeFromDb { usage: Usage, gain_db: f32, responder: AudioCoreGetVolumeFromDbResponder },
6269    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
6270    /// `usage`. This is the same mapping as used by the VolumeControl from
6271    /// `BindUsageVolumeControl`.
6272    GetVolumeFromDb2 { usage: Usage2, gain_db: f32, responder: AudioCoreGetVolumeFromDb2Responder },
6273    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
6274    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
6275    GetDbFromVolume { usage: Usage, volume: f32, responder: AudioCoreGetDbFromVolumeResponder },
6276    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
6277    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
6278    GetDbFromVolume2 { usage: Usage2, volume: f32, responder: AudioCoreGetDbFromVolume2Responder },
6279    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
6280    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
6281    /// the Behavior specified will be applied to the streams of Usage `affected`.
6282    SetInteraction {
6283        active: Usage,
6284        affected: Usage,
6285        behavior: Behavior,
6286        control_handle: AudioCoreControlHandle,
6287    },
6288    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
6289    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
6290    /// the Behavior specified will be applied to the streams of Usage `affected`.
6291    SetInteraction2 {
6292        active: Usage2,
6293        affected: Usage2,
6294        behavior: Behavior,
6295        control_handle: AudioCoreControlHandle,
6296    },
6297    /// Re-initializes the set of rules that are currently governing the interaction of streams in
6298    /// audio_core. The default behavior is 'NONE'.
6299    ResetInteractions { control_handle: AudioCoreControlHandle },
6300    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
6301    /// does not provide a config.
6302    LoadDefaults { control_handle: AudioCoreControlHandle },
6303    /// An interaction was received which does not match any known method.
6304    #[non_exhaustive]
6305    _UnknownMethod {
6306        /// Ordinal of the method that was called.
6307        ordinal: u64,
6308        control_handle: AudioCoreControlHandle,
6309        method_type: fidl::MethodType,
6310    },
6311}
6312
6313impl AudioCoreRequest {
6314    #[allow(irrefutable_let_patterns)]
6315    pub fn into_create_audio_renderer(
6316        self,
6317    ) -> Option<(fidl::endpoints::ServerEnd<AudioRendererMarker>, AudioCoreControlHandle)> {
6318        if let AudioCoreRequest::CreateAudioRenderer { audio_out_request, control_handle } = self {
6319            Some((audio_out_request, control_handle))
6320        } else {
6321            None
6322        }
6323    }
6324
6325    #[allow(irrefutable_let_patterns)]
6326    pub fn into_create_audio_capturer_with_configuration(
6327        self,
6328    ) -> Option<(
6329        AudioStreamType,
6330        AudioCapturerConfiguration,
6331        fidl::endpoints::ServerEnd<AudioCapturerMarker>,
6332        AudioCoreControlHandle,
6333    )> {
6334        if let AudioCoreRequest::CreateAudioCapturerWithConfiguration {
6335            stream_type,
6336            configuration,
6337            audio_capturer_request,
6338            control_handle,
6339        } = self
6340        {
6341            Some((stream_type, configuration, audio_capturer_request, control_handle))
6342        } else {
6343            None
6344        }
6345    }
6346
6347    #[allow(irrefutable_let_patterns)]
6348    pub fn into_create_audio_capturer(
6349        self,
6350    ) -> Option<(bool, fidl::endpoints::ServerEnd<AudioCapturerMarker>, AudioCoreControlHandle)>
6351    {
6352        if let AudioCoreRequest::CreateAudioCapturer {
6353            loopback,
6354            audio_in_request,
6355            control_handle,
6356        } = self
6357        {
6358            Some((loopback, audio_in_request, control_handle))
6359        } else {
6360            None
6361        }
6362    }
6363
6364    #[allow(irrefutable_let_patterns)]
6365    pub fn into_set_render_usage_gain(
6366        self,
6367    ) -> Option<(AudioRenderUsage, f32, AudioCoreControlHandle)> {
6368        if let AudioCoreRequest::SetRenderUsageGain { usage, gain_db, control_handle } = self {
6369            Some((usage, gain_db, control_handle))
6370        } else {
6371            None
6372        }
6373    }
6374
6375    #[allow(irrefutable_let_patterns)]
6376    pub fn into_set_render_usage_gain2(
6377        self,
6378    ) -> Option<(AudioRenderUsage2, f32, AudioCoreControlHandle)> {
6379        if let AudioCoreRequest::SetRenderUsageGain2 { usage, gain_db, control_handle } = self {
6380            Some((usage, gain_db, control_handle))
6381        } else {
6382            None
6383        }
6384    }
6385
6386    #[allow(irrefutable_let_patterns)]
6387    pub fn into_set_capture_usage_gain(
6388        self,
6389    ) -> Option<(AudioCaptureUsage, f32, AudioCoreControlHandle)> {
6390        if let AudioCoreRequest::SetCaptureUsageGain { usage, gain_db, control_handle } = self {
6391            Some((usage, gain_db, control_handle))
6392        } else {
6393            None
6394        }
6395    }
6396
6397    #[allow(irrefutable_let_patterns)]
6398    pub fn into_set_capture_usage_gain2(
6399        self,
6400    ) -> Option<(AudioCaptureUsage2, f32, AudioCoreControlHandle)> {
6401        if let AudioCoreRequest::SetCaptureUsageGain2 { usage, gain_db, control_handle } = self {
6402            Some((usage, gain_db, control_handle))
6403        } else {
6404            None
6405        }
6406    }
6407
6408    #[allow(irrefutable_let_patterns)]
6409    pub fn into_bind_usage_volume_control(
6410        self,
6411    ) -> Option<(
6412        Usage,
6413        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6414        AudioCoreControlHandle,
6415    )> {
6416        if let AudioCoreRequest::BindUsageVolumeControl { usage, volume_control, control_handle } =
6417            self
6418        {
6419            Some((usage, volume_control, control_handle))
6420        } else {
6421            None
6422        }
6423    }
6424
6425    #[allow(irrefutable_let_patterns)]
6426    pub fn into_bind_usage_volume_control2(
6427        self,
6428    ) -> Option<(
6429        Usage2,
6430        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6431        AudioCoreControlHandle,
6432    )> {
6433        if let AudioCoreRequest::BindUsageVolumeControl2 { usage, volume_control, control_handle } =
6434            self
6435        {
6436            Some((usage, volume_control, control_handle))
6437        } else {
6438            None
6439        }
6440    }
6441
6442    #[allow(irrefutable_let_patterns)]
6443    pub fn into_get_volume_from_db(
6444        self,
6445    ) -> Option<(Usage, f32, AudioCoreGetVolumeFromDbResponder)> {
6446        if let AudioCoreRequest::GetVolumeFromDb { usage, gain_db, responder } = self {
6447            Some((usage, gain_db, responder))
6448        } else {
6449            None
6450        }
6451    }
6452
6453    #[allow(irrefutable_let_patterns)]
6454    pub fn into_get_volume_from_db2(
6455        self,
6456    ) -> Option<(Usage2, f32, AudioCoreGetVolumeFromDb2Responder)> {
6457        if let AudioCoreRequest::GetVolumeFromDb2 { usage, gain_db, responder } = self {
6458            Some((usage, gain_db, responder))
6459        } else {
6460            None
6461        }
6462    }
6463
6464    #[allow(irrefutable_let_patterns)]
6465    pub fn into_get_db_from_volume(
6466        self,
6467    ) -> Option<(Usage, f32, AudioCoreGetDbFromVolumeResponder)> {
6468        if let AudioCoreRequest::GetDbFromVolume { usage, volume, responder } = self {
6469            Some((usage, volume, responder))
6470        } else {
6471            None
6472        }
6473    }
6474
6475    #[allow(irrefutable_let_patterns)]
6476    pub fn into_get_db_from_volume2(
6477        self,
6478    ) -> Option<(Usage2, f32, AudioCoreGetDbFromVolume2Responder)> {
6479        if let AudioCoreRequest::GetDbFromVolume2 { usage, volume, responder } = self {
6480            Some((usage, volume, responder))
6481        } else {
6482            None
6483        }
6484    }
6485
6486    #[allow(irrefutable_let_patterns)]
6487    pub fn into_set_interaction(self) -> Option<(Usage, Usage, Behavior, AudioCoreControlHandle)> {
6488        if let AudioCoreRequest::SetInteraction { active, affected, behavior, control_handle } =
6489            self
6490        {
6491            Some((active, affected, behavior, control_handle))
6492        } else {
6493            None
6494        }
6495    }
6496
6497    #[allow(irrefutable_let_patterns)]
6498    pub fn into_set_interaction2(
6499        self,
6500    ) -> Option<(Usage2, Usage2, Behavior, AudioCoreControlHandle)> {
6501        if let AudioCoreRequest::SetInteraction2 { active, affected, behavior, control_handle } =
6502            self
6503        {
6504            Some((active, affected, behavior, control_handle))
6505        } else {
6506            None
6507        }
6508    }
6509
6510    #[allow(irrefutable_let_patterns)]
6511    pub fn into_reset_interactions(self) -> Option<(AudioCoreControlHandle)> {
6512        if let AudioCoreRequest::ResetInteractions { control_handle } = self {
6513            Some((control_handle))
6514        } else {
6515            None
6516        }
6517    }
6518
6519    #[allow(irrefutable_let_patterns)]
6520    pub fn into_load_defaults(self) -> Option<(AudioCoreControlHandle)> {
6521        if let AudioCoreRequest::LoadDefaults { control_handle } = self {
6522            Some((control_handle))
6523        } else {
6524            None
6525        }
6526    }
6527
6528    /// Name of the method defined in FIDL
6529    pub fn method_name(&self) -> &'static str {
6530        match *self {
6531            AudioCoreRequest::CreateAudioRenderer { .. } => "create_audio_renderer",
6532            AudioCoreRequest::CreateAudioCapturerWithConfiguration { .. } => {
6533                "create_audio_capturer_with_configuration"
6534            }
6535            AudioCoreRequest::CreateAudioCapturer { .. } => "create_audio_capturer",
6536            AudioCoreRequest::SetRenderUsageGain { .. } => "set_render_usage_gain",
6537            AudioCoreRequest::SetRenderUsageGain2 { .. } => "set_render_usage_gain2",
6538            AudioCoreRequest::SetCaptureUsageGain { .. } => "set_capture_usage_gain",
6539            AudioCoreRequest::SetCaptureUsageGain2 { .. } => "set_capture_usage_gain2",
6540            AudioCoreRequest::BindUsageVolumeControl { .. } => "bind_usage_volume_control",
6541            AudioCoreRequest::BindUsageVolumeControl2 { .. } => "bind_usage_volume_control2",
6542            AudioCoreRequest::GetVolumeFromDb { .. } => "get_volume_from_db",
6543            AudioCoreRequest::GetVolumeFromDb2 { .. } => "get_volume_from_db2",
6544            AudioCoreRequest::GetDbFromVolume { .. } => "get_db_from_volume",
6545            AudioCoreRequest::GetDbFromVolume2 { .. } => "get_db_from_volume2",
6546            AudioCoreRequest::SetInteraction { .. } => "set_interaction",
6547            AudioCoreRequest::SetInteraction2 { .. } => "set_interaction2",
6548            AudioCoreRequest::ResetInteractions { .. } => "reset_interactions",
6549            AudioCoreRequest::LoadDefaults { .. } => "load_defaults",
6550            AudioCoreRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
6551                "unknown one-way method"
6552            }
6553            AudioCoreRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
6554                "unknown two-way method"
6555            }
6556        }
6557    }
6558}
6559
6560#[derive(Debug, Clone)]
6561pub struct AudioCoreControlHandle {
6562    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6563}
6564
6565impl fidl::endpoints::ControlHandle for AudioCoreControlHandle {
6566    fn shutdown(&self) {
6567        self.inner.shutdown()
6568    }
6569
6570    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6571        self.inner.shutdown_with_epitaph(status)
6572    }
6573
6574    fn is_closed(&self) -> bool {
6575        self.inner.channel().is_closed()
6576    }
6577    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6578        self.inner.channel().on_closed()
6579    }
6580
6581    #[cfg(target_os = "fuchsia")]
6582    fn signal_peer(
6583        &self,
6584        clear_mask: zx::Signals,
6585        set_mask: zx::Signals,
6586    ) -> Result<(), zx_status::Status> {
6587        use fidl::Peered;
6588        self.inner.channel().signal_peer(clear_mask, set_mask)
6589    }
6590}
6591
6592impl AudioCoreControlHandle {}
6593
6594#[must_use = "FIDL methods require a response to be sent"]
6595#[derive(Debug)]
6596pub struct AudioCoreGetVolumeFromDbResponder {
6597    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6598    tx_id: u32,
6599}
6600
6601/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6602/// if the responder is dropped without sending a response, so that the client
6603/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6604impl std::ops::Drop for AudioCoreGetVolumeFromDbResponder {
6605    fn drop(&mut self) {
6606        self.control_handle.shutdown();
6607        // Safety: drops once, never accessed again
6608        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6609    }
6610}
6611
6612impl fidl::endpoints::Responder for AudioCoreGetVolumeFromDbResponder {
6613    type ControlHandle = AudioCoreControlHandle;
6614
6615    fn control_handle(&self) -> &AudioCoreControlHandle {
6616        &self.control_handle
6617    }
6618
6619    fn drop_without_shutdown(mut self) {
6620        // Safety: drops once, never accessed again due to mem::forget
6621        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6622        // Prevent Drop from running (which would shut down the channel)
6623        std::mem::forget(self);
6624    }
6625}
6626
6627impl AudioCoreGetVolumeFromDbResponder {
6628    /// Sends a response to the FIDL transaction.
6629    ///
6630    /// Sets the channel to shutdown if an error occurs.
6631    pub fn send(self, mut volume: f32) -> Result<(), fidl::Error> {
6632        let _result = self.send_raw(volume);
6633        if _result.is_err() {
6634            self.control_handle.shutdown();
6635        }
6636        self.drop_without_shutdown();
6637        _result
6638    }
6639
6640    /// Similar to "send" but does not shutdown the channel if an error occurs.
6641    pub fn send_no_shutdown_on_err(self, mut volume: f32) -> Result<(), fidl::Error> {
6642        let _result = self.send_raw(volume);
6643        self.drop_without_shutdown();
6644        _result
6645    }
6646
6647    fn send_raw(&self, mut volume: f32) -> Result<(), fidl::Error> {
6648        self.control_handle.inner.send::<AudioCoreGetVolumeFromDbResponse>(
6649            (volume,),
6650            self.tx_id,
6651            0x50e3ca45509770bf,
6652            fidl::encoding::DynamicFlags::empty(),
6653        )
6654    }
6655}
6656
6657#[must_use = "FIDL methods require a response to be sent"]
6658#[derive(Debug)]
6659pub struct AudioCoreGetVolumeFromDb2Responder {
6660    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6661    tx_id: u32,
6662}
6663
6664/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6665/// if the responder is dropped without sending a response, so that the client
6666/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6667impl std::ops::Drop for AudioCoreGetVolumeFromDb2Responder {
6668    fn drop(&mut self) {
6669        self.control_handle.shutdown();
6670        // Safety: drops once, never accessed again
6671        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6672    }
6673}
6674
6675impl fidl::endpoints::Responder for AudioCoreGetVolumeFromDb2Responder {
6676    type ControlHandle = AudioCoreControlHandle;
6677
6678    fn control_handle(&self) -> &AudioCoreControlHandle {
6679        &self.control_handle
6680    }
6681
6682    fn drop_without_shutdown(mut self) {
6683        // Safety: drops once, never accessed again due to mem::forget
6684        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6685        // Prevent Drop from running (which would shut down the channel)
6686        std::mem::forget(self);
6687    }
6688}
6689
6690impl AudioCoreGetVolumeFromDb2Responder {
6691    /// Sends a response to the FIDL transaction.
6692    ///
6693    /// Sets the channel to shutdown if an error occurs.
6694    pub fn send(self, mut volume: f32) -> Result<(), fidl::Error> {
6695        let _result = self.send_raw(volume);
6696        if _result.is_err() {
6697            self.control_handle.shutdown();
6698        }
6699        self.drop_without_shutdown();
6700        _result
6701    }
6702
6703    /// Similar to "send" but does not shutdown the channel if an error occurs.
6704    pub fn send_no_shutdown_on_err(self, mut volume: f32) -> Result<(), fidl::Error> {
6705        let _result = self.send_raw(volume);
6706        self.drop_without_shutdown();
6707        _result
6708    }
6709
6710    fn send_raw(&self, mut volume: f32) -> Result<(), fidl::Error> {
6711        self.control_handle
6712            .inner
6713            .send::<fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>>(
6714                fidl::encoding::Flexible::new((volume,)),
6715                self.tx_id,
6716                0x165c811091ef99da,
6717                fidl::encoding::DynamicFlags::FLEXIBLE,
6718            )
6719    }
6720}
6721
6722#[must_use = "FIDL methods require a response to be sent"]
6723#[derive(Debug)]
6724pub struct AudioCoreGetDbFromVolumeResponder {
6725    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6726    tx_id: u32,
6727}
6728
6729/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6730/// if the responder is dropped without sending a response, so that the client
6731/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6732impl std::ops::Drop for AudioCoreGetDbFromVolumeResponder {
6733    fn drop(&mut self) {
6734        self.control_handle.shutdown();
6735        // Safety: drops once, never accessed again
6736        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6737    }
6738}
6739
6740impl fidl::endpoints::Responder for AudioCoreGetDbFromVolumeResponder {
6741    type ControlHandle = AudioCoreControlHandle;
6742
6743    fn control_handle(&self) -> &AudioCoreControlHandle {
6744        &self.control_handle
6745    }
6746
6747    fn drop_without_shutdown(mut self) {
6748        // Safety: drops once, never accessed again due to mem::forget
6749        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6750        // Prevent Drop from running (which would shut down the channel)
6751        std::mem::forget(self);
6752    }
6753}
6754
6755impl AudioCoreGetDbFromVolumeResponder {
6756    /// Sends a response to the FIDL transaction.
6757    ///
6758    /// Sets the channel to shutdown if an error occurs.
6759    pub fn send(self, mut gain_db: f32) -> Result<(), fidl::Error> {
6760        let _result = self.send_raw(gain_db);
6761        if _result.is_err() {
6762            self.control_handle.shutdown();
6763        }
6764        self.drop_without_shutdown();
6765        _result
6766    }
6767
6768    /// Similar to "send" but does not shutdown the channel if an error occurs.
6769    pub fn send_no_shutdown_on_err(self, mut gain_db: f32) -> Result<(), fidl::Error> {
6770        let _result = self.send_raw(gain_db);
6771        self.drop_without_shutdown();
6772        _result
6773    }
6774
6775    fn send_raw(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
6776        self.control_handle.inner.send::<AudioCoreGetDbFromVolumeResponse>(
6777            (gain_db,),
6778            self.tx_id,
6779            0x3e8eec27dd5a8bda,
6780            fidl::encoding::DynamicFlags::empty(),
6781        )
6782    }
6783}
6784
6785#[must_use = "FIDL methods require a response to be sent"]
6786#[derive(Debug)]
6787pub struct AudioCoreGetDbFromVolume2Responder {
6788    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6789    tx_id: u32,
6790}
6791
6792/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6793/// if the responder is dropped without sending a response, so that the client
6794/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6795impl std::ops::Drop for AudioCoreGetDbFromVolume2Responder {
6796    fn drop(&mut self) {
6797        self.control_handle.shutdown();
6798        // Safety: drops once, never accessed again
6799        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6800    }
6801}
6802
6803impl fidl::endpoints::Responder for AudioCoreGetDbFromVolume2Responder {
6804    type ControlHandle = AudioCoreControlHandle;
6805
6806    fn control_handle(&self) -> &AudioCoreControlHandle {
6807        &self.control_handle
6808    }
6809
6810    fn drop_without_shutdown(mut self) {
6811        // Safety: drops once, never accessed again due to mem::forget
6812        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6813        // Prevent Drop from running (which would shut down the channel)
6814        std::mem::forget(self);
6815    }
6816}
6817
6818impl AudioCoreGetDbFromVolume2Responder {
6819    /// Sends a response to the FIDL transaction.
6820    ///
6821    /// Sets the channel to shutdown if an error occurs.
6822    pub fn send(self, mut gain_db: f32) -> Result<(), fidl::Error> {
6823        let _result = self.send_raw(gain_db);
6824        if _result.is_err() {
6825            self.control_handle.shutdown();
6826        }
6827        self.drop_without_shutdown();
6828        _result
6829    }
6830
6831    /// Similar to "send" but does not shutdown the channel if an error occurs.
6832    pub fn send_no_shutdown_on_err(self, mut gain_db: f32) -> Result<(), fidl::Error> {
6833        let _result = self.send_raw(gain_db);
6834        self.drop_without_shutdown();
6835        _result
6836    }
6837
6838    fn send_raw(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
6839        self.control_handle
6840            .inner
6841            .send::<fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>>(
6842                fidl::encoding::Flexible::new((gain_db,)),
6843                self.tx_id,
6844                0x5f421a8ebf265bf3,
6845                fidl::encoding::DynamicFlags::FLEXIBLE,
6846            )
6847    }
6848}
6849
6850#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6851pub struct AudioDeviceEnumeratorMarker;
6852
6853impl fidl::endpoints::ProtocolMarker for AudioDeviceEnumeratorMarker {
6854    type Proxy = AudioDeviceEnumeratorProxy;
6855    type RequestStream = AudioDeviceEnumeratorRequestStream;
6856    #[cfg(target_os = "fuchsia")]
6857    type SynchronousProxy = AudioDeviceEnumeratorSynchronousProxy;
6858
6859    const DEBUG_NAME: &'static str = "fuchsia.media.AudioDeviceEnumerator";
6860}
6861impl fidl::endpoints::DiscoverableProtocolMarker for AudioDeviceEnumeratorMarker {}
6862
6863pub trait AudioDeviceEnumeratorProxyInterface: Send + Sync {
6864    type GetDevicesResponseFut: std::future::Future<Output = Result<Vec<AudioDeviceInfo>, fidl::Error>>
6865        + Send;
6866    fn r#get_devices(&self) -> Self::GetDevicesResponseFut;
6867    type GetDeviceGainResponseFut: std::future::Future<Output = Result<(u64, AudioGainInfo), fidl::Error>>
6868        + Send;
6869    fn r#get_device_gain(&self, device_token: u64) -> Self::GetDeviceGainResponseFut;
6870    fn r#set_device_gain(
6871        &self,
6872        device_token: u64,
6873        gain_info: &AudioGainInfo,
6874        valid_flags: AudioGainValidFlags,
6875    ) -> Result<(), fidl::Error>;
6876    fn r#add_device_by_channel(
6877        &self,
6878        device_name: &str,
6879        is_input: bool,
6880        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
6881    ) -> Result<(), fidl::Error>;
6882}
6883#[derive(Debug)]
6884#[cfg(target_os = "fuchsia")]
6885pub struct AudioDeviceEnumeratorSynchronousProxy {
6886    client: fidl::client::sync::Client,
6887}
6888
6889#[cfg(target_os = "fuchsia")]
6890impl fidl::endpoints::SynchronousProxy for AudioDeviceEnumeratorSynchronousProxy {
6891    type Proxy = AudioDeviceEnumeratorProxy;
6892    type Protocol = AudioDeviceEnumeratorMarker;
6893
6894    fn from_channel(inner: fidl::Channel) -> Self {
6895        Self::new(inner)
6896    }
6897
6898    fn into_channel(self) -> fidl::Channel {
6899        self.client.into_channel()
6900    }
6901
6902    fn as_channel(&self) -> &fidl::Channel {
6903        self.client.as_channel()
6904    }
6905}
6906
6907#[cfg(target_os = "fuchsia")]
6908impl AudioDeviceEnumeratorSynchronousProxy {
6909    pub fn new(channel: fidl::Channel) -> Self {
6910        Self { client: fidl::client::sync::Client::new(channel) }
6911    }
6912
6913    pub fn into_channel(self) -> fidl::Channel {
6914        self.client.into_channel()
6915    }
6916
6917    /// Waits until an event arrives and returns it. It is safe for other
6918    /// threads to make concurrent requests while waiting for an event.
6919    pub fn wait_for_event(
6920        &self,
6921        deadline: zx::MonotonicInstant,
6922    ) -> Result<AudioDeviceEnumeratorEvent, fidl::Error> {
6923        AudioDeviceEnumeratorEvent::decode(
6924            self.client.wait_for_event::<AudioDeviceEnumeratorMarker>(deadline)?,
6925        )
6926    }
6927
6928    /// Obtain the list of currently active audio devices.
6929    pub fn r#get_devices(
6930        &self,
6931        ___deadline: zx::MonotonicInstant,
6932    ) -> Result<Vec<AudioDeviceInfo>, fidl::Error> {
6933        let _response = self.client.send_query::<
6934            fidl::encoding::EmptyPayload,
6935            AudioDeviceEnumeratorGetDevicesResponse,
6936            AudioDeviceEnumeratorMarker,
6937        >(
6938            (),
6939            0x4ce1aa218aeb12a6,
6940            fidl::encoding::DynamicFlags::empty(),
6941            ___deadline,
6942        )?;
6943        Ok(_response.devices)
6944    }
6945
6946    /// Gain/Mute/AGC control
6947    ///
6948    /// Note that each of these operations requires a device_token in order to
6949    /// target the proper input/output.
6950    ///
6951    /// The Get command returns the device_token of the device whose gain is
6952    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
6953    /// device_token was invalid or the device had been removed from the system
6954    /// before the Get command could be processed.
6955    ///
6956    /// Set commands which are given an invalid device token are ignored and
6957    /// have no effect on the system. In addition, users do not need to control
6958    /// all of the gain settings for an audio device with each call. Only the
6959    /// settings with a corresponding flag set in the set_flags parameter will
6960    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
6961    /// a SetDeviceGain call to care only about the mute setting in the
6962    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
6963    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
6964    /// status to be changed simultaneously.
6965    pub fn r#get_device_gain(
6966        &self,
6967        mut device_token: u64,
6968        ___deadline: zx::MonotonicInstant,
6969    ) -> Result<(u64, AudioGainInfo), fidl::Error> {
6970        let _response = self.client.send_query::<
6971            AudioDeviceEnumeratorGetDeviceGainRequest,
6972            AudioDeviceEnumeratorGetDeviceGainResponse,
6973            AudioDeviceEnumeratorMarker,
6974        >(
6975            (device_token,),
6976            0x25dd4723403c414b,
6977            fidl::encoding::DynamicFlags::empty(),
6978            ___deadline,
6979        )?;
6980        Ok((_response.device_token, _response.gain_info))
6981    }
6982
6983    pub fn r#set_device_gain(
6984        &self,
6985        mut device_token: u64,
6986        mut gain_info: &AudioGainInfo,
6987        mut valid_flags: AudioGainValidFlags,
6988    ) -> Result<(), fidl::Error> {
6989        self.client.send::<AudioDeviceEnumeratorSetDeviceGainRequest>(
6990            (device_token, gain_info, valid_flags),
6991            0x5bdabc8ebe83591,
6992            fidl::encoding::DynamicFlags::empty(),
6993        )
6994    }
6995
6996    /// # Deprecation
6997    ///
6998    /// StreamConfig is not supported anymore, instead use an
6999    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
7000    /// , see
7001    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
7002    pub fn r#add_device_by_channel(
7003        &self,
7004        mut device_name: &str,
7005        mut is_input: bool,
7006        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7007    ) -> Result<(), fidl::Error> {
7008        self.client.send::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(
7009            (device_name, is_input, channel),
7010            0x72cdbada4d70ed67,
7011            fidl::encoding::DynamicFlags::empty(),
7012        )
7013    }
7014}
7015
7016#[cfg(target_os = "fuchsia")]
7017impl From<AudioDeviceEnumeratorSynchronousProxy> for zx::NullableHandle {
7018    fn from(value: AudioDeviceEnumeratorSynchronousProxy) -> Self {
7019        value.into_channel().into()
7020    }
7021}
7022
7023#[cfg(target_os = "fuchsia")]
7024impl From<fidl::Channel> for AudioDeviceEnumeratorSynchronousProxy {
7025    fn from(value: fidl::Channel) -> Self {
7026        Self::new(value)
7027    }
7028}
7029
7030#[cfg(target_os = "fuchsia")]
7031impl fidl::endpoints::FromClient for AudioDeviceEnumeratorSynchronousProxy {
7032    type Protocol = AudioDeviceEnumeratorMarker;
7033
7034    fn from_client(value: fidl::endpoints::ClientEnd<AudioDeviceEnumeratorMarker>) -> Self {
7035        Self::new(value.into_channel())
7036    }
7037}
7038
7039#[derive(Debug, Clone)]
7040pub struct AudioDeviceEnumeratorProxy {
7041    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7042}
7043
7044impl fidl::endpoints::Proxy for AudioDeviceEnumeratorProxy {
7045    type Protocol = AudioDeviceEnumeratorMarker;
7046
7047    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7048        Self::new(inner)
7049    }
7050
7051    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7052        self.client.into_channel().map_err(|client| Self { client })
7053    }
7054
7055    fn as_channel(&self) -> &::fidl::AsyncChannel {
7056        self.client.as_channel()
7057    }
7058}
7059
7060impl AudioDeviceEnumeratorProxy {
7061    /// Create a new Proxy for fuchsia.media/AudioDeviceEnumerator.
7062    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7063        let protocol_name =
7064            <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7065        Self { client: fidl::client::Client::new(channel, protocol_name) }
7066    }
7067
7068    /// Get a Stream of events from the remote end of the protocol.
7069    ///
7070    /// # Panics
7071    ///
7072    /// Panics if the event stream was already taken.
7073    pub fn take_event_stream(&self) -> AudioDeviceEnumeratorEventStream {
7074        AudioDeviceEnumeratorEventStream { event_receiver: self.client.take_event_receiver() }
7075    }
7076
7077    /// Obtain the list of currently active audio devices.
7078    pub fn r#get_devices(
7079        &self,
7080    ) -> fidl::client::QueryResponseFut<
7081        Vec<AudioDeviceInfo>,
7082        fidl::encoding::DefaultFuchsiaResourceDialect,
7083    > {
7084        AudioDeviceEnumeratorProxyInterface::r#get_devices(self)
7085    }
7086
7087    /// Gain/Mute/AGC control
7088    ///
7089    /// Note that each of these operations requires a device_token in order to
7090    /// target the proper input/output.
7091    ///
7092    /// The Get command returns the device_token of the device whose gain is
7093    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
7094    /// device_token was invalid or the device had been removed from the system
7095    /// before the Get command could be processed.
7096    ///
7097    /// Set commands which are given an invalid device token are ignored and
7098    /// have no effect on the system. In addition, users do not need to control
7099    /// all of the gain settings for an audio device with each call. Only the
7100    /// settings with a corresponding flag set in the set_flags parameter will
7101    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
7102    /// a SetDeviceGain call to care only about the mute setting in the
7103    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
7104    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
7105    /// status to be changed simultaneously.
7106    pub fn r#get_device_gain(
7107        &self,
7108        mut device_token: u64,
7109    ) -> fidl::client::QueryResponseFut<
7110        (u64, AudioGainInfo),
7111        fidl::encoding::DefaultFuchsiaResourceDialect,
7112    > {
7113        AudioDeviceEnumeratorProxyInterface::r#get_device_gain(self, device_token)
7114    }
7115
7116    pub fn r#set_device_gain(
7117        &self,
7118        mut device_token: u64,
7119        mut gain_info: &AudioGainInfo,
7120        mut valid_flags: AudioGainValidFlags,
7121    ) -> Result<(), fidl::Error> {
7122        AudioDeviceEnumeratorProxyInterface::r#set_device_gain(
7123            self,
7124            device_token,
7125            gain_info,
7126            valid_flags,
7127        )
7128    }
7129
7130    /// # Deprecation
7131    ///
7132    /// StreamConfig is not supported anymore, instead use an
7133    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
7134    /// , see
7135    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
7136    pub fn r#add_device_by_channel(
7137        &self,
7138        mut device_name: &str,
7139        mut is_input: bool,
7140        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7141    ) -> Result<(), fidl::Error> {
7142        AudioDeviceEnumeratorProxyInterface::r#add_device_by_channel(
7143            self,
7144            device_name,
7145            is_input,
7146            channel,
7147        )
7148    }
7149}
7150
7151impl AudioDeviceEnumeratorProxyInterface for AudioDeviceEnumeratorProxy {
7152    type GetDevicesResponseFut = fidl::client::QueryResponseFut<
7153        Vec<AudioDeviceInfo>,
7154        fidl::encoding::DefaultFuchsiaResourceDialect,
7155    >;
7156    fn r#get_devices(&self) -> Self::GetDevicesResponseFut {
7157        fn _decode(
7158            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7159        ) -> Result<Vec<AudioDeviceInfo>, fidl::Error> {
7160            let _response = fidl::client::decode_transaction_body::<
7161                AudioDeviceEnumeratorGetDevicesResponse,
7162                fidl::encoding::DefaultFuchsiaResourceDialect,
7163                0x4ce1aa218aeb12a6,
7164            >(_buf?)?;
7165            Ok(_response.devices)
7166        }
7167        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioDeviceInfo>>(
7168            (),
7169            0x4ce1aa218aeb12a6,
7170            fidl::encoding::DynamicFlags::empty(),
7171            _decode,
7172        )
7173    }
7174
7175    type GetDeviceGainResponseFut = fidl::client::QueryResponseFut<
7176        (u64, AudioGainInfo),
7177        fidl::encoding::DefaultFuchsiaResourceDialect,
7178    >;
7179    fn r#get_device_gain(&self, mut device_token: u64) -> Self::GetDeviceGainResponseFut {
7180        fn _decode(
7181            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7182        ) -> Result<(u64, AudioGainInfo), fidl::Error> {
7183            let _response = fidl::client::decode_transaction_body::<
7184                AudioDeviceEnumeratorGetDeviceGainResponse,
7185                fidl::encoding::DefaultFuchsiaResourceDialect,
7186                0x25dd4723403c414b,
7187            >(_buf?)?;
7188            Ok((_response.device_token, _response.gain_info))
7189        }
7190        self.client.send_query_and_decode::<
7191            AudioDeviceEnumeratorGetDeviceGainRequest,
7192            (u64, AudioGainInfo),
7193        >(
7194            (device_token,),
7195            0x25dd4723403c414b,
7196            fidl::encoding::DynamicFlags::empty(),
7197            _decode,
7198        )
7199    }
7200
7201    fn r#set_device_gain(
7202        &self,
7203        mut device_token: u64,
7204        mut gain_info: &AudioGainInfo,
7205        mut valid_flags: AudioGainValidFlags,
7206    ) -> Result<(), fidl::Error> {
7207        self.client.send::<AudioDeviceEnumeratorSetDeviceGainRequest>(
7208            (device_token, gain_info, valid_flags),
7209            0x5bdabc8ebe83591,
7210            fidl::encoding::DynamicFlags::empty(),
7211        )
7212    }
7213
7214    fn r#add_device_by_channel(
7215        &self,
7216        mut device_name: &str,
7217        mut is_input: bool,
7218        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7219    ) -> Result<(), fidl::Error> {
7220        self.client.send::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(
7221            (device_name, is_input, channel),
7222            0x72cdbada4d70ed67,
7223            fidl::encoding::DynamicFlags::empty(),
7224        )
7225    }
7226}
7227
7228pub struct AudioDeviceEnumeratorEventStream {
7229    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7230}
7231
7232impl std::marker::Unpin for AudioDeviceEnumeratorEventStream {}
7233
7234impl futures::stream::FusedStream for AudioDeviceEnumeratorEventStream {
7235    fn is_terminated(&self) -> bool {
7236        self.event_receiver.is_terminated()
7237    }
7238}
7239
7240impl futures::Stream for AudioDeviceEnumeratorEventStream {
7241    type Item = Result<AudioDeviceEnumeratorEvent, fidl::Error>;
7242
7243    fn poll_next(
7244        mut self: std::pin::Pin<&mut Self>,
7245        cx: &mut std::task::Context<'_>,
7246    ) -> std::task::Poll<Option<Self::Item>> {
7247        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7248            &mut self.event_receiver,
7249            cx
7250        )?) {
7251            Some(buf) => std::task::Poll::Ready(Some(AudioDeviceEnumeratorEvent::decode(buf))),
7252            None => std::task::Poll::Ready(None),
7253        }
7254    }
7255}
7256
7257#[derive(Debug)]
7258pub enum AudioDeviceEnumeratorEvent {
7259    OnDeviceAdded { device: AudioDeviceInfo },
7260    OnDeviceRemoved { device_token: u64 },
7261    OnDeviceGainChanged { device_token: u64, gain_info: AudioGainInfo },
7262    OnDefaultDeviceChanged { old_default_token: u64, new_default_token: u64 },
7263}
7264
7265impl AudioDeviceEnumeratorEvent {
7266    #[allow(irrefutable_let_patterns)]
7267    pub fn into_on_device_added(self) -> Option<AudioDeviceInfo> {
7268        if let AudioDeviceEnumeratorEvent::OnDeviceAdded { device } = self {
7269            Some((device))
7270        } else {
7271            None
7272        }
7273    }
7274    #[allow(irrefutable_let_patterns)]
7275    pub fn into_on_device_removed(self) -> Option<u64> {
7276        if let AudioDeviceEnumeratorEvent::OnDeviceRemoved { device_token } = self {
7277            Some((device_token))
7278        } else {
7279            None
7280        }
7281    }
7282    #[allow(irrefutable_let_patterns)]
7283    pub fn into_on_device_gain_changed(self) -> Option<(u64, AudioGainInfo)> {
7284        if let AudioDeviceEnumeratorEvent::OnDeviceGainChanged { device_token, gain_info } = self {
7285            Some((device_token, gain_info))
7286        } else {
7287            None
7288        }
7289    }
7290    #[allow(irrefutable_let_patterns)]
7291    pub fn into_on_default_device_changed(self) -> Option<(u64, u64)> {
7292        if let AudioDeviceEnumeratorEvent::OnDefaultDeviceChanged {
7293            old_default_token,
7294            new_default_token,
7295        } = self
7296        {
7297            Some((old_default_token, new_default_token))
7298        } else {
7299            None
7300        }
7301    }
7302
7303    /// Decodes a message buffer as a [`AudioDeviceEnumeratorEvent`].
7304    fn decode(
7305        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7306    ) -> Result<AudioDeviceEnumeratorEvent, fidl::Error> {
7307        let (bytes, _handles) = buf.split_mut();
7308        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7309        debug_assert_eq!(tx_header.tx_id, 0);
7310        match tx_header.ordinal {
7311            0xe0fbe40057c4b44 => {
7312                let mut out = fidl::new_empty!(
7313                    AudioDeviceEnumeratorOnDeviceAddedRequest,
7314                    fidl::encoding::DefaultFuchsiaResourceDialect
7315                );
7316                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceAddedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7317                Ok((AudioDeviceEnumeratorEvent::OnDeviceAdded { device: out.device }))
7318            }
7319            0x6f3b7574463d9ff8 => {
7320                let mut out = fidl::new_empty!(
7321                    AudioDeviceEnumeratorOnDeviceRemovedRequest,
7322                    fidl::encoding::DefaultFuchsiaResourceDialect
7323                );
7324                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceRemovedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7325                Ok((AudioDeviceEnumeratorEvent::OnDeviceRemoved { device_token: out.device_token }))
7326            }
7327            0x14aefcbbb076b0e9 => {
7328                let mut out = fidl::new_empty!(
7329                    AudioDeviceEnumeratorOnDeviceGainChangedRequest,
7330                    fidl::encoding::DefaultFuchsiaResourceDialect
7331                );
7332                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceGainChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7333                Ok((AudioDeviceEnumeratorEvent::OnDeviceGainChanged {
7334                    device_token: out.device_token,
7335                    gain_info: out.gain_info,
7336                }))
7337            }
7338            0x16357b42d4c16e11 => {
7339                let mut out = fidl::new_empty!(
7340                    AudioDeviceEnumeratorOnDefaultDeviceChangedRequest,
7341                    fidl::encoding::DefaultFuchsiaResourceDialect
7342                );
7343                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDefaultDeviceChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7344                Ok((AudioDeviceEnumeratorEvent::OnDefaultDeviceChanged {
7345                    old_default_token: out.old_default_token,
7346                    new_default_token: out.new_default_token,
7347                }))
7348            }
7349            _ => Err(fidl::Error::UnknownOrdinal {
7350                ordinal: tx_header.ordinal,
7351                protocol_name:
7352                    <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7353            }),
7354        }
7355    }
7356}
7357
7358/// A Stream of incoming requests for fuchsia.media/AudioDeviceEnumerator.
7359pub struct AudioDeviceEnumeratorRequestStream {
7360    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7361    is_terminated: bool,
7362}
7363
7364impl std::marker::Unpin for AudioDeviceEnumeratorRequestStream {}
7365
7366impl futures::stream::FusedStream for AudioDeviceEnumeratorRequestStream {
7367    fn is_terminated(&self) -> bool {
7368        self.is_terminated
7369    }
7370}
7371
7372impl fidl::endpoints::RequestStream for AudioDeviceEnumeratorRequestStream {
7373    type Protocol = AudioDeviceEnumeratorMarker;
7374    type ControlHandle = AudioDeviceEnumeratorControlHandle;
7375
7376    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7377        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7378    }
7379
7380    fn control_handle(&self) -> Self::ControlHandle {
7381        AudioDeviceEnumeratorControlHandle { inner: self.inner.clone() }
7382    }
7383
7384    fn into_inner(
7385        self,
7386    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7387    {
7388        (self.inner, self.is_terminated)
7389    }
7390
7391    fn from_inner(
7392        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7393        is_terminated: bool,
7394    ) -> Self {
7395        Self { inner, is_terminated }
7396    }
7397}
7398
7399impl futures::Stream for AudioDeviceEnumeratorRequestStream {
7400    type Item = Result<AudioDeviceEnumeratorRequest, fidl::Error>;
7401
7402    fn poll_next(
7403        mut self: std::pin::Pin<&mut Self>,
7404        cx: &mut std::task::Context<'_>,
7405    ) -> std::task::Poll<Option<Self::Item>> {
7406        let this = &mut *self;
7407        if this.inner.check_shutdown(cx) {
7408            this.is_terminated = true;
7409            return std::task::Poll::Ready(None);
7410        }
7411        if this.is_terminated {
7412            panic!("polled AudioDeviceEnumeratorRequestStream after completion");
7413        }
7414        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7415            |bytes, handles| {
7416                match this.inner.channel().read_etc(cx, bytes, handles) {
7417                    std::task::Poll::Ready(Ok(())) => {}
7418                    std::task::Poll::Pending => return std::task::Poll::Pending,
7419                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7420                        this.is_terminated = true;
7421                        return std::task::Poll::Ready(None);
7422                    }
7423                    std::task::Poll::Ready(Err(e)) => {
7424                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7425                            e.into(),
7426                        ))));
7427                    }
7428                }
7429
7430                // A message has been received from the channel
7431                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7432
7433                std::task::Poll::Ready(Some(match header.ordinal {
7434                0x4ce1aa218aeb12a6 => {
7435                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7436                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7437                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7438                    let control_handle = AudioDeviceEnumeratorControlHandle {
7439                        inner: this.inner.clone(),
7440                    };
7441                    Ok(AudioDeviceEnumeratorRequest::GetDevices {
7442                        responder: AudioDeviceEnumeratorGetDevicesResponder {
7443                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7444                            tx_id: header.tx_id,
7445                        },
7446                    })
7447                }
7448                0x25dd4723403c414b => {
7449                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7450                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorGetDeviceGainRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7451                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorGetDeviceGainRequest>(&header, _body_bytes, handles, &mut req)?;
7452                    let control_handle = AudioDeviceEnumeratorControlHandle {
7453                        inner: this.inner.clone(),
7454                    };
7455                    Ok(AudioDeviceEnumeratorRequest::GetDeviceGain {device_token: req.device_token,
7456
7457                        responder: AudioDeviceEnumeratorGetDeviceGainResponder {
7458                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7459                            tx_id: header.tx_id,
7460                        },
7461                    })
7462                }
7463                0x5bdabc8ebe83591 => {
7464                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7465                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorSetDeviceGainRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7466                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorSetDeviceGainRequest>(&header, _body_bytes, handles, &mut req)?;
7467                    let control_handle = AudioDeviceEnumeratorControlHandle {
7468                        inner: this.inner.clone(),
7469                    };
7470                    Ok(AudioDeviceEnumeratorRequest::SetDeviceGain {device_token: req.device_token,
7471gain_info: req.gain_info,
7472valid_flags: req.valid_flags,
7473
7474                        control_handle,
7475                    })
7476                }
7477                0x72cdbada4d70ed67 => {
7478                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7479                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorAddDeviceByChannelRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7480                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(&header, _body_bytes, handles, &mut req)?;
7481                    let control_handle = AudioDeviceEnumeratorControlHandle {
7482                        inner: this.inner.clone(),
7483                    };
7484                    Ok(AudioDeviceEnumeratorRequest::AddDeviceByChannel {device_name: req.device_name,
7485is_input: req.is_input,
7486channel: req.channel,
7487
7488                        control_handle,
7489                    })
7490                }
7491                _ => Err(fidl::Error::UnknownOrdinal {
7492                    ordinal: header.ordinal,
7493                    protocol_name: <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7494                }),
7495            }))
7496            },
7497        )
7498    }
7499}
7500
7501#[derive(Debug)]
7502pub enum AudioDeviceEnumeratorRequest {
7503    /// Obtain the list of currently active audio devices.
7504    GetDevices { responder: AudioDeviceEnumeratorGetDevicesResponder },
7505    /// Gain/Mute/AGC control
7506    ///
7507    /// Note that each of these operations requires a device_token in order to
7508    /// target the proper input/output.
7509    ///
7510    /// The Get command returns the device_token of the device whose gain is
7511    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
7512    /// device_token was invalid or the device had been removed from the system
7513    /// before the Get command could be processed.
7514    ///
7515    /// Set commands which are given an invalid device token are ignored and
7516    /// have no effect on the system. In addition, users do not need to control
7517    /// all of the gain settings for an audio device with each call. Only the
7518    /// settings with a corresponding flag set in the set_flags parameter will
7519    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
7520    /// a SetDeviceGain call to care only about the mute setting in the
7521    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
7522    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
7523    /// status to be changed simultaneously.
7524    GetDeviceGain { device_token: u64, responder: AudioDeviceEnumeratorGetDeviceGainResponder },
7525    SetDeviceGain {
7526        device_token: u64,
7527        gain_info: AudioGainInfo,
7528        valid_flags: AudioGainValidFlags,
7529        control_handle: AudioDeviceEnumeratorControlHandle,
7530    },
7531    /// # Deprecation
7532    ///
7533    /// StreamConfig is not supported anymore, instead use an
7534    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
7535    /// , see
7536    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
7537    AddDeviceByChannel {
7538        device_name: String,
7539        is_input: bool,
7540        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7541        control_handle: AudioDeviceEnumeratorControlHandle,
7542    },
7543}
7544
7545impl AudioDeviceEnumeratorRequest {
7546    #[allow(irrefutable_let_patterns)]
7547    pub fn into_get_devices(self) -> Option<(AudioDeviceEnumeratorGetDevicesResponder)> {
7548        if let AudioDeviceEnumeratorRequest::GetDevices { responder } = self {
7549            Some((responder))
7550        } else {
7551            None
7552        }
7553    }
7554
7555    #[allow(irrefutable_let_patterns)]
7556    pub fn into_get_device_gain(
7557        self,
7558    ) -> Option<(u64, AudioDeviceEnumeratorGetDeviceGainResponder)> {
7559        if let AudioDeviceEnumeratorRequest::GetDeviceGain { device_token, responder } = self {
7560            Some((device_token, responder))
7561        } else {
7562            None
7563        }
7564    }
7565
7566    #[allow(irrefutable_let_patterns)]
7567    pub fn into_set_device_gain(
7568        self,
7569    ) -> Option<(u64, AudioGainInfo, AudioGainValidFlags, AudioDeviceEnumeratorControlHandle)> {
7570        if let AudioDeviceEnumeratorRequest::SetDeviceGain {
7571            device_token,
7572            gain_info,
7573            valid_flags,
7574            control_handle,
7575        } = self
7576        {
7577            Some((device_token, gain_info, valid_flags, control_handle))
7578        } else {
7579            None
7580        }
7581    }
7582
7583    #[allow(irrefutable_let_patterns)]
7584    pub fn into_add_device_by_channel(
7585        self,
7586    ) -> Option<(
7587        String,
7588        bool,
7589        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7590        AudioDeviceEnumeratorControlHandle,
7591    )> {
7592        if let AudioDeviceEnumeratorRequest::AddDeviceByChannel {
7593            device_name,
7594            is_input,
7595            channel,
7596            control_handle,
7597        } = self
7598        {
7599            Some((device_name, is_input, channel, control_handle))
7600        } else {
7601            None
7602        }
7603    }
7604
7605    /// Name of the method defined in FIDL
7606    pub fn method_name(&self) -> &'static str {
7607        match *self {
7608            AudioDeviceEnumeratorRequest::GetDevices { .. } => "get_devices",
7609            AudioDeviceEnumeratorRequest::GetDeviceGain { .. } => "get_device_gain",
7610            AudioDeviceEnumeratorRequest::SetDeviceGain { .. } => "set_device_gain",
7611            AudioDeviceEnumeratorRequest::AddDeviceByChannel { .. } => "add_device_by_channel",
7612        }
7613    }
7614}
7615
7616#[derive(Debug, Clone)]
7617pub struct AudioDeviceEnumeratorControlHandle {
7618    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7619}
7620
7621impl fidl::endpoints::ControlHandle for AudioDeviceEnumeratorControlHandle {
7622    fn shutdown(&self) {
7623        self.inner.shutdown()
7624    }
7625
7626    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7627        self.inner.shutdown_with_epitaph(status)
7628    }
7629
7630    fn is_closed(&self) -> bool {
7631        self.inner.channel().is_closed()
7632    }
7633    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7634        self.inner.channel().on_closed()
7635    }
7636
7637    #[cfg(target_os = "fuchsia")]
7638    fn signal_peer(
7639        &self,
7640        clear_mask: zx::Signals,
7641        set_mask: zx::Signals,
7642    ) -> Result<(), zx_status::Status> {
7643        use fidl::Peered;
7644        self.inner.channel().signal_peer(clear_mask, set_mask)
7645    }
7646}
7647
7648impl AudioDeviceEnumeratorControlHandle {
7649    pub fn send_on_device_added(&self, mut device: &AudioDeviceInfo) -> Result<(), fidl::Error> {
7650        self.inner.send::<AudioDeviceEnumeratorOnDeviceAddedRequest>(
7651            (device,),
7652            0,
7653            0xe0fbe40057c4b44,
7654            fidl::encoding::DynamicFlags::empty(),
7655        )
7656    }
7657
7658    pub fn send_on_device_removed(&self, mut device_token: u64) -> Result<(), fidl::Error> {
7659        self.inner.send::<AudioDeviceEnumeratorOnDeviceRemovedRequest>(
7660            (device_token,),
7661            0,
7662            0x6f3b7574463d9ff8,
7663            fidl::encoding::DynamicFlags::empty(),
7664        )
7665    }
7666
7667    pub fn send_on_device_gain_changed(
7668        &self,
7669        mut device_token: u64,
7670        mut gain_info: &AudioGainInfo,
7671    ) -> Result<(), fidl::Error> {
7672        self.inner.send::<AudioDeviceEnumeratorOnDeviceGainChangedRequest>(
7673            (device_token, gain_info),
7674            0,
7675            0x14aefcbbb076b0e9,
7676            fidl::encoding::DynamicFlags::empty(),
7677        )
7678    }
7679
7680    pub fn send_on_default_device_changed(
7681        &self,
7682        mut old_default_token: u64,
7683        mut new_default_token: u64,
7684    ) -> Result<(), fidl::Error> {
7685        self.inner.send::<AudioDeviceEnumeratorOnDefaultDeviceChangedRequest>(
7686            (old_default_token, new_default_token),
7687            0,
7688            0x16357b42d4c16e11,
7689            fidl::encoding::DynamicFlags::empty(),
7690        )
7691    }
7692}
7693
7694#[must_use = "FIDL methods require a response to be sent"]
7695#[derive(Debug)]
7696pub struct AudioDeviceEnumeratorGetDevicesResponder {
7697    control_handle: std::mem::ManuallyDrop<AudioDeviceEnumeratorControlHandle>,
7698    tx_id: u32,
7699}
7700
7701/// Set the the channel to be shutdown (see [`AudioDeviceEnumeratorControlHandle::shutdown`])
7702/// if the responder is dropped without sending a response, so that the client
7703/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7704impl std::ops::Drop for AudioDeviceEnumeratorGetDevicesResponder {
7705    fn drop(&mut self) {
7706        self.control_handle.shutdown();
7707        // Safety: drops once, never accessed again
7708        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7709    }
7710}
7711
7712impl fidl::endpoints::Responder for AudioDeviceEnumeratorGetDevicesResponder {
7713    type ControlHandle = AudioDeviceEnumeratorControlHandle;
7714
7715    fn control_handle(&self) -> &AudioDeviceEnumeratorControlHandle {
7716        &self.control_handle
7717    }
7718
7719    fn drop_without_shutdown(mut self) {
7720        // Safety: drops once, never accessed again due to mem::forget
7721        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7722        // Prevent Drop from running (which would shut down the channel)
7723        std::mem::forget(self);
7724    }
7725}
7726
7727impl AudioDeviceEnumeratorGetDevicesResponder {
7728    /// Sends a response to the FIDL transaction.
7729    ///
7730    /// Sets the channel to shutdown if an error occurs.
7731    pub fn send(self, mut devices: &[AudioDeviceInfo]) -> Result<(), fidl::Error> {
7732        let _result = self.send_raw(devices);
7733        if _result.is_err() {
7734            self.control_handle.shutdown();
7735        }
7736        self.drop_without_shutdown();
7737        _result
7738    }
7739
7740    /// Similar to "send" but does not shutdown the channel if an error occurs.
7741    pub fn send_no_shutdown_on_err(
7742        self,
7743        mut devices: &[AudioDeviceInfo],
7744    ) -> Result<(), fidl::Error> {
7745        let _result = self.send_raw(devices);
7746        self.drop_without_shutdown();
7747        _result
7748    }
7749
7750    fn send_raw(&self, mut devices: &[AudioDeviceInfo]) -> Result<(), fidl::Error> {
7751        self.control_handle.inner.send::<AudioDeviceEnumeratorGetDevicesResponse>(
7752            (devices,),
7753            self.tx_id,
7754            0x4ce1aa218aeb12a6,
7755            fidl::encoding::DynamicFlags::empty(),
7756        )
7757    }
7758}
7759
7760#[must_use = "FIDL methods require a response to be sent"]
7761#[derive(Debug)]
7762pub struct AudioDeviceEnumeratorGetDeviceGainResponder {
7763    control_handle: std::mem::ManuallyDrop<AudioDeviceEnumeratorControlHandle>,
7764    tx_id: u32,
7765}
7766
7767/// Set the the channel to be shutdown (see [`AudioDeviceEnumeratorControlHandle::shutdown`])
7768/// if the responder is dropped without sending a response, so that the client
7769/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7770impl std::ops::Drop for AudioDeviceEnumeratorGetDeviceGainResponder {
7771    fn drop(&mut self) {
7772        self.control_handle.shutdown();
7773        // Safety: drops once, never accessed again
7774        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7775    }
7776}
7777
7778impl fidl::endpoints::Responder for AudioDeviceEnumeratorGetDeviceGainResponder {
7779    type ControlHandle = AudioDeviceEnumeratorControlHandle;
7780
7781    fn control_handle(&self) -> &AudioDeviceEnumeratorControlHandle {
7782        &self.control_handle
7783    }
7784
7785    fn drop_without_shutdown(mut self) {
7786        // Safety: drops once, never accessed again due to mem::forget
7787        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7788        // Prevent Drop from running (which would shut down the channel)
7789        std::mem::forget(self);
7790    }
7791}
7792
7793impl AudioDeviceEnumeratorGetDeviceGainResponder {
7794    /// Sends a response to the FIDL transaction.
7795    ///
7796    /// Sets the channel to shutdown if an error occurs.
7797    pub fn send(
7798        self,
7799        mut device_token: u64,
7800        mut gain_info: &AudioGainInfo,
7801    ) -> Result<(), fidl::Error> {
7802        let _result = self.send_raw(device_token, gain_info);
7803        if _result.is_err() {
7804            self.control_handle.shutdown();
7805        }
7806        self.drop_without_shutdown();
7807        _result
7808    }
7809
7810    /// Similar to "send" but does not shutdown the channel if an error occurs.
7811    pub fn send_no_shutdown_on_err(
7812        self,
7813        mut device_token: u64,
7814        mut gain_info: &AudioGainInfo,
7815    ) -> Result<(), fidl::Error> {
7816        let _result = self.send_raw(device_token, gain_info);
7817        self.drop_without_shutdown();
7818        _result
7819    }
7820
7821    fn send_raw(
7822        &self,
7823        mut device_token: u64,
7824        mut gain_info: &AudioGainInfo,
7825    ) -> Result<(), fidl::Error> {
7826        self.control_handle.inner.send::<AudioDeviceEnumeratorGetDeviceGainResponse>(
7827            (device_token, gain_info),
7828            self.tx_id,
7829            0x25dd4723403c414b,
7830            fidl::encoding::DynamicFlags::empty(),
7831        )
7832    }
7833}
7834
7835#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7836pub struct AudioRendererMarker;
7837
7838impl fidl::endpoints::ProtocolMarker for AudioRendererMarker {
7839    type Proxy = AudioRendererProxy;
7840    type RequestStream = AudioRendererRequestStream;
7841    #[cfg(target_os = "fuchsia")]
7842    type SynchronousProxy = AudioRendererSynchronousProxy;
7843
7844    const DEBUG_NAME: &'static str = "fuchsia.media.AudioRenderer";
7845}
7846impl fidl::endpoints::DiscoverableProtocolMarker for AudioRendererMarker {}
7847
7848pub trait AudioRendererProxyInterface: Send + Sync {
7849    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
7850    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
7851    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7852    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
7853    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
7854    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
7855    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7856    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
7857    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
7858    fn r#bind_gain_control(
7859        &self,
7860        gain_control_request: fidl::endpoints::ServerEnd<
7861            fidl_fuchsia_media_audio::GainControlMarker,
7862        >,
7863    ) -> Result<(), fidl::Error>;
7864    fn r#set_pts_units(
7865        &self,
7866        tick_per_second_numerator: u32,
7867        tick_per_second_denominator: u32,
7868    ) -> Result<(), fidl::Error>;
7869    fn r#set_pts_continuity_threshold(&self, threshold_seconds: f32) -> Result<(), fidl::Error>;
7870    type GetReferenceClockResponseFut: std::future::Future<Output = Result<fidl::Clock, fidl::Error>>
7871        + Send;
7872    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
7873    fn r#set_reference_clock(
7874        &self,
7875        reference_clock: Option<fidl::Clock>,
7876    ) -> Result<(), fidl::Error>;
7877    fn r#set_usage(&self, usage: AudioRenderUsage) -> Result<(), fidl::Error>;
7878    fn r#set_usage2(&self, usage2: AudioRenderUsage2) -> Result<(), fidl::Error>;
7879    fn r#set_pcm_stream_type(&self, type_: &AudioStreamType) -> Result<(), fidl::Error>;
7880    fn r#enable_min_lead_time_events(&self, enabled: bool) -> Result<(), fidl::Error>;
7881    type GetMinLeadTimeResponseFut: std::future::Future<Output = Result<i64, fidl::Error>> + Send;
7882    fn r#get_min_lead_time(&self) -> Self::GetMinLeadTimeResponseFut;
7883    type PlayResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>> + Send;
7884    fn r#play(&self, reference_time: i64, media_time: i64) -> Self::PlayResponseFut;
7885    fn r#play_no_reply(&self, reference_time: i64, media_time: i64) -> Result<(), fidl::Error>;
7886    type PauseResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>> + Send;
7887    fn r#pause(&self) -> Self::PauseResponseFut;
7888    fn r#pause_no_reply(&self) -> Result<(), fidl::Error>;
7889}
7890#[derive(Debug)]
7891#[cfg(target_os = "fuchsia")]
7892pub struct AudioRendererSynchronousProxy {
7893    client: fidl::client::sync::Client,
7894}
7895
7896#[cfg(target_os = "fuchsia")]
7897impl fidl::endpoints::SynchronousProxy for AudioRendererSynchronousProxy {
7898    type Proxy = AudioRendererProxy;
7899    type Protocol = AudioRendererMarker;
7900
7901    fn from_channel(inner: fidl::Channel) -> Self {
7902        Self::new(inner)
7903    }
7904
7905    fn into_channel(self) -> fidl::Channel {
7906        self.client.into_channel()
7907    }
7908
7909    fn as_channel(&self) -> &fidl::Channel {
7910        self.client.as_channel()
7911    }
7912}
7913
7914#[cfg(target_os = "fuchsia")]
7915impl AudioRendererSynchronousProxy {
7916    pub fn new(channel: fidl::Channel) -> Self {
7917        Self { client: fidl::client::sync::Client::new(channel) }
7918    }
7919
7920    pub fn into_channel(self) -> fidl::Channel {
7921        self.client.into_channel()
7922    }
7923
7924    /// Waits until an event arrives and returns it. It is safe for other
7925    /// threads to make concurrent requests while waiting for an event.
7926    pub fn wait_for_event(
7927        &self,
7928        deadline: zx::MonotonicInstant,
7929    ) -> Result<AudioRendererEvent, fidl::Error> {
7930        AudioRendererEvent::decode(self.client.wait_for_event::<AudioRendererMarker>(deadline)?)
7931    }
7932
7933    /// Adds a payload buffer to the current buffer set associated with the
7934    /// connection. A `StreamPacket` struct reference a payload buffer in the
7935    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
7936    ///
7937    /// A buffer with ID `id` must not be in the current set when this method is
7938    /// invoked, otherwise the service will close the connection.
7939    pub fn r#add_payload_buffer(
7940        &self,
7941        mut id: u32,
7942        mut payload_buffer: fidl::Vmo,
7943    ) -> Result<(), fidl::Error> {
7944        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
7945            (id, payload_buffer),
7946            0x3b3a37fc34fe5b56,
7947            fidl::encoding::DynamicFlags::empty(),
7948        )
7949    }
7950
7951    /// Removes a payload buffer from the current buffer set associated with the
7952    /// connection.
7953    ///
7954    /// A buffer with ID `id` must exist in the current set when this method is
7955    /// invoked, otherwise the service will will close the connection.
7956    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
7957        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
7958            (id,),
7959            0x5d1e4f74c3658262,
7960            fidl::encoding::DynamicFlags::empty(),
7961        )
7962    }
7963
7964    /// Sends a packet to the service. The response is sent when the service is
7965    /// done with the associated payload memory.
7966    ///
7967    /// `packet` must be valid for the current buffer set, otherwise the service
7968    /// will close the connection.
7969    pub fn r#send_packet(
7970        &self,
7971        mut packet: &StreamPacket,
7972        ___deadline: zx::MonotonicInstant,
7973    ) -> Result<(), fidl::Error> {
7974        let _response = self.client.send_query::<
7975            StreamSinkSendPacketRequest,
7976            fidl::encoding::EmptyPayload,
7977            AudioRendererMarker,
7978        >(
7979            (packet,),
7980            0x67cddd607442775f,
7981            fidl::encoding::DynamicFlags::empty(),
7982            ___deadline,
7983        )?;
7984        Ok(_response)
7985    }
7986
7987    /// Sends a packet to the service. This interface doesn't define how the
7988    /// client knows when the sink is done with the associated payload memory.
7989    /// The inheriting interface must define that.
7990    ///
7991    /// `packet` must be valid for the current buffer set, otherwise the service
7992    /// will close the connection.
7993    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
7994        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
7995            (packet,),
7996            0x8d9b8b413ceba9d,
7997            fidl::encoding::DynamicFlags::empty(),
7998        )
7999    }
8000
8001    /// Indicates the stream has ended. The precise semantics of this method are
8002    /// determined by the inheriting interface.
8003    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
8004        self.client.send::<fidl::encoding::EmptyPayload>(
8005            (),
8006            0x6180fd6f7e793b71,
8007            fidl::encoding::DynamicFlags::empty(),
8008        )
8009    }
8010
8011    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8012    /// and not yet released. The response is sent after all packets have been
8013    /// released.
8014    pub fn r#discard_all_packets(
8015        &self,
8016        ___deadline: zx::MonotonicInstant,
8017    ) -> Result<(), fidl::Error> {
8018        let _response = self.client.send_query::<
8019            fidl::encoding::EmptyPayload,
8020            fidl::encoding::EmptyPayload,
8021            AudioRendererMarker,
8022        >(
8023            (),
8024            0x6f4dad7af2917665,
8025            fidl::encoding::DynamicFlags::empty(),
8026            ___deadline,
8027        )?;
8028        Ok(_response)
8029    }
8030
8031    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8032    /// and not yet released.
8033    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
8034        self.client.send::<fidl::encoding::EmptyPayload>(
8035            (),
8036            0x50d36d0d23081bc4,
8037            fidl::encoding::DynamicFlags::empty(),
8038        )
8039    }
8040
8041    /// Binds to the gain control for this AudioRenderer.
8042    pub fn r#bind_gain_control(
8043        &self,
8044        mut gain_control_request: fidl::endpoints::ServerEnd<
8045            fidl_fuchsia_media_audio::GainControlMarker,
8046        >,
8047    ) -> Result<(), fidl::Error> {
8048        self.client.send::<AudioRendererBindGainControlRequest>(
8049            (gain_control_request,),
8050            0x293f5c7f8fba2bdc,
8051            fidl::encoding::DynamicFlags::empty(),
8052        )
8053    }
8054
8055    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
8056    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
8057    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
8058    pub fn r#set_pts_units(
8059        &self,
8060        mut tick_per_second_numerator: u32,
8061        mut tick_per_second_denominator: u32,
8062    ) -> Result<(), fidl::Error> {
8063        self.client.send::<AudioRendererSetPtsUnitsRequest>(
8064            (tick_per_second_numerator, tick_per_second_denominator),
8065            0xf68cd108785a27c,
8066            fidl::encoding::DynamicFlags::empty(),
8067        )
8068    }
8069
8070    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
8071    /// and expected PTS (determined using interpolation). Beyond this threshold,
8072    /// a stream is no longer considered 'continuous' by the renderer.
8073    ///
8074    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
8075    /// Most users should not need to change this value from its default.
8076    ///
8077    /// Example:
8078    /// A user is playing back 48KHz audio from a container, which also contains
8079    /// video and needs to be synchronized with the audio. The timestamps are
8080    /// provided explicitly per packet by the container, and expressed in mSec
8081    /// units. This means that a single tick of the media timeline (1 mSec)
8082    /// represents exactly 48 frames of audio. The application in this scenario
8083    /// delivers packets of audio to the AudioRenderer, each with exactly 470
8084    /// frames of audio, and each with an explicit timestamp set to the best
8085    /// possible representation of the presentation time (given this media
8086    /// clock's resolution). So, starting from zero, the timestamps would be..
8087    ///
8088    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
8089    ///
8090    /// In this example, attempting to use the presentation time to compute the
8091    /// starting frame number of the audio in the packet would be wrong the
8092    /// majority of the time. The first timestamp is correct (by definition), but
8093    /// it will be 24 packets before the timestamps and frame numbers come back
8094    /// into alignment (the 24th packet would start with the 11280th audio frame
8095    /// and have a PTS of exactly 235).
8096    ///
8097    /// One way to fix this situation is to set the PTS continuity threshold
8098    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
8099    /// the number of frames contained within a single tick of the media clock,
8100    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
8101    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
8102    /// explicitly provided PTS would be considered to be a continuation of the
8103    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
8104    /// would work well.
8105    ///
8106    /// Other possible uses:
8107    /// Users who are scheduling audio explicitly, relative to a clock which has
8108    /// not been configured as the reference clock, can use this value to control
8109    /// the maximum acceptable synchronization error before a discontinuity is
8110    /// introduced. E.g., if a user is scheduling audio based on a recovered
8111    /// common media clock, and has not published that clock as the reference
8112    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
8113    /// can accumulate before the AudioRenderer deliberately inserts a
8114    /// presentation discontinuity to account for the error.
8115    ///
8116    /// Users whose need to deal with a container where their timestamps may be
8117    /// even less correct than +/- 1/2 of a PTS tick may set this value to
8118    /// something larger. This should be the maximum level of inaccuracy present
8119    /// in the container timestamps, if known. Failing that, it could be set to
8120    /// the maximum tolerable level of drift error before absolute timestamps are
8121    /// explicitly obeyed. Finally, a user could set this number to a very large
8122    /// value (86400.0 seconds, for example) to effectively cause *all*
8123    /// timestamps to be ignored after the first, thus treating all audio as
8124    /// continuous with previously delivered packets. Conversely, users who wish
8125    /// to *always* explicitly schedule their audio packets exactly may specify
8126    /// a CT of 0.
8127    ///
8128    /// Note: explicitly specifying high-frequency PTS units reduces the default
8129    /// continuity threshold accordingly. Internally, this threshold is stored as an
8130    /// integer of 1/8192 subframes. The default threshold is computed as follows:
8131    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
8132    /// For this reason, specifying PTS units with a frequency greater than 8192x
8133    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
8134    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
8135    pub fn r#set_pts_continuity_threshold(
8136        &self,
8137        mut threshold_seconds: f32,
8138    ) -> Result<(), fidl::Error> {
8139        self.client.send::<AudioRendererSetPtsContinuityThresholdRequest>(
8140            (threshold_seconds,),
8141            0x2849ba571d1971ba,
8142            fidl::encoding::DynamicFlags::empty(),
8143        )
8144    }
8145
8146    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
8147    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
8148    pub fn r#get_reference_clock(
8149        &self,
8150        ___deadline: zx::MonotonicInstant,
8151    ) -> Result<fidl::Clock, fidl::Error> {
8152        let _response = self.client.send_query::<
8153            fidl::encoding::EmptyPayload,
8154            AudioRendererGetReferenceClockResponse,
8155            AudioRendererMarker,
8156        >(
8157            (),
8158            0x2f7a7f011a172f7e,
8159            fidl::encoding::DynamicFlags::empty(),
8160            ___deadline,
8161        )?;
8162        Ok(_response.reference_clock)
8163    }
8164
8165    /// Sets the reference clock that controls this renderer's playback rate. If the input
8166    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
8167    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
8168    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
8169    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
8170    ///
8171    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
8172    /// cannot be called a second time (even if the renderer format has not yet been set).
8173    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
8174    /// diverge at some later time, they should create a clone of the monotonic clock, set
8175    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
8176    pub fn r#set_reference_clock(
8177        &self,
8178        mut reference_clock: Option<fidl::Clock>,
8179    ) -> Result<(), fidl::Error> {
8180        self.client.send::<AudioRendererSetReferenceClockRequest>(
8181            (reference_clock,),
8182            0x39acd05d832b5fed,
8183            fidl::encoding::DynamicFlags::empty(),
8184        )
8185    }
8186
8187    /// Sets the usage of the render stream. This method may not be called after
8188    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8189    pub fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
8190        self.client.send::<AudioRendererSetUsageRequest>(
8191            (usage,),
8192            0x3994bd23b55a733e,
8193            fidl::encoding::DynamicFlags::empty(),
8194        )
8195    }
8196
8197    /// Sets the usage of the render stream. This method may not be called after
8198    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8199    pub fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
8200        self.client.send::<AudioRendererSetUsage2Request>(
8201            (usage2,),
8202            0x2904035c7132b103,
8203            fidl::encoding::DynamicFlags::FLEXIBLE,
8204        )
8205    }
8206
8207    /// Sets the type of the stream to be delivered by the client. Using this method implies
8208    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
8209    ///
8210    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
8211    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
8212    /// methods such as `SendPacket`/`SendPacketNoReply`.
8213    pub fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
8214        self.client.send::<AudioRendererSetPcmStreamTypeRequest>(
8215            (type_,),
8216            0x27aa715d8901fa19,
8217            fidl::encoding::DynamicFlags::empty(),
8218        )
8219    }
8220
8221    /// Enables or disables notifications about changes to the minimum clock lead
8222    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
8223    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
8224    /// event with the current minimum lead time for the AudioRenderer. If the
8225    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
8226    /// new value. This behavior will continue until the user calls
8227    /// `EnableMinLeadTimeEvents(false)`.
8228    ///
8229    /// The minimum clock lead time is the amount of time ahead of the reference
8230    /// clock's understanding of "now" that packets needs to arrive (relative to
8231    /// the playback clock transformation) in order for the mixer to be able to
8232    /// mix packet. For example...
8233    ///
8234    /// + Let the PTS of packet X be P(X)
8235    /// + Let the function which transforms PTS -> RefClock be R(p) (this
8236    ///   function is determined by the call to Play(...)
8237    /// + Let the minimum lead time be MLT
8238    ///
8239    /// If R(P(X)) < RefClock.Now() + MLT
8240    /// Then the packet is late, and some (or all) of the packet's payload will
8241    /// need to be skipped in order to present the packet at the scheduled time.
8242    ///
8243    /// The value `min_lead_time_nsec = 0` is a special value which indicates
8244    /// that the AudioRenderer is not yet routed to an output device. If `Play`
8245    /// is called before the AudioRenderer is routed, any played packets will be
8246    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
8247    /// calling `Play`.
8248    pub fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
8249        self.client.send::<AudioRendererEnableMinLeadTimeEventsRequest>(
8250            (enabled,),
8251            0x62808dfad72bf890,
8252            fidl::encoding::DynamicFlags::empty(),
8253        )
8254    }
8255
8256    ///
8257    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
8258    /// there's little reason to do so. This is because lead time is a function
8259    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
8260    /// If min lead time events are enabled before `SetPcmStreamType` (with
8261    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
8262    /// response to `SetPcmStreamType`.
8263    pub fn r#get_min_lead_time(
8264        &self,
8265        ___deadline: zx::MonotonicInstant,
8266    ) -> Result<i64, fidl::Error> {
8267        let _response = self.client.send_query::<
8268            fidl::encoding::EmptyPayload,
8269            AudioRendererGetMinLeadTimeResponse,
8270            AudioRendererMarker,
8271        >(
8272            (),
8273            0x1cf3c3ecd8fec26b,
8274            fidl::encoding::DynamicFlags::empty(),
8275            ___deadline,
8276        )?;
8277        Ok(_response.min_lead_time_nsec)
8278    }
8279
8280    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
8281    /// of the media timeline, using specific values provided by the caller (or
8282    /// default values if not specified). In an optional callback, returns the
8283    /// timestamp values ultimately used -- these set the ongoing relationship
8284    /// between the media and reference timelines (i.e., how to translate between
8285    /// the domain of presentation timestamps, and the realm of local system
8286    /// time).
8287    ///
8288    /// Local system time is specified in units of nanoseconds; media_time is
8289    /// specified in the units defined by the user in the `SetPtsUnits` function,
8290    /// or nanoseconds if `SetPtsUnits` is not called.
8291    ///
8292    /// The act of placing an AudioRenderer into the playback state establishes a
8293    /// relationship between 1) the user-defined media (or presentation) timeline
8294    /// for this particular AudioRenderer, and 2) the real-world system reference
8295    /// timeline. To communicate how to translate between timelines, the Play()
8296    /// callback provides an equivalent timestamp in each time domain. The first
8297    /// value ('reference_time') is given in terms of this renderer's reference
8298    /// clock; the second value ('media_time') is what media instant exactly
8299    /// corresponds to that local time. Restated, the frame at 'media_time' in
8300    /// the audio stream should be presented at 'reference_time' according to
8301    /// the reference clock.
8302    ///
8303    /// Note: on calling this API, media_time immediately starts advancing. It is
8304    /// possible (if uncommon) for a caller to specify a system time that is
8305    /// far in the past, or far into the future. This, along with the specified
8306    /// media time, is simply used to determine what media time corresponds to
8307    /// 'now', and THAT media time is then intersected with presentation
8308    /// timestamps of packets already submitted, to determine which media frames
8309    /// should be presented next.
8310    ///
8311    /// With the corresponding reference_time and media_time values, a user can
8312    /// translate arbitrary time values from one timeline into the other. After
8313    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
8314    /// given the 'ref_start' and 'media_start' values from `Play`, then for
8315    /// any 'ref_time':
8316    ///
8317    /// media_time = ( (ref_time - ref_start) / 1e9
8318    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
8319    ///              + media_start
8320    ///
8321    /// Conversely, for any presentation timestamp 'media_time':
8322    ///
8323    /// ref_time = ( (media_time - media_start)
8324    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
8325    ///              * 1e9 )
8326    ///            + ref_start
8327    ///
8328    /// Users, depending on their use case, may optionally choose not to specify
8329    /// one or both of these timestamps. A timestamp may be omitted by supplying
8330    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
8331    /// any omitted timestamp value using the following rules:
8332    ///
8333    /// Reference Time
8334    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
8335    /// reference time to begin presentation, based on the minimum lead times for
8336    /// the output devices that are currently bound to this AudioRenderer. For
8337    /// example, if an AudioRenderer is bound to an internal audio output
8338    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
8339    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
8340    /// is omitted) select a reference time 80 mSec from now.
8341    ///
8342    /// Media Time
8343    /// If media_time is omitted, the AudioRenderer will select one of two
8344    /// values.
8345    /// - If the AudioRenderer is resuming from the paused state, and packets
8346    /// have not been discarded since being paused, then the AudioRenderer will
8347    /// use a media_time corresponding to the instant at which the presentation
8348    /// became paused.
8349    /// - If the AudioRenderer is being placed into a playing state for the first
8350    /// time following startup or a 'discard packets' operation, the initial
8351    /// media_time will be set to the PTS of the first payload in the pending
8352    /// packet queue. If the pending queue is empty, initial media_time will be
8353    /// set to zero.
8354    ///
8355    /// Return Value
8356    /// When requested, the AudioRenderer will return the 'reference_time' and
8357    /// 'media_time' which were selected and used (whether they were explicitly
8358    /// specified or not) in the return value of the play call.
8359    ///
8360    /// Examples
8361    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
8362    /// to start playing as soon as possible. The user may call Play without
8363    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
8364    ///
8365    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
8366    /// playback at a specified 'reference_time', in sync with some other media
8367    /// stream, either initially or after discarding packets. The user would call
8368    /// `Play(reference_time, NO_TIMESTAMP)`.
8369    ///
8370    /// 3. A user has queued some audio using `SendPacket`. The first of these
8371    /// packets has a PTS of zero, and the user wishes playback to begin as soon
8372    /// as possible, but wishes to skip all of the audio content between PTS 0
8373    /// and PTS 'media_time'. The user would call
8374    /// `Play(NO_TIMESTAMP, media_time)`.
8375    ///
8376    /// 4. A user has queued some audio using `SendPacket` and want to present
8377    /// this media in synch with another player in a different device. The
8378    /// coordinator of the group of distributed players sends an explicit
8379    /// message to each player telling them to begin presentation of audio at
8380    /// PTS 'media_time', at the time (based on the group's shared reference
8381    /// clock) 'reference_time'. Here the user would call
8382    /// `Play(reference_time, media_time)`.
8383    pub fn r#play(
8384        &self,
8385        mut reference_time: i64,
8386        mut media_time: i64,
8387        ___deadline: zx::MonotonicInstant,
8388    ) -> Result<(i64, i64), fidl::Error> {
8389        let _response = self
8390            .client
8391            .send_query::<AudioRendererPlayRequest, AudioRendererPlayResponse, AudioRendererMarker>(
8392                (reference_time, media_time),
8393                0x3c0162db084f74a3,
8394                fidl::encoding::DynamicFlags::empty(),
8395                ___deadline,
8396            )?;
8397        Ok((_response.reference_time, _response.media_time))
8398    }
8399
8400    pub fn r#play_no_reply(
8401        &self,
8402        mut reference_time: i64,
8403        mut media_time: i64,
8404    ) -> Result<(), fidl::Error> {
8405        self.client.send::<AudioRendererPlayNoReplyRequest>(
8406            (reference_time, media_time),
8407            0x1b7fe832b68c22ef,
8408            fidl::encoding::DynamicFlags::empty(),
8409        )
8410    }
8411
8412    /// Immediately puts the AudioRenderer into the paused state and then report
8413    /// the relationship between the media and reference timelines which was
8414    /// established (if requested).
8415    ///
8416    /// If the AudioRenderer is already in the paused state when this called,
8417    /// the previously-established timeline values are returned (if requested).
8418    pub fn r#pause(&self, ___deadline: zx::MonotonicInstant) -> Result<(i64, i64), fidl::Error> {
8419        let _response = self.client.send_query::<
8420            fidl::encoding::EmptyPayload,
8421            AudioRendererPauseResponse,
8422            AudioRendererMarker,
8423        >(
8424            (),
8425            0x41d557588d93d153,
8426            fidl::encoding::DynamicFlags::empty(),
8427            ___deadline,
8428        )?;
8429        Ok((_response.reference_time, _response.media_time))
8430    }
8431
8432    pub fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
8433        self.client.send::<fidl::encoding::EmptyPayload>(
8434            (),
8435            0x24cc45d4f3855ab,
8436            fidl::encoding::DynamicFlags::empty(),
8437        )
8438    }
8439}
8440
8441#[cfg(target_os = "fuchsia")]
8442impl From<AudioRendererSynchronousProxy> for zx::NullableHandle {
8443    fn from(value: AudioRendererSynchronousProxy) -> Self {
8444        value.into_channel().into()
8445    }
8446}
8447
8448#[cfg(target_os = "fuchsia")]
8449impl From<fidl::Channel> for AudioRendererSynchronousProxy {
8450    fn from(value: fidl::Channel) -> Self {
8451        Self::new(value)
8452    }
8453}
8454
8455#[cfg(target_os = "fuchsia")]
8456impl fidl::endpoints::FromClient for AudioRendererSynchronousProxy {
8457    type Protocol = AudioRendererMarker;
8458
8459    fn from_client(value: fidl::endpoints::ClientEnd<AudioRendererMarker>) -> Self {
8460        Self::new(value.into_channel())
8461    }
8462}
8463
8464#[derive(Debug, Clone)]
8465pub struct AudioRendererProxy {
8466    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8467}
8468
8469impl fidl::endpoints::Proxy for AudioRendererProxy {
8470    type Protocol = AudioRendererMarker;
8471
8472    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8473        Self::new(inner)
8474    }
8475
8476    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8477        self.client.into_channel().map_err(|client| Self { client })
8478    }
8479
8480    fn as_channel(&self) -> &::fidl::AsyncChannel {
8481        self.client.as_channel()
8482    }
8483}
8484
8485impl AudioRendererProxy {
8486    /// Create a new Proxy for fuchsia.media/AudioRenderer.
8487    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8488        let protocol_name = <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8489        Self { client: fidl::client::Client::new(channel, protocol_name) }
8490    }
8491
8492    /// Get a Stream of events from the remote end of the protocol.
8493    ///
8494    /// # Panics
8495    ///
8496    /// Panics if the event stream was already taken.
8497    pub fn take_event_stream(&self) -> AudioRendererEventStream {
8498        AudioRendererEventStream { event_receiver: self.client.take_event_receiver() }
8499    }
8500
8501    /// Adds a payload buffer to the current buffer set associated with the
8502    /// connection. A `StreamPacket` struct reference a payload buffer in the
8503    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
8504    ///
8505    /// A buffer with ID `id` must not be in the current set when this method is
8506    /// invoked, otherwise the service will close the connection.
8507    pub fn r#add_payload_buffer(
8508        &self,
8509        mut id: u32,
8510        mut payload_buffer: fidl::Vmo,
8511    ) -> Result<(), fidl::Error> {
8512        AudioRendererProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
8513    }
8514
8515    /// Removes a payload buffer from the current buffer set associated with the
8516    /// connection.
8517    ///
8518    /// A buffer with ID `id` must exist in the current set when this method is
8519    /// invoked, otherwise the service will will close the connection.
8520    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
8521        AudioRendererProxyInterface::r#remove_payload_buffer(self, id)
8522    }
8523
8524    /// Sends a packet to the service. The response is sent when the service is
8525    /// done with the associated payload memory.
8526    ///
8527    /// `packet` must be valid for the current buffer set, otherwise the service
8528    /// will close the connection.
8529    pub fn r#send_packet(
8530        &self,
8531        mut packet: &StreamPacket,
8532    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8533        AudioRendererProxyInterface::r#send_packet(self, packet)
8534    }
8535
8536    /// Sends a packet to the service. This interface doesn't define how the
8537    /// client knows when the sink is done with the associated payload memory.
8538    /// The inheriting interface must define that.
8539    ///
8540    /// `packet` must be valid for the current buffer set, otherwise the service
8541    /// will close the connection.
8542    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
8543        AudioRendererProxyInterface::r#send_packet_no_reply(self, packet)
8544    }
8545
8546    /// Indicates the stream has ended. The precise semantics of this method are
8547    /// determined by the inheriting interface.
8548    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
8549        AudioRendererProxyInterface::r#end_of_stream(self)
8550    }
8551
8552    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8553    /// and not yet released. The response is sent after all packets have been
8554    /// released.
8555    pub fn r#discard_all_packets(
8556        &self,
8557    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8558        AudioRendererProxyInterface::r#discard_all_packets(self)
8559    }
8560
8561    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8562    /// and not yet released.
8563    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
8564        AudioRendererProxyInterface::r#discard_all_packets_no_reply(self)
8565    }
8566
8567    /// Binds to the gain control for this AudioRenderer.
8568    pub fn r#bind_gain_control(
8569        &self,
8570        mut gain_control_request: fidl::endpoints::ServerEnd<
8571            fidl_fuchsia_media_audio::GainControlMarker,
8572        >,
8573    ) -> Result<(), fidl::Error> {
8574        AudioRendererProxyInterface::r#bind_gain_control(self, gain_control_request)
8575    }
8576
8577    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
8578    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
8579    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
8580    pub fn r#set_pts_units(
8581        &self,
8582        mut tick_per_second_numerator: u32,
8583        mut tick_per_second_denominator: u32,
8584    ) -> Result<(), fidl::Error> {
8585        AudioRendererProxyInterface::r#set_pts_units(
8586            self,
8587            tick_per_second_numerator,
8588            tick_per_second_denominator,
8589        )
8590    }
8591
8592    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
8593    /// and expected PTS (determined using interpolation). Beyond this threshold,
8594    /// a stream is no longer considered 'continuous' by the renderer.
8595    ///
8596    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
8597    /// Most users should not need to change this value from its default.
8598    ///
8599    /// Example:
8600    /// A user is playing back 48KHz audio from a container, which also contains
8601    /// video and needs to be synchronized with the audio. The timestamps are
8602    /// provided explicitly per packet by the container, and expressed in mSec
8603    /// units. This means that a single tick of the media timeline (1 mSec)
8604    /// represents exactly 48 frames of audio. The application in this scenario
8605    /// delivers packets of audio to the AudioRenderer, each with exactly 470
8606    /// frames of audio, and each with an explicit timestamp set to the best
8607    /// possible representation of the presentation time (given this media
8608    /// clock's resolution). So, starting from zero, the timestamps would be..
8609    ///
8610    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
8611    ///
8612    /// In this example, attempting to use the presentation time to compute the
8613    /// starting frame number of the audio in the packet would be wrong the
8614    /// majority of the time. The first timestamp is correct (by definition), but
8615    /// it will be 24 packets before the timestamps and frame numbers come back
8616    /// into alignment (the 24th packet would start with the 11280th audio frame
8617    /// and have a PTS of exactly 235).
8618    ///
8619    /// One way to fix this situation is to set the PTS continuity threshold
8620    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
8621    /// the number of frames contained within a single tick of the media clock,
8622    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
8623    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
8624    /// explicitly provided PTS would be considered to be a continuation of the
8625    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
8626    /// would work well.
8627    ///
8628    /// Other possible uses:
8629    /// Users who are scheduling audio explicitly, relative to a clock which has
8630    /// not been configured as the reference clock, can use this value to control
8631    /// the maximum acceptable synchronization error before a discontinuity is
8632    /// introduced. E.g., if a user is scheduling audio based on a recovered
8633    /// common media clock, and has not published that clock as the reference
8634    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
8635    /// can accumulate before the AudioRenderer deliberately inserts a
8636    /// presentation discontinuity to account for the error.
8637    ///
8638    /// Users whose need to deal with a container where their timestamps may be
8639    /// even less correct than +/- 1/2 of a PTS tick may set this value to
8640    /// something larger. This should be the maximum level of inaccuracy present
8641    /// in the container timestamps, if known. Failing that, it could be set to
8642    /// the maximum tolerable level of drift error before absolute timestamps are
8643    /// explicitly obeyed. Finally, a user could set this number to a very large
8644    /// value (86400.0 seconds, for example) to effectively cause *all*
8645    /// timestamps to be ignored after the first, thus treating all audio as
8646    /// continuous with previously delivered packets. Conversely, users who wish
8647    /// to *always* explicitly schedule their audio packets exactly may specify
8648    /// a CT of 0.
8649    ///
8650    /// Note: explicitly specifying high-frequency PTS units reduces the default
8651    /// continuity threshold accordingly. Internally, this threshold is stored as an
8652    /// integer of 1/8192 subframes. The default threshold is computed as follows:
8653    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
8654    /// For this reason, specifying PTS units with a frequency greater than 8192x
8655    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
8656    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
8657    pub fn r#set_pts_continuity_threshold(
8658        &self,
8659        mut threshold_seconds: f32,
8660    ) -> Result<(), fidl::Error> {
8661        AudioRendererProxyInterface::r#set_pts_continuity_threshold(self, threshold_seconds)
8662    }
8663
8664    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
8665    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
8666    pub fn r#get_reference_clock(
8667        &self,
8668    ) -> fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>
8669    {
8670        AudioRendererProxyInterface::r#get_reference_clock(self)
8671    }
8672
8673    /// Sets the reference clock that controls this renderer's playback rate. If the input
8674    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
8675    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
8676    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
8677    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
8678    ///
8679    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
8680    /// cannot be called a second time (even if the renderer format has not yet been set).
8681    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
8682    /// diverge at some later time, they should create a clone of the monotonic clock, set
8683    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
8684    pub fn r#set_reference_clock(
8685        &self,
8686        mut reference_clock: Option<fidl::Clock>,
8687    ) -> Result<(), fidl::Error> {
8688        AudioRendererProxyInterface::r#set_reference_clock(self, reference_clock)
8689    }
8690
8691    /// Sets the usage of the render stream. This method may not be called after
8692    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8693    pub fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
8694        AudioRendererProxyInterface::r#set_usage(self, usage)
8695    }
8696
8697    /// Sets the usage of the render stream. This method may not be called after
8698    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8699    pub fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
8700        AudioRendererProxyInterface::r#set_usage2(self, usage2)
8701    }
8702
8703    /// Sets the type of the stream to be delivered by the client. Using this method implies
8704    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
8705    ///
8706    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
8707    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
8708    /// methods such as `SendPacket`/`SendPacketNoReply`.
8709    pub fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
8710        AudioRendererProxyInterface::r#set_pcm_stream_type(self, type_)
8711    }
8712
8713    /// Enables or disables notifications about changes to the minimum clock lead
8714    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
8715    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
8716    /// event with the current minimum lead time for the AudioRenderer. If the
8717    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
8718    /// new value. This behavior will continue until the user calls
8719    /// `EnableMinLeadTimeEvents(false)`.
8720    ///
8721    /// The minimum clock lead time is the amount of time ahead of the reference
8722    /// clock's understanding of "now" that packets needs to arrive (relative to
8723    /// the playback clock transformation) in order for the mixer to be able to
8724    /// mix packet. For example...
8725    ///
8726    /// + Let the PTS of packet X be P(X)
8727    /// + Let the function which transforms PTS -> RefClock be R(p) (this
8728    ///   function is determined by the call to Play(...)
8729    /// + Let the minimum lead time be MLT
8730    ///
8731    /// If R(P(X)) < RefClock.Now() + MLT
8732    /// Then the packet is late, and some (or all) of the packet's payload will
8733    /// need to be skipped in order to present the packet at the scheduled time.
8734    ///
8735    /// The value `min_lead_time_nsec = 0` is a special value which indicates
8736    /// that the AudioRenderer is not yet routed to an output device. If `Play`
8737    /// is called before the AudioRenderer is routed, any played packets will be
8738    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
8739    /// calling `Play`.
8740    pub fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
8741        AudioRendererProxyInterface::r#enable_min_lead_time_events(self, enabled)
8742    }
8743
8744    ///
8745    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
8746    /// there's little reason to do so. This is because lead time is a function
8747    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
8748    /// If min lead time events are enabled before `SetPcmStreamType` (with
8749    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
8750    /// response to `SetPcmStreamType`.
8751    pub fn r#get_min_lead_time(
8752        &self,
8753    ) -> fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect> {
8754        AudioRendererProxyInterface::r#get_min_lead_time(self)
8755    }
8756
8757    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
8758    /// of the media timeline, using specific values provided by the caller (or
8759    /// default values if not specified). In an optional callback, returns the
8760    /// timestamp values ultimately used -- these set the ongoing relationship
8761    /// between the media and reference timelines (i.e., how to translate between
8762    /// the domain of presentation timestamps, and the realm of local system
8763    /// time).
8764    ///
8765    /// Local system time is specified in units of nanoseconds; media_time is
8766    /// specified in the units defined by the user in the `SetPtsUnits` function,
8767    /// or nanoseconds if `SetPtsUnits` is not called.
8768    ///
8769    /// The act of placing an AudioRenderer into the playback state establishes a
8770    /// relationship between 1) the user-defined media (or presentation) timeline
8771    /// for this particular AudioRenderer, and 2) the real-world system reference
8772    /// timeline. To communicate how to translate between timelines, the Play()
8773    /// callback provides an equivalent timestamp in each time domain. The first
8774    /// value ('reference_time') is given in terms of this renderer's reference
8775    /// clock; the second value ('media_time') is what media instant exactly
8776    /// corresponds to that local time. Restated, the frame at 'media_time' in
8777    /// the audio stream should be presented at 'reference_time' according to
8778    /// the reference clock.
8779    ///
8780    /// Note: on calling this API, media_time immediately starts advancing. It is
8781    /// possible (if uncommon) for a caller to specify a system time that is
8782    /// far in the past, or far into the future. This, along with the specified
8783    /// media time, is simply used to determine what media time corresponds to
8784    /// 'now', and THAT media time is then intersected with presentation
8785    /// timestamps of packets already submitted, to determine which media frames
8786    /// should be presented next.
8787    ///
8788    /// With the corresponding reference_time and media_time values, a user can
8789    /// translate arbitrary time values from one timeline into the other. After
8790    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
8791    /// given the 'ref_start' and 'media_start' values from `Play`, then for
8792    /// any 'ref_time':
8793    ///
8794    /// media_time = ( (ref_time - ref_start) / 1e9
8795    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
8796    ///              + media_start
8797    ///
8798    /// Conversely, for any presentation timestamp 'media_time':
8799    ///
8800    /// ref_time = ( (media_time - media_start)
8801    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
8802    ///              * 1e9 )
8803    ///            + ref_start
8804    ///
8805    /// Users, depending on their use case, may optionally choose not to specify
8806    /// one or both of these timestamps. A timestamp may be omitted by supplying
8807    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
8808    /// any omitted timestamp value using the following rules:
8809    ///
8810    /// Reference Time
8811    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
8812    /// reference time to begin presentation, based on the minimum lead times for
8813    /// the output devices that are currently bound to this AudioRenderer. For
8814    /// example, if an AudioRenderer is bound to an internal audio output
8815    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
8816    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
8817    /// is omitted) select a reference time 80 mSec from now.
8818    ///
8819    /// Media Time
8820    /// If media_time is omitted, the AudioRenderer will select one of two
8821    /// values.
8822    /// - If the AudioRenderer is resuming from the paused state, and packets
8823    /// have not been discarded since being paused, then the AudioRenderer will
8824    /// use a media_time corresponding to the instant at which the presentation
8825    /// became paused.
8826    /// - If the AudioRenderer is being placed into a playing state for the first
8827    /// time following startup or a 'discard packets' operation, the initial
8828    /// media_time will be set to the PTS of the first payload in the pending
8829    /// packet queue. If the pending queue is empty, initial media_time will be
8830    /// set to zero.
8831    ///
8832    /// Return Value
8833    /// When requested, the AudioRenderer will return the 'reference_time' and
8834    /// 'media_time' which were selected and used (whether they were explicitly
8835    /// specified or not) in the return value of the play call.
8836    ///
8837    /// Examples
8838    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
8839    /// to start playing as soon as possible. The user may call Play without
8840    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
8841    ///
8842    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
8843    /// playback at a specified 'reference_time', in sync with some other media
8844    /// stream, either initially or after discarding packets. The user would call
8845    /// `Play(reference_time, NO_TIMESTAMP)`.
8846    ///
8847    /// 3. A user has queued some audio using `SendPacket`. The first of these
8848    /// packets has a PTS of zero, and the user wishes playback to begin as soon
8849    /// as possible, but wishes to skip all of the audio content between PTS 0
8850    /// and PTS 'media_time'. The user would call
8851    /// `Play(NO_TIMESTAMP, media_time)`.
8852    ///
8853    /// 4. A user has queued some audio using `SendPacket` and want to present
8854    /// this media in synch with another player in a different device. The
8855    /// coordinator of the group of distributed players sends an explicit
8856    /// message to each player telling them to begin presentation of audio at
8857    /// PTS 'media_time', at the time (based on the group's shared reference
8858    /// clock) 'reference_time'. Here the user would call
8859    /// `Play(reference_time, media_time)`.
8860    pub fn r#play(
8861        &self,
8862        mut reference_time: i64,
8863        mut media_time: i64,
8864    ) -> fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>
8865    {
8866        AudioRendererProxyInterface::r#play(self, reference_time, media_time)
8867    }
8868
8869    pub fn r#play_no_reply(
8870        &self,
8871        mut reference_time: i64,
8872        mut media_time: i64,
8873    ) -> Result<(), fidl::Error> {
8874        AudioRendererProxyInterface::r#play_no_reply(self, reference_time, media_time)
8875    }
8876
8877    /// Immediately puts the AudioRenderer into the paused state and then report
8878    /// the relationship between the media and reference timelines which was
8879    /// established (if requested).
8880    ///
8881    /// If the AudioRenderer is already in the paused state when this called,
8882    /// the previously-established timeline values are returned (if requested).
8883    pub fn r#pause(
8884        &self,
8885    ) -> fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>
8886    {
8887        AudioRendererProxyInterface::r#pause(self)
8888    }
8889
8890    pub fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
8891        AudioRendererProxyInterface::r#pause_no_reply(self)
8892    }
8893}
8894
8895impl AudioRendererProxyInterface for AudioRendererProxy {
8896    fn r#add_payload_buffer(
8897        &self,
8898        mut id: u32,
8899        mut payload_buffer: fidl::Vmo,
8900    ) -> Result<(), fidl::Error> {
8901        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
8902            (id, payload_buffer),
8903            0x3b3a37fc34fe5b56,
8904            fidl::encoding::DynamicFlags::empty(),
8905        )
8906    }
8907
8908    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
8909        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
8910            (id,),
8911            0x5d1e4f74c3658262,
8912            fidl::encoding::DynamicFlags::empty(),
8913        )
8914    }
8915
8916    type SendPacketResponseFut =
8917        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8918    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
8919        fn _decode(
8920            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8921        ) -> Result<(), fidl::Error> {
8922            let _response = fidl::client::decode_transaction_body::<
8923                fidl::encoding::EmptyPayload,
8924                fidl::encoding::DefaultFuchsiaResourceDialect,
8925                0x67cddd607442775f,
8926            >(_buf?)?;
8927            Ok(_response)
8928        }
8929        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
8930            (packet,),
8931            0x67cddd607442775f,
8932            fidl::encoding::DynamicFlags::empty(),
8933            _decode,
8934        )
8935    }
8936
8937    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
8938        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
8939            (packet,),
8940            0x8d9b8b413ceba9d,
8941            fidl::encoding::DynamicFlags::empty(),
8942        )
8943    }
8944
8945    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
8946        self.client.send::<fidl::encoding::EmptyPayload>(
8947            (),
8948            0x6180fd6f7e793b71,
8949            fidl::encoding::DynamicFlags::empty(),
8950        )
8951    }
8952
8953    type DiscardAllPacketsResponseFut =
8954        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8955    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
8956        fn _decode(
8957            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8958        ) -> Result<(), fidl::Error> {
8959            let _response = fidl::client::decode_transaction_body::<
8960                fidl::encoding::EmptyPayload,
8961                fidl::encoding::DefaultFuchsiaResourceDialect,
8962                0x6f4dad7af2917665,
8963            >(_buf?)?;
8964            Ok(_response)
8965        }
8966        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
8967            (),
8968            0x6f4dad7af2917665,
8969            fidl::encoding::DynamicFlags::empty(),
8970            _decode,
8971        )
8972    }
8973
8974    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
8975        self.client.send::<fidl::encoding::EmptyPayload>(
8976            (),
8977            0x50d36d0d23081bc4,
8978            fidl::encoding::DynamicFlags::empty(),
8979        )
8980    }
8981
8982    fn r#bind_gain_control(
8983        &self,
8984        mut gain_control_request: fidl::endpoints::ServerEnd<
8985            fidl_fuchsia_media_audio::GainControlMarker,
8986        >,
8987    ) -> Result<(), fidl::Error> {
8988        self.client.send::<AudioRendererBindGainControlRequest>(
8989            (gain_control_request,),
8990            0x293f5c7f8fba2bdc,
8991            fidl::encoding::DynamicFlags::empty(),
8992        )
8993    }
8994
8995    fn r#set_pts_units(
8996        &self,
8997        mut tick_per_second_numerator: u32,
8998        mut tick_per_second_denominator: u32,
8999    ) -> Result<(), fidl::Error> {
9000        self.client.send::<AudioRendererSetPtsUnitsRequest>(
9001            (tick_per_second_numerator, tick_per_second_denominator),
9002            0xf68cd108785a27c,
9003            fidl::encoding::DynamicFlags::empty(),
9004        )
9005    }
9006
9007    fn r#set_pts_continuity_threshold(
9008        &self,
9009        mut threshold_seconds: f32,
9010    ) -> Result<(), fidl::Error> {
9011        self.client.send::<AudioRendererSetPtsContinuityThresholdRequest>(
9012            (threshold_seconds,),
9013            0x2849ba571d1971ba,
9014            fidl::encoding::DynamicFlags::empty(),
9015        )
9016    }
9017
9018    type GetReferenceClockResponseFut =
9019        fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>;
9020    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
9021        fn _decode(
9022            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9023        ) -> Result<fidl::Clock, fidl::Error> {
9024            let _response = fidl::client::decode_transaction_body::<
9025                AudioRendererGetReferenceClockResponse,
9026                fidl::encoding::DefaultFuchsiaResourceDialect,
9027                0x2f7a7f011a172f7e,
9028            >(_buf?)?;
9029            Ok(_response.reference_clock)
9030        }
9031        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Clock>(
9032            (),
9033            0x2f7a7f011a172f7e,
9034            fidl::encoding::DynamicFlags::empty(),
9035            _decode,
9036        )
9037    }
9038
9039    fn r#set_reference_clock(
9040        &self,
9041        mut reference_clock: Option<fidl::Clock>,
9042    ) -> Result<(), fidl::Error> {
9043        self.client.send::<AudioRendererSetReferenceClockRequest>(
9044            (reference_clock,),
9045            0x39acd05d832b5fed,
9046            fidl::encoding::DynamicFlags::empty(),
9047        )
9048    }
9049
9050    fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
9051        self.client.send::<AudioRendererSetUsageRequest>(
9052            (usage,),
9053            0x3994bd23b55a733e,
9054            fidl::encoding::DynamicFlags::empty(),
9055        )
9056    }
9057
9058    fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
9059        self.client.send::<AudioRendererSetUsage2Request>(
9060            (usage2,),
9061            0x2904035c7132b103,
9062            fidl::encoding::DynamicFlags::FLEXIBLE,
9063        )
9064    }
9065
9066    fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
9067        self.client.send::<AudioRendererSetPcmStreamTypeRequest>(
9068            (type_,),
9069            0x27aa715d8901fa19,
9070            fidl::encoding::DynamicFlags::empty(),
9071        )
9072    }
9073
9074    fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
9075        self.client.send::<AudioRendererEnableMinLeadTimeEventsRequest>(
9076            (enabled,),
9077            0x62808dfad72bf890,
9078            fidl::encoding::DynamicFlags::empty(),
9079        )
9080    }
9081
9082    type GetMinLeadTimeResponseFut =
9083        fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect>;
9084    fn r#get_min_lead_time(&self) -> Self::GetMinLeadTimeResponseFut {
9085        fn _decode(
9086            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9087        ) -> Result<i64, fidl::Error> {
9088            let _response = fidl::client::decode_transaction_body::<
9089                AudioRendererGetMinLeadTimeResponse,
9090                fidl::encoding::DefaultFuchsiaResourceDialect,
9091                0x1cf3c3ecd8fec26b,
9092            >(_buf?)?;
9093            Ok(_response.min_lead_time_nsec)
9094        }
9095        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i64>(
9096            (),
9097            0x1cf3c3ecd8fec26b,
9098            fidl::encoding::DynamicFlags::empty(),
9099            _decode,
9100        )
9101    }
9102
9103    type PlayResponseFut =
9104        fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>;
9105    fn r#play(&self, mut reference_time: i64, mut media_time: i64) -> Self::PlayResponseFut {
9106        fn _decode(
9107            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9108        ) -> Result<(i64, i64), fidl::Error> {
9109            let _response = fidl::client::decode_transaction_body::<
9110                AudioRendererPlayResponse,
9111                fidl::encoding::DefaultFuchsiaResourceDialect,
9112                0x3c0162db084f74a3,
9113            >(_buf?)?;
9114            Ok((_response.reference_time, _response.media_time))
9115        }
9116        self.client.send_query_and_decode::<AudioRendererPlayRequest, (i64, i64)>(
9117            (reference_time, media_time),
9118            0x3c0162db084f74a3,
9119            fidl::encoding::DynamicFlags::empty(),
9120            _decode,
9121        )
9122    }
9123
9124    fn r#play_no_reply(
9125        &self,
9126        mut reference_time: i64,
9127        mut media_time: i64,
9128    ) -> Result<(), fidl::Error> {
9129        self.client.send::<AudioRendererPlayNoReplyRequest>(
9130            (reference_time, media_time),
9131            0x1b7fe832b68c22ef,
9132            fidl::encoding::DynamicFlags::empty(),
9133        )
9134    }
9135
9136    type PauseResponseFut =
9137        fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>;
9138    fn r#pause(&self) -> Self::PauseResponseFut {
9139        fn _decode(
9140            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9141        ) -> Result<(i64, i64), fidl::Error> {
9142            let _response = fidl::client::decode_transaction_body::<
9143                AudioRendererPauseResponse,
9144                fidl::encoding::DefaultFuchsiaResourceDialect,
9145                0x41d557588d93d153,
9146            >(_buf?)?;
9147            Ok((_response.reference_time, _response.media_time))
9148        }
9149        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i64, i64)>(
9150            (),
9151            0x41d557588d93d153,
9152            fidl::encoding::DynamicFlags::empty(),
9153            _decode,
9154        )
9155    }
9156
9157    fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
9158        self.client.send::<fidl::encoding::EmptyPayload>(
9159            (),
9160            0x24cc45d4f3855ab,
9161            fidl::encoding::DynamicFlags::empty(),
9162        )
9163    }
9164}
9165
9166pub struct AudioRendererEventStream {
9167    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
9168}
9169
9170impl std::marker::Unpin for AudioRendererEventStream {}
9171
9172impl futures::stream::FusedStream for AudioRendererEventStream {
9173    fn is_terminated(&self) -> bool {
9174        self.event_receiver.is_terminated()
9175    }
9176}
9177
9178impl futures::Stream for AudioRendererEventStream {
9179    type Item = Result<AudioRendererEvent, fidl::Error>;
9180
9181    fn poll_next(
9182        mut self: std::pin::Pin<&mut Self>,
9183        cx: &mut std::task::Context<'_>,
9184    ) -> std::task::Poll<Option<Self::Item>> {
9185        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9186            &mut self.event_receiver,
9187            cx
9188        )?) {
9189            Some(buf) => std::task::Poll::Ready(Some(AudioRendererEvent::decode(buf))),
9190            None => std::task::Poll::Ready(None),
9191        }
9192    }
9193}
9194
9195#[derive(Debug)]
9196pub enum AudioRendererEvent {
9197    OnMinLeadTimeChanged {
9198        min_lead_time_nsec: i64,
9199    },
9200    #[non_exhaustive]
9201    _UnknownEvent {
9202        /// Ordinal of the event that was sent.
9203        ordinal: u64,
9204    },
9205}
9206
9207impl AudioRendererEvent {
9208    #[allow(irrefutable_let_patterns)]
9209    pub fn into_on_min_lead_time_changed(self) -> Option<i64> {
9210        if let AudioRendererEvent::OnMinLeadTimeChanged { min_lead_time_nsec } = self {
9211            Some((min_lead_time_nsec))
9212        } else {
9213            None
9214        }
9215    }
9216
9217    /// Decodes a message buffer as a [`AudioRendererEvent`].
9218    fn decode(
9219        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9220    ) -> Result<AudioRendererEvent, fidl::Error> {
9221        let (bytes, _handles) = buf.split_mut();
9222        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9223        debug_assert_eq!(tx_header.tx_id, 0);
9224        match tx_header.ordinal {
9225            0x4feff7d278978c4e => {
9226                let mut out = fidl::new_empty!(
9227                    AudioRendererOnMinLeadTimeChangedRequest,
9228                    fidl::encoding::DefaultFuchsiaResourceDialect
9229                );
9230                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererOnMinLeadTimeChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
9231                Ok((AudioRendererEvent::OnMinLeadTimeChanged {
9232                    min_lead_time_nsec: out.min_lead_time_nsec,
9233                }))
9234            }
9235            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
9236                Ok(AudioRendererEvent::_UnknownEvent { ordinal: tx_header.ordinal })
9237            }
9238            _ => Err(fidl::Error::UnknownOrdinal {
9239                ordinal: tx_header.ordinal,
9240                protocol_name: <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9241            }),
9242        }
9243    }
9244}
9245
9246/// A Stream of incoming requests for fuchsia.media/AudioRenderer.
9247pub struct AudioRendererRequestStream {
9248    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9249    is_terminated: bool,
9250}
9251
9252impl std::marker::Unpin for AudioRendererRequestStream {}
9253
9254impl futures::stream::FusedStream for AudioRendererRequestStream {
9255    fn is_terminated(&self) -> bool {
9256        self.is_terminated
9257    }
9258}
9259
9260impl fidl::endpoints::RequestStream for AudioRendererRequestStream {
9261    type Protocol = AudioRendererMarker;
9262    type ControlHandle = AudioRendererControlHandle;
9263
9264    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
9265        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9266    }
9267
9268    fn control_handle(&self) -> Self::ControlHandle {
9269        AudioRendererControlHandle { inner: self.inner.clone() }
9270    }
9271
9272    fn into_inner(
9273        self,
9274    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
9275    {
9276        (self.inner, self.is_terminated)
9277    }
9278
9279    fn from_inner(
9280        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9281        is_terminated: bool,
9282    ) -> Self {
9283        Self { inner, is_terminated }
9284    }
9285}
9286
9287impl futures::Stream for AudioRendererRequestStream {
9288    type Item = Result<AudioRendererRequest, fidl::Error>;
9289
9290    fn poll_next(
9291        mut self: std::pin::Pin<&mut Self>,
9292        cx: &mut std::task::Context<'_>,
9293    ) -> std::task::Poll<Option<Self::Item>> {
9294        let this = &mut *self;
9295        if this.inner.check_shutdown(cx) {
9296            this.is_terminated = true;
9297            return std::task::Poll::Ready(None);
9298        }
9299        if this.is_terminated {
9300            panic!("polled AudioRendererRequestStream after completion");
9301        }
9302        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
9303            |bytes, handles| {
9304                match this.inner.channel().read_etc(cx, bytes, handles) {
9305                    std::task::Poll::Ready(Ok(())) => {}
9306                    std::task::Poll::Pending => return std::task::Poll::Pending,
9307                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
9308                        this.is_terminated = true;
9309                        return std::task::Poll::Ready(None);
9310                    }
9311                    std::task::Poll::Ready(Err(e)) => {
9312                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9313                            e.into(),
9314                        ))));
9315                    }
9316                }
9317
9318                // A message has been received from the channel
9319                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9320
9321                std::task::Poll::Ready(Some(match header.ordinal {
9322                    0x3b3a37fc34fe5b56 => {
9323                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9324                        let mut req = fidl::new_empty!(
9325                            StreamBufferSetAddPayloadBufferRequest,
9326                            fidl::encoding::DefaultFuchsiaResourceDialect
9327                        );
9328                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
9329                        let control_handle =
9330                            AudioRendererControlHandle { inner: this.inner.clone() };
9331                        Ok(AudioRendererRequest::AddPayloadBuffer {
9332                            id: req.id,
9333                            payload_buffer: req.payload_buffer,
9334
9335                            control_handle,
9336                        })
9337                    }
9338                    0x5d1e4f74c3658262 => {
9339                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9340                        let mut req = fidl::new_empty!(
9341                            StreamBufferSetRemovePayloadBufferRequest,
9342                            fidl::encoding::DefaultFuchsiaResourceDialect
9343                        );
9344                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
9345                        let control_handle =
9346                            AudioRendererControlHandle { inner: this.inner.clone() };
9347                        Ok(AudioRendererRequest::RemovePayloadBuffer { id: req.id, control_handle })
9348                    }
9349                    0x67cddd607442775f => {
9350                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9351                        let mut req = fidl::new_empty!(
9352                            StreamSinkSendPacketRequest,
9353                            fidl::encoding::DefaultFuchsiaResourceDialect
9354                        );
9355                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
9356                        let control_handle =
9357                            AudioRendererControlHandle { inner: this.inner.clone() };
9358                        Ok(AudioRendererRequest::SendPacket {
9359                            packet: req.packet,
9360
9361                            responder: AudioRendererSendPacketResponder {
9362                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9363                                tx_id: header.tx_id,
9364                            },
9365                        })
9366                    }
9367                    0x8d9b8b413ceba9d => {
9368                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9369                        let mut req = fidl::new_empty!(
9370                            StreamSinkSendPacketNoReplyRequest,
9371                            fidl::encoding::DefaultFuchsiaResourceDialect
9372                        );
9373                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
9374                        let control_handle =
9375                            AudioRendererControlHandle { inner: this.inner.clone() };
9376                        Ok(AudioRendererRequest::SendPacketNoReply {
9377                            packet: req.packet,
9378
9379                            control_handle,
9380                        })
9381                    }
9382                    0x6180fd6f7e793b71 => {
9383                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9384                        let mut req = fidl::new_empty!(
9385                            fidl::encoding::EmptyPayload,
9386                            fidl::encoding::DefaultFuchsiaResourceDialect
9387                        );
9388                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9389                        let control_handle =
9390                            AudioRendererControlHandle { inner: this.inner.clone() };
9391                        Ok(AudioRendererRequest::EndOfStream { control_handle })
9392                    }
9393                    0x6f4dad7af2917665 => {
9394                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9395                        let mut req = fidl::new_empty!(
9396                            fidl::encoding::EmptyPayload,
9397                            fidl::encoding::DefaultFuchsiaResourceDialect
9398                        );
9399                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9400                        let control_handle =
9401                            AudioRendererControlHandle { inner: this.inner.clone() };
9402                        Ok(AudioRendererRequest::DiscardAllPackets {
9403                            responder: AudioRendererDiscardAllPacketsResponder {
9404                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9405                                tx_id: header.tx_id,
9406                            },
9407                        })
9408                    }
9409                    0x50d36d0d23081bc4 => {
9410                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9411                        let mut req = fidl::new_empty!(
9412                            fidl::encoding::EmptyPayload,
9413                            fidl::encoding::DefaultFuchsiaResourceDialect
9414                        );
9415                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9416                        let control_handle =
9417                            AudioRendererControlHandle { inner: this.inner.clone() };
9418                        Ok(AudioRendererRequest::DiscardAllPacketsNoReply { control_handle })
9419                    }
9420                    0x293f5c7f8fba2bdc => {
9421                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9422                        let mut req = fidl::new_empty!(
9423                            AudioRendererBindGainControlRequest,
9424                            fidl::encoding::DefaultFuchsiaResourceDialect
9425                        );
9426                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererBindGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
9427                        let control_handle =
9428                            AudioRendererControlHandle { inner: this.inner.clone() };
9429                        Ok(AudioRendererRequest::BindGainControl {
9430                            gain_control_request: req.gain_control_request,
9431
9432                            control_handle,
9433                        })
9434                    }
9435                    0xf68cd108785a27c => {
9436                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9437                        let mut req = fidl::new_empty!(
9438                            AudioRendererSetPtsUnitsRequest,
9439                            fidl::encoding::DefaultFuchsiaResourceDialect
9440                        );
9441                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetPtsUnitsRequest>(&header, _body_bytes, handles, &mut req)?;
9442                        let control_handle =
9443                            AudioRendererControlHandle { inner: this.inner.clone() };
9444                        Ok(AudioRendererRequest::SetPtsUnits {
9445                            tick_per_second_numerator: req.tick_per_second_numerator,
9446                            tick_per_second_denominator: req.tick_per_second_denominator,
9447
9448                            control_handle,
9449                        })
9450                    }
9451                    0x2849ba571d1971ba => {
9452                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9453                        let mut req = fidl::new_empty!(
9454                            AudioRendererSetPtsContinuityThresholdRequest,
9455                            fidl::encoding::DefaultFuchsiaResourceDialect
9456                        );
9457                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetPtsContinuityThresholdRequest>(&header, _body_bytes, handles, &mut req)?;
9458                        let control_handle =
9459                            AudioRendererControlHandle { inner: this.inner.clone() };
9460                        Ok(AudioRendererRequest::SetPtsContinuityThreshold {
9461                            threshold_seconds: req.threshold_seconds,
9462
9463                            control_handle,
9464                        })
9465                    }
9466                    0x2f7a7f011a172f7e => {
9467                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9468                        let mut req = fidl::new_empty!(
9469                            fidl::encoding::EmptyPayload,
9470                            fidl::encoding::DefaultFuchsiaResourceDialect
9471                        );
9472                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9473                        let control_handle =
9474                            AudioRendererControlHandle { inner: this.inner.clone() };
9475                        Ok(AudioRendererRequest::GetReferenceClock {
9476                            responder: AudioRendererGetReferenceClockResponder {
9477                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9478                                tx_id: header.tx_id,
9479                            },
9480                        })
9481                    }
9482                    0x39acd05d832b5fed => {
9483                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9484                        let mut req = fidl::new_empty!(
9485                            AudioRendererSetReferenceClockRequest,
9486                            fidl::encoding::DefaultFuchsiaResourceDialect
9487                        );
9488                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetReferenceClockRequest>(&header, _body_bytes, handles, &mut req)?;
9489                        let control_handle =
9490                            AudioRendererControlHandle { inner: this.inner.clone() };
9491                        Ok(AudioRendererRequest::SetReferenceClock {
9492                            reference_clock: req.reference_clock,
9493
9494                            control_handle,
9495                        })
9496                    }
9497                    0x3994bd23b55a733e => {
9498                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9499                        let mut req = fidl::new_empty!(
9500                            AudioRendererSetUsageRequest,
9501                            fidl::encoding::DefaultFuchsiaResourceDialect
9502                        );
9503                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetUsageRequest>(&header, _body_bytes, handles, &mut req)?;
9504                        let control_handle =
9505                            AudioRendererControlHandle { inner: this.inner.clone() };
9506                        Ok(AudioRendererRequest::SetUsage { usage: req.usage, control_handle })
9507                    }
9508                    0x2904035c7132b103 => {
9509                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9510                        let mut req = fidl::new_empty!(
9511                            AudioRendererSetUsage2Request,
9512                            fidl::encoding::DefaultFuchsiaResourceDialect
9513                        );
9514                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetUsage2Request>(&header, _body_bytes, handles, &mut req)?;
9515                        let control_handle =
9516                            AudioRendererControlHandle { inner: this.inner.clone() };
9517                        Ok(AudioRendererRequest::SetUsage2 { usage2: req.usage2, control_handle })
9518                    }
9519                    0x27aa715d8901fa19 => {
9520                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9521                        let mut req = fidl::new_empty!(
9522                            AudioRendererSetPcmStreamTypeRequest,
9523                            fidl::encoding::DefaultFuchsiaResourceDialect
9524                        );
9525                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetPcmStreamTypeRequest>(&header, _body_bytes, handles, &mut req)?;
9526                        let control_handle =
9527                            AudioRendererControlHandle { inner: this.inner.clone() };
9528                        Ok(AudioRendererRequest::SetPcmStreamType {
9529                            type_: req.type_,
9530
9531                            control_handle,
9532                        })
9533                    }
9534                    0x62808dfad72bf890 => {
9535                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9536                        let mut req = fidl::new_empty!(
9537                            AudioRendererEnableMinLeadTimeEventsRequest,
9538                            fidl::encoding::DefaultFuchsiaResourceDialect
9539                        );
9540                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererEnableMinLeadTimeEventsRequest>(&header, _body_bytes, handles, &mut req)?;
9541                        let control_handle =
9542                            AudioRendererControlHandle { inner: this.inner.clone() };
9543                        Ok(AudioRendererRequest::EnableMinLeadTimeEvents {
9544                            enabled: req.enabled,
9545
9546                            control_handle,
9547                        })
9548                    }
9549                    0x1cf3c3ecd8fec26b => {
9550                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9551                        let mut req = fidl::new_empty!(
9552                            fidl::encoding::EmptyPayload,
9553                            fidl::encoding::DefaultFuchsiaResourceDialect
9554                        );
9555                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9556                        let control_handle =
9557                            AudioRendererControlHandle { inner: this.inner.clone() };
9558                        Ok(AudioRendererRequest::GetMinLeadTime {
9559                            responder: AudioRendererGetMinLeadTimeResponder {
9560                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9561                                tx_id: header.tx_id,
9562                            },
9563                        })
9564                    }
9565                    0x3c0162db084f74a3 => {
9566                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9567                        let mut req = fidl::new_empty!(
9568                            AudioRendererPlayRequest,
9569                            fidl::encoding::DefaultFuchsiaResourceDialect
9570                        );
9571                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererPlayRequest>(&header, _body_bytes, handles, &mut req)?;
9572                        let control_handle =
9573                            AudioRendererControlHandle { inner: this.inner.clone() };
9574                        Ok(AudioRendererRequest::Play {
9575                            reference_time: req.reference_time,
9576                            media_time: req.media_time,
9577
9578                            responder: AudioRendererPlayResponder {
9579                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9580                                tx_id: header.tx_id,
9581                            },
9582                        })
9583                    }
9584                    0x1b7fe832b68c22ef => {
9585                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9586                        let mut req = fidl::new_empty!(
9587                            AudioRendererPlayNoReplyRequest,
9588                            fidl::encoding::DefaultFuchsiaResourceDialect
9589                        );
9590                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererPlayNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
9591                        let control_handle =
9592                            AudioRendererControlHandle { inner: this.inner.clone() };
9593                        Ok(AudioRendererRequest::PlayNoReply {
9594                            reference_time: req.reference_time,
9595                            media_time: req.media_time,
9596
9597                            control_handle,
9598                        })
9599                    }
9600                    0x41d557588d93d153 => {
9601                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9602                        let mut req = fidl::new_empty!(
9603                            fidl::encoding::EmptyPayload,
9604                            fidl::encoding::DefaultFuchsiaResourceDialect
9605                        );
9606                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9607                        let control_handle =
9608                            AudioRendererControlHandle { inner: this.inner.clone() };
9609                        Ok(AudioRendererRequest::Pause {
9610                            responder: AudioRendererPauseResponder {
9611                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9612                                tx_id: header.tx_id,
9613                            },
9614                        })
9615                    }
9616                    0x24cc45d4f3855ab => {
9617                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9618                        let mut req = fidl::new_empty!(
9619                            fidl::encoding::EmptyPayload,
9620                            fidl::encoding::DefaultFuchsiaResourceDialect
9621                        );
9622                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9623                        let control_handle =
9624                            AudioRendererControlHandle { inner: this.inner.clone() };
9625                        Ok(AudioRendererRequest::PauseNoReply { control_handle })
9626                    }
9627                    _ if header.tx_id == 0
9628                        && header
9629                            .dynamic_flags()
9630                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
9631                    {
9632                        Ok(AudioRendererRequest::_UnknownMethod {
9633                            ordinal: header.ordinal,
9634                            control_handle: AudioRendererControlHandle {
9635                                inner: this.inner.clone(),
9636                            },
9637                            method_type: fidl::MethodType::OneWay,
9638                        })
9639                    }
9640                    _ if header
9641                        .dynamic_flags()
9642                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
9643                    {
9644                        this.inner.send_framework_err(
9645                            fidl::encoding::FrameworkErr::UnknownMethod,
9646                            header.tx_id,
9647                            header.ordinal,
9648                            header.dynamic_flags(),
9649                            (bytes, handles),
9650                        )?;
9651                        Ok(AudioRendererRequest::_UnknownMethod {
9652                            ordinal: header.ordinal,
9653                            control_handle: AudioRendererControlHandle {
9654                                inner: this.inner.clone(),
9655                            },
9656                            method_type: fidl::MethodType::TwoWay,
9657                        })
9658                    }
9659                    _ => Err(fidl::Error::UnknownOrdinal {
9660                        ordinal: header.ordinal,
9661                        protocol_name:
9662                            <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9663                    }),
9664                }))
9665            },
9666        )
9667    }
9668}
9669
9670/// AudioRenderers can be in one of two states at any time: _configurable_ or _operational_. A
9671/// renderer is considered operational whenever it has packets queued to be rendered; otherwise it
9672/// is _configurable_. Once an AudioRenderer enters the operational state, calls to "configuring"
9673/// methods are disallowed and will cause the audio service to disconnect the client's connection.
9674/// The following are considered configuring methods: `AddPayloadBuffer`, `SetPcmStreamType`,
9675/// `SetStreamType`, `SetPtsUnits`, `SetPtsContinuityThreshold`.
9676///
9677/// If an AudioRenderer must be reconfigured, the client must ensure that no packets are still
9678/// enqueued when these "configuring" methods are called. Thus it is best practice to call
9679/// `DiscardAllPackets` on the AudioRenderer (and ideally `Stop` before `DiscardAllPackets`), prior
9680/// to reconfiguring the renderer.
9681#[derive(Debug)]
9682pub enum AudioRendererRequest {
9683    /// Adds a payload buffer to the current buffer set associated with the
9684    /// connection. A `StreamPacket` struct reference a payload buffer in the
9685    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
9686    ///
9687    /// A buffer with ID `id` must not be in the current set when this method is
9688    /// invoked, otherwise the service will close the connection.
9689    AddPayloadBuffer {
9690        id: u32,
9691        payload_buffer: fidl::Vmo,
9692        control_handle: AudioRendererControlHandle,
9693    },
9694    /// Removes a payload buffer from the current buffer set associated with the
9695    /// connection.
9696    ///
9697    /// A buffer with ID `id` must exist in the current set when this method is
9698    /// invoked, otherwise the service will will close the connection.
9699    RemovePayloadBuffer {
9700        id: u32,
9701        control_handle: AudioRendererControlHandle,
9702    },
9703    /// Sends a packet to the service. The response is sent when the service is
9704    /// done with the associated payload memory.
9705    ///
9706    /// `packet` must be valid for the current buffer set, otherwise the service
9707    /// will close the connection.
9708    SendPacket {
9709        packet: StreamPacket,
9710        responder: AudioRendererSendPacketResponder,
9711    },
9712    /// Sends a packet to the service. This interface doesn't define how the
9713    /// client knows when the sink is done with the associated payload memory.
9714    /// The inheriting interface must define that.
9715    ///
9716    /// `packet` must be valid for the current buffer set, otherwise the service
9717    /// will close the connection.
9718    SendPacketNoReply {
9719        packet: StreamPacket,
9720        control_handle: AudioRendererControlHandle,
9721    },
9722    /// Indicates the stream has ended. The precise semantics of this method are
9723    /// determined by the inheriting interface.
9724    EndOfStream {
9725        control_handle: AudioRendererControlHandle,
9726    },
9727    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
9728    /// and not yet released. The response is sent after all packets have been
9729    /// released.
9730    DiscardAllPackets {
9731        responder: AudioRendererDiscardAllPacketsResponder,
9732    },
9733    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
9734    /// and not yet released.
9735    DiscardAllPacketsNoReply {
9736        control_handle: AudioRendererControlHandle,
9737    },
9738    /// Binds to the gain control for this AudioRenderer.
9739    BindGainControl {
9740        gain_control_request:
9741            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
9742        control_handle: AudioRendererControlHandle,
9743    },
9744    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
9745    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
9746    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
9747    SetPtsUnits {
9748        tick_per_second_numerator: u32,
9749        tick_per_second_denominator: u32,
9750        control_handle: AudioRendererControlHandle,
9751    },
9752    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
9753    /// and expected PTS (determined using interpolation). Beyond this threshold,
9754    /// a stream is no longer considered 'continuous' by the renderer.
9755    ///
9756    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
9757    /// Most users should not need to change this value from its default.
9758    ///
9759    /// Example:
9760    /// A user is playing back 48KHz audio from a container, which also contains
9761    /// video and needs to be synchronized with the audio. The timestamps are
9762    /// provided explicitly per packet by the container, and expressed in mSec
9763    /// units. This means that a single tick of the media timeline (1 mSec)
9764    /// represents exactly 48 frames of audio. The application in this scenario
9765    /// delivers packets of audio to the AudioRenderer, each with exactly 470
9766    /// frames of audio, and each with an explicit timestamp set to the best
9767    /// possible representation of the presentation time (given this media
9768    /// clock's resolution). So, starting from zero, the timestamps would be..
9769    ///
9770    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
9771    ///
9772    /// In this example, attempting to use the presentation time to compute the
9773    /// starting frame number of the audio in the packet would be wrong the
9774    /// majority of the time. The first timestamp is correct (by definition), but
9775    /// it will be 24 packets before the timestamps and frame numbers come back
9776    /// into alignment (the 24th packet would start with the 11280th audio frame
9777    /// and have a PTS of exactly 235).
9778    ///
9779    /// One way to fix this situation is to set the PTS continuity threshold
9780    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
9781    /// the number of frames contained within a single tick of the media clock,
9782    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
9783    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
9784    /// explicitly provided PTS would be considered to be a continuation of the
9785    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
9786    /// would work well.
9787    ///
9788    /// Other possible uses:
9789    /// Users who are scheduling audio explicitly, relative to a clock which has
9790    /// not been configured as the reference clock, can use this value to control
9791    /// the maximum acceptable synchronization error before a discontinuity is
9792    /// introduced. E.g., if a user is scheduling audio based on a recovered
9793    /// common media clock, and has not published that clock as the reference
9794    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
9795    /// can accumulate before the AudioRenderer deliberately inserts a
9796    /// presentation discontinuity to account for the error.
9797    ///
9798    /// Users whose need to deal with a container where their timestamps may be
9799    /// even less correct than +/- 1/2 of a PTS tick may set this value to
9800    /// something larger. This should be the maximum level of inaccuracy present
9801    /// in the container timestamps, if known. Failing that, it could be set to
9802    /// the maximum tolerable level of drift error before absolute timestamps are
9803    /// explicitly obeyed. Finally, a user could set this number to a very large
9804    /// value (86400.0 seconds, for example) to effectively cause *all*
9805    /// timestamps to be ignored after the first, thus treating all audio as
9806    /// continuous with previously delivered packets. Conversely, users who wish
9807    /// to *always* explicitly schedule their audio packets exactly may specify
9808    /// a CT of 0.
9809    ///
9810    /// Note: explicitly specifying high-frequency PTS units reduces the default
9811    /// continuity threshold accordingly. Internally, this threshold is stored as an
9812    /// integer of 1/8192 subframes. The default threshold is computed as follows:
9813    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
9814    /// For this reason, specifying PTS units with a frequency greater than 8192x
9815    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
9816    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
9817    SetPtsContinuityThreshold {
9818        threshold_seconds: f32,
9819        control_handle: AudioRendererControlHandle,
9820    },
9821    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
9822    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
9823    GetReferenceClock {
9824        responder: AudioRendererGetReferenceClockResponder,
9825    },
9826    /// Sets the reference clock that controls this renderer's playback rate. If the input
9827    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
9828    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
9829    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
9830    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
9831    ///
9832    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
9833    /// cannot be called a second time (even if the renderer format has not yet been set).
9834    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
9835    /// diverge at some later time, they should create a clone of the monotonic clock, set
9836    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
9837    SetReferenceClock {
9838        reference_clock: Option<fidl::Clock>,
9839        control_handle: AudioRendererControlHandle,
9840    },
9841    /// Sets the usage of the render stream. This method may not be called after
9842    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
9843    SetUsage {
9844        usage: AudioRenderUsage,
9845        control_handle: AudioRendererControlHandle,
9846    },
9847    /// Sets the usage of the render stream. This method may not be called after
9848    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
9849    SetUsage2 {
9850        usage2: AudioRenderUsage2,
9851        control_handle: AudioRendererControlHandle,
9852    },
9853    /// Sets the type of the stream to be delivered by the client. Using this method implies
9854    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
9855    ///
9856    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
9857    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
9858    /// methods such as `SendPacket`/`SendPacketNoReply`.
9859    SetPcmStreamType {
9860        type_: AudioStreamType,
9861        control_handle: AudioRendererControlHandle,
9862    },
9863    /// Enables or disables notifications about changes to the minimum clock lead
9864    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
9865    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
9866    /// event with the current minimum lead time for the AudioRenderer. If the
9867    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
9868    /// new value. This behavior will continue until the user calls
9869    /// `EnableMinLeadTimeEvents(false)`.
9870    ///
9871    /// The minimum clock lead time is the amount of time ahead of the reference
9872    /// clock's understanding of "now" that packets needs to arrive (relative to
9873    /// the playback clock transformation) in order for the mixer to be able to
9874    /// mix packet. For example...
9875    ///
9876    /// + Let the PTS of packet X be P(X)
9877    /// + Let the function which transforms PTS -> RefClock be R(p) (this
9878    ///   function is determined by the call to Play(...)
9879    /// + Let the minimum lead time be MLT
9880    ///
9881    /// If R(P(X)) < RefClock.Now() + MLT
9882    /// Then the packet is late, and some (or all) of the packet's payload will
9883    /// need to be skipped in order to present the packet at the scheduled time.
9884    ///
9885    /// The value `min_lead_time_nsec = 0` is a special value which indicates
9886    /// that the AudioRenderer is not yet routed to an output device. If `Play`
9887    /// is called before the AudioRenderer is routed, any played packets will be
9888    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
9889    /// calling `Play`.
9890    EnableMinLeadTimeEvents {
9891        enabled: bool,
9892        control_handle: AudioRendererControlHandle,
9893    },
9894    ///
9895    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
9896    /// there's little reason to do so. This is because lead time is a function
9897    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
9898    /// If min lead time events are enabled before `SetPcmStreamType` (with
9899    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
9900    /// response to `SetPcmStreamType`.
9901    GetMinLeadTime {
9902        responder: AudioRendererGetMinLeadTimeResponder,
9903    },
9904    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
9905    /// of the media timeline, using specific values provided by the caller (or
9906    /// default values if not specified). In an optional callback, returns the
9907    /// timestamp values ultimately used -- these set the ongoing relationship
9908    /// between the media and reference timelines (i.e., how to translate between
9909    /// the domain of presentation timestamps, and the realm of local system
9910    /// time).
9911    ///
9912    /// Local system time is specified in units of nanoseconds; media_time is
9913    /// specified in the units defined by the user in the `SetPtsUnits` function,
9914    /// or nanoseconds if `SetPtsUnits` is not called.
9915    ///
9916    /// The act of placing an AudioRenderer into the playback state establishes a
9917    /// relationship between 1) the user-defined media (or presentation) timeline
9918    /// for this particular AudioRenderer, and 2) the real-world system reference
9919    /// timeline. To communicate how to translate between timelines, the Play()
9920    /// callback provides an equivalent timestamp in each time domain. The first
9921    /// value ('reference_time') is given in terms of this renderer's reference
9922    /// clock; the second value ('media_time') is what media instant exactly
9923    /// corresponds to that local time. Restated, the frame at 'media_time' in
9924    /// the audio stream should be presented at 'reference_time' according to
9925    /// the reference clock.
9926    ///
9927    /// Note: on calling this API, media_time immediately starts advancing. It is
9928    /// possible (if uncommon) for a caller to specify a system time that is
9929    /// far in the past, or far into the future. This, along with the specified
9930    /// media time, is simply used to determine what media time corresponds to
9931    /// 'now', and THAT media time is then intersected with presentation
9932    /// timestamps of packets already submitted, to determine which media frames
9933    /// should be presented next.
9934    ///
9935    /// With the corresponding reference_time and media_time values, a user can
9936    /// translate arbitrary time values from one timeline into the other. After
9937    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
9938    /// given the 'ref_start' and 'media_start' values from `Play`, then for
9939    /// any 'ref_time':
9940    ///
9941    /// media_time = ( (ref_time - ref_start) / 1e9
9942    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
9943    ///              + media_start
9944    ///
9945    /// Conversely, for any presentation timestamp 'media_time':
9946    ///
9947    /// ref_time = ( (media_time - media_start)
9948    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
9949    ///              * 1e9 )
9950    ///            + ref_start
9951    ///
9952    /// Users, depending on their use case, may optionally choose not to specify
9953    /// one or both of these timestamps. A timestamp may be omitted by supplying
9954    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
9955    /// any omitted timestamp value using the following rules:
9956    ///
9957    /// Reference Time
9958    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
9959    /// reference time to begin presentation, based on the minimum lead times for
9960    /// the output devices that are currently bound to this AudioRenderer. For
9961    /// example, if an AudioRenderer is bound to an internal audio output
9962    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
9963    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
9964    /// is omitted) select a reference time 80 mSec from now.
9965    ///
9966    /// Media Time
9967    /// If media_time is omitted, the AudioRenderer will select one of two
9968    /// values.
9969    /// - If the AudioRenderer is resuming from the paused state, and packets
9970    /// have not been discarded since being paused, then the AudioRenderer will
9971    /// use a media_time corresponding to the instant at which the presentation
9972    /// became paused.
9973    /// - If the AudioRenderer is being placed into a playing state for the first
9974    /// time following startup or a 'discard packets' operation, the initial
9975    /// media_time will be set to the PTS of the first payload in the pending
9976    /// packet queue. If the pending queue is empty, initial media_time will be
9977    /// set to zero.
9978    ///
9979    /// Return Value
9980    /// When requested, the AudioRenderer will return the 'reference_time' and
9981    /// 'media_time' which were selected and used (whether they were explicitly
9982    /// specified or not) in the return value of the play call.
9983    ///
9984    /// Examples
9985    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
9986    /// to start playing as soon as possible. The user may call Play without
9987    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
9988    ///
9989    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
9990    /// playback at a specified 'reference_time', in sync with some other media
9991    /// stream, either initially or after discarding packets. The user would call
9992    /// `Play(reference_time, NO_TIMESTAMP)`.
9993    ///
9994    /// 3. A user has queued some audio using `SendPacket`. The first of these
9995    /// packets has a PTS of zero, and the user wishes playback to begin as soon
9996    /// as possible, but wishes to skip all of the audio content between PTS 0
9997    /// and PTS 'media_time'. The user would call
9998    /// `Play(NO_TIMESTAMP, media_time)`.
9999    ///
10000    /// 4. A user has queued some audio using `SendPacket` and want to present
10001    /// this media in synch with another player in a different device. The
10002    /// coordinator of the group of distributed players sends an explicit
10003    /// message to each player telling them to begin presentation of audio at
10004    /// PTS 'media_time', at the time (based on the group's shared reference
10005    /// clock) 'reference_time'. Here the user would call
10006    /// `Play(reference_time, media_time)`.
10007    Play {
10008        reference_time: i64,
10009        media_time: i64,
10010        responder: AudioRendererPlayResponder,
10011    },
10012    PlayNoReply {
10013        reference_time: i64,
10014        media_time: i64,
10015        control_handle: AudioRendererControlHandle,
10016    },
10017    /// Immediately puts the AudioRenderer into the paused state and then report
10018    /// the relationship between the media and reference timelines which was
10019    /// established (if requested).
10020    ///
10021    /// If the AudioRenderer is already in the paused state when this called,
10022    /// the previously-established timeline values are returned (if requested).
10023    Pause {
10024        responder: AudioRendererPauseResponder,
10025    },
10026    PauseNoReply {
10027        control_handle: AudioRendererControlHandle,
10028    },
10029    /// An interaction was received which does not match any known method.
10030    #[non_exhaustive]
10031    _UnknownMethod {
10032        /// Ordinal of the method that was called.
10033        ordinal: u64,
10034        control_handle: AudioRendererControlHandle,
10035        method_type: fidl::MethodType,
10036    },
10037}
10038
10039impl AudioRendererRequest {
10040    #[allow(irrefutable_let_patterns)]
10041    pub fn into_add_payload_buffer(self) -> Option<(u32, fidl::Vmo, AudioRendererControlHandle)> {
10042        if let AudioRendererRequest::AddPayloadBuffer { id, payload_buffer, control_handle } = self
10043        {
10044            Some((id, payload_buffer, control_handle))
10045        } else {
10046            None
10047        }
10048    }
10049
10050    #[allow(irrefutable_let_patterns)]
10051    pub fn into_remove_payload_buffer(self) -> Option<(u32, AudioRendererControlHandle)> {
10052        if let AudioRendererRequest::RemovePayloadBuffer { id, control_handle } = self {
10053            Some((id, control_handle))
10054        } else {
10055            None
10056        }
10057    }
10058
10059    #[allow(irrefutable_let_patterns)]
10060    pub fn into_send_packet(self) -> Option<(StreamPacket, AudioRendererSendPacketResponder)> {
10061        if let AudioRendererRequest::SendPacket { packet, responder } = self {
10062            Some((packet, responder))
10063        } else {
10064            None
10065        }
10066    }
10067
10068    #[allow(irrefutable_let_patterns)]
10069    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, AudioRendererControlHandle)> {
10070        if let AudioRendererRequest::SendPacketNoReply { packet, control_handle } = self {
10071            Some((packet, control_handle))
10072        } else {
10073            None
10074        }
10075    }
10076
10077    #[allow(irrefutable_let_patterns)]
10078    pub fn into_end_of_stream(self) -> Option<(AudioRendererControlHandle)> {
10079        if let AudioRendererRequest::EndOfStream { control_handle } = self {
10080            Some((control_handle))
10081        } else {
10082            None
10083        }
10084    }
10085
10086    #[allow(irrefutable_let_patterns)]
10087    pub fn into_discard_all_packets(self) -> Option<(AudioRendererDiscardAllPacketsResponder)> {
10088        if let AudioRendererRequest::DiscardAllPackets { responder } = self {
10089            Some((responder))
10090        } else {
10091            None
10092        }
10093    }
10094
10095    #[allow(irrefutable_let_patterns)]
10096    pub fn into_discard_all_packets_no_reply(self) -> Option<(AudioRendererControlHandle)> {
10097        if let AudioRendererRequest::DiscardAllPacketsNoReply { control_handle } = self {
10098            Some((control_handle))
10099        } else {
10100            None
10101        }
10102    }
10103
10104    #[allow(irrefutable_let_patterns)]
10105    pub fn into_bind_gain_control(
10106        self,
10107    ) -> Option<(
10108        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
10109        AudioRendererControlHandle,
10110    )> {
10111        if let AudioRendererRequest::BindGainControl { gain_control_request, control_handle } = self
10112        {
10113            Some((gain_control_request, control_handle))
10114        } else {
10115            None
10116        }
10117    }
10118
10119    #[allow(irrefutable_let_patterns)]
10120    pub fn into_set_pts_units(self) -> Option<(u32, u32, AudioRendererControlHandle)> {
10121        if let AudioRendererRequest::SetPtsUnits {
10122            tick_per_second_numerator,
10123            tick_per_second_denominator,
10124            control_handle,
10125        } = self
10126        {
10127            Some((tick_per_second_numerator, tick_per_second_denominator, control_handle))
10128        } else {
10129            None
10130        }
10131    }
10132
10133    #[allow(irrefutable_let_patterns)]
10134    pub fn into_set_pts_continuity_threshold(self) -> Option<(f32, AudioRendererControlHandle)> {
10135        if let AudioRendererRequest::SetPtsContinuityThreshold {
10136            threshold_seconds,
10137            control_handle,
10138        } = self
10139        {
10140            Some((threshold_seconds, control_handle))
10141        } else {
10142            None
10143        }
10144    }
10145
10146    #[allow(irrefutable_let_patterns)]
10147    pub fn into_get_reference_clock(self) -> Option<(AudioRendererGetReferenceClockResponder)> {
10148        if let AudioRendererRequest::GetReferenceClock { responder } = self {
10149            Some((responder))
10150        } else {
10151            None
10152        }
10153    }
10154
10155    #[allow(irrefutable_let_patterns)]
10156    pub fn into_set_reference_clock(
10157        self,
10158    ) -> Option<(Option<fidl::Clock>, AudioRendererControlHandle)> {
10159        if let AudioRendererRequest::SetReferenceClock { reference_clock, control_handle } = self {
10160            Some((reference_clock, control_handle))
10161        } else {
10162            None
10163        }
10164    }
10165
10166    #[allow(irrefutable_let_patterns)]
10167    pub fn into_set_usage(self) -> Option<(AudioRenderUsage, AudioRendererControlHandle)> {
10168        if let AudioRendererRequest::SetUsage { usage, control_handle } = self {
10169            Some((usage, control_handle))
10170        } else {
10171            None
10172        }
10173    }
10174
10175    #[allow(irrefutable_let_patterns)]
10176    pub fn into_set_usage2(self) -> Option<(AudioRenderUsage2, AudioRendererControlHandle)> {
10177        if let AudioRendererRequest::SetUsage2 { usage2, control_handle } = self {
10178            Some((usage2, control_handle))
10179        } else {
10180            None
10181        }
10182    }
10183
10184    #[allow(irrefutable_let_patterns)]
10185    pub fn into_set_pcm_stream_type(self) -> Option<(AudioStreamType, AudioRendererControlHandle)> {
10186        if let AudioRendererRequest::SetPcmStreamType { type_, control_handle } = self {
10187            Some((type_, control_handle))
10188        } else {
10189            None
10190        }
10191    }
10192
10193    #[allow(irrefutable_let_patterns)]
10194    pub fn into_enable_min_lead_time_events(self) -> Option<(bool, AudioRendererControlHandle)> {
10195        if let AudioRendererRequest::EnableMinLeadTimeEvents { enabled, control_handle } = self {
10196            Some((enabled, control_handle))
10197        } else {
10198            None
10199        }
10200    }
10201
10202    #[allow(irrefutable_let_patterns)]
10203    pub fn into_get_min_lead_time(self) -> Option<(AudioRendererGetMinLeadTimeResponder)> {
10204        if let AudioRendererRequest::GetMinLeadTime { responder } = self {
10205            Some((responder))
10206        } else {
10207            None
10208        }
10209    }
10210
10211    #[allow(irrefutable_let_patterns)]
10212    pub fn into_play(self) -> Option<(i64, i64, AudioRendererPlayResponder)> {
10213        if let AudioRendererRequest::Play { reference_time, media_time, responder } = self {
10214            Some((reference_time, media_time, responder))
10215        } else {
10216            None
10217        }
10218    }
10219
10220    #[allow(irrefutable_let_patterns)]
10221    pub fn into_play_no_reply(self) -> Option<(i64, i64, AudioRendererControlHandle)> {
10222        if let AudioRendererRequest::PlayNoReply { reference_time, media_time, control_handle } =
10223            self
10224        {
10225            Some((reference_time, media_time, control_handle))
10226        } else {
10227            None
10228        }
10229    }
10230
10231    #[allow(irrefutable_let_patterns)]
10232    pub fn into_pause(self) -> Option<(AudioRendererPauseResponder)> {
10233        if let AudioRendererRequest::Pause { responder } = self { Some((responder)) } else { None }
10234    }
10235
10236    #[allow(irrefutable_let_patterns)]
10237    pub fn into_pause_no_reply(self) -> Option<(AudioRendererControlHandle)> {
10238        if let AudioRendererRequest::PauseNoReply { control_handle } = self {
10239            Some((control_handle))
10240        } else {
10241            None
10242        }
10243    }
10244
10245    /// Name of the method defined in FIDL
10246    pub fn method_name(&self) -> &'static str {
10247        match *self {
10248            AudioRendererRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
10249            AudioRendererRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
10250            AudioRendererRequest::SendPacket { .. } => "send_packet",
10251            AudioRendererRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
10252            AudioRendererRequest::EndOfStream { .. } => "end_of_stream",
10253            AudioRendererRequest::DiscardAllPackets { .. } => "discard_all_packets",
10254            AudioRendererRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
10255            AudioRendererRequest::BindGainControl { .. } => "bind_gain_control",
10256            AudioRendererRequest::SetPtsUnits { .. } => "set_pts_units",
10257            AudioRendererRequest::SetPtsContinuityThreshold { .. } => {
10258                "set_pts_continuity_threshold"
10259            }
10260            AudioRendererRequest::GetReferenceClock { .. } => "get_reference_clock",
10261            AudioRendererRequest::SetReferenceClock { .. } => "set_reference_clock",
10262            AudioRendererRequest::SetUsage { .. } => "set_usage",
10263            AudioRendererRequest::SetUsage2 { .. } => "set_usage2",
10264            AudioRendererRequest::SetPcmStreamType { .. } => "set_pcm_stream_type",
10265            AudioRendererRequest::EnableMinLeadTimeEvents { .. } => "enable_min_lead_time_events",
10266            AudioRendererRequest::GetMinLeadTime { .. } => "get_min_lead_time",
10267            AudioRendererRequest::Play { .. } => "play",
10268            AudioRendererRequest::PlayNoReply { .. } => "play_no_reply",
10269            AudioRendererRequest::Pause { .. } => "pause",
10270            AudioRendererRequest::PauseNoReply { .. } => "pause_no_reply",
10271            AudioRendererRequest::_UnknownMethod {
10272                method_type: fidl::MethodType::OneWay, ..
10273            } => "unknown one-way method",
10274            AudioRendererRequest::_UnknownMethod {
10275                method_type: fidl::MethodType::TwoWay, ..
10276            } => "unknown two-way method",
10277        }
10278    }
10279}
10280
10281#[derive(Debug, Clone)]
10282pub struct AudioRendererControlHandle {
10283    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10284}
10285
10286impl fidl::endpoints::ControlHandle for AudioRendererControlHandle {
10287    fn shutdown(&self) {
10288        self.inner.shutdown()
10289    }
10290
10291    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
10292        self.inner.shutdown_with_epitaph(status)
10293    }
10294
10295    fn is_closed(&self) -> bool {
10296        self.inner.channel().is_closed()
10297    }
10298    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
10299        self.inner.channel().on_closed()
10300    }
10301
10302    #[cfg(target_os = "fuchsia")]
10303    fn signal_peer(
10304        &self,
10305        clear_mask: zx::Signals,
10306        set_mask: zx::Signals,
10307    ) -> Result<(), zx_status::Status> {
10308        use fidl::Peered;
10309        self.inner.channel().signal_peer(clear_mask, set_mask)
10310    }
10311}
10312
10313impl AudioRendererControlHandle {
10314    pub fn send_on_min_lead_time_changed(
10315        &self,
10316        mut min_lead_time_nsec: i64,
10317    ) -> Result<(), fidl::Error> {
10318        self.inner.send::<AudioRendererOnMinLeadTimeChangedRequest>(
10319            (min_lead_time_nsec,),
10320            0,
10321            0x4feff7d278978c4e,
10322            fidl::encoding::DynamicFlags::empty(),
10323        )
10324    }
10325}
10326
10327#[must_use = "FIDL methods require a response to be sent"]
10328#[derive(Debug)]
10329pub struct AudioRendererSendPacketResponder {
10330    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10331    tx_id: u32,
10332}
10333
10334/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10335/// if the responder is dropped without sending a response, so that the client
10336/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10337impl std::ops::Drop for AudioRendererSendPacketResponder {
10338    fn drop(&mut self) {
10339        self.control_handle.shutdown();
10340        // Safety: drops once, never accessed again
10341        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10342    }
10343}
10344
10345impl fidl::endpoints::Responder for AudioRendererSendPacketResponder {
10346    type ControlHandle = AudioRendererControlHandle;
10347
10348    fn control_handle(&self) -> &AudioRendererControlHandle {
10349        &self.control_handle
10350    }
10351
10352    fn drop_without_shutdown(mut self) {
10353        // Safety: drops once, never accessed again due to mem::forget
10354        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10355        // Prevent Drop from running (which would shut down the channel)
10356        std::mem::forget(self);
10357    }
10358}
10359
10360impl AudioRendererSendPacketResponder {
10361    /// Sends a response to the FIDL transaction.
10362    ///
10363    /// Sets the channel to shutdown if an error occurs.
10364    pub fn send(self) -> Result<(), fidl::Error> {
10365        let _result = self.send_raw();
10366        if _result.is_err() {
10367            self.control_handle.shutdown();
10368        }
10369        self.drop_without_shutdown();
10370        _result
10371    }
10372
10373    /// Similar to "send" but does not shutdown the channel if an error occurs.
10374    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10375        let _result = self.send_raw();
10376        self.drop_without_shutdown();
10377        _result
10378    }
10379
10380    fn send_raw(&self) -> Result<(), fidl::Error> {
10381        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10382            (),
10383            self.tx_id,
10384            0x67cddd607442775f,
10385            fidl::encoding::DynamicFlags::empty(),
10386        )
10387    }
10388}
10389
10390#[must_use = "FIDL methods require a response to be sent"]
10391#[derive(Debug)]
10392pub struct AudioRendererDiscardAllPacketsResponder {
10393    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10394    tx_id: u32,
10395}
10396
10397/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10398/// if the responder is dropped without sending a response, so that the client
10399/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10400impl std::ops::Drop for AudioRendererDiscardAllPacketsResponder {
10401    fn drop(&mut self) {
10402        self.control_handle.shutdown();
10403        // Safety: drops once, never accessed again
10404        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10405    }
10406}
10407
10408impl fidl::endpoints::Responder for AudioRendererDiscardAllPacketsResponder {
10409    type ControlHandle = AudioRendererControlHandle;
10410
10411    fn control_handle(&self) -> &AudioRendererControlHandle {
10412        &self.control_handle
10413    }
10414
10415    fn drop_without_shutdown(mut self) {
10416        // Safety: drops once, never accessed again due to mem::forget
10417        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10418        // Prevent Drop from running (which would shut down the channel)
10419        std::mem::forget(self);
10420    }
10421}
10422
10423impl AudioRendererDiscardAllPacketsResponder {
10424    /// Sends a response to the FIDL transaction.
10425    ///
10426    /// Sets the channel to shutdown if an error occurs.
10427    pub fn send(self) -> Result<(), fidl::Error> {
10428        let _result = self.send_raw();
10429        if _result.is_err() {
10430            self.control_handle.shutdown();
10431        }
10432        self.drop_without_shutdown();
10433        _result
10434    }
10435
10436    /// Similar to "send" but does not shutdown the channel if an error occurs.
10437    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10438        let _result = self.send_raw();
10439        self.drop_without_shutdown();
10440        _result
10441    }
10442
10443    fn send_raw(&self) -> Result<(), fidl::Error> {
10444        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10445            (),
10446            self.tx_id,
10447            0x6f4dad7af2917665,
10448            fidl::encoding::DynamicFlags::empty(),
10449        )
10450    }
10451}
10452
10453#[must_use = "FIDL methods require a response to be sent"]
10454#[derive(Debug)]
10455pub struct AudioRendererGetReferenceClockResponder {
10456    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10457    tx_id: u32,
10458}
10459
10460/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10461/// if the responder is dropped without sending a response, so that the client
10462/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10463impl std::ops::Drop for AudioRendererGetReferenceClockResponder {
10464    fn drop(&mut self) {
10465        self.control_handle.shutdown();
10466        // Safety: drops once, never accessed again
10467        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10468    }
10469}
10470
10471impl fidl::endpoints::Responder for AudioRendererGetReferenceClockResponder {
10472    type ControlHandle = AudioRendererControlHandle;
10473
10474    fn control_handle(&self) -> &AudioRendererControlHandle {
10475        &self.control_handle
10476    }
10477
10478    fn drop_without_shutdown(mut self) {
10479        // Safety: drops once, never accessed again due to mem::forget
10480        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10481        // Prevent Drop from running (which would shut down the channel)
10482        std::mem::forget(self);
10483    }
10484}
10485
10486impl AudioRendererGetReferenceClockResponder {
10487    /// Sends a response to the FIDL transaction.
10488    ///
10489    /// Sets the channel to shutdown if an error occurs.
10490    pub fn send(self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
10491        let _result = self.send_raw(reference_clock);
10492        if _result.is_err() {
10493            self.control_handle.shutdown();
10494        }
10495        self.drop_without_shutdown();
10496        _result
10497    }
10498
10499    /// Similar to "send" but does not shutdown the channel if an error occurs.
10500    pub fn send_no_shutdown_on_err(
10501        self,
10502        mut reference_clock: fidl::Clock,
10503    ) -> Result<(), fidl::Error> {
10504        let _result = self.send_raw(reference_clock);
10505        self.drop_without_shutdown();
10506        _result
10507    }
10508
10509    fn send_raw(&self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
10510        self.control_handle.inner.send::<AudioRendererGetReferenceClockResponse>(
10511            (reference_clock,),
10512            self.tx_id,
10513            0x2f7a7f011a172f7e,
10514            fidl::encoding::DynamicFlags::empty(),
10515        )
10516    }
10517}
10518
10519#[must_use = "FIDL methods require a response to be sent"]
10520#[derive(Debug)]
10521pub struct AudioRendererGetMinLeadTimeResponder {
10522    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10523    tx_id: u32,
10524}
10525
10526/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10527/// if the responder is dropped without sending a response, so that the client
10528/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10529impl std::ops::Drop for AudioRendererGetMinLeadTimeResponder {
10530    fn drop(&mut self) {
10531        self.control_handle.shutdown();
10532        // Safety: drops once, never accessed again
10533        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10534    }
10535}
10536
10537impl fidl::endpoints::Responder for AudioRendererGetMinLeadTimeResponder {
10538    type ControlHandle = AudioRendererControlHandle;
10539
10540    fn control_handle(&self) -> &AudioRendererControlHandle {
10541        &self.control_handle
10542    }
10543
10544    fn drop_without_shutdown(mut self) {
10545        // Safety: drops once, never accessed again due to mem::forget
10546        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10547        // Prevent Drop from running (which would shut down the channel)
10548        std::mem::forget(self);
10549    }
10550}
10551
10552impl AudioRendererGetMinLeadTimeResponder {
10553    /// Sends a response to the FIDL transaction.
10554    ///
10555    /// Sets the channel to shutdown if an error occurs.
10556    pub fn send(self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
10557        let _result = self.send_raw(min_lead_time_nsec);
10558        if _result.is_err() {
10559            self.control_handle.shutdown();
10560        }
10561        self.drop_without_shutdown();
10562        _result
10563    }
10564
10565    /// Similar to "send" but does not shutdown the channel if an error occurs.
10566    pub fn send_no_shutdown_on_err(self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
10567        let _result = self.send_raw(min_lead_time_nsec);
10568        self.drop_without_shutdown();
10569        _result
10570    }
10571
10572    fn send_raw(&self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
10573        self.control_handle.inner.send::<AudioRendererGetMinLeadTimeResponse>(
10574            (min_lead_time_nsec,),
10575            self.tx_id,
10576            0x1cf3c3ecd8fec26b,
10577            fidl::encoding::DynamicFlags::empty(),
10578        )
10579    }
10580}
10581
10582#[must_use = "FIDL methods require a response to be sent"]
10583#[derive(Debug)]
10584pub struct AudioRendererPlayResponder {
10585    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10586    tx_id: u32,
10587}
10588
10589/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10590/// if the responder is dropped without sending a response, so that the client
10591/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10592impl std::ops::Drop for AudioRendererPlayResponder {
10593    fn drop(&mut self) {
10594        self.control_handle.shutdown();
10595        // Safety: drops once, never accessed again
10596        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10597    }
10598}
10599
10600impl fidl::endpoints::Responder for AudioRendererPlayResponder {
10601    type ControlHandle = AudioRendererControlHandle;
10602
10603    fn control_handle(&self) -> &AudioRendererControlHandle {
10604        &self.control_handle
10605    }
10606
10607    fn drop_without_shutdown(mut self) {
10608        // Safety: drops once, never accessed again due to mem::forget
10609        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10610        // Prevent Drop from running (which would shut down the channel)
10611        std::mem::forget(self);
10612    }
10613}
10614
10615impl AudioRendererPlayResponder {
10616    /// Sends a response to the FIDL transaction.
10617    ///
10618    /// Sets the channel to shutdown if an error occurs.
10619    pub fn send(self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10620        let _result = self.send_raw(reference_time, media_time);
10621        if _result.is_err() {
10622            self.control_handle.shutdown();
10623        }
10624        self.drop_without_shutdown();
10625        _result
10626    }
10627
10628    /// Similar to "send" but does not shutdown the channel if an error occurs.
10629    pub fn send_no_shutdown_on_err(
10630        self,
10631        mut reference_time: i64,
10632        mut media_time: i64,
10633    ) -> Result<(), fidl::Error> {
10634        let _result = self.send_raw(reference_time, media_time);
10635        self.drop_without_shutdown();
10636        _result
10637    }
10638
10639    fn send_raw(&self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10640        self.control_handle.inner.send::<AudioRendererPlayResponse>(
10641            (reference_time, media_time),
10642            self.tx_id,
10643            0x3c0162db084f74a3,
10644            fidl::encoding::DynamicFlags::empty(),
10645        )
10646    }
10647}
10648
10649#[must_use = "FIDL methods require a response to be sent"]
10650#[derive(Debug)]
10651pub struct AudioRendererPauseResponder {
10652    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10653    tx_id: u32,
10654}
10655
10656/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10657/// if the responder is dropped without sending a response, so that the client
10658/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10659impl std::ops::Drop for AudioRendererPauseResponder {
10660    fn drop(&mut self) {
10661        self.control_handle.shutdown();
10662        // Safety: drops once, never accessed again
10663        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10664    }
10665}
10666
10667impl fidl::endpoints::Responder for AudioRendererPauseResponder {
10668    type ControlHandle = AudioRendererControlHandle;
10669
10670    fn control_handle(&self) -> &AudioRendererControlHandle {
10671        &self.control_handle
10672    }
10673
10674    fn drop_without_shutdown(mut self) {
10675        // Safety: drops once, never accessed again due to mem::forget
10676        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10677        // Prevent Drop from running (which would shut down the channel)
10678        std::mem::forget(self);
10679    }
10680}
10681
10682impl AudioRendererPauseResponder {
10683    /// Sends a response to the FIDL transaction.
10684    ///
10685    /// Sets the channel to shutdown if an error occurs.
10686    pub fn send(self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10687        let _result = self.send_raw(reference_time, media_time);
10688        if _result.is_err() {
10689            self.control_handle.shutdown();
10690        }
10691        self.drop_without_shutdown();
10692        _result
10693    }
10694
10695    /// Similar to "send" but does not shutdown the channel if an error occurs.
10696    pub fn send_no_shutdown_on_err(
10697        self,
10698        mut reference_time: i64,
10699        mut media_time: i64,
10700    ) -> Result<(), fidl::Error> {
10701        let _result = self.send_raw(reference_time, media_time);
10702        self.drop_without_shutdown();
10703        _result
10704    }
10705
10706    fn send_raw(&self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10707        self.control_handle.inner.send::<AudioRendererPauseResponse>(
10708            (reference_time, media_time),
10709            self.tx_id,
10710            0x41d557588d93d153,
10711            fidl::encoding::DynamicFlags::empty(),
10712        )
10713    }
10714}
10715
10716#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
10717pub struct ProfileProviderMarker;
10718
10719impl fidl::endpoints::ProtocolMarker for ProfileProviderMarker {
10720    type Proxy = ProfileProviderProxy;
10721    type RequestStream = ProfileProviderRequestStream;
10722    #[cfg(target_os = "fuchsia")]
10723    type SynchronousProxy = ProfileProviderSynchronousProxy;
10724
10725    const DEBUG_NAME: &'static str = "fuchsia.media.ProfileProvider";
10726}
10727impl fidl::endpoints::DiscoverableProtocolMarker for ProfileProviderMarker {}
10728
10729pub trait ProfileProviderProxyInterface: Send + Sync {
10730    type RegisterHandlerWithCapacityResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>>
10731        + Send;
10732    fn r#register_handler_with_capacity(
10733        &self,
10734        thread_handle: fidl::Thread,
10735        name: &str,
10736        period: i64,
10737        capacity: f32,
10738    ) -> Self::RegisterHandlerWithCapacityResponseFut;
10739    type UnregisterHandlerResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
10740    fn r#unregister_handler(
10741        &self,
10742        thread_handle: fidl::Thread,
10743        name: &str,
10744    ) -> Self::UnregisterHandlerResponseFut;
10745    type RegisterMemoryRangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
10746        + Send;
10747    fn r#register_memory_range(
10748        &self,
10749        vmar_handle: fidl::Vmar,
10750        name: &str,
10751    ) -> Self::RegisterMemoryRangeResponseFut;
10752    type UnregisterMemoryRangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
10753        + Send;
10754    fn r#unregister_memory_range(
10755        &self,
10756        vmar_handle: fidl::Vmar,
10757    ) -> Self::UnregisterMemoryRangeResponseFut;
10758}
10759#[derive(Debug)]
10760#[cfg(target_os = "fuchsia")]
10761pub struct ProfileProviderSynchronousProxy {
10762    client: fidl::client::sync::Client,
10763}
10764
10765#[cfg(target_os = "fuchsia")]
10766impl fidl::endpoints::SynchronousProxy for ProfileProviderSynchronousProxy {
10767    type Proxy = ProfileProviderProxy;
10768    type Protocol = ProfileProviderMarker;
10769
10770    fn from_channel(inner: fidl::Channel) -> Self {
10771        Self::new(inner)
10772    }
10773
10774    fn into_channel(self) -> fidl::Channel {
10775        self.client.into_channel()
10776    }
10777
10778    fn as_channel(&self) -> &fidl::Channel {
10779        self.client.as_channel()
10780    }
10781}
10782
10783#[cfg(target_os = "fuchsia")]
10784impl ProfileProviderSynchronousProxy {
10785    pub fn new(channel: fidl::Channel) -> Self {
10786        Self { client: fidl::client::sync::Client::new(channel) }
10787    }
10788
10789    pub fn into_channel(self) -> fidl::Channel {
10790        self.client.into_channel()
10791    }
10792
10793    /// Waits until an event arrives and returns it. It is safe for other
10794    /// threads to make concurrent requests while waiting for an event.
10795    pub fn wait_for_event(
10796        &self,
10797        deadline: zx::MonotonicInstant,
10798    ) -> Result<ProfileProviderEvent, fidl::Error> {
10799        ProfileProviderEvent::decode(self.client.wait_for_event::<ProfileProviderMarker>(deadline)?)
10800    }
10801
10802    /// Register a thread as a media thread. This notifies the media subsystem that this thread
10803    /// should have an elevated scheduling profile applied to it in order to meet audio or video
10804    /// deadlines.
10805    ///
10806    /// `name` is the name of a system scheduling role to apply to the thread given by
10807    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
10808    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
10809    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
10810    /// the scheduling interval the thread needs to be running to achieve good performance or to
10811    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
10812    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
10813    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
10814    /// be rejected or result in scaling back the performance of other threads to fit resource
10815    /// limits.
10816    ///
10817    /// Capacity, max runtime, and period have the following relationship:
10818    ///
10819    ///   capacity = max runtime / period
10820    ///
10821    /// Where:
10822    ///
10823    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
10824    ///
10825    /// For heterogeneous systems, the capacity should be planned / measured against the highest
10826    /// performance processor(s) in the system. The system will automatically adjust the effective
10827    /// capacity to account for slower processors and operating points and will avoid processors and
10828    /// operating points that are too slow to meet the requested scheduling parameters (provided
10829    /// they are reasonable).
10830    ///
10831    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
10832    /// may be zero to indicate not applicable.
10833    pub fn r#register_handler_with_capacity(
10834        &self,
10835        mut thread_handle: fidl::Thread,
10836        mut name: &str,
10837        mut period: i64,
10838        mut capacity: f32,
10839        ___deadline: zx::MonotonicInstant,
10840    ) -> Result<(i64, i64), fidl::Error> {
10841        let _response = self.client.send_query::<
10842            ProfileProviderRegisterHandlerWithCapacityRequest,
10843            ProfileProviderRegisterHandlerWithCapacityResponse,
10844            ProfileProviderMarker,
10845        >(
10846            (thread_handle, name, period, capacity,),
10847            0x60459ecef7458176,
10848            fidl::encoding::DynamicFlags::empty(),
10849            ___deadline,
10850        )?;
10851        Ok((_response.period, _response.capacity))
10852    }
10853
10854    /// Reset a thread's scheduling profile to the default.
10855    pub fn r#unregister_handler(
10856        &self,
10857        mut thread_handle: fidl::Thread,
10858        mut name: &str,
10859        ___deadline: zx::MonotonicInstant,
10860    ) -> Result<(), fidl::Error> {
10861        let _response = self.client.send_query::<
10862            ProfileProviderUnregisterHandlerRequest,
10863            fidl::encoding::EmptyPayload,
10864            ProfileProviderMarker,
10865        >(
10866            (thread_handle, name,),
10867            0x724d9d5fd8ef544c,
10868            fidl::encoding::DynamicFlags::empty(),
10869            ___deadline,
10870        )?;
10871        Ok(_response)
10872    }
10873
10874    /// Register a memory range as being used for media processing. This notifies the media
10875    /// subsystem that this memory should have an elevated memory profile applied to it in order to
10876    /// meet audio or video deadlines.
10877    ///
10878    /// `name` is the name of a system memory role to apply to the memory given by
10879    /// `vmar_handle` -- different products may customize the underlying memory strategy based
10880    /// on the requested role.
10881    pub fn r#register_memory_range(
10882        &self,
10883        mut vmar_handle: fidl::Vmar,
10884        mut name: &str,
10885        ___deadline: zx::MonotonicInstant,
10886    ) -> Result<(), fidl::Error> {
10887        let _response = self.client.send_query::<
10888            ProfileProviderRegisterMemoryRangeRequest,
10889            fidl::encoding::EmptyPayload,
10890            ProfileProviderMarker,
10891        >(
10892            (vmar_handle, name,),
10893            0x2f509d3523e9562d,
10894            fidl::encoding::DynamicFlags::empty(),
10895            ___deadline,
10896        )?;
10897        Ok(_response)
10898    }
10899
10900    /// Reset a memory range's memory profile.
10901    pub fn r#unregister_memory_range(
10902        &self,
10903        mut vmar_handle: fidl::Vmar,
10904        ___deadline: zx::MonotonicInstant,
10905    ) -> Result<(), fidl::Error> {
10906        let _response = self.client.send_query::<
10907            ProfileProviderUnregisterMemoryRangeRequest,
10908            fidl::encoding::EmptyPayload,
10909            ProfileProviderMarker,
10910        >(
10911            (vmar_handle,),
10912            0x2dc313d6aa81ad27,
10913            fidl::encoding::DynamicFlags::empty(),
10914            ___deadline,
10915        )?;
10916        Ok(_response)
10917    }
10918}
10919
10920#[cfg(target_os = "fuchsia")]
10921impl From<ProfileProviderSynchronousProxy> for zx::NullableHandle {
10922    fn from(value: ProfileProviderSynchronousProxy) -> Self {
10923        value.into_channel().into()
10924    }
10925}
10926
10927#[cfg(target_os = "fuchsia")]
10928impl From<fidl::Channel> for ProfileProviderSynchronousProxy {
10929    fn from(value: fidl::Channel) -> Self {
10930        Self::new(value)
10931    }
10932}
10933
10934#[cfg(target_os = "fuchsia")]
10935impl fidl::endpoints::FromClient for ProfileProviderSynchronousProxy {
10936    type Protocol = ProfileProviderMarker;
10937
10938    fn from_client(value: fidl::endpoints::ClientEnd<ProfileProviderMarker>) -> Self {
10939        Self::new(value.into_channel())
10940    }
10941}
10942
10943#[derive(Debug, Clone)]
10944pub struct ProfileProviderProxy {
10945    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
10946}
10947
10948impl fidl::endpoints::Proxy for ProfileProviderProxy {
10949    type Protocol = ProfileProviderMarker;
10950
10951    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
10952        Self::new(inner)
10953    }
10954
10955    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
10956        self.client.into_channel().map_err(|client| Self { client })
10957    }
10958
10959    fn as_channel(&self) -> &::fidl::AsyncChannel {
10960        self.client.as_channel()
10961    }
10962}
10963
10964impl ProfileProviderProxy {
10965    /// Create a new Proxy for fuchsia.media/ProfileProvider.
10966    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
10967        let protocol_name = <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10968        Self { client: fidl::client::Client::new(channel, protocol_name) }
10969    }
10970
10971    /// Get a Stream of events from the remote end of the protocol.
10972    ///
10973    /// # Panics
10974    ///
10975    /// Panics if the event stream was already taken.
10976    pub fn take_event_stream(&self) -> ProfileProviderEventStream {
10977        ProfileProviderEventStream { event_receiver: self.client.take_event_receiver() }
10978    }
10979
10980    /// Register a thread as a media thread. This notifies the media subsystem that this thread
10981    /// should have an elevated scheduling profile applied to it in order to meet audio or video
10982    /// deadlines.
10983    ///
10984    /// `name` is the name of a system scheduling role to apply to the thread given by
10985    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
10986    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
10987    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
10988    /// the scheduling interval the thread needs to be running to achieve good performance or to
10989    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
10990    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
10991    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
10992    /// be rejected or result in scaling back the performance of other threads to fit resource
10993    /// limits.
10994    ///
10995    /// Capacity, max runtime, and period have the following relationship:
10996    ///
10997    ///   capacity = max runtime / period
10998    ///
10999    /// Where:
11000    ///
11001    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
11002    ///
11003    /// For heterogeneous systems, the capacity should be planned / measured against the highest
11004    /// performance processor(s) in the system. The system will automatically adjust the effective
11005    /// capacity to account for slower processors and operating points and will avoid processors and
11006    /// operating points that are too slow to meet the requested scheduling parameters (provided
11007    /// they are reasonable).
11008    ///
11009    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
11010    /// may be zero to indicate not applicable.
11011    pub fn r#register_handler_with_capacity(
11012        &self,
11013        mut thread_handle: fidl::Thread,
11014        mut name: &str,
11015        mut period: i64,
11016        mut capacity: f32,
11017    ) -> fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>
11018    {
11019        ProfileProviderProxyInterface::r#register_handler_with_capacity(
11020            self,
11021            thread_handle,
11022            name,
11023            period,
11024            capacity,
11025        )
11026    }
11027
11028    /// Reset a thread's scheduling profile to the default.
11029    pub fn r#unregister_handler(
11030        &self,
11031        mut thread_handle: fidl::Thread,
11032        mut name: &str,
11033    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
11034        ProfileProviderProxyInterface::r#unregister_handler(self, thread_handle, name)
11035    }
11036
11037    /// Register a memory range as being used for media processing. This notifies the media
11038    /// subsystem that this memory should have an elevated memory profile applied to it in order to
11039    /// meet audio or video deadlines.
11040    ///
11041    /// `name` is the name of a system memory role to apply to the memory given by
11042    /// `vmar_handle` -- different products may customize the underlying memory strategy based
11043    /// on the requested role.
11044    pub fn r#register_memory_range(
11045        &self,
11046        mut vmar_handle: fidl::Vmar,
11047        mut name: &str,
11048    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
11049        ProfileProviderProxyInterface::r#register_memory_range(self, vmar_handle, name)
11050    }
11051
11052    /// Reset a memory range's memory profile.
11053    pub fn r#unregister_memory_range(
11054        &self,
11055        mut vmar_handle: fidl::Vmar,
11056    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
11057        ProfileProviderProxyInterface::r#unregister_memory_range(self, vmar_handle)
11058    }
11059}
11060
11061impl ProfileProviderProxyInterface for ProfileProviderProxy {
11062    type RegisterHandlerWithCapacityResponseFut =
11063        fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>;
11064    fn r#register_handler_with_capacity(
11065        &self,
11066        mut thread_handle: fidl::Thread,
11067        mut name: &str,
11068        mut period: i64,
11069        mut capacity: f32,
11070    ) -> Self::RegisterHandlerWithCapacityResponseFut {
11071        fn _decode(
11072            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11073        ) -> Result<(i64, i64), fidl::Error> {
11074            let _response = fidl::client::decode_transaction_body::<
11075                ProfileProviderRegisterHandlerWithCapacityResponse,
11076                fidl::encoding::DefaultFuchsiaResourceDialect,
11077                0x60459ecef7458176,
11078            >(_buf?)?;
11079            Ok((_response.period, _response.capacity))
11080        }
11081        self.client
11082            .send_query_and_decode::<ProfileProviderRegisterHandlerWithCapacityRequest, (i64, i64)>(
11083                (thread_handle, name, period, capacity),
11084                0x60459ecef7458176,
11085                fidl::encoding::DynamicFlags::empty(),
11086                _decode,
11087            )
11088    }
11089
11090    type UnregisterHandlerResponseFut =
11091        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
11092    fn r#unregister_handler(
11093        &self,
11094        mut thread_handle: fidl::Thread,
11095        mut name: &str,
11096    ) -> Self::UnregisterHandlerResponseFut {
11097        fn _decode(
11098            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11099        ) -> Result<(), fidl::Error> {
11100            let _response = fidl::client::decode_transaction_body::<
11101                fidl::encoding::EmptyPayload,
11102                fidl::encoding::DefaultFuchsiaResourceDialect,
11103                0x724d9d5fd8ef544c,
11104            >(_buf?)?;
11105            Ok(_response)
11106        }
11107        self.client.send_query_and_decode::<ProfileProviderUnregisterHandlerRequest, ()>(
11108            (thread_handle, name),
11109            0x724d9d5fd8ef544c,
11110            fidl::encoding::DynamicFlags::empty(),
11111            _decode,
11112        )
11113    }
11114
11115    type RegisterMemoryRangeResponseFut =
11116        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
11117    fn r#register_memory_range(
11118        &self,
11119        mut vmar_handle: fidl::Vmar,
11120        mut name: &str,
11121    ) -> Self::RegisterMemoryRangeResponseFut {
11122        fn _decode(
11123            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11124        ) -> Result<(), fidl::Error> {
11125            let _response = fidl::client::decode_transaction_body::<
11126                fidl::encoding::EmptyPayload,
11127                fidl::encoding::DefaultFuchsiaResourceDialect,
11128                0x2f509d3523e9562d,
11129            >(_buf?)?;
11130            Ok(_response)
11131        }
11132        self.client.send_query_and_decode::<ProfileProviderRegisterMemoryRangeRequest, ()>(
11133            (vmar_handle, name),
11134            0x2f509d3523e9562d,
11135            fidl::encoding::DynamicFlags::empty(),
11136            _decode,
11137        )
11138    }
11139
11140    type UnregisterMemoryRangeResponseFut =
11141        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
11142    fn r#unregister_memory_range(
11143        &self,
11144        mut vmar_handle: fidl::Vmar,
11145    ) -> Self::UnregisterMemoryRangeResponseFut {
11146        fn _decode(
11147            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11148        ) -> Result<(), fidl::Error> {
11149            let _response = fidl::client::decode_transaction_body::<
11150                fidl::encoding::EmptyPayload,
11151                fidl::encoding::DefaultFuchsiaResourceDialect,
11152                0x2dc313d6aa81ad27,
11153            >(_buf?)?;
11154            Ok(_response)
11155        }
11156        self.client.send_query_and_decode::<ProfileProviderUnregisterMemoryRangeRequest, ()>(
11157            (vmar_handle,),
11158            0x2dc313d6aa81ad27,
11159            fidl::encoding::DynamicFlags::empty(),
11160            _decode,
11161        )
11162    }
11163}
11164
11165pub struct ProfileProviderEventStream {
11166    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
11167}
11168
11169impl std::marker::Unpin for ProfileProviderEventStream {}
11170
11171impl futures::stream::FusedStream for ProfileProviderEventStream {
11172    fn is_terminated(&self) -> bool {
11173        self.event_receiver.is_terminated()
11174    }
11175}
11176
11177impl futures::Stream for ProfileProviderEventStream {
11178    type Item = Result<ProfileProviderEvent, fidl::Error>;
11179
11180    fn poll_next(
11181        mut self: std::pin::Pin<&mut Self>,
11182        cx: &mut std::task::Context<'_>,
11183    ) -> std::task::Poll<Option<Self::Item>> {
11184        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
11185            &mut self.event_receiver,
11186            cx
11187        )?) {
11188            Some(buf) => std::task::Poll::Ready(Some(ProfileProviderEvent::decode(buf))),
11189            None => std::task::Poll::Ready(None),
11190        }
11191    }
11192}
11193
11194#[derive(Debug)]
11195pub enum ProfileProviderEvent {}
11196
11197impl ProfileProviderEvent {
11198    /// Decodes a message buffer as a [`ProfileProviderEvent`].
11199    fn decode(
11200        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
11201    ) -> Result<ProfileProviderEvent, fidl::Error> {
11202        let (bytes, _handles) = buf.split_mut();
11203        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11204        debug_assert_eq!(tx_header.tx_id, 0);
11205        match tx_header.ordinal {
11206            _ => Err(fidl::Error::UnknownOrdinal {
11207                ordinal: tx_header.ordinal,
11208                protocol_name:
11209                    <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11210            }),
11211        }
11212    }
11213}
11214
11215/// A Stream of incoming requests for fuchsia.media/ProfileProvider.
11216pub struct ProfileProviderRequestStream {
11217    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11218    is_terminated: bool,
11219}
11220
11221impl std::marker::Unpin for ProfileProviderRequestStream {}
11222
11223impl futures::stream::FusedStream for ProfileProviderRequestStream {
11224    fn is_terminated(&self) -> bool {
11225        self.is_terminated
11226    }
11227}
11228
11229impl fidl::endpoints::RequestStream for ProfileProviderRequestStream {
11230    type Protocol = ProfileProviderMarker;
11231    type ControlHandle = ProfileProviderControlHandle;
11232
11233    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
11234        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
11235    }
11236
11237    fn control_handle(&self) -> Self::ControlHandle {
11238        ProfileProviderControlHandle { inner: self.inner.clone() }
11239    }
11240
11241    fn into_inner(
11242        self,
11243    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
11244    {
11245        (self.inner, self.is_terminated)
11246    }
11247
11248    fn from_inner(
11249        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11250        is_terminated: bool,
11251    ) -> Self {
11252        Self { inner, is_terminated }
11253    }
11254}
11255
11256impl futures::Stream for ProfileProviderRequestStream {
11257    type Item = Result<ProfileProviderRequest, fidl::Error>;
11258
11259    fn poll_next(
11260        mut self: std::pin::Pin<&mut Self>,
11261        cx: &mut std::task::Context<'_>,
11262    ) -> std::task::Poll<Option<Self::Item>> {
11263        let this = &mut *self;
11264        if this.inner.check_shutdown(cx) {
11265            this.is_terminated = true;
11266            return std::task::Poll::Ready(None);
11267        }
11268        if this.is_terminated {
11269            panic!("polled ProfileProviderRequestStream after completion");
11270        }
11271        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
11272            |bytes, handles| {
11273                match this.inner.channel().read_etc(cx, bytes, handles) {
11274                    std::task::Poll::Ready(Ok(())) => {}
11275                    std::task::Poll::Pending => return std::task::Poll::Pending,
11276                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
11277                        this.is_terminated = true;
11278                        return std::task::Poll::Ready(None);
11279                    }
11280                    std::task::Poll::Ready(Err(e)) => {
11281                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
11282                            e.into(),
11283                        ))));
11284                    }
11285                }
11286
11287                // A message has been received from the channel
11288                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11289
11290                std::task::Poll::Ready(Some(match header.ordinal {
11291                    0x60459ecef7458176 => {
11292                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11293                        let mut req = fidl::new_empty!(
11294                            ProfileProviderRegisterHandlerWithCapacityRequest,
11295                            fidl::encoding::DefaultFuchsiaResourceDialect
11296                        );
11297                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderRegisterHandlerWithCapacityRequest>(&header, _body_bytes, handles, &mut req)?;
11298                        let control_handle =
11299                            ProfileProviderControlHandle { inner: this.inner.clone() };
11300                        Ok(ProfileProviderRequest::RegisterHandlerWithCapacity {
11301                            thread_handle: req.thread_handle,
11302                            name: req.name,
11303                            period: req.period,
11304                            capacity: req.capacity,
11305
11306                            responder: ProfileProviderRegisterHandlerWithCapacityResponder {
11307                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11308                                tx_id: header.tx_id,
11309                            },
11310                        })
11311                    }
11312                    0x724d9d5fd8ef544c => {
11313                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11314                        let mut req = fidl::new_empty!(
11315                            ProfileProviderUnregisterHandlerRequest,
11316                            fidl::encoding::DefaultFuchsiaResourceDialect
11317                        );
11318                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderUnregisterHandlerRequest>(&header, _body_bytes, handles, &mut req)?;
11319                        let control_handle =
11320                            ProfileProviderControlHandle { inner: this.inner.clone() };
11321                        Ok(ProfileProviderRequest::UnregisterHandler {
11322                            thread_handle: req.thread_handle,
11323                            name: req.name,
11324
11325                            responder: ProfileProviderUnregisterHandlerResponder {
11326                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11327                                tx_id: header.tx_id,
11328                            },
11329                        })
11330                    }
11331                    0x2f509d3523e9562d => {
11332                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11333                        let mut req = fidl::new_empty!(
11334                            ProfileProviderRegisterMemoryRangeRequest,
11335                            fidl::encoding::DefaultFuchsiaResourceDialect
11336                        );
11337                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderRegisterMemoryRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11338                        let control_handle =
11339                            ProfileProviderControlHandle { inner: this.inner.clone() };
11340                        Ok(ProfileProviderRequest::RegisterMemoryRange {
11341                            vmar_handle: req.vmar_handle,
11342                            name: req.name,
11343
11344                            responder: ProfileProviderRegisterMemoryRangeResponder {
11345                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11346                                tx_id: header.tx_id,
11347                            },
11348                        })
11349                    }
11350                    0x2dc313d6aa81ad27 => {
11351                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11352                        let mut req = fidl::new_empty!(
11353                            ProfileProviderUnregisterMemoryRangeRequest,
11354                            fidl::encoding::DefaultFuchsiaResourceDialect
11355                        );
11356                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderUnregisterMemoryRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11357                        let control_handle =
11358                            ProfileProviderControlHandle { inner: this.inner.clone() };
11359                        Ok(ProfileProviderRequest::UnregisterMemoryRange {
11360                            vmar_handle: req.vmar_handle,
11361
11362                            responder: ProfileProviderUnregisterMemoryRangeResponder {
11363                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11364                                tx_id: header.tx_id,
11365                            },
11366                        })
11367                    }
11368                    _ => Err(fidl::Error::UnknownOrdinal {
11369                        ordinal: header.ordinal,
11370                        protocol_name:
11371                            <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11372                    }),
11373                }))
11374            },
11375        )
11376    }
11377}
11378
11379#[derive(Debug)]
11380pub enum ProfileProviderRequest {
11381    /// Register a thread as a media thread. This notifies the media subsystem that this thread
11382    /// should have an elevated scheduling profile applied to it in order to meet audio or video
11383    /// deadlines.
11384    ///
11385    /// `name` is the name of a system scheduling role to apply to the thread given by
11386    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
11387    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
11388    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
11389    /// the scheduling interval the thread needs to be running to achieve good performance or to
11390    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
11391    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
11392    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
11393    /// be rejected or result in scaling back the performance of other threads to fit resource
11394    /// limits.
11395    ///
11396    /// Capacity, max runtime, and period have the following relationship:
11397    ///
11398    ///   capacity = max runtime / period
11399    ///
11400    /// Where:
11401    ///
11402    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
11403    ///
11404    /// For heterogeneous systems, the capacity should be planned / measured against the highest
11405    /// performance processor(s) in the system. The system will automatically adjust the effective
11406    /// capacity to account for slower processors and operating points and will avoid processors and
11407    /// operating points that are too slow to meet the requested scheduling parameters (provided
11408    /// they are reasonable).
11409    ///
11410    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
11411    /// may be zero to indicate not applicable.
11412    RegisterHandlerWithCapacity {
11413        thread_handle: fidl::Thread,
11414        name: String,
11415        period: i64,
11416        capacity: f32,
11417        responder: ProfileProviderRegisterHandlerWithCapacityResponder,
11418    },
11419    /// Reset a thread's scheduling profile to the default.
11420    UnregisterHandler {
11421        thread_handle: fidl::Thread,
11422        name: String,
11423        responder: ProfileProviderUnregisterHandlerResponder,
11424    },
11425    /// Register a memory range as being used for media processing. This notifies the media
11426    /// subsystem that this memory should have an elevated memory profile applied to it in order to
11427    /// meet audio or video deadlines.
11428    ///
11429    /// `name` is the name of a system memory role to apply to the memory given by
11430    /// `vmar_handle` -- different products may customize the underlying memory strategy based
11431    /// on the requested role.
11432    RegisterMemoryRange {
11433        vmar_handle: fidl::Vmar,
11434        name: String,
11435        responder: ProfileProviderRegisterMemoryRangeResponder,
11436    },
11437    /// Reset a memory range's memory profile.
11438    UnregisterMemoryRange {
11439        vmar_handle: fidl::Vmar,
11440        responder: ProfileProviderUnregisterMemoryRangeResponder,
11441    },
11442}
11443
11444impl ProfileProviderRequest {
11445    #[allow(irrefutable_let_patterns)]
11446    pub fn into_register_handler_with_capacity(
11447        self,
11448    ) -> Option<(fidl::Thread, String, i64, f32, ProfileProviderRegisterHandlerWithCapacityResponder)>
11449    {
11450        if let ProfileProviderRequest::RegisterHandlerWithCapacity {
11451            thread_handle,
11452            name,
11453            period,
11454            capacity,
11455            responder,
11456        } = self
11457        {
11458            Some((thread_handle, name, period, capacity, responder))
11459        } else {
11460            None
11461        }
11462    }
11463
11464    #[allow(irrefutable_let_patterns)]
11465    pub fn into_unregister_handler(
11466        self,
11467    ) -> Option<(fidl::Thread, String, ProfileProviderUnregisterHandlerResponder)> {
11468        if let ProfileProviderRequest::UnregisterHandler { thread_handle, name, responder } = self {
11469            Some((thread_handle, name, responder))
11470        } else {
11471            None
11472        }
11473    }
11474
11475    #[allow(irrefutable_let_patterns)]
11476    pub fn into_register_memory_range(
11477        self,
11478    ) -> Option<(fidl::Vmar, String, ProfileProviderRegisterMemoryRangeResponder)> {
11479        if let ProfileProviderRequest::RegisterMemoryRange { vmar_handle, name, responder } = self {
11480            Some((vmar_handle, name, responder))
11481        } else {
11482            None
11483        }
11484    }
11485
11486    #[allow(irrefutable_let_patterns)]
11487    pub fn into_unregister_memory_range(
11488        self,
11489    ) -> Option<(fidl::Vmar, ProfileProviderUnregisterMemoryRangeResponder)> {
11490        if let ProfileProviderRequest::UnregisterMemoryRange { vmar_handle, responder } = self {
11491            Some((vmar_handle, responder))
11492        } else {
11493            None
11494        }
11495    }
11496
11497    /// Name of the method defined in FIDL
11498    pub fn method_name(&self) -> &'static str {
11499        match *self {
11500            ProfileProviderRequest::RegisterHandlerWithCapacity { .. } => {
11501                "register_handler_with_capacity"
11502            }
11503            ProfileProviderRequest::UnregisterHandler { .. } => "unregister_handler",
11504            ProfileProviderRequest::RegisterMemoryRange { .. } => "register_memory_range",
11505            ProfileProviderRequest::UnregisterMemoryRange { .. } => "unregister_memory_range",
11506        }
11507    }
11508}
11509
11510#[derive(Debug, Clone)]
11511pub struct ProfileProviderControlHandle {
11512    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11513}
11514
11515impl fidl::endpoints::ControlHandle for ProfileProviderControlHandle {
11516    fn shutdown(&self) {
11517        self.inner.shutdown()
11518    }
11519
11520    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
11521        self.inner.shutdown_with_epitaph(status)
11522    }
11523
11524    fn is_closed(&self) -> bool {
11525        self.inner.channel().is_closed()
11526    }
11527    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
11528        self.inner.channel().on_closed()
11529    }
11530
11531    #[cfg(target_os = "fuchsia")]
11532    fn signal_peer(
11533        &self,
11534        clear_mask: zx::Signals,
11535        set_mask: zx::Signals,
11536    ) -> Result<(), zx_status::Status> {
11537        use fidl::Peered;
11538        self.inner.channel().signal_peer(clear_mask, set_mask)
11539    }
11540}
11541
11542impl ProfileProviderControlHandle {}
11543
11544#[must_use = "FIDL methods require a response to be sent"]
11545#[derive(Debug)]
11546pub struct ProfileProviderRegisterHandlerWithCapacityResponder {
11547    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11548    tx_id: u32,
11549}
11550
11551/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11552/// if the responder is dropped without sending a response, so that the client
11553/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11554impl std::ops::Drop for ProfileProviderRegisterHandlerWithCapacityResponder {
11555    fn drop(&mut self) {
11556        self.control_handle.shutdown();
11557        // Safety: drops once, never accessed again
11558        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11559    }
11560}
11561
11562impl fidl::endpoints::Responder for ProfileProviderRegisterHandlerWithCapacityResponder {
11563    type ControlHandle = ProfileProviderControlHandle;
11564
11565    fn control_handle(&self) -> &ProfileProviderControlHandle {
11566        &self.control_handle
11567    }
11568
11569    fn drop_without_shutdown(mut self) {
11570        // Safety: drops once, never accessed again due to mem::forget
11571        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11572        // Prevent Drop from running (which would shut down the channel)
11573        std::mem::forget(self);
11574    }
11575}
11576
11577impl ProfileProviderRegisterHandlerWithCapacityResponder {
11578    /// Sends a response to the FIDL transaction.
11579    ///
11580    /// Sets the channel to shutdown if an error occurs.
11581    pub fn send(self, mut period: i64, mut capacity: i64) -> Result<(), fidl::Error> {
11582        let _result = self.send_raw(period, capacity);
11583        if _result.is_err() {
11584            self.control_handle.shutdown();
11585        }
11586        self.drop_without_shutdown();
11587        _result
11588    }
11589
11590    /// Similar to "send" but does not shutdown the channel if an error occurs.
11591    pub fn send_no_shutdown_on_err(
11592        self,
11593        mut period: i64,
11594        mut capacity: i64,
11595    ) -> Result<(), fidl::Error> {
11596        let _result = self.send_raw(period, capacity);
11597        self.drop_without_shutdown();
11598        _result
11599    }
11600
11601    fn send_raw(&self, mut period: i64, mut capacity: i64) -> Result<(), fidl::Error> {
11602        self.control_handle.inner.send::<ProfileProviderRegisterHandlerWithCapacityResponse>(
11603            (period, capacity),
11604            self.tx_id,
11605            0x60459ecef7458176,
11606            fidl::encoding::DynamicFlags::empty(),
11607        )
11608    }
11609}
11610
11611#[must_use = "FIDL methods require a response to be sent"]
11612#[derive(Debug)]
11613pub struct ProfileProviderUnregisterHandlerResponder {
11614    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11615    tx_id: u32,
11616}
11617
11618/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11619/// if the responder is dropped without sending a response, so that the client
11620/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11621impl std::ops::Drop for ProfileProviderUnregisterHandlerResponder {
11622    fn drop(&mut self) {
11623        self.control_handle.shutdown();
11624        // Safety: drops once, never accessed again
11625        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11626    }
11627}
11628
11629impl fidl::endpoints::Responder for ProfileProviderUnregisterHandlerResponder {
11630    type ControlHandle = ProfileProviderControlHandle;
11631
11632    fn control_handle(&self) -> &ProfileProviderControlHandle {
11633        &self.control_handle
11634    }
11635
11636    fn drop_without_shutdown(mut self) {
11637        // Safety: drops once, never accessed again due to mem::forget
11638        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11639        // Prevent Drop from running (which would shut down the channel)
11640        std::mem::forget(self);
11641    }
11642}
11643
11644impl ProfileProviderUnregisterHandlerResponder {
11645    /// Sends a response to the FIDL transaction.
11646    ///
11647    /// Sets the channel to shutdown if an error occurs.
11648    pub fn send(self) -> Result<(), fidl::Error> {
11649        let _result = self.send_raw();
11650        if _result.is_err() {
11651            self.control_handle.shutdown();
11652        }
11653        self.drop_without_shutdown();
11654        _result
11655    }
11656
11657    /// Similar to "send" but does not shutdown the channel if an error occurs.
11658    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11659        let _result = self.send_raw();
11660        self.drop_without_shutdown();
11661        _result
11662    }
11663
11664    fn send_raw(&self) -> Result<(), fidl::Error> {
11665        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11666            (),
11667            self.tx_id,
11668            0x724d9d5fd8ef544c,
11669            fidl::encoding::DynamicFlags::empty(),
11670        )
11671    }
11672}
11673
11674#[must_use = "FIDL methods require a response to be sent"]
11675#[derive(Debug)]
11676pub struct ProfileProviderRegisterMemoryRangeResponder {
11677    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11678    tx_id: u32,
11679}
11680
11681/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11682/// if the responder is dropped without sending a response, so that the client
11683/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11684impl std::ops::Drop for ProfileProviderRegisterMemoryRangeResponder {
11685    fn drop(&mut self) {
11686        self.control_handle.shutdown();
11687        // Safety: drops once, never accessed again
11688        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11689    }
11690}
11691
11692impl fidl::endpoints::Responder for ProfileProviderRegisterMemoryRangeResponder {
11693    type ControlHandle = ProfileProviderControlHandle;
11694
11695    fn control_handle(&self) -> &ProfileProviderControlHandle {
11696        &self.control_handle
11697    }
11698
11699    fn drop_without_shutdown(mut self) {
11700        // Safety: drops once, never accessed again due to mem::forget
11701        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11702        // Prevent Drop from running (which would shut down the channel)
11703        std::mem::forget(self);
11704    }
11705}
11706
11707impl ProfileProviderRegisterMemoryRangeResponder {
11708    /// Sends a response to the FIDL transaction.
11709    ///
11710    /// Sets the channel to shutdown if an error occurs.
11711    pub fn send(self) -> Result<(), fidl::Error> {
11712        let _result = self.send_raw();
11713        if _result.is_err() {
11714            self.control_handle.shutdown();
11715        }
11716        self.drop_without_shutdown();
11717        _result
11718    }
11719
11720    /// Similar to "send" but does not shutdown the channel if an error occurs.
11721    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11722        let _result = self.send_raw();
11723        self.drop_without_shutdown();
11724        _result
11725    }
11726
11727    fn send_raw(&self) -> Result<(), fidl::Error> {
11728        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11729            (),
11730            self.tx_id,
11731            0x2f509d3523e9562d,
11732            fidl::encoding::DynamicFlags::empty(),
11733        )
11734    }
11735}
11736
11737#[must_use = "FIDL methods require a response to be sent"]
11738#[derive(Debug)]
11739pub struct ProfileProviderUnregisterMemoryRangeResponder {
11740    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11741    tx_id: u32,
11742}
11743
11744/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11745/// if the responder is dropped without sending a response, so that the client
11746/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11747impl std::ops::Drop for ProfileProviderUnregisterMemoryRangeResponder {
11748    fn drop(&mut self) {
11749        self.control_handle.shutdown();
11750        // Safety: drops once, never accessed again
11751        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11752    }
11753}
11754
11755impl fidl::endpoints::Responder for ProfileProviderUnregisterMemoryRangeResponder {
11756    type ControlHandle = ProfileProviderControlHandle;
11757
11758    fn control_handle(&self) -> &ProfileProviderControlHandle {
11759        &self.control_handle
11760    }
11761
11762    fn drop_without_shutdown(mut self) {
11763        // Safety: drops once, never accessed again due to mem::forget
11764        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11765        // Prevent Drop from running (which would shut down the channel)
11766        std::mem::forget(self);
11767    }
11768}
11769
11770impl ProfileProviderUnregisterMemoryRangeResponder {
11771    /// Sends a response to the FIDL transaction.
11772    ///
11773    /// Sets the channel to shutdown if an error occurs.
11774    pub fn send(self) -> Result<(), fidl::Error> {
11775        let _result = self.send_raw();
11776        if _result.is_err() {
11777            self.control_handle.shutdown();
11778        }
11779        self.drop_without_shutdown();
11780        _result
11781    }
11782
11783    /// Similar to "send" but does not shutdown the channel if an error occurs.
11784    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11785        let _result = self.send_raw();
11786        self.drop_without_shutdown();
11787        _result
11788    }
11789
11790    fn send_raw(&self) -> Result<(), fidl::Error> {
11791        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11792            (),
11793            self.tx_id,
11794            0x2dc313d6aa81ad27,
11795            fidl::encoding::DynamicFlags::empty(),
11796        )
11797    }
11798}
11799
11800#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
11801pub struct SessionAudioConsumerFactoryMarker;
11802
11803impl fidl::endpoints::ProtocolMarker for SessionAudioConsumerFactoryMarker {
11804    type Proxy = SessionAudioConsumerFactoryProxy;
11805    type RequestStream = SessionAudioConsumerFactoryRequestStream;
11806    #[cfg(target_os = "fuchsia")]
11807    type SynchronousProxy = SessionAudioConsumerFactorySynchronousProxy;
11808
11809    const DEBUG_NAME: &'static str = "fuchsia.media.SessionAudioConsumerFactory";
11810}
11811impl fidl::endpoints::DiscoverableProtocolMarker for SessionAudioConsumerFactoryMarker {}
11812
11813pub trait SessionAudioConsumerFactoryProxyInterface: Send + Sync {
11814    fn r#create_audio_consumer(
11815        &self,
11816        session_id: u64,
11817        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
11818    ) -> Result<(), fidl::Error>;
11819}
11820#[derive(Debug)]
11821#[cfg(target_os = "fuchsia")]
11822pub struct SessionAudioConsumerFactorySynchronousProxy {
11823    client: fidl::client::sync::Client,
11824}
11825
11826#[cfg(target_os = "fuchsia")]
11827impl fidl::endpoints::SynchronousProxy for SessionAudioConsumerFactorySynchronousProxy {
11828    type Proxy = SessionAudioConsumerFactoryProxy;
11829    type Protocol = SessionAudioConsumerFactoryMarker;
11830
11831    fn from_channel(inner: fidl::Channel) -> Self {
11832        Self::new(inner)
11833    }
11834
11835    fn into_channel(self) -> fidl::Channel {
11836        self.client.into_channel()
11837    }
11838
11839    fn as_channel(&self) -> &fidl::Channel {
11840        self.client.as_channel()
11841    }
11842}
11843
11844#[cfg(target_os = "fuchsia")]
11845impl SessionAudioConsumerFactorySynchronousProxy {
11846    pub fn new(channel: fidl::Channel) -> Self {
11847        Self { client: fidl::client::sync::Client::new(channel) }
11848    }
11849
11850    pub fn into_channel(self) -> fidl::Channel {
11851        self.client.into_channel()
11852    }
11853
11854    /// Waits until an event arrives and returns it. It is safe for other
11855    /// threads to make concurrent requests while waiting for an event.
11856    pub fn wait_for_event(
11857        &self,
11858        deadline: zx::MonotonicInstant,
11859    ) -> Result<SessionAudioConsumerFactoryEvent, fidl::Error> {
11860        SessionAudioConsumerFactoryEvent::decode(
11861            self.client.wait_for_event::<SessionAudioConsumerFactoryMarker>(deadline)?,
11862        )
11863    }
11864
11865    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
11866    /// to a particular session. `session_id` is the identifier of the media session
11867    /// for which audio is to be rendered.
11868    pub fn r#create_audio_consumer(
11869        &self,
11870        mut session_id: u64,
11871        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
11872    ) -> Result<(), fidl::Error> {
11873        self.client.send::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
11874            (session_id, audio_consumer_request),
11875            0x6fab96f988e7d7fb,
11876            fidl::encoding::DynamicFlags::empty(),
11877        )
11878    }
11879}
11880
11881#[cfg(target_os = "fuchsia")]
11882impl From<SessionAudioConsumerFactorySynchronousProxy> for zx::NullableHandle {
11883    fn from(value: SessionAudioConsumerFactorySynchronousProxy) -> Self {
11884        value.into_channel().into()
11885    }
11886}
11887
11888#[cfg(target_os = "fuchsia")]
11889impl From<fidl::Channel> for SessionAudioConsumerFactorySynchronousProxy {
11890    fn from(value: fidl::Channel) -> Self {
11891        Self::new(value)
11892    }
11893}
11894
11895#[cfg(target_os = "fuchsia")]
11896impl fidl::endpoints::FromClient for SessionAudioConsumerFactorySynchronousProxy {
11897    type Protocol = SessionAudioConsumerFactoryMarker;
11898
11899    fn from_client(value: fidl::endpoints::ClientEnd<SessionAudioConsumerFactoryMarker>) -> Self {
11900        Self::new(value.into_channel())
11901    }
11902}
11903
11904#[derive(Debug, Clone)]
11905pub struct SessionAudioConsumerFactoryProxy {
11906    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
11907}
11908
11909impl fidl::endpoints::Proxy for SessionAudioConsumerFactoryProxy {
11910    type Protocol = SessionAudioConsumerFactoryMarker;
11911
11912    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
11913        Self::new(inner)
11914    }
11915
11916    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
11917        self.client.into_channel().map_err(|client| Self { client })
11918    }
11919
11920    fn as_channel(&self) -> &::fidl::AsyncChannel {
11921        self.client.as_channel()
11922    }
11923}
11924
11925impl SessionAudioConsumerFactoryProxy {
11926    /// Create a new Proxy for fuchsia.media/SessionAudioConsumerFactory.
11927    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
11928        let protocol_name =
11929            <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
11930        Self { client: fidl::client::Client::new(channel, protocol_name) }
11931    }
11932
11933    /// Get a Stream of events from the remote end of the protocol.
11934    ///
11935    /// # Panics
11936    ///
11937    /// Panics if the event stream was already taken.
11938    pub fn take_event_stream(&self) -> SessionAudioConsumerFactoryEventStream {
11939        SessionAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
11940    }
11941
11942    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
11943    /// to a particular session. `session_id` is the identifier of the media session
11944    /// for which audio is to be rendered.
11945    pub fn r#create_audio_consumer(
11946        &self,
11947        mut session_id: u64,
11948        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
11949    ) -> Result<(), fidl::Error> {
11950        SessionAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
11951            self,
11952            session_id,
11953            audio_consumer_request,
11954        )
11955    }
11956}
11957
11958impl SessionAudioConsumerFactoryProxyInterface for SessionAudioConsumerFactoryProxy {
11959    fn r#create_audio_consumer(
11960        &self,
11961        mut session_id: u64,
11962        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
11963    ) -> Result<(), fidl::Error> {
11964        self.client.send::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
11965            (session_id, audio_consumer_request),
11966            0x6fab96f988e7d7fb,
11967            fidl::encoding::DynamicFlags::empty(),
11968        )
11969    }
11970}
11971
11972pub struct SessionAudioConsumerFactoryEventStream {
11973    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
11974}
11975
11976impl std::marker::Unpin for SessionAudioConsumerFactoryEventStream {}
11977
11978impl futures::stream::FusedStream for SessionAudioConsumerFactoryEventStream {
11979    fn is_terminated(&self) -> bool {
11980        self.event_receiver.is_terminated()
11981    }
11982}
11983
11984impl futures::Stream for SessionAudioConsumerFactoryEventStream {
11985    type Item = Result<SessionAudioConsumerFactoryEvent, fidl::Error>;
11986
11987    fn poll_next(
11988        mut self: std::pin::Pin<&mut Self>,
11989        cx: &mut std::task::Context<'_>,
11990    ) -> std::task::Poll<Option<Self::Item>> {
11991        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
11992            &mut self.event_receiver,
11993            cx
11994        )?) {
11995            Some(buf) => {
11996                std::task::Poll::Ready(Some(SessionAudioConsumerFactoryEvent::decode(buf)))
11997            }
11998            None => std::task::Poll::Ready(None),
11999        }
12000    }
12001}
12002
12003#[derive(Debug)]
12004pub enum SessionAudioConsumerFactoryEvent {}
12005
12006impl SessionAudioConsumerFactoryEvent {
12007    /// Decodes a message buffer as a [`SessionAudioConsumerFactoryEvent`].
12008    fn decode(
12009        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
12010    ) -> Result<SessionAudioConsumerFactoryEvent, fidl::Error> {
12011        let (bytes, _handles) = buf.split_mut();
12012        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12013        debug_assert_eq!(tx_header.tx_id, 0);
12014        match tx_header.ordinal {
12015            _ => Err(fidl::Error::UnknownOrdinal {
12016                ordinal: tx_header.ordinal,
12017                protocol_name: <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12018            })
12019        }
12020    }
12021}
12022
12023/// A Stream of incoming requests for fuchsia.media/SessionAudioConsumerFactory.
12024pub struct SessionAudioConsumerFactoryRequestStream {
12025    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12026    is_terminated: bool,
12027}
12028
12029impl std::marker::Unpin for SessionAudioConsumerFactoryRequestStream {}
12030
12031impl futures::stream::FusedStream for SessionAudioConsumerFactoryRequestStream {
12032    fn is_terminated(&self) -> bool {
12033        self.is_terminated
12034    }
12035}
12036
12037impl fidl::endpoints::RequestStream for SessionAudioConsumerFactoryRequestStream {
12038    type Protocol = SessionAudioConsumerFactoryMarker;
12039    type ControlHandle = SessionAudioConsumerFactoryControlHandle;
12040
12041    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
12042        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
12043    }
12044
12045    fn control_handle(&self) -> Self::ControlHandle {
12046        SessionAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
12047    }
12048
12049    fn into_inner(
12050        self,
12051    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
12052    {
12053        (self.inner, self.is_terminated)
12054    }
12055
12056    fn from_inner(
12057        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12058        is_terminated: bool,
12059    ) -> Self {
12060        Self { inner, is_terminated }
12061    }
12062}
12063
12064impl futures::Stream for SessionAudioConsumerFactoryRequestStream {
12065    type Item = Result<SessionAudioConsumerFactoryRequest, fidl::Error>;
12066
12067    fn poll_next(
12068        mut self: std::pin::Pin<&mut Self>,
12069        cx: &mut std::task::Context<'_>,
12070    ) -> std::task::Poll<Option<Self::Item>> {
12071        let this = &mut *self;
12072        if this.inner.check_shutdown(cx) {
12073            this.is_terminated = true;
12074            return std::task::Poll::Ready(None);
12075        }
12076        if this.is_terminated {
12077            panic!("polled SessionAudioConsumerFactoryRequestStream after completion");
12078        }
12079        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
12080            |bytes, handles| {
12081                match this.inner.channel().read_etc(cx, bytes, handles) {
12082                    std::task::Poll::Ready(Ok(())) => {}
12083                    std::task::Poll::Pending => return std::task::Poll::Pending,
12084                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
12085                        this.is_terminated = true;
12086                        return std::task::Poll::Ready(None);
12087                    }
12088                    std::task::Poll::Ready(Err(e)) => {
12089                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
12090                            e.into(),
12091                        ))));
12092                    }
12093                }
12094
12095                // A message has been received from the channel
12096                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12097
12098                std::task::Poll::Ready(Some(match header.ordinal {
12099                0x6fab96f988e7d7fb => {
12100                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12101                    let mut req = fidl::new_empty!(SessionAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
12102                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
12103                    let control_handle = SessionAudioConsumerFactoryControlHandle {
12104                        inner: this.inner.clone(),
12105                    };
12106                    Ok(SessionAudioConsumerFactoryRequest::CreateAudioConsumer {session_id: req.session_id,
12107audio_consumer_request: req.audio_consumer_request,
12108
12109                        control_handle,
12110                    })
12111                }
12112                _ => Err(fidl::Error::UnknownOrdinal {
12113                    ordinal: header.ordinal,
12114                    protocol_name: <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12115                }),
12116            }))
12117            },
12118        )
12119    }
12120}
12121
12122/// Interface for creating audio consumers bound to a session.
12123#[derive(Debug)]
12124pub enum SessionAudioConsumerFactoryRequest {
12125    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
12126    /// to a particular session. `session_id` is the identifier of the media session
12127    /// for which audio is to be rendered.
12128    CreateAudioConsumer {
12129        session_id: u64,
12130        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12131        control_handle: SessionAudioConsumerFactoryControlHandle,
12132    },
12133}
12134
12135impl SessionAudioConsumerFactoryRequest {
12136    #[allow(irrefutable_let_patterns)]
12137    pub fn into_create_audio_consumer(
12138        self,
12139    ) -> Option<(
12140        u64,
12141        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12142        SessionAudioConsumerFactoryControlHandle,
12143    )> {
12144        if let SessionAudioConsumerFactoryRequest::CreateAudioConsumer {
12145            session_id,
12146            audio_consumer_request,
12147            control_handle,
12148        } = self
12149        {
12150            Some((session_id, audio_consumer_request, control_handle))
12151        } else {
12152            None
12153        }
12154    }
12155
12156    /// Name of the method defined in FIDL
12157    pub fn method_name(&self) -> &'static str {
12158        match *self {
12159            SessionAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
12160                "create_audio_consumer"
12161            }
12162        }
12163    }
12164}
12165
12166#[derive(Debug, Clone)]
12167pub struct SessionAudioConsumerFactoryControlHandle {
12168    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12169}
12170
12171impl fidl::endpoints::ControlHandle for SessionAudioConsumerFactoryControlHandle {
12172    fn shutdown(&self) {
12173        self.inner.shutdown()
12174    }
12175
12176    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
12177        self.inner.shutdown_with_epitaph(status)
12178    }
12179
12180    fn is_closed(&self) -> bool {
12181        self.inner.channel().is_closed()
12182    }
12183    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
12184        self.inner.channel().on_closed()
12185    }
12186
12187    #[cfg(target_os = "fuchsia")]
12188    fn signal_peer(
12189        &self,
12190        clear_mask: zx::Signals,
12191        set_mask: zx::Signals,
12192    ) -> Result<(), zx_status::Status> {
12193        use fidl::Peered;
12194        self.inner.channel().signal_peer(clear_mask, set_mask)
12195    }
12196}
12197
12198impl SessionAudioConsumerFactoryControlHandle {}
12199
12200#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
12201pub struct SimpleStreamSinkMarker;
12202
12203impl fidl::endpoints::ProtocolMarker for SimpleStreamSinkMarker {
12204    type Proxy = SimpleStreamSinkProxy;
12205    type RequestStream = SimpleStreamSinkRequestStream;
12206    #[cfg(target_os = "fuchsia")]
12207    type SynchronousProxy = SimpleStreamSinkSynchronousProxy;
12208
12209    const DEBUG_NAME: &'static str = "(anonymous) SimpleStreamSink";
12210}
12211
12212pub trait SimpleStreamSinkProxyInterface: Send + Sync {
12213    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
12214    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
12215    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
12216    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
12217    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
12218    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
12219    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
12220    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
12221    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
12222}
12223#[derive(Debug)]
12224#[cfg(target_os = "fuchsia")]
12225pub struct SimpleStreamSinkSynchronousProxy {
12226    client: fidl::client::sync::Client,
12227}
12228
12229#[cfg(target_os = "fuchsia")]
12230impl fidl::endpoints::SynchronousProxy for SimpleStreamSinkSynchronousProxy {
12231    type Proxy = SimpleStreamSinkProxy;
12232    type Protocol = SimpleStreamSinkMarker;
12233
12234    fn from_channel(inner: fidl::Channel) -> Self {
12235        Self::new(inner)
12236    }
12237
12238    fn into_channel(self) -> fidl::Channel {
12239        self.client.into_channel()
12240    }
12241
12242    fn as_channel(&self) -> &fidl::Channel {
12243        self.client.as_channel()
12244    }
12245}
12246
12247#[cfg(target_os = "fuchsia")]
12248impl SimpleStreamSinkSynchronousProxy {
12249    pub fn new(channel: fidl::Channel) -> Self {
12250        Self { client: fidl::client::sync::Client::new(channel) }
12251    }
12252
12253    pub fn into_channel(self) -> fidl::Channel {
12254        self.client.into_channel()
12255    }
12256
12257    /// Waits until an event arrives and returns it. It is safe for other
12258    /// threads to make concurrent requests while waiting for an event.
12259    pub fn wait_for_event(
12260        &self,
12261        deadline: zx::MonotonicInstant,
12262    ) -> Result<SimpleStreamSinkEvent, fidl::Error> {
12263        SimpleStreamSinkEvent::decode(
12264            self.client.wait_for_event::<SimpleStreamSinkMarker>(deadline)?,
12265        )
12266    }
12267
12268    /// Adds a payload buffer to the current buffer set associated with the
12269    /// connection. A `StreamPacket` struct reference a payload buffer in the
12270    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
12271    ///
12272    /// A buffer with ID `id` must not be in the current set when this method is
12273    /// invoked, otherwise the service will close the connection.
12274    pub fn r#add_payload_buffer(
12275        &self,
12276        mut id: u32,
12277        mut payload_buffer: fidl::Vmo,
12278    ) -> Result<(), fidl::Error> {
12279        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
12280            (id, payload_buffer),
12281            0x3b3a37fc34fe5b56,
12282            fidl::encoding::DynamicFlags::empty(),
12283        )
12284    }
12285
12286    /// Removes a payload buffer from the current buffer set associated with the
12287    /// connection.
12288    ///
12289    /// A buffer with ID `id` must exist in the current set when this method is
12290    /// invoked, otherwise the service will will close the connection.
12291    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
12292        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
12293            (id,),
12294            0x5d1e4f74c3658262,
12295            fidl::encoding::DynamicFlags::empty(),
12296        )
12297    }
12298
12299    /// Sends a packet to the service. The response is sent when the service is
12300    /// done with the associated payload memory.
12301    ///
12302    /// `packet` must be valid for the current buffer set, otherwise the service
12303    /// will close the connection.
12304    pub fn r#send_packet(
12305        &self,
12306        mut packet: &StreamPacket,
12307        ___deadline: zx::MonotonicInstant,
12308    ) -> Result<(), fidl::Error> {
12309        let _response = self.client.send_query::<
12310            StreamSinkSendPacketRequest,
12311            fidl::encoding::EmptyPayload,
12312            SimpleStreamSinkMarker,
12313        >(
12314            (packet,),
12315            0x67cddd607442775f,
12316            fidl::encoding::DynamicFlags::empty(),
12317            ___deadline,
12318        )?;
12319        Ok(_response)
12320    }
12321
12322    /// Sends a packet to the service. This interface doesn't define how the
12323    /// client knows when the sink is done with the associated payload memory.
12324    /// The inheriting interface must define that.
12325    ///
12326    /// `packet` must be valid for the current buffer set, otherwise the service
12327    /// will close the connection.
12328    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12329        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
12330            (packet,),
12331            0x8d9b8b413ceba9d,
12332            fidl::encoding::DynamicFlags::empty(),
12333        )
12334    }
12335
12336    /// Indicates the stream has ended. The precise semantics of this method are
12337    /// determined by the inheriting interface.
12338    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12339        self.client.send::<fidl::encoding::EmptyPayload>(
12340            (),
12341            0x6180fd6f7e793b71,
12342            fidl::encoding::DynamicFlags::empty(),
12343        )
12344    }
12345
12346    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12347    /// and not yet released. The response is sent after all packets have been
12348    /// released.
12349    pub fn r#discard_all_packets(
12350        &self,
12351        ___deadline: zx::MonotonicInstant,
12352    ) -> Result<(), fidl::Error> {
12353        let _response = self.client.send_query::<
12354            fidl::encoding::EmptyPayload,
12355            fidl::encoding::EmptyPayload,
12356            SimpleStreamSinkMarker,
12357        >(
12358            (),
12359            0x6f4dad7af2917665,
12360            fidl::encoding::DynamicFlags::empty(),
12361            ___deadline,
12362        )?;
12363        Ok(_response)
12364    }
12365
12366    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12367    /// and not yet released.
12368    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12369        self.client.send::<fidl::encoding::EmptyPayload>(
12370            (),
12371            0x50d36d0d23081bc4,
12372            fidl::encoding::DynamicFlags::empty(),
12373        )
12374    }
12375}
12376
12377#[cfg(target_os = "fuchsia")]
12378impl From<SimpleStreamSinkSynchronousProxy> for zx::NullableHandle {
12379    fn from(value: SimpleStreamSinkSynchronousProxy) -> Self {
12380        value.into_channel().into()
12381    }
12382}
12383
12384#[cfg(target_os = "fuchsia")]
12385impl From<fidl::Channel> for SimpleStreamSinkSynchronousProxy {
12386    fn from(value: fidl::Channel) -> Self {
12387        Self::new(value)
12388    }
12389}
12390
12391#[cfg(target_os = "fuchsia")]
12392impl fidl::endpoints::FromClient for SimpleStreamSinkSynchronousProxy {
12393    type Protocol = SimpleStreamSinkMarker;
12394
12395    fn from_client(value: fidl::endpoints::ClientEnd<SimpleStreamSinkMarker>) -> Self {
12396        Self::new(value.into_channel())
12397    }
12398}
12399
12400#[derive(Debug, Clone)]
12401pub struct SimpleStreamSinkProxy {
12402    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
12403}
12404
12405impl fidl::endpoints::Proxy for SimpleStreamSinkProxy {
12406    type Protocol = SimpleStreamSinkMarker;
12407
12408    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
12409        Self::new(inner)
12410    }
12411
12412    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
12413        self.client.into_channel().map_err(|client| Self { client })
12414    }
12415
12416    fn as_channel(&self) -> &::fidl::AsyncChannel {
12417        self.client.as_channel()
12418    }
12419}
12420
12421impl SimpleStreamSinkProxy {
12422    /// Create a new Proxy for fuchsia.media/SimpleStreamSink.
12423    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
12424        let protocol_name = <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
12425        Self { client: fidl::client::Client::new(channel, protocol_name) }
12426    }
12427
12428    /// Get a Stream of events from the remote end of the protocol.
12429    ///
12430    /// # Panics
12431    ///
12432    /// Panics if the event stream was already taken.
12433    pub fn take_event_stream(&self) -> SimpleStreamSinkEventStream {
12434        SimpleStreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
12435    }
12436
12437    /// Adds a payload buffer to the current buffer set associated with the
12438    /// connection. A `StreamPacket` struct reference a payload buffer in the
12439    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
12440    ///
12441    /// A buffer with ID `id` must not be in the current set when this method is
12442    /// invoked, otherwise the service will close the connection.
12443    pub fn r#add_payload_buffer(
12444        &self,
12445        mut id: u32,
12446        mut payload_buffer: fidl::Vmo,
12447    ) -> Result<(), fidl::Error> {
12448        SimpleStreamSinkProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
12449    }
12450
12451    /// Removes a payload buffer from the current buffer set associated with the
12452    /// connection.
12453    ///
12454    /// A buffer with ID `id` must exist in the current set when this method is
12455    /// invoked, otherwise the service will will close the connection.
12456    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
12457        SimpleStreamSinkProxyInterface::r#remove_payload_buffer(self, id)
12458    }
12459
12460    /// Sends a packet to the service. The response is sent when the service is
12461    /// done with the associated payload memory.
12462    ///
12463    /// `packet` must be valid for the current buffer set, otherwise the service
12464    /// will close the connection.
12465    pub fn r#send_packet(
12466        &self,
12467        mut packet: &StreamPacket,
12468    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
12469        SimpleStreamSinkProxyInterface::r#send_packet(self, packet)
12470    }
12471
12472    /// Sends a packet to the service. This interface doesn't define how the
12473    /// client knows when the sink is done with the associated payload memory.
12474    /// The inheriting interface must define that.
12475    ///
12476    /// `packet` must be valid for the current buffer set, otherwise the service
12477    /// will close the connection.
12478    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12479        SimpleStreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
12480    }
12481
12482    /// Indicates the stream has ended. The precise semantics of this method are
12483    /// determined by the inheriting interface.
12484    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12485        SimpleStreamSinkProxyInterface::r#end_of_stream(self)
12486    }
12487
12488    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12489    /// and not yet released. The response is sent after all packets have been
12490    /// released.
12491    pub fn r#discard_all_packets(
12492        &self,
12493    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
12494        SimpleStreamSinkProxyInterface::r#discard_all_packets(self)
12495    }
12496
12497    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12498    /// and not yet released.
12499    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12500        SimpleStreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
12501    }
12502}
12503
12504impl SimpleStreamSinkProxyInterface for SimpleStreamSinkProxy {
12505    fn r#add_payload_buffer(
12506        &self,
12507        mut id: u32,
12508        mut payload_buffer: fidl::Vmo,
12509    ) -> Result<(), fidl::Error> {
12510        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
12511            (id, payload_buffer),
12512            0x3b3a37fc34fe5b56,
12513            fidl::encoding::DynamicFlags::empty(),
12514        )
12515    }
12516
12517    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
12518        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
12519            (id,),
12520            0x5d1e4f74c3658262,
12521            fidl::encoding::DynamicFlags::empty(),
12522        )
12523    }
12524
12525    type SendPacketResponseFut =
12526        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
12527    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
12528        fn _decode(
12529            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12530        ) -> Result<(), fidl::Error> {
12531            let _response = fidl::client::decode_transaction_body::<
12532                fidl::encoding::EmptyPayload,
12533                fidl::encoding::DefaultFuchsiaResourceDialect,
12534                0x67cddd607442775f,
12535            >(_buf?)?;
12536            Ok(_response)
12537        }
12538        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
12539            (packet,),
12540            0x67cddd607442775f,
12541            fidl::encoding::DynamicFlags::empty(),
12542            _decode,
12543        )
12544    }
12545
12546    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12547        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
12548            (packet,),
12549            0x8d9b8b413ceba9d,
12550            fidl::encoding::DynamicFlags::empty(),
12551        )
12552    }
12553
12554    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12555        self.client.send::<fidl::encoding::EmptyPayload>(
12556            (),
12557            0x6180fd6f7e793b71,
12558            fidl::encoding::DynamicFlags::empty(),
12559        )
12560    }
12561
12562    type DiscardAllPacketsResponseFut =
12563        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
12564    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
12565        fn _decode(
12566            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12567        ) -> Result<(), fidl::Error> {
12568            let _response = fidl::client::decode_transaction_body::<
12569                fidl::encoding::EmptyPayload,
12570                fidl::encoding::DefaultFuchsiaResourceDialect,
12571                0x6f4dad7af2917665,
12572            >(_buf?)?;
12573            Ok(_response)
12574        }
12575        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
12576            (),
12577            0x6f4dad7af2917665,
12578            fidl::encoding::DynamicFlags::empty(),
12579            _decode,
12580        )
12581    }
12582
12583    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12584        self.client.send::<fidl::encoding::EmptyPayload>(
12585            (),
12586            0x50d36d0d23081bc4,
12587            fidl::encoding::DynamicFlags::empty(),
12588        )
12589    }
12590}
12591
12592pub struct SimpleStreamSinkEventStream {
12593    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
12594}
12595
12596impl std::marker::Unpin for SimpleStreamSinkEventStream {}
12597
12598impl futures::stream::FusedStream for SimpleStreamSinkEventStream {
12599    fn is_terminated(&self) -> bool {
12600        self.event_receiver.is_terminated()
12601    }
12602}
12603
12604impl futures::Stream for SimpleStreamSinkEventStream {
12605    type Item = Result<SimpleStreamSinkEvent, fidl::Error>;
12606
12607    fn poll_next(
12608        mut self: std::pin::Pin<&mut Self>,
12609        cx: &mut std::task::Context<'_>,
12610    ) -> std::task::Poll<Option<Self::Item>> {
12611        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
12612            &mut self.event_receiver,
12613            cx
12614        )?) {
12615            Some(buf) => std::task::Poll::Ready(Some(SimpleStreamSinkEvent::decode(buf))),
12616            None => std::task::Poll::Ready(None),
12617        }
12618    }
12619}
12620
12621#[derive(Debug)]
12622pub enum SimpleStreamSinkEvent {}
12623
12624impl SimpleStreamSinkEvent {
12625    /// Decodes a message buffer as a [`SimpleStreamSinkEvent`].
12626    fn decode(
12627        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
12628    ) -> Result<SimpleStreamSinkEvent, fidl::Error> {
12629        let (bytes, _handles) = buf.split_mut();
12630        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12631        debug_assert_eq!(tx_header.tx_id, 0);
12632        match tx_header.ordinal {
12633            _ => Err(fidl::Error::UnknownOrdinal {
12634                ordinal: tx_header.ordinal,
12635                protocol_name:
12636                    <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12637            }),
12638        }
12639    }
12640}
12641
12642/// A Stream of incoming requests for fuchsia.media/SimpleStreamSink.
12643pub struct SimpleStreamSinkRequestStream {
12644    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12645    is_terminated: bool,
12646}
12647
12648impl std::marker::Unpin for SimpleStreamSinkRequestStream {}
12649
12650impl futures::stream::FusedStream for SimpleStreamSinkRequestStream {
12651    fn is_terminated(&self) -> bool {
12652        self.is_terminated
12653    }
12654}
12655
12656impl fidl::endpoints::RequestStream for SimpleStreamSinkRequestStream {
12657    type Protocol = SimpleStreamSinkMarker;
12658    type ControlHandle = SimpleStreamSinkControlHandle;
12659
12660    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
12661        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
12662    }
12663
12664    fn control_handle(&self) -> Self::ControlHandle {
12665        SimpleStreamSinkControlHandle { inner: self.inner.clone() }
12666    }
12667
12668    fn into_inner(
12669        self,
12670    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
12671    {
12672        (self.inner, self.is_terminated)
12673    }
12674
12675    fn from_inner(
12676        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12677        is_terminated: bool,
12678    ) -> Self {
12679        Self { inner, is_terminated }
12680    }
12681}
12682
12683impl futures::Stream for SimpleStreamSinkRequestStream {
12684    type Item = Result<SimpleStreamSinkRequest, fidl::Error>;
12685
12686    fn poll_next(
12687        mut self: std::pin::Pin<&mut Self>,
12688        cx: &mut std::task::Context<'_>,
12689    ) -> std::task::Poll<Option<Self::Item>> {
12690        let this = &mut *self;
12691        if this.inner.check_shutdown(cx) {
12692            this.is_terminated = true;
12693            return std::task::Poll::Ready(None);
12694        }
12695        if this.is_terminated {
12696            panic!("polled SimpleStreamSinkRequestStream after completion");
12697        }
12698        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
12699            |bytes, handles| {
12700                match this.inner.channel().read_etc(cx, bytes, handles) {
12701                    std::task::Poll::Ready(Ok(())) => {}
12702                    std::task::Poll::Pending => return std::task::Poll::Pending,
12703                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
12704                        this.is_terminated = true;
12705                        return std::task::Poll::Ready(None);
12706                    }
12707                    std::task::Poll::Ready(Err(e)) => {
12708                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
12709                            e.into(),
12710                        ))));
12711                    }
12712                }
12713
12714                // A message has been received from the channel
12715                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12716
12717                std::task::Poll::Ready(Some(match header.ordinal {
12718                    0x3b3a37fc34fe5b56 => {
12719                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12720                        let mut req = fidl::new_empty!(
12721                            StreamBufferSetAddPayloadBufferRequest,
12722                            fidl::encoding::DefaultFuchsiaResourceDialect
12723                        );
12724                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
12725                        let control_handle =
12726                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12727                        Ok(SimpleStreamSinkRequest::AddPayloadBuffer {
12728                            id: req.id,
12729                            payload_buffer: req.payload_buffer,
12730
12731                            control_handle,
12732                        })
12733                    }
12734                    0x5d1e4f74c3658262 => {
12735                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12736                        let mut req = fidl::new_empty!(
12737                            StreamBufferSetRemovePayloadBufferRequest,
12738                            fidl::encoding::DefaultFuchsiaResourceDialect
12739                        );
12740                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
12741                        let control_handle =
12742                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12743                        Ok(SimpleStreamSinkRequest::RemovePayloadBuffer {
12744                            id: req.id,
12745
12746                            control_handle,
12747                        })
12748                    }
12749                    0x67cddd607442775f => {
12750                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12751                        let mut req = fidl::new_empty!(
12752                            StreamSinkSendPacketRequest,
12753                            fidl::encoding::DefaultFuchsiaResourceDialect
12754                        );
12755                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
12756                        let control_handle =
12757                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12758                        Ok(SimpleStreamSinkRequest::SendPacket {
12759                            packet: req.packet,
12760
12761                            responder: SimpleStreamSinkSendPacketResponder {
12762                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12763                                tx_id: header.tx_id,
12764                            },
12765                        })
12766                    }
12767                    0x8d9b8b413ceba9d => {
12768                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12769                        let mut req = fidl::new_empty!(
12770                            StreamSinkSendPacketNoReplyRequest,
12771                            fidl::encoding::DefaultFuchsiaResourceDialect
12772                        );
12773                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
12774                        let control_handle =
12775                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12776                        Ok(SimpleStreamSinkRequest::SendPacketNoReply {
12777                            packet: req.packet,
12778
12779                            control_handle,
12780                        })
12781                    }
12782                    0x6180fd6f7e793b71 => {
12783                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12784                        let mut req = fidl::new_empty!(
12785                            fidl::encoding::EmptyPayload,
12786                            fidl::encoding::DefaultFuchsiaResourceDialect
12787                        );
12788                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12789                        let control_handle =
12790                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12791                        Ok(SimpleStreamSinkRequest::EndOfStream { control_handle })
12792                    }
12793                    0x6f4dad7af2917665 => {
12794                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12795                        let mut req = fidl::new_empty!(
12796                            fidl::encoding::EmptyPayload,
12797                            fidl::encoding::DefaultFuchsiaResourceDialect
12798                        );
12799                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12800                        let control_handle =
12801                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12802                        Ok(SimpleStreamSinkRequest::DiscardAllPackets {
12803                            responder: SimpleStreamSinkDiscardAllPacketsResponder {
12804                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12805                                tx_id: header.tx_id,
12806                            },
12807                        })
12808                    }
12809                    0x50d36d0d23081bc4 => {
12810                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12811                        let mut req = fidl::new_empty!(
12812                            fidl::encoding::EmptyPayload,
12813                            fidl::encoding::DefaultFuchsiaResourceDialect
12814                        );
12815                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12816                        let control_handle =
12817                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12818                        Ok(SimpleStreamSinkRequest::DiscardAllPacketsNoReply { control_handle })
12819                    }
12820                    _ => Err(fidl::Error::UnknownOrdinal {
12821                        ordinal: header.ordinal,
12822                        protocol_name:
12823                            <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12824                    }),
12825                }))
12826            },
12827        )
12828    }
12829}
12830
12831/// A StreamSink that uses StreamBufferSet for buffer management.
12832#[derive(Debug)]
12833pub enum SimpleStreamSinkRequest {
12834    /// Adds a payload buffer to the current buffer set associated with the
12835    /// connection. A `StreamPacket` struct reference a payload buffer in the
12836    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
12837    ///
12838    /// A buffer with ID `id` must not be in the current set when this method is
12839    /// invoked, otherwise the service will close the connection.
12840    AddPayloadBuffer {
12841        id: u32,
12842        payload_buffer: fidl::Vmo,
12843        control_handle: SimpleStreamSinkControlHandle,
12844    },
12845    /// Removes a payload buffer from the current buffer set associated with the
12846    /// connection.
12847    ///
12848    /// A buffer with ID `id` must exist in the current set when this method is
12849    /// invoked, otherwise the service will will close the connection.
12850    RemovePayloadBuffer { id: u32, control_handle: SimpleStreamSinkControlHandle },
12851    /// Sends a packet to the service. The response is sent when the service is
12852    /// done with the associated payload memory.
12853    ///
12854    /// `packet` must be valid for the current buffer set, otherwise the service
12855    /// will close the connection.
12856    SendPacket { packet: StreamPacket, responder: SimpleStreamSinkSendPacketResponder },
12857    /// Sends a packet to the service. This interface doesn't define how the
12858    /// client knows when the sink is done with the associated payload memory.
12859    /// The inheriting interface must define that.
12860    ///
12861    /// `packet` must be valid for the current buffer set, otherwise the service
12862    /// will close the connection.
12863    SendPacketNoReply { packet: StreamPacket, control_handle: SimpleStreamSinkControlHandle },
12864    /// Indicates the stream has ended. The precise semantics of this method are
12865    /// determined by the inheriting interface.
12866    EndOfStream { control_handle: SimpleStreamSinkControlHandle },
12867    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12868    /// and not yet released. The response is sent after all packets have been
12869    /// released.
12870    DiscardAllPackets { responder: SimpleStreamSinkDiscardAllPacketsResponder },
12871    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12872    /// and not yet released.
12873    DiscardAllPacketsNoReply { control_handle: SimpleStreamSinkControlHandle },
12874}
12875
12876impl SimpleStreamSinkRequest {
12877    #[allow(irrefutable_let_patterns)]
12878    pub fn into_add_payload_buffer(
12879        self,
12880    ) -> Option<(u32, fidl::Vmo, SimpleStreamSinkControlHandle)> {
12881        if let SimpleStreamSinkRequest::AddPayloadBuffer { id, payload_buffer, control_handle } =
12882            self
12883        {
12884            Some((id, payload_buffer, control_handle))
12885        } else {
12886            None
12887        }
12888    }
12889
12890    #[allow(irrefutable_let_patterns)]
12891    pub fn into_remove_payload_buffer(self) -> Option<(u32, SimpleStreamSinkControlHandle)> {
12892        if let SimpleStreamSinkRequest::RemovePayloadBuffer { id, control_handle } = self {
12893            Some((id, control_handle))
12894        } else {
12895            None
12896        }
12897    }
12898
12899    #[allow(irrefutable_let_patterns)]
12900    pub fn into_send_packet(self) -> Option<(StreamPacket, SimpleStreamSinkSendPacketResponder)> {
12901        if let SimpleStreamSinkRequest::SendPacket { packet, responder } = self {
12902            Some((packet, responder))
12903        } else {
12904            None
12905        }
12906    }
12907
12908    #[allow(irrefutable_let_patterns)]
12909    pub fn into_send_packet_no_reply(
12910        self,
12911    ) -> Option<(StreamPacket, SimpleStreamSinkControlHandle)> {
12912        if let SimpleStreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
12913            Some((packet, control_handle))
12914        } else {
12915            None
12916        }
12917    }
12918
12919    #[allow(irrefutable_let_patterns)]
12920    pub fn into_end_of_stream(self) -> Option<(SimpleStreamSinkControlHandle)> {
12921        if let SimpleStreamSinkRequest::EndOfStream { control_handle } = self {
12922            Some((control_handle))
12923        } else {
12924            None
12925        }
12926    }
12927
12928    #[allow(irrefutable_let_patterns)]
12929    pub fn into_discard_all_packets(self) -> Option<(SimpleStreamSinkDiscardAllPacketsResponder)> {
12930        if let SimpleStreamSinkRequest::DiscardAllPackets { responder } = self {
12931            Some((responder))
12932        } else {
12933            None
12934        }
12935    }
12936
12937    #[allow(irrefutable_let_patterns)]
12938    pub fn into_discard_all_packets_no_reply(self) -> Option<(SimpleStreamSinkControlHandle)> {
12939        if let SimpleStreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
12940            Some((control_handle))
12941        } else {
12942            None
12943        }
12944    }
12945
12946    /// Name of the method defined in FIDL
12947    pub fn method_name(&self) -> &'static str {
12948        match *self {
12949            SimpleStreamSinkRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
12950            SimpleStreamSinkRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
12951            SimpleStreamSinkRequest::SendPacket { .. } => "send_packet",
12952            SimpleStreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
12953            SimpleStreamSinkRequest::EndOfStream { .. } => "end_of_stream",
12954            SimpleStreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
12955            SimpleStreamSinkRequest::DiscardAllPacketsNoReply { .. } => {
12956                "discard_all_packets_no_reply"
12957            }
12958        }
12959    }
12960}
12961
12962#[derive(Debug, Clone)]
12963pub struct SimpleStreamSinkControlHandle {
12964    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12965}
12966
12967impl fidl::endpoints::ControlHandle for SimpleStreamSinkControlHandle {
12968    fn shutdown(&self) {
12969        self.inner.shutdown()
12970    }
12971
12972    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
12973        self.inner.shutdown_with_epitaph(status)
12974    }
12975
12976    fn is_closed(&self) -> bool {
12977        self.inner.channel().is_closed()
12978    }
12979    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
12980        self.inner.channel().on_closed()
12981    }
12982
12983    #[cfg(target_os = "fuchsia")]
12984    fn signal_peer(
12985        &self,
12986        clear_mask: zx::Signals,
12987        set_mask: zx::Signals,
12988    ) -> Result<(), zx_status::Status> {
12989        use fidl::Peered;
12990        self.inner.channel().signal_peer(clear_mask, set_mask)
12991    }
12992}
12993
12994impl SimpleStreamSinkControlHandle {}
12995
12996#[must_use = "FIDL methods require a response to be sent"]
12997#[derive(Debug)]
12998pub struct SimpleStreamSinkSendPacketResponder {
12999    control_handle: std::mem::ManuallyDrop<SimpleStreamSinkControlHandle>,
13000    tx_id: u32,
13001}
13002
13003/// Set the the channel to be shutdown (see [`SimpleStreamSinkControlHandle::shutdown`])
13004/// if the responder is dropped without sending a response, so that the client
13005/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13006impl std::ops::Drop for SimpleStreamSinkSendPacketResponder {
13007    fn drop(&mut self) {
13008        self.control_handle.shutdown();
13009        // Safety: drops once, never accessed again
13010        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13011    }
13012}
13013
13014impl fidl::endpoints::Responder for SimpleStreamSinkSendPacketResponder {
13015    type ControlHandle = SimpleStreamSinkControlHandle;
13016
13017    fn control_handle(&self) -> &SimpleStreamSinkControlHandle {
13018        &self.control_handle
13019    }
13020
13021    fn drop_without_shutdown(mut self) {
13022        // Safety: drops once, never accessed again due to mem::forget
13023        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13024        // Prevent Drop from running (which would shut down the channel)
13025        std::mem::forget(self);
13026    }
13027}
13028
13029impl SimpleStreamSinkSendPacketResponder {
13030    /// Sends a response to the FIDL transaction.
13031    ///
13032    /// Sets the channel to shutdown if an error occurs.
13033    pub fn send(self) -> Result<(), fidl::Error> {
13034        let _result = self.send_raw();
13035        if _result.is_err() {
13036            self.control_handle.shutdown();
13037        }
13038        self.drop_without_shutdown();
13039        _result
13040    }
13041
13042    /// Similar to "send" but does not shutdown the channel if an error occurs.
13043    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
13044        let _result = self.send_raw();
13045        self.drop_without_shutdown();
13046        _result
13047    }
13048
13049    fn send_raw(&self) -> Result<(), fidl::Error> {
13050        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
13051            (),
13052            self.tx_id,
13053            0x67cddd607442775f,
13054            fidl::encoding::DynamicFlags::empty(),
13055        )
13056    }
13057}
13058
13059#[must_use = "FIDL methods require a response to be sent"]
13060#[derive(Debug)]
13061pub struct SimpleStreamSinkDiscardAllPacketsResponder {
13062    control_handle: std::mem::ManuallyDrop<SimpleStreamSinkControlHandle>,
13063    tx_id: u32,
13064}
13065
13066/// Set the the channel to be shutdown (see [`SimpleStreamSinkControlHandle::shutdown`])
13067/// if the responder is dropped without sending a response, so that the client
13068/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13069impl std::ops::Drop for SimpleStreamSinkDiscardAllPacketsResponder {
13070    fn drop(&mut self) {
13071        self.control_handle.shutdown();
13072        // Safety: drops once, never accessed again
13073        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13074    }
13075}
13076
13077impl fidl::endpoints::Responder for SimpleStreamSinkDiscardAllPacketsResponder {
13078    type ControlHandle = SimpleStreamSinkControlHandle;
13079
13080    fn control_handle(&self) -> &SimpleStreamSinkControlHandle {
13081        &self.control_handle
13082    }
13083
13084    fn drop_without_shutdown(mut self) {
13085        // Safety: drops once, never accessed again due to mem::forget
13086        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13087        // Prevent Drop from running (which would shut down the channel)
13088        std::mem::forget(self);
13089    }
13090}
13091
13092impl SimpleStreamSinkDiscardAllPacketsResponder {
13093    /// Sends a response to the FIDL transaction.
13094    ///
13095    /// Sets the channel to shutdown if an error occurs.
13096    pub fn send(self) -> Result<(), fidl::Error> {
13097        let _result = self.send_raw();
13098        if _result.is_err() {
13099            self.control_handle.shutdown();
13100        }
13101        self.drop_without_shutdown();
13102        _result
13103    }
13104
13105    /// Similar to "send" but does not shutdown the channel if an error occurs.
13106    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
13107        let _result = self.send_raw();
13108        self.drop_without_shutdown();
13109        _result
13110    }
13111
13112    fn send_raw(&self) -> Result<(), fidl::Error> {
13113        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
13114            (),
13115            self.tx_id,
13116            0x6f4dad7af2917665,
13117            fidl::encoding::DynamicFlags::empty(),
13118        )
13119    }
13120}
13121
13122#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
13123pub struct StreamBufferSetMarker;
13124
13125impl fidl::endpoints::ProtocolMarker for StreamBufferSetMarker {
13126    type Proxy = StreamBufferSetProxy;
13127    type RequestStream = StreamBufferSetRequestStream;
13128    #[cfg(target_os = "fuchsia")]
13129    type SynchronousProxy = StreamBufferSetSynchronousProxy;
13130
13131    const DEBUG_NAME: &'static str = "(anonymous) StreamBufferSet";
13132}
13133
13134pub trait StreamBufferSetProxyInterface: Send + Sync {
13135    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
13136    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
13137}
13138#[derive(Debug)]
13139#[cfg(target_os = "fuchsia")]
13140pub struct StreamBufferSetSynchronousProxy {
13141    client: fidl::client::sync::Client,
13142}
13143
13144#[cfg(target_os = "fuchsia")]
13145impl fidl::endpoints::SynchronousProxy for StreamBufferSetSynchronousProxy {
13146    type Proxy = StreamBufferSetProxy;
13147    type Protocol = StreamBufferSetMarker;
13148
13149    fn from_channel(inner: fidl::Channel) -> Self {
13150        Self::new(inner)
13151    }
13152
13153    fn into_channel(self) -> fidl::Channel {
13154        self.client.into_channel()
13155    }
13156
13157    fn as_channel(&self) -> &fidl::Channel {
13158        self.client.as_channel()
13159    }
13160}
13161
13162#[cfg(target_os = "fuchsia")]
13163impl StreamBufferSetSynchronousProxy {
13164    pub fn new(channel: fidl::Channel) -> Self {
13165        Self { client: fidl::client::sync::Client::new(channel) }
13166    }
13167
13168    pub fn into_channel(self) -> fidl::Channel {
13169        self.client.into_channel()
13170    }
13171
13172    /// Waits until an event arrives and returns it. It is safe for other
13173    /// threads to make concurrent requests while waiting for an event.
13174    pub fn wait_for_event(
13175        &self,
13176        deadline: zx::MonotonicInstant,
13177    ) -> Result<StreamBufferSetEvent, fidl::Error> {
13178        StreamBufferSetEvent::decode(self.client.wait_for_event::<StreamBufferSetMarker>(deadline)?)
13179    }
13180
13181    /// Adds a payload buffer to the current buffer set associated with the
13182    /// connection. A `StreamPacket` struct reference a payload buffer in the
13183    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13184    ///
13185    /// A buffer with ID `id` must not be in the current set when this method is
13186    /// invoked, otherwise the service will close the connection.
13187    pub fn r#add_payload_buffer(
13188        &self,
13189        mut id: u32,
13190        mut payload_buffer: fidl::Vmo,
13191    ) -> Result<(), fidl::Error> {
13192        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
13193            (id, payload_buffer),
13194            0x3b3a37fc34fe5b56,
13195            fidl::encoding::DynamicFlags::empty(),
13196        )
13197    }
13198
13199    /// Removes a payload buffer from the current buffer set associated with the
13200    /// connection.
13201    ///
13202    /// A buffer with ID `id` must exist in the current set when this method is
13203    /// invoked, otherwise the service will will close the connection.
13204    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
13205        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
13206            (id,),
13207            0x5d1e4f74c3658262,
13208            fidl::encoding::DynamicFlags::empty(),
13209        )
13210    }
13211}
13212
13213#[cfg(target_os = "fuchsia")]
13214impl From<StreamBufferSetSynchronousProxy> for zx::NullableHandle {
13215    fn from(value: StreamBufferSetSynchronousProxy) -> Self {
13216        value.into_channel().into()
13217    }
13218}
13219
13220#[cfg(target_os = "fuchsia")]
13221impl From<fidl::Channel> for StreamBufferSetSynchronousProxy {
13222    fn from(value: fidl::Channel) -> Self {
13223        Self::new(value)
13224    }
13225}
13226
13227#[cfg(target_os = "fuchsia")]
13228impl fidl::endpoints::FromClient for StreamBufferSetSynchronousProxy {
13229    type Protocol = StreamBufferSetMarker;
13230
13231    fn from_client(value: fidl::endpoints::ClientEnd<StreamBufferSetMarker>) -> Self {
13232        Self::new(value.into_channel())
13233    }
13234}
13235
13236#[derive(Debug, Clone)]
13237pub struct StreamBufferSetProxy {
13238    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
13239}
13240
13241impl fidl::endpoints::Proxy for StreamBufferSetProxy {
13242    type Protocol = StreamBufferSetMarker;
13243
13244    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
13245        Self::new(inner)
13246    }
13247
13248    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
13249        self.client.into_channel().map_err(|client| Self { client })
13250    }
13251
13252    fn as_channel(&self) -> &::fidl::AsyncChannel {
13253        self.client.as_channel()
13254    }
13255}
13256
13257impl StreamBufferSetProxy {
13258    /// Create a new Proxy for fuchsia.media/StreamBufferSet.
13259    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
13260        let protocol_name = <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
13261        Self { client: fidl::client::Client::new(channel, protocol_name) }
13262    }
13263
13264    /// Get a Stream of events from the remote end of the protocol.
13265    ///
13266    /// # Panics
13267    ///
13268    /// Panics if the event stream was already taken.
13269    pub fn take_event_stream(&self) -> StreamBufferSetEventStream {
13270        StreamBufferSetEventStream { event_receiver: self.client.take_event_receiver() }
13271    }
13272
13273    /// Adds a payload buffer to the current buffer set associated with the
13274    /// connection. A `StreamPacket` struct reference a payload buffer in the
13275    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13276    ///
13277    /// A buffer with ID `id` must not be in the current set when this method is
13278    /// invoked, otherwise the service will close the connection.
13279    pub fn r#add_payload_buffer(
13280        &self,
13281        mut id: u32,
13282        mut payload_buffer: fidl::Vmo,
13283    ) -> Result<(), fidl::Error> {
13284        StreamBufferSetProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
13285    }
13286
13287    /// Removes a payload buffer from the current buffer set associated with the
13288    /// connection.
13289    ///
13290    /// A buffer with ID `id` must exist in the current set when this method is
13291    /// invoked, otherwise the service will will close the connection.
13292    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
13293        StreamBufferSetProxyInterface::r#remove_payload_buffer(self, id)
13294    }
13295}
13296
13297impl StreamBufferSetProxyInterface for StreamBufferSetProxy {
13298    fn r#add_payload_buffer(
13299        &self,
13300        mut id: u32,
13301        mut payload_buffer: fidl::Vmo,
13302    ) -> Result<(), fidl::Error> {
13303        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
13304            (id, payload_buffer),
13305            0x3b3a37fc34fe5b56,
13306            fidl::encoding::DynamicFlags::empty(),
13307        )
13308    }
13309
13310    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
13311        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
13312            (id,),
13313            0x5d1e4f74c3658262,
13314            fidl::encoding::DynamicFlags::empty(),
13315        )
13316    }
13317}
13318
13319pub struct StreamBufferSetEventStream {
13320    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
13321}
13322
13323impl std::marker::Unpin for StreamBufferSetEventStream {}
13324
13325impl futures::stream::FusedStream for StreamBufferSetEventStream {
13326    fn is_terminated(&self) -> bool {
13327        self.event_receiver.is_terminated()
13328    }
13329}
13330
13331impl futures::Stream for StreamBufferSetEventStream {
13332    type Item = Result<StreamBufferSetEvent, fidl::Error>;
13333
13334    fn poll_next(
13335        mut self: std::pin::Pin<&mut Self>,
13336        cx: &mut std::task::Context<'_>,
13337    ) -> std::task::Poll<Option<Self::Item>> {
13338        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
13339            &mut self.event_receiver,
13340            cx
13341        )?) {
13342            Some(buf) => std::task::Poll::Ready(Some(StreamBufferSetEvent::decode(buf))),
13343            None => std::task::Poll::Ready(None),
13344        }
13345    }
13346}
13347
13348#[derive(Debug)]
13349pub enum StreamBufferSetEvent {}
13350
13351impl StreamBufferSetEvent {
13352    /// Decodes a message buffer as a [`StreamBufferSetEvent`].
13353    fn decode(
13354        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
13355    ) -> Result<StreamBufferSetEvent, fidl::Error> {
13356        let (bytes, _handles) = buf.split_mut();
13357        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13358        debug_assert_eq!(tx_header.tx_id, 0);
13359        match tx_header.ordinal {
13360            _ => Err(fidl::Error::UnknownOrdinal {
13361                ordinal: tx_header.ordinal,
13362                protocol_name:
13363                    <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
13364            }),
13365        }
13366    }
13367}
13368
13369/// A Stream of incoming requests for fuchsia.media/StreamBufferSet.
13370pub struct StreamBufferSetRequestStream {
13371    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13372    is_terminated: bool,
13373}
13374
13375impl std::marker::Unpin for StreamBufferSetRequestStream {}
13376
13377impl futures::stream::FusedStream for StreamBufferSetRequestStream {
13378    fn is_terminated(&self) -> bool {
13379        self.is_terminated
13380    }
13381}
13382
13383impl fidl::endpoints::RequestStream for StreamBufferSetRequestStream {
13384    type Protocol = StreamBufferSetMarker;
13385    type ControlHandle = StreamBufferSetControlHandle;
13386
13387    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
13388        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
13389    }
13390
13391    fn control_handle(&self) -> Self::ControlHandle {
13392        StreamBufferSetControlHandle { inner: self.inner.clone() }
13393    }
13394
13395    fn into_inner(
13396        self,
13397    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
13398    {
13399        (self.inner, self.is_terminated)
13400    }
13401
13402    fn from_inner(
13403        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13404        is_terminated: bool,
13405    ) -> Self {
13406        Self { inner, is_terminated }
13407    }
13408}
13409
13410impl futures::Stream for StreamBufferSetRequestStream {
13411    type Item = Result<StreamBufferSetRequest, fidl::Error>;
13412
13413    fn poll_next(
13414        mut self: std::pin::Pin<&mut Self>,
13415        cx: &mut std::task::Context<'_>,
13416    ) -> std::task::Poll<Option<Self::Item>> {
13417        let this = &mut *self;
13418        if this.inner.check_shutdown(cx) {
13419            this.is_terminated = true;
13420            return std::task::Poll::Ready(None);
13421        }
13422        if this.is_terminated {
13423            panic!("polled StreamBufferSetRequestStream after completion");
13424        }
13425        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
13426            |bytes, handles| {
13427                match this.inner.channel().read_etc(cx, bytes, handles) {
13428                    std::task::Poll::Ready(Ok(())) => {}
13429                    std::task::Poll::Pending => return std::task::Poll::Pending,
13430                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
13431                        this.is_terminated = true;
13432                        return std::task::Poll::Ready(None);
13433                    }
13434                    std::task::Poll::Ready(Err(e)) => {
13435                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
13436                            e.into(),
13437                        ))));
13438                    }
13439                }
13440
13441                // A message has been received from the channel
13442                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13443
13444                std::task::Poll::Ready(Some(match header.ordinal {
13445                    0x3b3a37fc34fe5b56 => {
13446                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13447                        let mut req = fidl::new_empty!(
13448                            StreamBufferSetAddPayloadBufferRequest,
13449                            fidl::encoding::DefaultFuchsiaResourceDialect
13450                        );
13451                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
13452                        let control_handle =
13453                            StreamBufferSetControlHandle { inner: this.inner.clone() };
13454                        Ok(StreamBufferSetRequest::AddPayloadBuffer {
13455                            id: req.id,
13456                            payload_buffer: req.payload_buffer,
13457
13458                            control_handle,
13459                        })
13460                    }
13461                    0x5d1e4f74c3658262 => {
13462                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13463                        let mut req = fidl::new_empty!(
13464                            StreamBufferSetRemovePayloadBufferRequest,
13465                            fidl::encoding::DefaultFuchsiaResourceDialect
13466                        );
13467                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
13468                        let control_handle =
13469                            StreamBufferSetControlHandle { inner: this.inner.clone() };
13470                        Ok(StreamBufferSetRequest::RemovePayloadBuffer {
13471                            id: req.id,
13472
13473                            control_handle,
13474                        })
13475                    }
13476                    _ => Err(fidl::Error::UnknownOrdinal {
13477                        ordinal: header.ordinal,
13478                        protocol_name:
13479                            <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
13480                    }),
13481                }))
13482            },
13483        )
13484    }
13485}
13486
13487/// Manages a set of payload buffers for a stream. This interface is typically
13488/// inherited along with `StreamSink` or `StreamSource` to enable the transport
13489/// of elementary streams between clients and services.
13490#[derive(Debug)]
13491pub enum StreamBufferSetRequest {
13492    /// Adds a payload buffer to the current buffer set associated with the
13493    /// connection. A `StreamPacket` struct reference a payload buffer in the
13494    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13495    ///
13496    /// A buffer with ID `id` must not be in the current set when this method is
13497    /// invoked, otherwise the service will close the connection.
13498    AddPayloadBuffer {
13499        id: u32,
13500        payload_buffer: fidl::Vmo,
13501        control_handle: StreamBufferSetControlHandle,
13502    },
13503    /// Removes a payload buffer from the current buffer set associated with the
13504    /// connection.
13505    ///
13506    /// A buffer with ID `id` must exist in the current set when this method is
13507    /// invoked, otherwise the service will will close the connection.
13508    RemovePayloadBuffer { id: u32, control_handle: StreamBufferSetControlHandle },
13509}
13510
13511impl StreamBufferSetRequest {
13512    #[allow(irrefutable_let_patterns)]
13513    pub fn into_add_payload_buffer(self) -> Option<(u32, fidl::Vmo, StreamBufferSetControlHandle)> {
13514        if let StreamBufferSetRequest::AddPayloadBuffer { id, payload_buffer, control_handle } =
13515            self
13516        {
13517            Some((id, payload_buffer, control_handle))
13518        } else {
13519            None
13520        }
13521    }
13522
13523    #[allow(irrefutable_let_patterns)]
13524    pub fn into_remove_payload_buffer(self) -> Option<(u32, StreamBufferSetControlHandle)> {
13525        if let StreamBufferSetRequest::RemovePayloadBuffer { id, control_handle } = self {
13526            Some((id, control_handle))
13527        } else {
13528            None
13529        }
13530    }
13531
13532    /// Name of the method defined in FIDL
13533    pub fn method_name(&self) -> &'static str {
13534        match *self {
13535            StreamBufferSetRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
13536            StreamBufferSetRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
13537        }
13538    }
13539}
13540
13541#[derive(Debug, Clone)]
13542pub struct StreamBufferSetControlHandle {
13543    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13544}
13545
13546impl fidl::endpoints::ControlHandle for StreamBufferSetControlHandle {
13547    fn shutdown(&self) {
13548        self.inner.shutdown()
13549    }
13550
13551    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
13552        self.inner.shutdown_with_epitaph(status)
13553    }
13554
13555    fn is_closed(&self) -> bool {
13556        self.inner.channel().is_closed()
13557    }
13558    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
13559        self.inner.channel().on_closed()
13560    }
13561
13562    #[cfg(target_os = "fuchsia")]
13563    fn signal_peer(
13564        &self,
13565        clear_mask: zx::Signals,
13566        set_mask: zx::Signals,
13567    ) -> Result<(), zx_status::Status> {
13568        use fidl::Peered;
13569        self.inner.channel().signal_peer(clear_mask, set_mask)
13570    }
13571}
13572
13573impl StreamBufferSetControlHandle {}
13574
13575#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
13576pub struct StreamProcessorMarker;
13577
13578impl fidl::endpoints::ProtocolMarker for StreamProcessorMarker {
13579    type Proxy = StreamProcessorProxy;
13580    type RequestStream = StreamProcessorRequestStream;
13581    #[cfg(target_os = "fuchsia")]
13582    type SynchronousProxy = StreamProcessorSynchronousProxy;
13583
13584    const DEBUG_NAME: &'static str = "(anonymous) StreamProcessor";
13585}
13586
13587pub trait StreamProcessorProxyInterface: Send + Sync {
13588    fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error>;
13589    fn r#set_input_buffer_partial_settings(
13590        &self,
13591        input_settings: StreamBufferPartialSettings,
13592    ) -> Result<(), fidl::Error>;
13593    fn r#set_output_buffer_partial_settings(
13594        &self,
13595        output_settings: StreamBufferPartialSettings,
13596    ) -> Result<(), fidl::Error>;
13597    fn r#complete_output_buffer_partial_settings(
13598        &self,
13599        buffer_lifetime_ordinal: u64,
13600    ) -> Result<(), fidl::Error>;
13601    fn r#flush_end_of_stream_and_close_stream(
13602        &self,
13603        stream_lifetime_ordinal: u64,
13604    ) -> Result<(), fidl::Error>;
13605    fn r#close_current_stream(
13606        &self,
13607        stream_lifetime_ordinal: u64,
13608        release_input_buffers: bool,
13609        release_output_buffers: bool,
13610    ) -> Result<(), fidl::Error>;
13611    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
13612    fn r#sync(&self) -> Self::SyncResponseFut;
13613    fn r#recycle_output_packet(
13614        &self,
13615        available_output_packet: &PacketHeader,
13616    ) -> Result<(), fidl::Error>;
13617    fn r#queue_input_format_details(
13618        &self,
13619        stream_lifetime_ordinal: u64,
13620        format_details: &FormatDetails,
13621    ) -> Result<(), fidl::Error>;
13622    fn r#queue_input_packet(&self, packet: &Packet) -> Result<(), fidl::Error>;
13623    fn r#queue_input_end_of_stream(&self, stream_lifetime_ordinal: u64) -> Result<(), fidl::Error>;
13624}
13625#[derive(Debug)]
13626#[cfg(target_os = "fuchsia")]
13627pub struct StreamProcessorSynchronousProxy {
13628    client: fidl::client::sync::Client,
13629}
13630
13631#[cfg(target_os = "fuchsia")]
13632impl fidl::endpoints::SynchronousProxy for StreamProcessorSynchronousProxy {
13633    type Proxy = StreamProcessorProxy;
13634    type Protocol = StreamProcessorMarker;
13635
13636    fn from_channel(inner: fidl::Channel) -> Self {
13637        Self::new(inner)
13638    }
13639
13640    fn into_channel(self) -> fidl::Channel {
13641        self.client.into_channel()
13642    }
13643
13644    fn as_channel(&self) -> &fidl::Channel {
13645        self.client.as_channel()
13646    }
13647}
13648
13649#[cfg(target_os = "fuchsia")]
13650impl StreamProcessorSynchronousProxy {
13651    pub fn new(channel: fidl::Channel) -> Self {
13652        Self { client: fidl::client::sync::Client::new(channel) }
13653    }
13654
13655    pub fn into_channel(self) -> fidl::Channel {
13656        self.client.into_channel()
13657    }
13658
13659    /// Waits until an event arrives and returns it. It is safe for other
13660    /// threads to make concurrent requests while waiting for an event.
13661    pub fn wait_for_event(
13662        &self,
13663        deadline: zx::MonotonicInstant,
13664    ) -> Result<StreamProcessorEvent, fidl::Error> {
13665        StreamProcessorEvent::decode(self.client.wait_for_event::<StreamProcessorMarker>(deadline)?)
13666    }
13667
13668    /// Permit the server to use OnStreamFailed() instead of the server just
13669    /// closing the whole StreamProcessor channel on stream failure.
13670    ///
13671    /// If the server hasn't seen this message by the time a stream fails, the
13672    /// server will close the StreamProcessor channel instead of sending
13673    /// OnStreamFailed().
13674    pub fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
13675        self.client.send::<fidl::encoding::EmptyPayload>(
13676            (),
13677            0x3940929617dbf02b,
13678            fidl::encoding::DynamicFlags::empty(),
13679        )
13680    }
13681
13682    /// This is the replacement for SetInputBufferSettings().
13683    ///
13684    /// When the client is using sysmem to allocate buffers, this message is
13685    /// used instead of SetInputBufferSettings()+AddInputBuffer().  Instead, a
13686    /// single SetInputBufferPartialSettings() provides the StreamProcessor with
13687    /// the client-specified input settings and a BufferCollectionToken which
13688    /// the StreamProcessor will use to convey constraints to sysmem.  Both the
13689    /// client and the StreamProcessor will be informed of the allocated buffers
13690    /// directly by sysmem via their BufferCollection channel (not via the
13691    /// StreamProcessor channel).
13692    ///
13693    /// The client must not QueueInput...() until after sysmem informs the client
13694    /// that buffer allocation has completed and was successful.
13695    ///
13696    /// The server should be prepared to see QueueInput...() before the server
13697    /// has necessarily heard from sysmem that the buffers are allocated - the
13698    /// server must tolerate either ordering, as the QueueInput...() and
13699    /// notification of sysmem allocation completion arrive on different
13700    /// channels, so the client having heard that allocation is complete doesn't
13701    /// mean the server knows that allocation is complete yet.  However, the
13702    /// server can expect that allocation is in fact complete and can expect to
13703    /// get the allocation information from sysmem immediately upon requesting
13704    /// the information from sysmem.
13705    pub fn r#set_input_buffer_partial_settings(
13706        &self,
13707        mut input_settings: StreamBufferPartialSettings,
13708    ) -> Result<(), fidl::Error> {
13709        self.client.send::<StreamProcessorSetInputBufferPartialSettingsRequest>(
13710            (&mut input_settings,),
13711            0xb02e0663a40e4c4,
13712            fidl::encoding::DynamicFlags::empty(),
13713        )
13714    }
13715
13716    /// This is the replacement for SetOutputBufferSettings().
13717    ///
13718    /// When the client is using sysmem to allocate buffers, this message is
13719    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
13720    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
13721    /// with the client-specified output settings and a BufferCollectionToken
13722    /// which the StreamProcessor will use to convey constraints to sysmem.
13723    /// Both the client and the StreamProcessor will be informed of the
13724    /// allocated buffers directly by sysmem via their BufferCollection channel
13725    /// (not via the StreamProcessor channel).
13726    ///
13727    /// Configuring output buffers is _required_ after OnOutputConstraints() is
13728    /// received by the client with buffer_constraints_action_required true and
13729    /// stream_lifetime_ordinal equal to the client's current
13730    /// stream_lifetime_ordinal (even if there is an active stream), and is
13731    /// _permitted_ any time there is no current stream.
13732    ///
13733    /// Closing the current stream occurs on the StreamControl ordering domain,
13734    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
13735    /// subsequent Sync() completion must be received by the client before the
13736    /// client knows that there's no longer a current stream.
13737    ///
13738    /// See also CompleteOutputBufferPartialSettings().
13739    pub fn r#set_output_buffer_partial_settings(
13740        &self,
13741        mut output_settings: StreamBufferPartialSettings,
13742    ) -> Result<(), fidl::Error> {
13743        self.client.send::<StreamProcessorSetOutputBufferPartialSettingsRequest>(
13744            (&mut output_settings,),
13745            0x118bb8c819a7bbbb,
13746            fidl::encoding::DynamicFlags::empty(),
13747        )
13748    }
13749
13750    /// After SetOutputBufferPartialSettings(), the server won't send
13751    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
13752    /// OnOutputEndOfStream() until after the client sends
13753    /// CompleteOutputBufferPartialSettings().
13754    ///
13755    /// Some clients may be able to send
13756    /// CompleteOutputBufferPartialSettings() immediately after
13757    /// SetOutputBufferPartialSettings() - in that case the client needs to be
13758    /// prepared to receive output without knowing the buffer count or packet
13759    /// count yet - such clients may internally delay processing the received
13760    /// output until the client has heard from sysmem (which is when the client
13761    /// will learn the buffer count and packet count).
13762    ///
13763    /// Other clients may first wait for sysmem to allocate, prepare to receive
13764    /// output, and then send CompleteOutputBufferPartialSettings().
13765    pub fn r#complete_output_buffer_partial_settings(
13766        &self,
13767        mut buffer_lifetime_ordinal: u64,
13768    ) -> Result<(), fidl::Error> {
13769        self.client.send::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(
13770            (buffer_lifetime_ordinal,),
13771            0x50529e5c680ae3ab,
13772            fidl::encoding::DynamicFlags::empty(),
13773        )
13774    }
13775
13776    /// This message is optional.
13777    ///
13778    /// This message is only valid after QueueInputEndOfStream() for this stream.
13779    /// The stream_lifetime_ordinal input parameter must match the
13780    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
13781    /// will close the channel.
13782    ///
13783    /// A client can use this message to flush through (not discard) the last
13784    /// input data of a stream so that the stream processor server generates
13785    /// corresponding output data for all the input data before the server moves
13786    /// on to the next stream, without forcing the client to wait for
13787    /// OnOutputEndOfStream() before queueing data of another stream.
13788    ///
13789    /// The difference between QueueInputEndOfStream() and
13790    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
13791    /// from the client that there will not be any more input data for the
13792    /// stream (and this info is needed by some stream processors for the stream
13793    /// processor to ever emit the very last output data).  The
13794    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
13795    /// later completely discarding the rest of the current stream by closing
13796    /// the current stream (with or without a stream switch).  In contrast,
13797    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
13798    /// the previously-queued input data be processed including the logical
13799    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
13800    /// before moving on to any newer stream - this essentially changes the
13801    /// close-stream handling from discard to flush-through for this stream
13802    /// only.
13803    ///
13804    /// A client using this message can start providing input data for a new
13805    /// stream without that causing discard of old stream data.  That's the
13806    /// purpose of this message - to allow a client to flush through (not
13807    /// discard) the old stream's last data (instead of the default when closing
13808    /// or switching streams which is discard).
13809    ///
13810    /// Because the old stream is not done processing yet and the old stream's
13811    /// data is not being discarded, the client must be prepared to continue to
13812    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
13813    /// is done. The client will know the stream_lifetime_ordinal is done when
13814    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
13815    /// closes.
13816    pub fn r#flush_end_of_stream_and_close_stream(
13817        &self,
13818        mut stream_lifetime_ordinal: u64,
13819    ) -> Result<(), fidl::Error> {
13820        self.client.send::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(
13821            (stream_lifetime_ordinal,),
13822            0x2b62c3e26d0667e6,
13823            fidl::encoding::DynamicFlags::empty(),
13824        )
13825    }
13826
13827    /// This "closes" the current stream, leaving no current stream.  In
13828    /// addition, this message can optionally release input buffers or output
13829    /// buffers.
13830    ///
13831    /// If there has never been any active stream, the stream_lifetime_ordinal
13832    /// must be zero or the server will close the channel.  If there has been an
13833    /// active stream, the stream_lifetime_ordinal must be the most recent
13834    /// active stream whether that stream is still active or not.  Else the
13835    /// server will close the channel.
13836    ///
13837    /// Multiple of this message without any new active stream in between is not
13838    /// to be considered an error, which allows a client to use this message to
13839    /// close the current stream to stop wasting processing power on a stream the
13840    /// user no longer cares about, then later decide that buffers should be
13841    /// released and send this message again with release_input_buffers and/or
13842    /// release_output_buffers true to get the buffers released, if the client is
13843    /// interested in trying to avoid overlap in resource usage between old
13844    /// buffers and new buffers (not all clients are).
13845    ///
13846    /// See also Sync().
13847    pub fn r#close_current_stream(
13848        &self,
13849        mut stream_lifetime_ordinal: u64,
13850        mut release_input_buffers: bool,
13851        mut release_output_buffers: bool,
13852    ) -> Result<(), fidl::Error> {
13853        self.client.send::<StreamProcessorCloseCurrentStreamRequest>(
13854            (stream_lifetime_ordinal, release_input_buffers, release_output_buffers),
13855            0x1d8a67522170ca07,
13856            fidl::encoding::DynamicFlags::empty(),
13857        )
13858    }
13859
13860    /// On completion, all previous StreamProcessor calls have done what they're
13861    /// going to do server-side, _except_ for processing of data queued using
13862    /// QueueInputPacket().
13863    ///
13864    /// The main purpose of this call is to enable the client to wait until
13865    /// CloseCurrentStream() with release_input_buffers and/or
13866    /// release_output_buffers set to true to take effect, before the client
13867    /// allocates new buffers and re-sets-up input and/or output buffers.  This
13868    /// de-overlapping of resource usage can be worthwhile for media buffers
13869    /// which can consume resource types whose overall pools aren't necessarily
13870    /// vast in comparison to resources consumed.  Especially if a client is
13871    /// reconfiguring buffers multiple times.
13872    ///
13873    /// Note that Sync() prior to allocating new media buffers is not alone
13874    /// sufficient to achieve non-overlap of media buffer resource usage system
13875    /// wide, but it can be a useful part of achieving that.
13876    ///
13877    /// The Sync() transits the Output ordering domain and the StreamControl
13878    /// ordering domain, but not the InputData ordering domain.
13879    ///
13880    /// This request can be used to avoid hitting kMaxInFlightStreams which is
13881    /// presently 10.  A client that stays <= 8 in-flight streams will
13882    /// comfortably stay under the limit of 10.  While the protocol permits
13883    /// repeated SetInputBufferSettings() and the like, a client that spams the
13884    /// channel can expect that the channel will just close if the server or the
13885    /// channel itself gets too far behind.
13886    pub fn r#sync(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
13887        let _response = self.client.send_query::<
13888            fidl::encoding::EmptyPayload,
13889            fidl::encoding::EmptyPayload,
13890            StreamProcessorMarker,
13891        >(
13892            (),
13893            0x4b3e44300b0ec6aa,
13894            fidl::encoding::DynamicFlags::empty(),
13895            ___deadline,
13896        )?;
13897        Ok(_response)
13898    }
13899
13900    /// After the client is done with an output packet, the client needs to tell
13901    /// the stream processor that the output packet can be re-used for more
13902    /// output, via this method.
13903    ///
13904    /// It's not permitted to recycle an output packet that's already free with
13905    /// the stream processor server.  It's permitted but discouraged for a
13906    /// client to recycle an output packet that has been deallocated by an
13907    /// explicit or implicit output buffer de-configuration().  See
13908    /// buffer_lifetime_ordinal for more on that. A server must ignore any such
13909    /// stale RecycleOutputPacket() calls.
13910    pub fn r#recycle_output_packet(
13911        &self,
13912        mut available_output_packet: &PacketHeader,
13913    ) -> Result<(), fidl::Error> {
13914        self.client.send::<StreamProcessorRecycleOutputPacketRequest>(
13915            (available_output_packet,),
13916            0x32763632b94e0bd5,
13917            fidl::encoding::DynamicFlags::empty(),
13918        )
13919    }
13920
13921    /// If the input format details are still the same as specified during
13922    /// StreamProcessor creation, this message is unnecessary and does not need
13923    /// to be sent.
13924    ///
13925    /// If the stream doesn't exist yet, this message creates the stream.
13926    ///
13927    /// The server won't send OnOutputConstraints() until after the client has
13928    /// sent at least one QueueInput* message.
13929    ///
13930    /// All servers must permit QueueInputFormatDetails() at the start of a
13931    /// stream without failing, as long as the new format is supported by the
13932    /// StreamProcessor instance.  Technically this allows for a server to only
13933    /// support the exact input format set during StreamProcessor creation, and
13934    /// that is by design.  A client that tries to switch formats and gets a
13935    /// StreamProcessor channel failure should try again one more time with a
13936    /// fresh StreamProcessor instance created with CodecFactory using the new
13937    /// input format during creation, before giving up.
13938    ///
13939    /// These format details override the format details specified during stream
13940    /// processor creation for this stream only.  The next stream will default
13941    /// back to the format details set during stream processor creation.
13942    ///
13943    /// This message is permitted at the start of the first stream (just like at
13944    /// the start of any stream).  The format specified need not match what was
13945    /// specified during stream processor creation, but if it doesn't match, the
13946    /// StreamProcessor channel might close as described above.
13947    pub fn r#queue_input_format_details(
13948        &self,
13949        mut stream_lifetime_ordinal: u64,
13950        mut format_details: &FormatDetails,
13951    ) -> Result<(), fidl::Error> {
13952        self.client.send::<StreamProcessorQueueInputFormatDetailsRequest>(
13953            (stream_lifetime_ordinal, format_details),
13954            0x170dc0979d52231,
13955            fidl::encoding::DynamicFlags::empty(),
13956        )
13957    }
13958
13959    /// This message queues input data to the stream processor for processing.
13960    ///
13961    /// If the stream doesn't exist yet, this message creates the new stream.
13962    ///
13963    /// The server won't send OnOutputConstraints() until after the client has
13964    /// sent at least one QueueInput* message.
13965    ///
13966    /// The client must continue to deliver input data via this message even if
13967    /// the stream processor has not yet generated the first OnOutputConstraints(),
13968    /// and even if the StreamProcessor is generating OnFreeInputPacket() for
13969    /// previously-queued input packets.  The input data must continue as long
13970    /// as there are free packets to be assured that the server will ever
13971    /// generate the first OnOutputConstraints().
13972    pub fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
13973        self.client.send::<StreamProcessorQueueInputPacketRequest>(
13974            (packet,),
13975            0x47173d2652d9df3b,
13976            fidl::encoding::DynamicFlags::empty(),
13977        )
13978    }
13979
13980    /// Inform the server that all QueueInputPacket() messages for this stream
13981    /// have been sent.
13982    ///
13983    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
13984    /// or StreamProcessor channel closing), there will later be a corresponding
13985    /// OnOutputEndOfStream().
13986    ///
13987    /// The corresponding OnOutputEndOfStream() message will be generated only if
13988    /// the server finishes processing the stream before the server sees the
13989    /// client close the stream (such as by starting a new stream).  A way to
13990    /// force the server to finish the stream before closing is to use
13991    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before any
13992    /// new stream.  Another way to force the server to finish the stream before
13993    /// closing is to wait for the OnOutputEndOfStream() before taking any action
13994    /// that closes the stream.
13995    ///
13996    /// In addition to serving as an "EndOfStream" marker to make it obvious
13997    /// client-side when all input data has been processed, if a client never
13998    /// sends QueueInputEndOfStream(), no amount of waiting will necessarily
13999    /// result in all input data getting processed through to the output.  Some
14000    /// stream processors have some internally-delayed data which only gets
14001    /// pushed through by additional input data _or_ by this EndOfStream marker.
14002    /// In that sense, this message can be viewed as a flush-through at
14003    /// InputData domain level, but the flush-through only takes effect if the
14004    /// stream processor even gets that far before the stream is just closed at
14005    /// StreamControl domain level.  This message is not alone sufficient to act
14006    /// as an overall flush-through at StreamControl level. For that, send this
14007    /// message first and then send FlushEndOfStreamAndCloseStream() (at which
14008    /// point it becomes possible to queue input data for a new stream without
14009    /// causing discard of this older stream's data), or wait for the
14010    /// OnOutputEndOfStream() before closing the current stream.
14011    ///
14012    /// If a client sends QueueInputPacket(), QueueInputFormatDetails(),
14013    /// QueueInputEndOfStream() for this stream after the first
14014    /// QueueInputEndOfStream() for this stream, a server should close the
14015    /// StreamProcessor channel.
14016    pub fn r#queue_input_end_of_stream(
14017        &self,
14018        mut stream_lifetime_ordinal: u64,
14019    ) -> Result<(), fidl::Error> {
14020        self.client.send::<StreamProcessorQueueInputEndOfStreamRequest>(
14021            (stream_lifetime_ordinal,),
14022            0x2051b6ad00f20b37,
14023            fidl::encoding::DynamicFlags::empty(),
14024        )
14025    }
14026}
14027
14028#[cfg(target_os = "fuchsia")]
14029impl From<StreamProcessorSynchronousProxy> for zx::NullableHandle {
14030    fn from(value: StreamProcessorSynchronousProxy) -> Self {
14031        value.into_channel().into()
14032    }
14033}
14034
14035#[cfg(target_os = "fuchsia")]
14036impl From<fidl::Channel> for StreamProcessorSynchronousProxy {
14037    fn from(value: fidl::Channel) -> Self {
14038        Self::new(value)
14039    }
14040}
14041
14042#[cfg(target_os = "fuchsia")]
14043impl fidl::endpoints::FromClient for StreamProcessorSynchronousProxy {
14044    type Protocol = StreamProcessorMarker;
14045
14046    fn from_client(value: fidl::endpoints::ClientEnd<StreamProcessorMarker>) -> Self {
14047        Self::new(value.into_channel())
14048    }
14049}
14050
14051#[derive(Debug, Clone)]
14052pub struct StreamProcessorProxy {
14053    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
14054}
14055
14056impl fidl::endpoints::Proxy for StreamProcessorProxy {
14057    type Protocol = StreamProcessorMarker;
14058
14059    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
14060        Self::new(inner)
14061    }
14062
14063    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
14064        self.client.into_channel().map_err(|client| Self { client })
14065    }
14066
14067    fn as_channel(&self) -> &::fidl::AsyncChannel {
14068        self.client.as_channel()
14069    }
14070}
14071
14072impl StreamProcessorProxy {
14073    /// Create a new Proxy for fuchsia.media/StreamProcessor.
14074    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
14075        let protocol_name = <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
14076        Self { client: fidl::client::Client::new(channel, protocol_name) }
14077    }
14078
14079    /// Get a Stream of events from the remote end of the protocol.
14080    ///
14081    /// # Panics
14082    ///
14083    /// Panics if the event stream was already taken.
14084    pub fn take_event_stream(&self) -> StreamProcessorEventStream {
14085        StreamProcessorEventStream { event_receiver: self.client.take_event_receiver() }
14086    }
14087
14088    /// Permit the server to use OnStreamFailed() instead of the server just
14089    /// closing the whole StreamProcessor channel on stream failure.
14090    ///
14091    /// If the server hasn't seen this message by the time a stream fails, the
14092    /// server will close the StreamProcessor channel instead of sending
14093    /// OnStreamFailed().
14094    pub fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
14095        StreamProcessorProxyInterface::r#enable_on_stream_failed(self)
14096    }
14097
14098    /// This is the replacement for SetInputBufferSettings().
14099    ///
14100    /// When the client is using sysmem to allocate buffers, this message is
14101    /// used instead of SetInputBufferSettings()+AddInputBuffer().  Instead, a
14102    /// single SetInputBufferPartialSettings() provides the StreamProcessor with
14103    /// the client-specified input settings and a BufferCollectionToken which
14104    /// the StreamProcessor will use to convey constraints to sysmem.  Both the
14105    /// client and the StreamProcessor will be informed of the allocated buffers
14106    /// directly by sysmem via their BufferCollection channel (not via the
14107    /// StreamProcessor channel).
14108    ///
14109    /// The client must not QueueInput...() until after sysmem informs the client
14110    /// that buffer allocation has completed and was successful.
14111    ///
14112    /// The server should be prepared to see QueueInput...() before the server
14113    /// has necessarily heard from sysmem that the buffers are allocated - the
14114    /// server must tolerate either ordering, as the QueueInput...() and
14115    /// notification of sysmem allocation completion arrive on different
14116    /// channels, so the client having heard that allocation is complete doesn't
14117    /// mean the server knows that allocation is complete yet.  However, the
14118    /// server can expect that allocation is in fact complete and can expect to
14119    /// get the allocation information from sysmem immediately upon requesting
14120    /// the information from sysmem.
14121    pub fn r#set_input_buffer_partial_settings(
14122        &self,
14123        mut input_settings: StreamBufferPartialSettings,
14124    ) -> Result<(), fidl::Error> {
14125        StreamProcessorProxyInterface::r#set_input_buffer_partial_settings(self, input_settings)
14126    }
14127
14128    /// This is the replacement for SetOutputBufferSettings().
14129    ///
14130    /// When the client is using sysmem to allocate buffers, this message is
14131    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
14132    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
14133    /// with the client-specified output settings and a BufferCollectionToken
14134    /// which the StreamProcessor will use to convey constraints to sysmem.
14135    /// Both the client and the StreamProcessor will be informed of the
14136    /// allocated buffers directly by sysmem via their BufferCollection channel
14137    /// (not via the StreamProcessor channel).
14138    ///
14139    /// Configuring output buffers is _required_ after OnOutputConstraints() is
14140    /// received by the client with buffer_constraints_action_required true and
14141    /// stream_lifetime_ordinal equal to the client's current
14142    /// stream_lifetime_ordinal (even if there is an active stream), and is
14143    /// _permitted_ any time there is no current stream.
14144    ///
14145    /// Closing the current stream occurs on the StreamControl ordering domain,
14146    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
14147    /// subsequent Sync() completion must be received by the client before the
14148    /// client knows that there's no longer a current stream.
14149    ///
14150    /// See also CompleteOutputBufferPartialSettings().
14151    pub fn r#set_output_buffer_partial_settings(
14152        &self,
14153        mut output_settings: StreamBufferPartialSettings,
14154    ) -> Result<(), fidl::Error> {
14155        StreamProcessorProxyInterface::r#set_output_buffer_partial_settings(self, output_settings)
14156    }
14157
14158    /// After SetOutputBufferPartialSettings(), the server won't send
14159    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
14160    /// OnOutputEndOfStream() until after the client sends
14161    /// CompleteOutputBufferPartialSettings().
14162    ///
14163    /// Some clients may be able to send
14164    /// CompleteOutputBufferPartialSettings() immediately after
14165    /// SetOutputBufferPartialSettings() - in that case the client needs to be
14166    /// prepared to receive output without knowing the buffer count or packet
14167    /// count yet - such clients may internally delay processing the received
14168    /// output until the client has heard from sysmem (which is when the client
14169    /// will learn the buffer count and packet count).
14170    ///
14171    /// Other clients may first wait for sysmem to allocate, prepare to receive
14172    /// output, and then send CompleteOutputBufferPartialSettings().
14173    pub fn r#complete_output_buffer_partial_settings(
14174        &self,
14175        mut buffer_lifetime_ordinal: u64,
14176    ) -> Result<(), fidl::Error> {
14177        StreamProcessorProxyInterface::r#complete_output_buffer_partial_settings(
14178            self,
14179            buffer_lifetime_ordinal,
14180        )
14181    }
14182
14183    /// This message is optional.
14184    ///
14185    /// This message is only valid after QueueInputEndOfStream() for this stream.
14186    /// The stream_lifetime_ordinal input parameter must match the
14187    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
14188    /// will close the channel.
14189    ///
14190    /// A client can use this message to flush through (not discard) the last
14191    /// input data of a stream so that the stream processor server generates
14192    /// corresponding output data for all the input data before the server moves
14193    /// on to the next stream, without forcing the client to wait for
14194    /// OnOutputEndOfStream() before queueing data of another stream.
14195    ///
14196    /// The difference between QueueInputEndOfStream() and
14197    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
14198    /// from the client that there will not be any more input data for the
14199    /// stream (and this info is needed by some stream processors for the stream
14200    /// processor to ever emit the very last output data).  The
14201    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
14202    /// later completely discarding the rest of the current stream by closing
14203    /// the current stream (with or without a stream switch).  In contrast,
14204    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
14205    /// the previously-queued input data be processed including the logical
14206    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
14207    /// before moving on to any newer stream - this essentially changes the
14208    /// close-stream handling from discard to flush-through for this stream
14209    /// only.
14210    ///
14211    /// A client using this message can start providing input data for a new
14212    /// stream without that causing discard of old stream data.  That's the
14213    /// purpose of this message - to allow a client to flush through (not
14214    /// discard) the old stream's last data (instead of the default when closing
14215    /// or switching streams which is discard).
14216    ///
14217    /// Because the old stream is not done processing yet and the old stream's
14218    /// data is not being discarded, the client must be prepared to continue to
14219    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
14220    /// is done. The client will know the stream_lifetime_ordinal is done when
14221    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
14222    /// closes.
14223    pub fn r#flush_end_of_stream_and_close_stream(
14224        &self,
14225        mut stream_lifetime_ordinal: u64,
14226    ) -> Result<(), fidl::Error> {
14227        StreamProcessorProxyInterface::r#flush_end_of_stream_and_close_stream(
14228            self,
14229            stream_lifetime_ordinal,
14230        )
14231    }
14232
14233    /// This "closes" the current stream, leaving no current stream.  In
14234    /// addition, this message can optionally release input buffers or output
14235    /// buffers.
14236    ///
14237    /// If there has never been any active stream, the stream_lifetime_ordinal
14238    /// must be zero or the server will close the channel.  If there has been an
14239    /// active stream, the stream_lifetime_ordinal must be the most recent
14240    /// active stream whether that stream is still active or not.  Else the
14241    /// server will close the channel.
14242    ///
14243    /// Multiple of this message without any new active stream in between is not
14244    /// to be considered an error, which allows a client to use this message to
14245    /// close the current stream to stop wasting processing power on a stream the
14246    /// user no longer cares about, then later decide that buffers should be
14247    /// released and send this message again with release_input_buffers and/or
14248    /// release_output_buffers true to get the buffers released, if the client is
14249    /// interested in trying to avoid overlap in resource usage between old
14250    /// buffers and new buffers (not all clients are).
14251    ///
14252    /// See also Sync().
14253    pub fn r#close_current_stream(
14254        &self,
14255        mut stream_lifetime_ordinal: u64,
14256        mut release_input_buffers: bool,
14257        mut release_output_buffers: bool,
14258    ) -> Result<(), fidl::Error> {
14259        StreamProcessorProxyInterface::r#close_current_stream(
14260            self,
14261            stream_lifetime_ordinal,
14262            release_input_buffers,
14263            release_output_buffers,
14264        )
14265    }
14266
14267    /// On completion, all previous StreamProcessor calls have done what they're
14268    /// going to do server-side, _except_ for processing of data queued using
14269    /// QueueInputPacket().
14270    ///
14271    /// The main purpose of this call is to enable the client to wait until
14272    /// CloseCurrentStream() with release_input_buffers and/or
14273    /// release_output_buffers set to true to take effect, before the client
14274    /// allocates new buffers and re-sets-up input and/or output buffers.  This
14275    /// de-overlapping of resource usage can be worthwhile for media buffers
14276    /// which can consume resource types whose overall pools aren't necessarily
14277    /// vast in comparison to resources consumed.  Especially if a client is
14278    /// reconfiguring buffers multiple times.
14279    ///
14280    /// Note that Sync() prior to allocating new media buffers is not alone
14281    /// sufficient to achieve non-overlap of media buffer resource usage system
14282    /// wide, but it can be a useful part of achieving that.
14283    ///
14284    /// The Sync() transits the Output ordering domain and the StreamControl
14285    /// ordering domain, but not the InputData ordering domain.
14286    ///
14287    /// This request can be used to avoid hitting kMaxInFlightStreams which is
14288    /// presently 10.  A client that stays <= 8 in-flight streams will
14289    /// comfortably stay under the limit of 10.  While the protocol permits
14290    /// repeated SetInputBufferSettings() and the like, a client that spams the
14291    /// channel can expect that the channel will just close if the server or the
14292    /// channel itself gets too far behind.
14293    pub fn r#sync(
14294        &self,
14295    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
14296        StreamProcessorProxyInterface::r#sync(self)
14297    }
14298
14299    /// After the client is done with an output packet, the client needs to tell
14300    /// the stream processor that the output packet can be re-used for more
14301    /// output, via this method.
14302    ///
14303    /// It's not permitted to recycle an output packet that's already free with
14304    /// the stream processor server.  It's permitted but discouraged for a
14305    /// client to recycle an output packet that has been deallocated by an
14306    /// explicit or implicit output buffer de-configuration().  See
14307    /// buffer_lifetime_ordinal for more on that. A server must ignore any such
14308    /// stale RecycleOutputPacket() calls.
14309    pub fn r#recycle_output_packet(
14310        &self,
14311        mut available_output_packet: &PacketHeader,
14312    ) -> Result<(), fidl::Error> {
14313        StreamProcessorProxyInterface::r#recycle_output_packet(self, available_output_packet)
14314    }
14315
14316    /// If the input format details are still the same as specified during
14317    /// StreamProcessor creation, this message is unnecessary and does not need
14318    /// to be sent.
14319    ///
14320    /// If the stream doesn't exist yet, this message creates the stream.
14321    ///
14322    /// The server won't send OnOutputConstraints() until after the client has
14323    /// sent at least one QueueInput* message.
14324    ///
14325    /// All servers must permit QueueInputFormatDetails() at the start of a
14326    /// stream without failing, as long as the new format is supported by the
14327    /// StreamProcessor instance.  Technically this allows for a server to only
14328    /// support the exact input format set during StreamProcessor creation, and
14329    /// that is by design.  A client that tries to switch formats and gets a
14330    /// StreamProcessor channel failure should try again one more time with a
14331    /// fresh StreamProcessor instance created with CodecFactory using the new
14332    /// input format during creation, before giving up.
14333    ///
14334    /// These format details override the format details specified during stream
14335    /// processor creation for this stream only.  The next stream will default
14336    /// back to the format details set during stream processor creation.
14337    ///
14338    /// This message is permitted at the start of the first stream (just like at
14339    /// the start of any stream).  The format specified need not match what was
14340    /// specified during stream processor creation, but if it doesn't match, the
14341    /// StreamProcessor channel might close as described above.
14342    pub fn r#queue_input_format_details(
14343        &self,
14344        mut stream_lifetime_ordinal: u64,
14345        mut format_details: &FormatDetails,
14346    ) -> Result<(), fidl::Error> {
14347        StreamProcessorProxyInterface::r#queue_input_format_details(
14348            self,
14349            stream_lifetime_ordinal,
14350            format_details,
14351        )
14352    }
14353
14354    /// This message queues input data to the stream processor for processing.
14355    ///
14356    /// If the stream doesn't exist yet, this message creates the new stream.
14357    ///
14358    /// The server won't send OnOutputConstraints() until after the client has
14359    /// sent at least one QueueInput* message.
14360    ///
14361    /// The client must continue to deliver input data via this message even if
14362    /// the stream processor has not yet generated the first OnOutputConstraints(),
14363    /// and even if the StreamProcessor is generating OnFreeInputPacket() for
14364    /// previously-queued input packets.  The input data must continue as long
14365    /// as there are free packets to be assured that the server will ever
14366    /// generate the first OnOutputConstraints().
14367    pub fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
14368        StreamProcessorProxyInterface::r#queue_input_packet(self, packet)
14369    }
14370
14371    /// Inform the server that all QueueInputPacket() messages for this stream
14372    /// have been sent.
14373    ///
14374    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
14375    /// or StreamProcessor channel closing), there will later be a corresponding
14376    /// OnOutputEndOfStream().
14377    ///
14378    /// The corresponding OnOutputEndOfStream() message will be generated only if
14379    /// the server finishes processing the stream before the server sees the
14380    /// client close the stream (such as by starting a new stream).  A way to
14381    /// force the server to finish the stream before closing is to use
14382    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before any
14383    /// new stream.  Another way to force the server to finish the stream before
14384    /// closing is to wait for the OnOutputEndOfStream() before taking any action
14385    /// that closes the stream.
14386    ///
14387    /// In addition to serving as an "EndOfStream" marker to make it obvious
14388    /// client-side when all input data has been processed, if a client never
14389    /// sends QueueInputEndOfStream(), no amount of waiting will necessarily
14390    /// result in all input data getting processed through to the output.  Some
14391    /// stream processors have some internally-delayed data which only gets
14392    /// pushed through by additional input data _or_ by this EndOfStream marker.
14393    /// In that sense, this message can be viewed as a flush-through at
14394    /// InputData domain level, but the flush-through only takes effect if the
14395    /// stream processor even gets that far before the stream is just closed at
14396    /// StreamControl domain level.  This message is not alone sufficient to act
14397    /// as an overall flush-through at StreamControl level. For that, send this
14398    /// message first and then send FlushEndOfStreamAndCloseStream() (at which
14399    /// point it becomes possible to queue input data for a new stream without
14400    /// causing discard of this older stream's data), or wait for the
14401    /// OnOutputEndOfStream() before closing the current stream.
14402    ///
14403    /// If a client sends QueueInputPacket(), QueueInputFormatDetails(),
14404    /// QueueInputEndOfStream() for this stream after the first
14405    /// QueueInputEndOfStream() for this stream, a server should close the
14406    /// StreamProcessor channel.
14407    pub fn r#queue_input_end_of_stream(
14408        &self,
14409        mut stream_lifetime_ordinal: u64,
14410    ) -> Result<(), fidl::Error> {
14411        StreamProcessorProxyInterface::r#queue_input_end_of_stream(self, stream_lifetime_ordinal)
14412    }
14413}
14414
14415impl StreamProcessorProxyInterface for StreamProcessorProxy {
14416    fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
14417        self.client.send::<fidl::encoding::EmptyPayload>(
14418            (),
14419            0x3940929617dbf02b,
14420            fidl::encoding::DynamicFlags::empty(),
14421        )
14422    }
14423
14424    fn r#set_input_buffer_partial_settings(
14425        &self,
14426        mut input_settings: StreamBufferPartialSettings,
14427    ) -> Result<(), fidl::Error> {
14428        self.client.send::<StreamProcessorSetInputBufferPartialSettingsRequest>(
14429            (&mut input_settings,),
14430            0xb02e0663a40e4c4,
14431            fidl::encoding::DynamicFlags::empty(),
14432        )
14433    }
14434
14435    fn r#set_output_buffer_partial_settings(
14436        &self,
14437        mut output_settings: StreamBufferPartialSettings,
14438    ) -> Result<(), fidl::Error> {
14439        self.client.send::<StreamProcessorSetOutputBufferPartialSettingsRequest>(
14440            (&mut output_settings,),
14441            0x118bb8c819a7bbbb,
14442            fidl::encoding::DynamicFlags::empty(),
14443        )
14444    }
14445
14446    fn r#complete_output_buffer_partial_settings(
14447        &self,
14448        mut buffer_lifetime_ordinal: u64,
14449    ) -> Result<(), fidl::Error> {
14450        self.client.send::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(
14451            (buffer_lifetime_ordinal,),
14452            0x50529e5c680ae3ab,
14453            fidl::encoding::DynamicFlags::empty(),
14454        )
14455    }
14456
14457    fn r#flush_end_of_stream_and_close_stream(
14458        &self,
14459        mut stream_lifetime_ordinal: u64,
14460    ) -> Result<(), fidl::Error> {
14461        self.client.send::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(
14462            (stream_lifetime_ordinal,),
14463            0x2b62c3e26d0667e6,
14464            fidl::encoding::DynamicFlags::empty(),
14465        )
14466    }
14467
14468    fn r#close_current_stream(
14469        &self,
14470        mut stream_lifetime_ordinal: u64,
14471        mut release_input_buffers: bool,
14472        mut release_output_buffers: bool,
14473    ) -> Result<(), fidl::Error> {
14474        self.client.send::<StreamProcessorCloseCurrentStreamRequest>(
14475            (stream_lifetime_ordinal, release_input_buffers, release_output_buffers),
14476            0x1d8a67522170ca07,
14477            fidl::encoding::DynamicFlags::empty(),
14478        )
14479    }
14480
14481    type SyncResponseFut =
14482        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
14483    fn r#sync(&self) -> Self::SyncResponseFut {
14484        fn _decode(
14485            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
14486        ) -> Result<(), fidl::Error> {
14487            let _response = fidl::client::decode_transaction_body::<
14488                fidl::encoding::EmptyPayload,
14489                fidl::encoding::DefaultFuchsiaResourceDialect,
14490                0x4b3e44300b0ec6aa,
14491            >(_buf?)?;
14492            Ok(_response)
14493        }
14494        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
14495            (),
14496            0x4b3e44300b0ec6aa,
14497            fidl::encoding::DynamicFlags::empty(),
14498            _decode,
14499        )
14500    }
14501
14502    fn r#recycle_output_packet(
14503        &self,
14504        mut available_output_packet: &PacketHeader,
14505    ) -> Result<(), fidl::Error> {
14506        self.client.send::<StreamProcessorRecycleOutputPacketRequest>(
14507            (available_output_packet,),
14508            0x32763632b94e0bd5,
14509            fidl::encoding::DynamicFlags::empty(),
14510        )
14511    }
14512
14513    fn r#queue_input_format_details(
14514        &self,
14515        mut stream_lifetime_ordinal: u64,
14516        mut format_details: &FormatDetails,
14517    ) -> Result<(), fidl::Error> {
14518        self.client.send::<StreamProcessorQueueInputFormatDetailsRequest>(
14519            (stream_lifetime_ordinal, format_details),
14520            0x170dc0979d52231,
14521            fidl::encoding::DynamicFlags::empty(),
14522        )
14523    }
14524
14525    fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
14526        self.client.send::<StreamProcessorQueueInputPacketRequest>(
14527            (packet,),
14528            0x47173d2652d9df3b,
14529            fidl::encoding::DynamicFlags::empty(),
14530        )
14531    }
14532
14533    fn r#queue_input_end_of_stream(
14534        &self,
14535        mut stream_lifetime_ordinal: u64,
14536    ) -> Result<(), fidl::Error> {
14537        self.client.send::<StreamProcessorQueueInputEndOfStreamRequest>(
14538            (stream_lifetime_ordinal,),
14539            0x2051b6ad00f20b37,
14540            fidl::encoding::DynamicFlags::empty(),
14541        )
14542    }
14543}
14544
14545pub struct StreamProcessorEventStream {
14546    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
14547}
14548
14549impl std::marker::Unpin for StreamProcessorEventStream {}
14550
14551impl futures::stream::FusedStream for StreamProcessorEventStream {
14552    fn is_terminated(&self) -> bool {
14553        self.event_receiver.is_terminated()
14554    }
14555}
14556
14557impl futures::Stream for StreamProcessorEventStream {
14558    type Item = Result<StreamProcessorEvent, fidl::Error>;
14559
14560    fn poll_next(
14561        mut self: std::pin::Pin<&mut Self>,
14562        cx: &mut std::task::Context<'_>,
14563    ) -> std::task::Poll<Option<Self::Item>> {
14564        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
14565            &mut self.event_receiver,
14566            cx
14567        )?) {
14568            Some(buf) => std::task::Poll::Ready(Some(StreamProcessorEvent::decode(buf))),
14569            None => std::task::Poll::Ready(None),
14570        }
14571    }
14572}
14573
14574#[derive(Debug)]
14575pub enum StreamProcessorEvent {
14576    OnStreamFailed {
14577        stream_lifetime_ordinal: u64,
14578        error: StreamError,
14579    },
14580    OnInputConstraints {
14581        input_constraints: StreamBufferConstraints,
14582    },
14583    OnOutputConstraints {
14584        output_config: StreamOutputConstraints,
14585    },
14586    OnOutputFormat {
14587        output_format: StreamOutputFormat,
14588    },
14589    OnOutputPacket {
14590        output_packet: Packet,
14591        error_detected_before: bool,
14592        error_detected_during: bool,
14593    },
14594    OnOutputEndOfStream {
14595        stream_lifetime_ordinal: u64,
14596        error_detected_before: bool,
14597    },
14598    OnFreeInputPacket {
14599        free_input_packet: PacketHeader,
14600    },
14601    #[non_exhaustive]
14602    _UnknownEvent {
14603        /// Ordinal of the event that was sent.
14604        ordinal: u64,
14605    },
14606}
14607
14608impl StreamProcessorEvent {
14609    #[allow(irrefutable_let_patterns)]
14610    pub fn into_on_stream_failed(self) -> Option<(u64, StreamError)> {
14611        if let StreamProcessorEvent::OnStreamFailed { stream_lifetime_ordinal, error } = self {
14612            Some((stream_lifetime_ordinal, error))
14613        } else {
14614            None
14615        }
14616    }
14617    #[allow(irrefutable_let_patterns)]
14618    pub fn into_on_input_constraints(self) -> Option<StreamBufferConstraints> {
14619        if let StreamProcessorEvent::OnInputConstraints { input_constraints } = self {
14620            Some((input_constraints))
14621        } else {
14622            None
14623        }
14624    }
14625    #[allow(irrefutable_let_patterns)]
14626    pub fn into_on_output_constraints(self) -> Option<StreamOutputConstraints> {
14627        if let StreamProcessorEvent::OnOutputConstraints { output_config } = self {
14628            Some((output_config))
14629        } else {
14630            None
14631        }
14632    }
14633    #[allow(irrefutable_let_patterns)]
14634    pub fn into_on_output_format(self) -> Option<StreamOutputFormat> {
14635        if let StreamProcessorEvent::OnOutputFormat { output_format } = self {
14636            Some((output_format))
14637        } else {
14638            None
14639        }
14640    }
14641    #[allow(irrefutable_let_patterns)]
14642    pub fn into_on_output_packet(self) -> Option<(Packet, bool, bool)> {
14643        if let StreamProcessorEvent::OnOutputPacket {
14644            output_packet,
14645            error_detected_before,
14646            error_detected_during,
14647        } = self
14648        {
14649            Some((output_packet, error_detected_before, error_detected_during))
14650        } else {
14651            None
14652        }
14653    }
14654    #[allow(irrefutable_let_patterns)]
14655    pub fn into_on_output_end_of_stream(self) -> Option<(u64, bool)> {
14656        if let StreamProcessorEvent::OnOutputEndOfStream {
14657            stream_lifetime_ordinal,
14658            error_detected_before,
14659        } = self
14660        {
14661            Some((stream_lifetime_ordinal, error_detected_before))
14662        } else {
14663            None
14664        }
14665    }
14666    #[allow(irrefutable_let_patterns)]
14667    pub fn into_on_free_input_packet(self) -> Option<PacketHeader> {
14668        if let StreamProcessorEvent::OnFreeInputPacket { free_input_packet } = self {
14669            Some((free_input_packet))
14670        } else {
14671            None
14672        }
14673    }
14674
14675    /// Decodes a message buffer as a [`StreamProcessorEvent`].
14676    fn decode(
14677        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
14678    ) -> Result<StreamProcessorEvent, fidl::Error> {
14679        let (bytes, _handles) = buf.split_mut();
14680        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14681        debug_assert_eq!(tx_header.tx_id, 0);
14682        match tx_header.ordinal {
14683            0x77ccf70bb061cf8e => {
14684                let mut out = fidl::new_empty!(
14685                    StreamProcessorOnStreamFailedRequest,
14686                    fidl::encoding::DefaultFuchsiaResourceDialect
14687                );
14688                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnStreamFailedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14689                Ok((StreamProcessorEvent::OnStreamFailed {
14690                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
14691                    error: out.error,
14692                }))
14693            }
14694            0x211da9966a8ca0 => {
14695                let mut out = fidl::new_empty!(
14696                    StreamProcessorOnInputConstraintsRequest,
14697                    fidl::encoding::DefaultFuchsiaResourceDialect
14698                );
14699                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnInputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14700                Ok((StreamProcessorEvent::OnInputConstraints {
14701                    input_constraints: out.input_constraints,
14702                }))
14703            }
14704            0x40d8234504c170f3 => {
14705                let mut out = fidl::new_empty!(
14706                    StreamProcessorOnOutputConstraintsRequest,
14707                    fidl::encoding::DefaultFuchsiaResourceDialect
14708                );
14709                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14710                Ok((StreamProcessorEvent::OnOutputConstraints { output_config: out.output_config }))
14711            }
14712            0x131b77ae120360bc => {
14713                let mut out = fidl::new_empty!(
14714                    StreamProcessorOnOutputFormatRequest,
14715                    fidl::encoding::DefaultFuchsiaResourceDialect
14716                );
14717                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputFormatRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14718                Ok((StreamProcessorEvent::OnOutputFormat { output_format: out.output_format }))
14719            }
14720            0x5c2029be1090ce93 => {
14721                let mut out = fidl::new_empty!(
14722                    StreamProcessorOnOutputPacketRequest,
14723                    fidl::encoding::DefaultFuchsiaResourceDialect
14724                );
14725                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14726                Ok((StreamProcessorEvent::OnOutputPacket {
14727                    output_packet: out.output_packet,
14728                    error_detected_before: out.error_detected_before,
14729                    error_detected_during: out.error_detected_during,
14730                }))
14731            }
14732            0x3bb65d237cfa50e6 => {
14733                let mut out = fidl::new_empty!(
14734                    StreamProcessorOnOutputEndOfStreamRequest,
14735                    fidl::encoding::DefaultFuchsiaResourceDialect
14736                );
14737                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputEndOfStreamRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14738                Ok((StreamProcessorEvent::OnOutputEndOfStream {
14739                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
14740                    error_detected_before: out.error_detected_before,
14741                }))
14742            }
14743            0xeef799b28708bbd => {
14744                let mut out = fidl::new_empty!(
14745                    StreamProcessorOnFreeInputPacketRequest,
14746                    fidl::encoding::DefaultFuchsiaResourceDialect
14747                );
14748                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnFreeInputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14749                Ok((StreamProcessorEvent::OnFreeInputPacket {
14750                    free_input_packet: out.free_input_packet,
14751                }))
14752            }
14753            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
14754                Ok(StreamProcessorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
14755            }
14756            _ => Err(fidl::Error::UnknownOrdinal {
14757                ordinal: tx_header.ordinal,
14758                protocol_name:
14759                    <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
14760            }),
14761        }
14762    }
14763}
14764
14765/// A Stream of incoming requests for fuchsia.media/StreamProcessor.
14766pub struct StreamProcessorRequestStream {
14767    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
14768    is_terminated: bool,
14769}
14770
14771impl std::marker::Unpin for StreamProcessorRequestStream {}
14772
14773impl futures::stream::FusedStream for StreamProcessorRequestStream {
14774    fn is_terminated(&self) -> bool {
14775        self.is_terminated
14776    }
14777}
14778
14779impl fidl::endpoints::RequestStream for StreamProcessorRequestStream {
14780    type Protocol = StreamProcessorMarker;
14781    type ControlHandle = StreamProcessorControlHandle;
14782
14783    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
14784        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
14785    }
14786
14787    fn control_handle(&self) -> Self::ControlHandle {
14788        StreamProcessorControlHandle { inner: self.inner.clone() }
14789    }
14790
14791    fn into_inner(
14792        self,
14793    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
14794    {
14795        (self.inner, self.is_terminated)
14796    }
14797
14798    fn from_inner(
14799        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
14800        is_terminated: bool,
14801    ) -> Self {
14802        Self { inner, is_terminated }
14803    }
14804}
14805
14806impl futures::Stream for StreamProcessorRequestStream {
14807    type Item = Result<StreamProcessorRequest, fidl::Error>;
14808
14809    fn poll_next(
14810        mut self: std::pin::Pin<&mut Self>,
14811        cx: &mut std::task::Context<'_>,
14812    ) -> std::task::Poll<Option<Self::Item>> {
14813        let this = &mut *self;
14814        if this.inner.check_shutdown(cx) {
14815            this.is_terminated = true;
14816            return std::task::Poll::Ready(None);
14817        }
14818        if this.is_terminated {
14819            panic!("polled StreamProcessorRequestStream after completion");
14820        }
14821        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
14822            |bytes, handles| {
14823                match this.inner.channel().read_etc(cx, bytes, handles) {
14824                    std::task::Poll::Ready(Ok(())) => {}
14825                    std::task::Poll::Pending => return std::task::Poll::Pending,
14826                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
14827                        this.is_terminated = true;
14828                        return std::task::Poll::Ready(None);
14829                    }
14830                    std::task::Poll::Ready(Err(e)) => {
14831                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
14832                            e.into(),
14833                        ))));
14834                    }
14835                }
14836
14837                // A message has been received from the channel
14838                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14839
14840                std::task::Poll::Ready(Some(match header.ordinal {
14841                    0x3940929617dbf02b => {
14842                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14843                        let mut req = fidl::new_empty!(
14844                            fidl::encoding::EmptyPayload,
14845                            fidl::encoding::DefaultFuchsiaResourceDialect
14846                        );
14847                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
14848                        let control_handle =
14849                            StreamProcessorControlHandle { inner: this.inner.clone() };
14850                        Ok(StreamProcessorRequest::EnableOnStreamFailed { control_handle })
14851                    }
14852                    0xb02e0663a40e4c4 => {
14853                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14854                        let mut req = fidl::new_empty!(
14855                            StreamProcessorSetInputBufferPartialSettingsRequest,
14856                            fidl::encoding::DefaultFuchsiaResourceDialect
14857                        );
14858                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorSetInputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
14859                        let control_handle =
14860                            StreamProcessorControlHandle { inner: this.inner.clone() };
14861                        Ok(StreamProcessorRequest::SetInputBufferPartialSettings {
14862                            input_settings: req.input_settings,
14863
14864                            control_handle,
14865                        })
14866                    }
14867                    0x118bb8c819a7bbbb => {
14868                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14869                        let mut req = fidl::new_empty!(
14870                            StreamProcessorSetOutputBufferPartialSettingsRequest,
14871                            fidl::encoding::DefaultFuchsiaResourceDialect
14872                        );
14873                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorSetOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
14874                        let control_handle =
14875                            StreamProcessorControlHandle { inner: this.inner.clone() };
14876                        Ok(StreamProcessorRequest::SetOutputBufferPartialSettings {
14877                            output_settings: req.output_settings,
14878
14879                            control_handle,
14880                        })
14881                    }
14882                    0x50529e5c680ae3ab => {
14883                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14884                        let mut req = fidl::new_empty!(
14885                            StreamProcessorCompleteOutputBufferPartialSettingsRequest,
14886                            fidl::encoding::DefaultFuchsiaResourceDialect
14887                        );
14888                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
14889                        let control_handle =
14890                            StreamProcessorControlHandle { inner: this.inner.clone() };
14891                        Ok(StreamProcessorRequest::CompleteOutputBufferPartialSettings {
14892                            buffer_lifetime_ordinal: req.buffer_lifetime_ordinal,
14893
14894                            control_handle,
14895                        })
14896                    }
14897                    0x2b62c3e26d0667e6 => {
14898                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14899                        let mut req = fidl::new_empty!(
14900                            StreamProcessorFlushEndOfStreamAndCloseStreamRequest,
14901                            fidl::encoding::DefaultFuchsiaResourceDialect
14902                        );
14903                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(&header, _body_bytes, handles, &mut req)?;
14904                        let control_handle =
14905                            StreamProcessorControlHandle { inner: this.inner.clone() };
14906                        Ok(StreamProcessorRequest::FlushEndOfStreamAndCloseStream {
14907                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
14908
14909                            control_handle,
14910                        })
14911                    }
14912                    0x1d8a67522170ca07 => {
14913                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14914                        let mut req = fidl::new_empty!(
14915                            StreamProcessorCloseCurrentStreamRequest,
14916                            fidl::encoding::DefaultFuchsiaResourceDialect
14917                        );
14918                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorCloseCurrentStreamRequest>(&header, _body_bytes, handles, &mut req)?;
14919                        let control_handle =
14920                            StreamProcessorControlHandle { inner: this.inner.clone() };
14921                        Ok(StreamProcessorRequest::CloseCurrentStream {
14922                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
14923                            release_input_buffers: req.release_input_buffers,
14924                            release_output_buffers: req.release_output_buffers,
14925
14926                            control_handle,
14927                        })
14928                    }
14929                    0x4b3e44300b0ec6aa => {
14930                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
14931                        let mut req = fidl::new_empty!(
14932                            fidl::encoding::EmptyPayload,
14933                            fidl::encoding::DefaultFuchsiaResourceDialect
14934                        );
14935                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
14936                        let control_handle =
14937                            StreamProcessorControlHandle { inner: this.inner.clone() };
14938                        Ok(StreamProcessorRequest::Sync {
14939                            responder: StreamProcessorSyncResponder {
14940                                control_handle: std::mem::ManuallyDrop::new(control_handle),
14941                                tx_id: header.tx_id,
14942                            },
14943                        })
14944                    }
14945                    0x32763632b94e0bd5 => {
14946                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14947                        let mut req = fidl::new_empty!(
14948                            StreamProcessorRecycleOutputPacketRequest,
14949                            fidl::encoding::DefaultFuchsiaResourceDialect
14950                        );
14951                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorRecycleOutputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
14952                        let control_handle =
14953                            StreamProcessorControlHandle { inner: this.inner.clone() };
14954                        Ok(StreamProcessorRequest::RecycleOutputPacket {
14955                            available_output_packet: req.available_output_packet,
14956
14957                            control_handle,
14958                        })
14959                    }
14960                    0x170dc0979d52231 => {
14961                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14962                        let mut req = fidl::new_empty!(
14963                            StreamProcessorQueueInputFormatDetailsRequest,
14964                            fidl::encoding::DefaultFuchsiaResourceDialect
14965                        );
14966                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputFormatDetailsRequest>(&header, _body_bytes, handles, &mut req)?;
14967                        let control_handle =
14968                            StreamProcessorControlHandle { inner: this.inner.clone() };
14969                        Ok(StreamProcessorRequest::QueueInputFormatDetails {
14970                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
14971                            format_details: req.format_details,
14972
14973                            control_handle,
14974                        })
14975                    }
14976                    0x47173d2652d9df3b => {
14977                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14978                        let mut req = fidl::new_empty!(
14979                            StreamProcessorQueueInputPacketRequest,
14980                            fidl::encoding::DefaultFuchsiaResourceDialect
14981                        );
14982                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
14983                        let control_handle =
14984                            StreamProcessorControlHandle { inner: this.inner.clone() };
14985                        Ok(StreamProcessorRequest::QueueInputPacket {
14986                            packet: req.packet,
14987
14988                            control_handle,
14989                        })
14990                    }
14991                    0x2051b6ad00f20b37 => {
14992                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14993                        let mut req = fidl::new_empty!(
14994                            StreamProcessorQueueInputEndOfStreamRequest,
14995                            fidl::encoding::DefaultFuchsiaResourceDialect
14996                        );
14997                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputEndOfStreamRequest>(&header, _body_bytes, handles, &mut req)?;
14998                        let control_handle =
14999                            StreamProcessorControlHandle { inner: this.inner.clone() };
15000                        Ok(StreamProcessorRequest::QueueInputEndOfStream {
15001                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
15002
15003                            control_handle,
15004                        })
15005                    }
15006                    _ if header.tx_id == 0
15007                        && header
15008                            .dynamic_flags()
15009                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
15010                    {
15011                        Ok(StreamProcessorRequest::_UnknownMethod {
15012                            ordinal: header.ordinal,
15013                            control_handle: StreamProcessorControlHandle {
15014                                inner: this.inner.clone(),
15015                            },
15016                            method_type: fidl::MethodType::OneWay,
15017                        })
15018                    }
15019                    _ if header
15020                        .dynamic_flags()
15021                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
15022                    {
15023                        this.inner.send_framework_err(
15024                            fidl::encoding::FrameworkErr::UnknownMethod,
15025                            header.tx_id,
15026                            header.ordinal,
15027                            header.dynamic_flags(),
15028                            (bytes, handles),
15029                        )?;
15030                        Ok(StreamProcessorRequest::_UnknownMethod {
15031                            ordinal: header.ordinal,
15032                            control_handle: StreamProcessorControlHandle {
15033                                inner: this.inner.clone(),
15034                            },
15035                            method_type: fidl::MethodType::TwoWay,
15036                        })
15037                    }
15038                    _ => Err(fidl::Error::UnknownOrdinal {
15039                        ordinal: header.ordinal,
15040                        protocol_name:
15041                            <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
15042                    }),
15043                }))
15044            },
15045        )
15046    }
15047}
15048
15049/// Overview of operation:
15050///
15051/// 1. Create
15052///   * create via CodecFactory - see CodecFactory
15053///   * create via LicenseSession - see LicenseSession
15054/// 2. Get input constraints
15055///   * OnInputConstraints() - sent unsolicited by stream processor shortly after
15056///     stream processor creation.
15057/// 3. Provide input buffers
15058///   * SetInputBufferPartialSettings()
15059/// 4. Deliver input data
15060///   * QueueInputPacket() + OnFreeInputPacket(), for as long as it takes,
15061///     possibly working through all input packets repeatedly before...
15062/// 5. Get output constraints and format
15063///   * OnOutputConstraints()
15064///   * This is not sent until after at least one QueueInput* message is sent by
15065///     the client, even if the underlying processor behind the StreamProcessor
15066///     doesn't fundamentally need any input data to determine its output
15067///     constraints.  This server behavior prevents clients taking an incorrect
15068///     dependency on the output constraints showing up before input is
15069///     delivered.
15070///   * A client must tolerate this arriving as late as after substantial input
15071///     data has been delivered, including lots of input packet recycling via
15072///     OnFreeInputPacket().
15073///   * This message can arrive more than once before the first output data.
15074/// 6. Provide output buffers
15075///   * SetOutputBufferPartialSettings() / CompleteOutputBufferPartialSettings()
15076/// 7. Data flows, with optional EndOfStream
15077///   * OnOutputPacket() / RecycleOutputPacket() / QueueInputPacket() /
15078///     OnFreeInputPacket() / QueueInputEndOfStream() / OnOutputEndOfStream()
15079///
15080/// Semi-trusted StreamProcessor server - SW decoders run in an isolate (with
15081/// very few capabilities) just in case the decoding SW has a vulnerability
15082/// which could be used to take over the StreamProcessor server.  Clients of the
15083/// stream processor interface using decoders and processing streams of separate
15084/// security contexts, to a greater extent than some other interfaces, need to
15085/// protect themselves against invalid server behavior, such as double-free of a
15086/// packet_index and any other invalid server behavior.  Having fed in
15087/// compressed data of one security context, don't place too much trust in a
15088/// single StreamProcessor instance to not mix data among any buffers that
15089/// StreamProcessor server has ever been told about.  Instead, create separate
15090/// StreamProcessor instances for use by security-separate client-side contexts.
15091/// While the picture for HW-based decoders looks somewhat different and is out
15092/// of scope of this paragraph, the client should always use separate
15093/// StreamProcessor instances for security-separate client-side contexts.
15094///
15095/// Descriptions of actions taken by methods of this protocol and the states of
15096/// things are given as if the methods are synchronously executed by the stream
15097/// processor server, but in reality, as is typical of FIDL interfaces, the
15098/// message processing is async.  The states described are to be read as the
15099/// state from the client's point of view unless otherwise stated.  Events
15100/// coming back from the server are of course delivered async, and a client that
15101/// processes more than one stream per StreamProcessor instance needs to care
15102/// whether a given event is from the current stream vs. some older
15103/// soon-to-be-gone stream.
15104///
15105/// The Sync() method's main purpose is to enable the client to robustly prevent
15106/// having both old and new buffers allocated in the system at the same time,
15107/// since media buffers can be significantly large, depending. The Sync() method
15108/// achieves this by only delivering it's response when all previous calls to
15109/// the StreamProcessor protocol have actually taken effect in the
15110/// StreamControl ordering domain. Sync() can also be used to wait for the
15111/// stream processor server to catch up if there's a possibility that a client
15112/// might otherwise get too far ahead of the StreamProcessor server, by for
15113/// example requesting creation of a large number of streams in a row.  It can
15114/// also be used during debugging to ensure that a stream processor server
15115/// hasn't gotten stuck.  Calling Sync() is entirely optional and never required
15116/// for correctness - only potentially required to de-overlap resource usage.
15117///
15118/// It's possible to re-use a StreamProcessor instance for another stream, and
15119/// doing so can sometimes skip over re-allocation of buffers. This can be a
15120/// useful thing to do for cases like seeking to a new location - at the
15121/// StreamProcessor interface that can look like switching to a new stream.
15122#[derive(Debug)]
15123pub enum StreamProcessorRequest {
15124    /// Permit the server to use OnStreamFailed() instead of the server just
15125    /// closing the whole StreamProcessor channel on stream failure.
15126    ///
15127    /// If the server hasn't seen this message by the time a stream fails, the
15128    /// server will close the StreamProcessor channel instead of sending
15129    /// OnStreamFailed().
15130    EnableOnStreamFailed { control_handle: StreamProcessorControlHandle },
15131    /// This is the replacement for SetInputBufferSettings().
15132    ///
15133    /// When the client is using sysmem to allocate buffers, this message is
15134    /// used instead of SetInputBufferSettings()+AddInputBuffer().  Instead, a
15135    /// single SetInputBufferPartialSettings() provides the StreamProcessor with
15136    /// the client-specified input settings and a BufferCollectionToken which
15137    /// the StreamProcessor will use to convey constraints to sysmem.  Both the
15138    /// client and the StreamProcessor will be informed of the allocated buffers
15139    /// directly by sysmem via their BufferCollection channel (not via the
15140    /// StreamProcessor channel).
15141    ///
15142    /// The client must not QueueInput...() until after sysmem informs the client
15143    /// that buffer allocation has completed and was successful.
15144    ///
15145    /// The server should be prepared to see QueueInput...() before the server
15146    /// has necessarily heard from sysmem that the buffers are allocated - the
15147    /// server must tolerate either ordering, as the QueueInput...() and
15148    /// notification of sysmem allocation completion arrive on different
15149    /// channels, so the client having heard that allocation is complete doesn't
15150    /// mean the server knows that allocation is complete yet.  However, the
15151    /// server can expect that allocation is in fact complete and can expect to
15152    /// get the allocation information from sysmem immediately upon requesting
15153    /// the information from sysmem.
15154    SetInputBufferPartialSettings {
15155        input_settings: StreamBufferPartialSettings,
15156        control_handle: StreamProcessorControlHandle,
15157    },
15158    /// This is the replacement for SetOutputBufferSettings().
15159    ///
15160    /// When the client is using sysmem to allocate buffers, this message is
15161    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
15162    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
15163    /// with the client-specified output settings and a BufferCollectionToken
15164    /// which the StreamProcessor will use to convey constraints to sysmem.
15165    /// Both the client and the StreamProcessor will be informed of the
15166    /// allocated buffers directly by sysmem via their BufferCollection channel
15167    /// (not via the StreamProcessor channel).
15168    ///
15169    /// Configuring output buffers is _required_ after OnOutputConstraints() is
15170    /// received by the client with buffer_constraints_action_required true and
15171    /// stream_lifetime_ordinal equal to the client's current
15172    /// stream_lifetime_ordinal (even if there is an active stream), and is
15173    /// _permitted_ any time there is no current stream.
15174    ///
15175    /// Closing the current stream occurs on the StreamControl ordering domain,
15176    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
15177    /// subsequent Sync() completion must be received by the client before the
15178    /// client knows that there's no longer a current stream.
15179    ///
15180    /// See also CompleteOutputBufferPartialSettings().
15181    SetOutputBufferPartialSettings {
15182        output_settings: StreamBufferPartialSettings,
15183        control_handle: StreamProcessorControlHandle,
15184    },
15185    /// After SetOutputBufferPartialSettings(), the server won't send
15186    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
15187    /// OnOutputEndOfStream() until after the client sends
15188    /// CompleteOutputBufferPartialSettings().
15189    ///
15190    /// Some clients may be able to send
15191    /// CompleteOutputBufferPartialSettings() immediately after
15192    /// SetOutputBufferPartialSettings() - in that case the client needs to be
15193    /// prepared to receive output without knowing the buffer count or packet
15194    /// count yet - such clients may internally delay processing the received
15195    /// output until the client has heard from sysmem (which is when the client
15196    /// will learn the buffer count and packet count).
15197    ///
15198    /// Other clients may first wait for sysmem to allocate, prepare to receive
15199    /// output, and then send CompleteOutputBufferPartialSettings().
15200    CompleteOutputBufferPartialSettings {
15201        buffer_lifetime_ordinal: u64,
15202        control_handle: StreamProcessorControlHandle,
15203    },
15204    /// This message is optional.
15205    ///
15206    /// This message is only valid after QueueInputEndOfStream() for this stream.
15207    /// The stream_lifetime_ordinal input parameter must match the
15208    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
15209    /// will close the channel.
15210    ///
15211    /// A client can use this message to flush through (not discard) the last
15212    /// input data of a stream so that the stream processor server generates
15213    /// corresponding output data for all the input data before the server moves
15214    /// on to the next stream, without forcing the client to wait for
15215    /// OnOutputEndOfStream() before queueing data of another stream.
15216    ///
15217    /// The difference between QueueInputEndOfStream() and
15218    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
15219    /// from the client that there will not be any more input data for the
15220    /// stream (and this info is needed by some stream processors for the stream
15221    /// processor to ever emit the very last output data).  The
15222    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
15223    /// later completely discarding the rest of the current stream by closing
15224    /// the current stream (with or without a stream switch).  In contrast,
15225    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
15226    /// the previously-queued input data be processed including the logical
15227    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
15228    /// before moving on to any newer stream - this essentially changes the
15229    /// close-stream handling from discard to flush-through for this stream
15230    /// only.
15231    ///
15232    /// A client using this message can start providing input data for a new
15233    /// stream without that causing discard of old stream data.  That's the
15234    /// purpose of this message - to allow a client to flush through (not
15235    /// discard) the old stream's last data (instead of the default when closing
15236    /// or switching streams which is discard).
15237    ///
15238    /// Because the old stream is not done processing yet and the old stream's
15239    /// data is not being discarded, the client must be prepared to continue to
15240    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
15241    /// is done. The client will know the stream_lifetime_ordinal is done when
15242    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
15243    /// closes.
15244    FlushEndOfStreamAndCloseStream {
15245        stream_lifetime_ordinal: u64,
15246        control_handle: StreamProcessorControlHandle,
15247    },
15248    /// This "closes" the current stream, leaving no current stream.  In
15249    /// addition, this message can optionally release input buffers or output
15250    /// buffers.
15251    ///
15252    /// If there has never been any active stream, the stream_lifetime_ordinal
15253    /// must be zero or the server will close the channel.  If there has been an
15254    /// active stream, the stream_lifetime_ordinal must be the most recent
15255    /// active stream whether that stream is still active or not.  Else the
15256    /// server will close the channel.
15257    ///
15258    /// Multiple of this message without any new active stream in between is not
15259    /// to be considered an error, which allows a client to use this message to
15260    /// close the current stream to stop wasting processing power on a stream the
15261    /// user no longer cares about, then later decide that buffers should be
15262    /// released and send this message again with release_input_buffers and/or
15263    /// release_output_buffers true to get the buffers released, if the client is
15264    /// interested in trying to avoid overlap in resource usage between old
15265    /// buffers and new buffers (not all clients are).
15266    ///
15267    /// See also Sync().
15268    CloseCurrentStream {
15269        stream_lifetime_ordinal: u64,
15270        release_input_buffers: bool,
15271        release_output_buffers: bool,
15272        control_handle: StreamProcessorControlHandle,
15273    },
15274    /// On completion, all previous StreamProcessor calls have done what they're
15275    /// going to do server-side, _except_ for processing of data queued using
15276    /// QueueInputPacket().
15277    ///
15278    /// The main purpose of this call is to enable the client to wait until
15279    /// CloseCurrentStream() with release_input_buffers and/or
15280    /// release_output_buffers set to true to take effect, before the client
15281    /// allocates new buffers and re-sets-up input and/or output buffers.  This
15282    /// de-overlapping of resource usage can be worthwhile for media buffers
15283    /// which can consume resource types whose overall pools aren't necessarily
15284    /// vast in comparison to resources consumed.  Especially if a client is
15285    /// reconfiguring buffers multiple times.
15286    ///
15287    /// Note that Sync() prior to allocating new media buffers is not alone
15288    /// sufficient to achieve non-overlap of media buffer resource usage system
15289    /// wide, but it can be a useful part of achieving that.
15290    ///
15291    /// The Sync() transits the Output ordering domain and the StreamControl
15292    /// ordering domain, but not the InputData ordering domain.
15293    ///
15294    /// This request can be used to avoid hitting kMaxInFlightStreams which is
15295    /// presently 10.  A client that stays <= 8 in-flight streams will
15296    /// comfortably stay under the limit of 10.  While the protocol permits
15297    /// repeated SetInputBufferSettings() and the like, a client that spams the
15298    /// channel can expect that the channel will just close if the server or the
15299    /// channel itself gets too far behind.
15300    Sync { responder: StreamProcessorSyncResponder },
15301    /// After the client is done with an output packet, the client needs to tell
15302    /// the stream processor that the output packet can be re-used for more
15303    /// output, via this method.
15304    ///
15305    /// It's not permitted to recycle an output packet that's already free with
15306    /// the stream processor server.  It's permitted but discouraged for a
15307    /// client to recycle an output packet that has been deallocated by an
15308    /// explicit or implicit output buffer de-configuration().  See
15309    /// buffer_lifetime_ordinal for more on that. A server must ignore any such
15310    /// stale RecycleOutputPacket() calls.
15311    RecycleOutputPacket {
15312        available_output_packet: PacketHeader,
15313        control_handle: StreamProcessorControlHandle,
15314    },
15315    /// If the input format details are still the same as specified during
15316    /// StreamProcessor creation, this message is unnecessary and does not need
15317    /// to be sent.
15318    ///
15319    /// If the stream doesn't exist yet, this message creates the stream.
15320    ///
15321    /// The server won't send OnOutputConstraints() until after the client has
15322    /// sent at least one QueueInput* message.
15323    ///
15324    /// All servers must permit QueueInputFormatDetails() at the start of a
15325    /// stream without failing, as long as the new format is supported by the
15326    /// StreamProcessor instance.  Technically this allows for a server to only
15327    /// support the exact input format set during StreamProcessor creation, and
15328    /// that is by design.  A client that tries to switch formats and gets a
15329    /// StreamProcessor channel failure should try again one more time with a
15330    /// fresh StreamProcessor instance created with CodecFactory using the new
15331    /// input format during creation, before giving up.
15332    ///
15333    /// These format details override the format details specified during stream
15334    /// processor creation for this stream only.  The next stream will default
15335    /// back to the format details set during stream processor creation.
15336    ///
15337    /// This message is permitted at the start of the first stream (just like at
15338    /// the start of any stream).  The format specified need not match what was
15339    /// specified during stream processor creation, but if it doesn't match, the
15340    /// StreamProcessor channel might close as described above.
15341    QueueInputFormatDetails {
15342        stream_lifetime_ordinal: u64,
15343        format_details: FormatDetails,
15344        control_handle: StreamProcessorControlHandle,
15345    },
15346    /// This message queues input data to the stream processor for processing.
15347    ///
15348    /// If the stream doesn't exist yet, this message creates the new stream.
15349    ///
15350    /// The server won't send OnOutputConstraints() until after the client has
15351    /// sent at least one QueueInput* message.
15352    ///
15353    /// The client must continue to deliver input data via this message even if
15354    /// the stream processor has not yet generated the first OnOutputConstraints(),
15355    /// and even if the StreamProcessor is generating OnFreeInputPacket() for
15356    /// previously-queued input packets.  The input data must continue as long
15357    /// as there are free packets to be assured that the server will ever
15358    /// generate the first OnOutputConstraints().
15359    QueueInputPacket { packet: Packet, control_handle: StreamProcessorControlHandle },
15360    /// Inform the server that all QueueInputPacket() messages for this stream
15361    /// have been sent.
15362    ///
15363    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
15364    /// or StreamProcessor channel closing), there will later be a corresponding
15365    /// OnOutputEndOfStream().
15366    ///
15367    /// The corresponding OnOutputEndOfStream() message will be generated only if
15368    /// the server finishes processing the stream before the server sees the
15369    /// client close the stream (such as by starting a new stream).  A way to
15370    /// force the server to finish the stream before closing is to use
15371    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before any
15372    /// new stream.  Another way to force the server to finish the stream before
15373    /// closing is to wait for the OnOutputEndOfStream() before taking any action
15374    /// that closes the stream.
15375    ///
15376    /// In addition to serving as an "EndOfStream" marker to make it obvious
15377    /// client-side when all input data has been processed, if a client never
15378    /// sends QueueInputEndOfStream(), no amount of waiting will necessarily
15379    /// result in all input data getting processed through to the output.  Some
15380    /// stream processors have some internally-delayed data which only gets
15381    /// pushed through by additional input data _or_ by this EndOfStream marker.
15382    /// In that sense, this message can be viewed as a flush-through at
15383    /// InputData domain level, but the flush-through only takes effect if the
15384    /// stream processor even gets that far before the stream is just closed at
15385    /// StreamControl domain level.  This message is not alone sufficient to act
15386    /// as an overall flush-through at StreamControl level. For that, send this
15387    /// message first and then send FlushEndOfStreamAndCloseStream() (at which
15388    /// point it becomes possible to queue input data for a new stream without
15389    /// causing discard of this older stream's data), or wait for the
15390    /// OnOutputEndOfStream() before closing the current stream.
15391    ///
15392    /// If a client sends QueueInputPacket(), QueueInputFormatDetails(),
15393    /// QueueInputEndOfStream() for this stream after the first
15394    /// QueueInputEndOfStream() for this stream, a server should close the
15395    /// StreamProcessor channel.
15396    QueueInputEndOfStream {
15397        stream_lifetime_ordinal: u64,
15398        control_handle: StreamProcessorControlHandle,
15399    },
15400    /// An interaction was received which does not match any known method.
15401    #[non_exhaustive]
15402    _UnknownMethod {
15403        /// Ordinal of the method that was called.
15404        ordinal: u64,
15405        control_handle: StreamProcessorControlHandle,
15406        method_type: fidl::MethodType,
15407    },
15408}
15409
15410impl StreamProcessorRequest {
15411    #[allow(irrefutable_let_patterns)]
15412    pub fn into_enable_on_stream_failed(self) -> Option<(StreamProcessorControlHandle)> {
15413        if let StreamProcessorRequest::EnableOnStreamFailed { control_handle } = self {
15414            Some((control_handle))
15415        } else {
15416            None
15417        }
15418    }
15419
15420    #[allow(irrefutable_let_patterns)]
15421    pub fn into_set_input_buffer_partial_settings(
15422        self,
15423    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
15424        if let StreamProcessorRequest::SetInputBufferPartialSettings {
15425            input_settings,
15426            control_handle,
15427        } = self
15428        {
15429            Some((input_settings, control_handle))
15430        } else {
15431            None
15432        }
15433    }
15434
15435    #[allow(irrefutable_let_patterns)]
15436    pub fn into_set_output_buffer_partial_settings(
15437        self,
15438    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
15439        if let StreamProcessorRequest::SetOutputBufferPartialSettings {
15440            output_settings,
15441            control_handle,
15442        } = self
15443        {
15444            Some((output_settings, control_handle))
15445        } else {
15446            None
15447        }
15448    }
15449
15450    #[allow(irrefutable_let_patterns)]
15451    pub fn into_complete_output_buffer_partial_settings(
15452        self,
15453    ) -> Option<(u64, StreamProcessorControlHandle)> {
15454        if let StreamProcessorRequest::CompleteOutputBufferPartialSettings {
15455            buffer_lifetime_ordinal,
15456            control_handle,
15457        } = self
15458        {
15459            Some((buffer_lifetime_ordinal, control_handle))
15460        } else {
15461            None
15462        }
15463    }
15464
15465    #[allow(irrefutable_let_patterns)]
15466    pub fn into_flush_end_of_stream_and_close_stream(
15467        self,
15468    ) -> Option<(u64, StreamProcessorControlHandle)> {
15469        if let StreamProcessorRequest::FlushEndOfStreamAndCloseStream {
15470            stream_lifetime_ordinal,
15471            control_handle,
15472        } = self
15473        {
15474            Some((stream_lifetime_ordinal, control_handle))
15475        } else {
15476            None
15477        }
15478    }
15479
15480    #[allow(irrefutable_let_patterns)]
15481    pub fn into_close_current_stream(
15482        self,
15483    ) -> Option<(u64, bool, bool, StreamProcessorControlHandle)> {
15484        if let StreamProcessorRequest::CloseCurrentStream {
15485            stream_lifetime_ordinal,
15486            release_input_buffers,
15487            release_output_buffers,
15488            control_handle,
15489        } = self
15490        {
15491            Some((
15492                stream_lifetime_ordinal,
15493                release_input_buffers,
15494                release_output_buffers,
15495                control_handle,
15496            ))
15497        } else {
15498            None
15499        }
15500    }
15501
15502    #[allow(irrefutable_let_patterns)]
15503    pub fn into_sync(self) -> Option<(StreamProcessorSyncResponder)> {
15504        if let StreamProcessorRequest::Sync { responder } = self { Some((responder)) } else { None }
15505    }
15506
15507    #[allow(irrefutable_let_patterns)]
15508    pub fn into_recycle_output_packet(
15509        self,
15510    ) -> Option<(PacketHeader, StreamProcessorControlHandle)> {
15511        if let StreamProcessorRequest::RecycleOutputPacket {
15512            available_output_packet,
15513            control_handle,
15514        } = self
15515        {
15516            Some((available_output_packet, control_handle))
15517        } else {
15518            None
15519        }
15520    }
15521
15522    #[allow(irrefutable_let_patterns)]
15523    pub fn into_queue_input_format_details(
15524        self,
15525    ) -> Option<(u64, FormatDetails, StreamProcessorControlHandle)> {
15526        if let StreamProcessorRequest::QueueInputFormatDetails {
15527            stream_lifetime_ordinal,
15528            format_details,
15529            control_handle,
15530        } = self
15531        {
15532            Some((stream_lifetime_ordinal, format_details, control_handle))
15533        } else {
15534            None
15535        }
15536    }
15537
15538    #[allow(irrefutable_let_patterns)]
15539    pub fn into_queue_input_packet(self) -> Option<(Packet, StreamProcessorControlHandle)> {
15540        if let StreamProcessorRequest::QueueInputPacket { packet, control_handle } = self {
15541            Some((packet, control_handle))
15542        } else {
15543            None
15544        }
15545    }
15546
15547    #[allow(irrefutable_let_patterns)]
15548    pub fn into_queue_input_end_of_stream(self) -> Option<(u64, StreamProcessorControlHandle)> {
15549        if let StreamProcessorRequest::QueueInputEndOfStream {
15550            stream_lifetime_ordinal,
15551            control_handle,
15552        } = self
15553        {
15554            Some((stream_lifetime_ordinal, control_handle))
15555        } else {
15556            None
15557        }
15558    }
15559
15560    /// Name of the method defined in FIDL
15561    pub fn method_name(&self) -> &'static str {
15562        match *self {
15563            StreamProcessorRequest::EnableOnStreamFailed { .. } => "enable_on_stream_failed",
15564            StreamProcessorRequest::SetInputBufferPartialSettings { .. } => {
15565                "set_input_buffer_partial_settings"
15566            }
15567            StreamProcessorRequest::SetOutputBufferPartialSettings { .. } => {
15568                "set_output_buffer_partial_settings"
15569            }
15570            StreamProcessorRequest::CompleteOutputBufferPartialSettings { .. } => {
15571                "complete_output_buffer_partial_settings"
15572            }
15573            StreamProcessorRequest::FlushEndOfStreamAndCloseStream { .. } => {
15574                "flush_end_of_stream_and_close_stream"
15575            }
15576            StreamProcessorRequest::CloseCurrentStream { .. } => "close_current_stream",
15577            StreamProcessorRequest::Sync { .. } => "sync",
15578            StreamProcessorRequest::RecycleOutputPacket { .. } => "recycle_output_packet",
15579            StreamProcessorRequest::QueueInputFormatDetails { .. } => "queue_input_format_details",
15580            StreamProcessorRequest::QueueInputPacket { .. } => "queue_input_packet",
15581            StreamProcessorRequest::QueueInputEndOfStream { .. } => "queue_input_end_of_stream",
15582            StreamProcessorRequest::_UnknownMethod {
15583                method_type: fidl::MethodType::OneWay,
15584                ..
15585            } => "unknown one-way method",
15586            StreamProcessorRequest::_UnknownMethod {
15587                method_type: fidl::MethodType::TwoWay,
15588                ..
15589            } => "unknown two-way method",
15590        }
15591    }
15592}
15593
15594#[derive(Debug, Clone)]
15595pub struct StreamProcessorControlHandle {
15596    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
15597}
15598
15599impl fidl::endpoints::ControlHandle for StreamProcessorControlHandle {
15600    fn shutdown(&self) {
15601        self.inner.shutdown()
15602    }
15603
15604    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
15605        self.inner.shutdown_with_epitaph(status)
15606    }
15607
15608    fn is_closed(&self) -> bool {
15609        self.inner.channel().is_closed()
15610    }
15611    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
15612        self.inner.channel().on_closed()
15613    }
15614
15615    #[cfg(target_os = "fuchsia")]
15616    fn signal_peer(
15617        &self,
15618        clear_mask: zx::Signals,
15619        set_mask: zx::Signals,
15620    ) -> Result<(), zx_status::Status> {
15621        use fidl::Peered;
15622        self.inner.channel().signal_peer(clear_mask, set_mask)
15623    }
15624}
15625
15626impl StreamProcessorControlHandle {
15627    pub fn send_on_stream_failed(
15628        &self,
15629        mut stream_lifetime_ordinal: u64,
15630        mut error: StreamError,
15631    ) -> Result<(), fidl::Error> {
15632        self.inner.send::<StreamProcessorOnStreamFailedRequest>(
15633            (stream_lifetime_ordinal, error),
15634            0,
15635            0x77ccf70bb061cf8e,
15636            fidl::encoding::DynamicFlags::empty(),
15637        )
15638    }
15639
15640    pub fn send_on_input_constraints(
15641        &self,
15642        mut input_constraints: &StreamBufferConstraints,
15643    ) -> Result<(), fidl::Error> {
15644        self.inner.send::<StreamProcessorOnInputConstraintsRequest>(
15645            (input_constraints,),
15646            0,
15647            0x211da9966a8ca0,
15648            fidl::encoding::DynamicFlags::empty(),
15649        )
15650    }
15651
15652    pub fn send_on_output_constraints(
15653        &self,
15654        mut output_config: &StreamOutputConstraints,
15655    ) -> Result<(), fidl::Error> {
15656        self.inner.send::<StreamProcessorOnOutputConstraintsRequest>(
15657            (output_config,),
15658            0,
15659            0x40d8234504c170f3,
15660            fidl::encoding::DynamicFlags::empty(),
15661        )
15662    }
15663
15664    pub fn send_on_output_format(
15665        &self,
15666        mut output_format: &StreamOutputFormat,
15667    ) -> Result<(), fidl::Error> {
15668        self.inner.send::<StreamProcessorOnOutputFormatRequest>(
15669            (output_format,),
15670            0,
15671            0x131b77ae120360bc,
15672            fidl::encoding::DynamicFlags::empty(),
15673        )
15674    }
15675
15676    pub fn send_on_output_packet(
15677        &self,
15678        mut output_packet: &Packet,
15679        mut error_detected_before: bool,
15680        mut error_detected_during: bool,
15681    ) -> Result<(), fidl::Error> {
15682        self.inner.send::<StreamProcessorOnOutputPacketRequest>(
15683            (output_packet, error_detected_before, error_detected_during),
15684            0,
15685            0x5c2029be1090ce93,
15686            fidl::encoding::DynamicFlags::empty(),
15687        )
15688    }
15689
15690    pub fn send_on_output_end_of_stream(
15691        &self,
15692        mut stream_lifetime_ordinal: u64,
15693        mut error_detected_before: bool,
15694    ) -> Result<(), fidl::Error> {
15695        self.inner.send::<StreamProcessorOnOutputEndOfStreamRequest>(
15696            (stream_lifetime_ordinal, error_detected_before),
15697            0,
15698            0x3bb65d237cfa50e6,
15699            fidl::encoding::DynamicFlags::empty(),
15700        )
15701    }
15702
15703    pub fn send_on_free_input_packet(
15704        &self,
15705        mut free_input_packet: &PacketHeader,
15706    ) -> Result<(), fidl::Error> {
15707        self.inner.send::<StreamProcessorOnFreeInputPacketRequest>(
15708            (free_input_packet,),
15709            0,
15710            0xeef799b28708bbd,
15711            fidl::encoding::DynamicFlags::empty(),
15712        )
15713    }
15714}
15715
15716#[must_use = "FIDL methods require a response to be sent"]
15717#[derive(Debug)]
15718pub struct StreamProcessorSyncResponder {
15719    control_handle: std::mem::ManuallyDrop<StreamProcessorControlHandle>,
15720    tx_id: u32,
15721}
15722
15723/// Set the the channel to be shutdown (see [`StreamProcessorControlHandle::shutdown`])
15724/// if the responder is dropped without sending a response, so that the client
15725/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
15726impl std::ops::Drop for StreamProcessorSyncResponder {
15727    fn drop(&mut self) {
15728        self.control_handle.shutdown();
15729        // Safety: drops once, never accessed again
15730        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
15731    }
15732}
15733
15734impl fidl::endpoints::Responder for StreamProcessorSyncResponder {
15735    type ControlHandle = StreamProcessorControlHandle;
15736
15737    fn control_handle(&self) -> &StreamProcessorControlHandle {
15738        &self.control_handle
15739    }
15740
15741    fn drop_without_shutdown(mut self) {
15742        // Safety: drops once, never accessed again due to mem::forget
15743        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
15744        // Prevent Drop from running (which would shut down the channel)
15745        std::mem::forget(self);
15746    }
15747}
15748
15749impl StreamProcessorSyncResponder {
15750    /// Sends a response to the FIDL transaction.
15751    ///
15752    /// Sets the channel to shutdown if an error occurs.
15753    pub fn send(self) -> Result<(), fidl::Error> {
15754        let _result = self.send_raw();
15755        if _result.is_err() {
15756            self.control_handle.shutdown();
15757        }
15758        self.drop_without_shutdown();
15759        _result
15760    }
15761
15762    /// Similar to "send" but does not shutdown the channel if an error occurs.
15763    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
15764        let _result = self.send_raw();
15765        self.drop_without_shutdown();
15766        _result
15767    }
15768
15769    fn send_raw(&self) -> Result<(), fidl::Error> {
15770        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
15771            (),
15772            self.tx_id,
15773            0x4b3e44300b0ec6aa,
15774            fidl::encoding::DynamicFlags::empty(),
15775        )
15776    }
15777}
15778
15779#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15780pub struct StreamSinkMarker;
15781
15782impl fidl::endpoints::ProtocolMarker for StreamSinkMarker {
15783    type Proxy = StreamSinkProxy;
15784    type RequestStream = StreamSinkRequestStream;
15785    #[cfg(target_os = "fuchsia")]
15786    type SynchronousProxy = StreamSinkSynchronousProxy;
15787
15788    const DEBUG_NAME: &'static str = "(anonymous) StreamSink";
15789}
15790
15791pub trait StreamSinkProxyInterface: Send + Sync {
15792    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
15793    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
15794    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
15795    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
15796    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
15797    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
15798    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
15799}
15800#[derive(Debug)]
15801#[cfg(target_os = "fuchsia")]
15802pub struct StreamSinkSynchronousProxy {
15803    client: fidl::client::sync::Client,
15804}
15805
15806#[cfg(target_os = "fuchsia")]
15807impl fidl::endpoints::SynchronousProxy for StreamSinkSynchronousProxy {
15808    type Proxy = StreamSinkProxy;
15809    type Protocol = StreamSinkMarker;
15810
15811    fn from_channel(inner: fidl::Channel) -> Self {
15812        Self::new(inner)
15813    }
15814
15815    fn into_channel(self) -> fidl::Channel {
15816        self.client.into_channel()
15817    }
15818
15819    fn as_channel(&self) -> &fidl::Channel {
15820        self.client.as_channel()
15821    }
15822}
15823
15824#[cfg(target_os = "fuchsia")]
15825impl StreamSinkSynchronousProxy {
15826    pub fn new(channel: fidl::Channel) -> Self {
15827        Self { client: fidl::client::sync::Client::new(channel) }
15828    }
15829
15830    pub fn into_channel(self) -> fidl::Channel {
15831        self.client.into_channel()
15832    }
15833
15834    /// Waits until an event arrives and returns it. It is safe for other
15835    /// threads to make concurrent requests while waiting for an event.
15836    pub fn wait_for_event(
15837        &self,
15838        deadline: zx::MonotonicInstant,
15839    ) -> Result<StreamSinkEvent, fidl::Error> {
15840        StreamSinkEvent::decode(self.client.wait_for_event::<StreamSinkMarker>(deadline)?)
15841    }
15842
15843    /// Sends a packet to the service. The response is sent when the service is
15844    /// done with the associated payload memory.
15845    ///
15846    /// `packet` must be valid for the current buffer set, otherwise the service
15847    /// will close the connection.
15848    pub fn r#send_packet(
15849        &self,
15850        mut packet: &StreamPacket,
15851        ___deadline: zx::MonotonicInstant,
15852    ) -> Result<(), fidl::Error> {
15853        let _response = self.client.send_query::<
15854            StreamSinkSendPacketRequest,
15855            fidl::encoding::EmptyPayload,
15856            StreamSinkMarker,
15857        >(
15858            (packet,),
15859            0x67cddd607442775f,
15860            fidl::encoding::DynamicFlags::empty(),
15861            ___deadline,
15862        )?;
15863        Ok(_response)
15864    }
15865
15866    /// Sends a packet to the service. This interface doesn't define how the
15867    /// client knows when the sink is done with the associated payload memory.
15868    /// The inheriting interface must define that.
15869    ///
15870    /// `packet` must be valid for the current buffer set, otherwise the service
15871    /// will close the connection.
15872    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
15873        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
15874            (packet,),
15875            0x8d9b8b413ceba9d,
15876            fidl::encoding::DynamicFlags::empty(),
15877        )
15878    }
15879
15880    /// Indicates the stream has ended. The precise semantics of this method are
15881    /// determined by the inheriting interface.
15882    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
15883        self.client.send::<fidl::encoding::EmptyPayload>(
15884            (),
15885            0x6180fd6f7e793b71,
15886            fidl::encoding::DynamicFlags::empty(),
15887        )
15888    }
15889
15890    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
15891    /// and not yet released. The response is sent after all packets have been
15892    /// released.
15893    pub fn r#discard_all_packets(
15894        &self,
15895        ___deadline: zx::MonotonicInstant,
15896    ) -> Result<(), fidl::Error> {
15897        let _response = self.client.send_query::<
15898            fidl::encoding::EmptyPayload,
15899            fidl::encoding::EmptyPayload,
15900            StreamSinkMarker,
15901        >(
15902            (),
15903            0x6f4dad7af2917665,
15904            fidl::encoding::DynamicFlags::empty(),
15905            ___deadline,
15906        )?;
15907        Ok(_response)
15908    }
15909
15910    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
15911    /// and not yet released.
15912    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
15913        self.client.send::<fidl::encoding::EmptyPayload>(
15914            (),
15915            0x50d36d0d23081bc4,
15916            fidl::encoding::DynamicFlags::empty(),
15917        )
15918    }
15919}
15920
15921#[cfg(target_os = "fuchsia")]
15922impl From<StreamSinkSynchronousProxy> for zx::NullableHandle {
15923    fn from(value: StreamSinkSynchronousProxy) -> Self {
15924        value.into_channel().into()
15925    }
15926}
15927
15928#[cfg(target_os = "fuchsia")]
15929impl From<fidl::Channel> for StreamSinkSynchronousProxy {
15930    fn from(value: fidl::Channel) -> Self {
15931        Self::new(value)
15932    }
15933}
15934
15935#[cfg(target_os = "fuchsia")]
15936impl fidl::endpoints::FromClient for StreamSinkSynchronousProxy {
15937    type Protocol = StreamSinkMarker;
15938
15939    fn from_client(value: fidl::endpoints::ClientEnd<StreamSinkMarker>) -> Self {
15940        Self::new(value.into_channel())
15941    }
15942}
15943
15944#[derive(Debug, Clone)]
15945pub struct StreamSinkProxy {
15946    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
15947}
15948
15949impl fidl::endpoints::Proxy for StreamSinkProxy {
15950    type Protocol = StreamSinkMarker;
15951
15952    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
15953        Self::new(inner)
15954    }
15955
15956    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
15957        self.client.into_channel().map_err(|client| Self { client })
15958    }
15959
15960    fn as_channel(&self) -> &::fidl::AsyncChannel {
15961        self.client.as_channel()
15962    }
15963}
15964
15965impl StreamSinkProxy {
15966    /// Create a new Proxy for fuchsia.media/StreamSink.
15967    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
15968        let protocol_name = <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
15969        Self { client: fidl::client::Client::new(channel, protocol_name) }
15970    }
15971
15972    /// Get a Stream of events from the remote end of the protocol.
15973    ///
15974    /// # Panics
15975    ///
15976    /// Panics if the event stream was already taken.
15977    pub fn take_event_stream(&self) -> StreamSinkEventStream {
15978        StreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
15979    }
15980
15981    /// Sends a packet to the service. The response is sent when the service is
15982    /// done with the associated payload memory.
15983    ///
15984    /// `packet` must be valid for the current buffer set, otherwise the service
15985    /// will close the connection.
15986    pub fn r#send_packet(
15987        &self,
15988        mut packet: &StreamPacket,
15989    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
15990        StreamSinkProxyInterface::r#send_packet(self, packet)
15991    }
15992
15993    /// Sends a packet to the service. This interface doesn't define how the
15994    /// client knows when the sink is done with the associated payload memory.
15995    /// The inheriting interface must define that.
15996    ///
15997    /// `packet` must be valid for the current buffer set, otherwise the service
15998    /// will close the connection.
15999    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16000        StreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
16001    }
16002
16003    /// Indicates the stream has ended. The precise semantics of this method are
16004    /// determined by the inheriting interface.
16005    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
16006        StreamSinkProxyInterface::r#end_of_stream(self)
16007    }
16008
16009    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
16010    /// and not yet released. The response is sent after all packets have been
16011    /// released.
16012    pub fn r#discard_all_packets(
16013        &self,
16014    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
16015        StreamSinkProxyInterface::r#discard_all_packets(self)
16016    }
16017
16018    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
16019    /// and not yet released.
16020    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16021        StreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
16022    }
16023}
16024
16025impl StreamSinkProxyInterface for StreamSinkProxy {
16026    type SendPacketResponseFut =
16027        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
16028    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
16029        fn _decode(
16030            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
16031        ) -> Result<(), fidl::Error> {
16032            let _response = fidl::client::decode_transaction_body::<
16033                fidl::encoding::EmptyPayload,
16034                fidl::encoding::DefaultFuchsiaResourceDialect,
16035                0x67cddd607442775f,
16036            >(_buf?)?;
16037            Ok(_response)
16038        }
16039        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
16040            (packet,),
16041            0x67cddd607442775f,
16042            fidl::encoding::DynamicFlags::empty(),
16043            _decode,
16044        )
16045    }
16046
16047    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16048        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
16049            (packet,),
16050            0x8d9b8b413ceba9d,
16051            fidl::encoding::DynamicFlags::empty(),
16052        )
16053    }
16054
16055    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
16056        self.client.send::<fidl::encoding::EmptyPayload>(
16057            (),
16058            0x6180fd6f7e793b71,
16059            fidl::encoding::DynamicFlags::empty(),
16060        )
16061    }
16062
16063    type DiscardAllPacketsResponseFut =
16064        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
16065    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
16066        fn _decode(
16067            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
16068        ) -> Result<(), fidl::Error> {
16069            let _response = fidl::client::decode_transaction_body::<
16070                fidl::encoding::EmptyPayload,
16071                fidl::encoding::DefaultFuchsiaResourceDialect,
16072                0x6f4dad7af2917665,
16073            >(_buf?)?;
16074            Ok(_response)
16075        }
16076        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
16077            (),
16078            0x6f4dad7af2917665,
16079            fidl::encoding::DynamicFlags::empty(),
16080            _decode,
16081        )
16082    }
16083
16084    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16085        self.client.send::<fidl::encoding::EmptyPayload>(
16086            (),
16087            0x50d36d0d23081bc4,
16088            fidl::encoding::DynamicFlags::empty(),
16089        )
16090    }
16091}
16092
16093pub struct StreamSinkEventStream {
16094    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
16095}
16096
16097impl std::marker::Unpin for StreamSinkEventStream {}
16098
16099impl futures::stream::FusedStream for StreamSinkEventStream {
16100    fn is_terminated(&self) -> bool {
16101        self.event_receiver.is_terminated()
16102    }
16103}
16104
16105impl futures::Stream for StreamSinkEventStream {
16106    type Item = Result<StreamSinkEvent, fidl::Error>;
16107
16108    fn poll_next(
16109        mut self: std::pin::Pin<&mut Self>,
16110        cx: &mut std::task::Context<'_>,
16111    ) -> std::task::Poll<Option<Self::Item>> {
16112        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
16113            &mut self.event_receiver,
16114            cx
16115        )?) {
16116            Some(buf) => std::task::Poll::Ready(Some(StreamSinkEvent::decode(buf))),
16117            None => std::task::Poll::Ready(None),
16118        }
16119    }
16120}
16121
16122#[derive(Debug)]
16123pub enum StreamSinkEvent {}
16124
16125impl StreamSinkEvent {
16126    /// Decodes a message buffer as a [`StreamSinkEvent`].
16127    fn decode(
16128        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
16129    ) -> Result<StreamSinkEvent, fidl::Error> {
16130        let (bytes, _handles) = buf.split_mut();
16131        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16132        debug_assert_eq!(tx_header.tx_id, 0);
16133        match tx_header.ordinal {
16134            _ => Err(fidl::Error::UnknownOrdinal {
16135                ordinal: tx_header.ordinal,
16136                protocol_name: <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16137            }),
16138        }
16139    }
16140}
16141
16142/// A Stream of incoming requests for fuchsia.media/StreamSink.
16143pub struct StreamSinkRequestStream {
16144    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16145    is_terminated: bool,
16146}
16147
16148impl std::marker::Unpin for StreamSinkRequestStream {}
16149
16150impl futures::stream::FusedStream for StreamSinkRequestStream {
16151    fn is_terminated(&self) -> bool {
16152        self.is_terminated
16153    }
16154}
16155
16156impl fidl::endpoints::RequestStream for StreamSinkRequestStream {
16157    type Protocol = StreamSinkMarker;
16158    type ControlHandle = StreamSinkControlHandle;
16159
16160    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
16161        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
16162    }
16163
16164    fn control_handle(&self) -> Self::ControlHandle {
16165        StreamSinkControlHandle { inner: self.inner.clone() }
16166    }
16167
16168    fn into_inner(
16169        self,
16170    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
16171    {
16172        (self.inner, self.is_terminated)
16173    }
16174
16175    fn from_inner(
16176        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16177        is_terminated: bool,
16178    ) -> Self {
16179        Self { inner, is_terminated }
16180    }
16181}
16182
16183impl futures::Stream for StreamSinkRequestStream {
16184    type Item = Result<StreamSinkRequest, fidl::Error>;
16185
16186    fn poll_next(
16187        mut self: std::pin::Pin<&mut Self>,
16188        cx: &mut std::task::Context<'_>,
16189    ) -> std::task::Poll<Option<Self::Item>> {
16190        let this = &mut *self;
16191        if this.inner.check_shutdown(cx) {
16192            this.is_terminated = true;
16193            return std::task::Poll::Ready(None);
16194        }
16195        if this.is_terminated {
16196            panic!("polled StreamSinkRequestStream after completion");
16197        }
16198        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
16199            |bytes, handles| {
16200                match this.inner.channel().read_etc(cx, bytes, handles) {
16201                    std::task::Poll::Ready(Ok(())) => {}
16202                    std::task::Poll::Pending => return std::task::Poll::Pending,
16203                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
16204                        this.is_terminated = true;
16205                        return std::task::Poll::Ready(None);
16206                    }
16207                    std::task::Poll::Ready(Err(e)) => {
16208                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
16209                            e.into(),
16210                        ))));
16211                    }
16212                }
16213
16214                // A message has been received from the channel
16215                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16216
16217                std::task::Poll::Ready(Some(match header.ordinal {
16218                    0x67cddd607442775f => {
16219                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16220                        let mut req = fidl::new_empty!(
16221                            StreamSinkSendPacketRequest,
16222                            fidl::encoding::DefaultFuchsiaResourceDialect
16223                        );
16224                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
16225                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16226                        Ok(StreamSinkRequest::SendPacket {
16227                            packet: req.packet,
16228
16229                            responder: StreamSinkSendPacketResponder {
16230                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16231                                tx_id: header.tx_id,
16232                            },
16233                        })
16234                    }
16235                    0x8d9b8b413ceba9d => {
16236                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16237                        let mut req = fidl::new_empty!(
16238                            StreamSinkSendPacketNoReplyRequest,
16239                            fidl::encoding::DefaultFuchsiaResourceDialect
16240                        );
16241                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
16242                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16243                        Ok(StreamSinkRequest::SendPacketNoReply {
16244                            packet: req.packet,
16245
16246                            control_handle,
16247                        })
16248                    }
16249                    0x6180fd6f7e793b71 => {
16250                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16251                        let mut req = fidl::new_empty!(
16252                            fidl::encoding::EmptyPayload,
16253                            fidl::encoding::DefaultFuchsiaResourceDialect
16254                        );
16255                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16256                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16257                        Ok(StreamSinkRequest::EndOfStream { control_handle })
16258                    }
16259                    0x6f4dad7af2917665 => {
16260                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16261                        let mut req = fidl::new_empty!(
16262                            fidl::encoding::EmptyPayload,
16263                            fidl::encoding::DefaultFuchsiaResourceDialect
16264                        );
16265                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16266                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16267                        Ok(StreamSinkRequest::DiscardAllPackets {
16268                            responder: StreamSinkDiscardAllPacketsResponder {
16269                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16270                                tx_id: header.tx_id,
16271                            },
16272                        })
16273                    }
16274                    0x50d36d0d23081bc4 => {
16275                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16276                        let mut req = fidl::new_empty!(
16277                            fidl::encoding::EmptyPayload,
16278                            fidl::encoding::DefaultFuchsiaResourceDialect
16279                        );
16280                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16281                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16282                        Ok(StreamSinkRequest::DiscardAllPacketsNoReply { control_handle })
16283                    }
16284                    _ => Err(fidl::Error::UnknownOrdinal {
16285                        ordinal: header.ordinal,
16286                        protocol_name:
16287                            <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16288                    }),
16289                }))
16290            },
16291        )
16292    }
16293}
16294
16295/// Consumes a stream of packets. This interface is typically inherited along
16296/// with `StreamBufferSet` to enable the transport of elementary streams from
16297/// clients to services.
16298#[derive(Debug)]
16299pub enum StreamSinkRequest {
16300    /// Sends a packet to the service. The response is sent when the service is
16301    /// done with the associated payload memory.
16302    ///
16303    /// `packet` must be valid for the current buffer set, otherwise the service
16304    /// will close the connection.
16305    SendPacket { packet: StreamPacket, responder: StreamSinkSendPacketResponder },
16306    /// Sends a packet to the service. This interface doesn't define how the
16307    /// client knows when the sink is done with the associated payload memory.
16308    /// The inheriting interface must define that.
16309    ///
16310    /// `packet` must be valid for the current buffer set, otherwise the service
16311    /// will close the connection.
16312    SendPacketNoReply { packet: StreamPacket, control_handle: StreamSinkControlHandle },
16313    /// Indicates the stream has ended. The precise semantics of this method are
16314    /// determined by the inheriting interface.
16315    EndOfStream { control_handle: StreamSinkControlHandle },
16316    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
16317    /// and not yet released. The response is sent after all packets have been
16318    /// released.
16319    DiscardAllPackets { responder: StreamSinkDiscardAllPacketsResponder },
16320    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
16321    /// and not yet released.
16322    DiscardAllPacketsNoReply { control_handle: StreamSinkControlHandle },
16323}
16324
16325impl StreamSinkRequest {
16326    #[allow(irrefutable_let_patterns)]
16327    pub fn into_send_packet(self) -> Option<(StreamPacket, StreamSinkSendPacketResponder)> {
16328        if let StreamSinkRequest::SendPacket { packet, responder } = self {
16329            Some((packet, responder))
16330        } else {
16331            None
16332        }
16333    }
16334
16335    #[allow(irrefutable_let_patterns)]
16336    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, StreamSinkControlHandle)> {
16337        if let StreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
16338            Some((packet, control_handle))
16339        } else {
16340            None
16341        }
16342    }
16343
16344    #[allow(irrefutable_let_patterns)]
16345    pub fn into_end_of_stream(self) -> Option<(StreamSinkControlHandle)> {
16346        if let StreamSinkRequest::EndOfStream { control_handle } = self {
16347            Some((control_handle))
16348        } else {
16349            None
16350        }
16351    }
16352
16353    #[allow(irrefutable_let_patterns)]
16354    pub fn into_discard_all_packets(self) -> Option<(StreamSinkDiscardAllPacketsResponder)> {
16355        if let StreamSinkRequest::DiscardAllPackets { responder } = self {
16356            Some((responder))
16357        } else {
16358            None
16359        }
16360    }
16361
16362    #[allow(irrefutable_let_patterns)]
16363    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSinkControlHandle)> {
16364        if let StreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
16365            Some((control_handle))
16366        } else {
16367            None
16368        }
16369    }
16370
16371    /// Name of the method defined in FIDL
16372    pub fn method_name(&self) -> &'static str {
16373        match *self {
16374            StreamSinkRequest::SendPacket { .. } => "send_packet",
16375            StreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
16376            StreamSinkRequest::EndOfStream { .. } => "end_of_stream",
16377            StreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
16378            StreamSinkRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
16379        }
16380    }
16381}
16382
16383#[derive(Debug, Clone)]
16384pub struct StreamSinkControlHandle {
16385    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16386}
16387
16388impl fidl::endpoints::ControlHandle for StreamSinkControlHandle {
16389    fn shutdown(&self) {
16390        self.inner.shutdown()
16391    }
16392
16393    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
16394        self.inner.shutdown_with_epitaph(status)
16395    }
16396
16397    fn is_closed(&self) -> bool {
16398        self.inner.channel().is_closed()
16399    }
16400    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
16401        self.inner.channel().on_closed()
16402    }
16403
16404    #[cfg(target_os = "fuchsia")]
16405    fn signal_peer(
16406        &self,
16407        clear_mask: zx::Signals,
16408        set_mask: zx::Signals,
16409    ) -> Result<(), zx_status::Status> {
16410        use fidl::Peered;
16411        self.inner.channel().signal_peer(clear_mask, set_mask)
16412    }
16413}
16414
16415impl StreamSinkControlHandle {}
16416
16417#[must_use = "FIDL methods require a response to be sent"]
16418#[derive(Debug)]
16419pub struct StreamSinkSendPacketResponder {
16420    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
16421    tx_id: u32,
16422}
16423
16424/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
16425/// if the responder is dropped without sending a response, so that the client
16426/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
16427impl std::ops::Drop for StreamSinkSendPacketResponder {
16428    fn drop(&mut self) {
16429        self.control_handle.shutdown();
16430        // Safety: drops once, never accessed again
16431        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16432    }
16433}
16434
16435impl fidl::endpoints::Responder for StreamSinkSendPacketResponder {
16436    type ControlHandle = StreamSinkControlHandle;
16437
16438    fn control_handle(&self) -> &StreamSinkControlHandle {
16439        &self.control_handle
16440    }
16441
16442    fn drop_without_shutdown(mut self) {
16443        // Safety: drops once, never accessed again due to mem::forget
16444        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16445        // Prevent Drop from running (which would shut down the channel)
16446        std::mem::forget(self);
16447    }
16448}
16449
16450impl StreamSinkSendPacketResponder {
16451    /// Sends a response to the FIDL transaction.
16452    ///
16453    /// Sets the channel to shutdown if an error occurs.
16454    pub fn send(self) -> Result<(), fidl::Error> {
16455        let _result = self.send_raw();
16456        if _result.is_err() {
16457            self.control_handle.shutdown();
16458        }
16459        self.drop_without_shutdown();
16460        _result
16461    }
16462
16463    /// Similar to "send" but does not shutdown the channel if an error occurs.
16464    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
16465        let _result = self.send_raw();
16466        self.drop_without_shutdown();
16467        _result
16468    }
16469
16470    fn send_raw(&self) -> Result<(), fidl::Error> {
16471        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
16472            (),
16473            self.tx_id,
16474            0x67cddd607442775f,
16475            fidl::encoding::DynamicFlags::empty(),
16476        )
16477    }
16478}
16479
16480#[must_use = "FIDL methods require a response to be sent"]
16481#[derive(Debug)]
16482pub struct StreamSinkDiscardAllPacketsResponder {
16483    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
16484    tx_id: u32,
16485}
16486
16487/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
16488/// if the responder is dropped without sending a response, so that the client
16489/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
16490impl std::ops::Drop for StreamSinkDiscardAllPacketsResponder {
16491    fn drop(&mut self) {
16492        self.control_handle.shutdown();
16493        // Safety: drops once, never accessed again
16494        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16495    }
16496}
16497
16498impl fidl::endpoints::Responder for StreamSinkDiscardAllPacketsResponder {
16499    type ControlHandle = StreamSinkControlHandle;
16500
16501    fn control_handle(&self) -> &StreamSinkControlHandle {
16502        &self.control_handle
16503    }
16504
16505    fn drop_without_shutdown(mut self) {
16506        // Safety: drops once, never accessed again due to mem::forget
16507        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16508        // Prevent Drop from running (which would shut down the channel)
16509        std::mem::forget(self);
16510    }
16511}
16512
16513impl StreamSinkDiscardAllPacketsResponder {
16514    /// Sends a response to the FIDL transaction.
16515    ///
16516    /// Sets the channel to shutdown if an error occurs.
16517    pub fn send(self) -> Result<(), fidl::Error> {
16518        let _result = self.send_raw();
16519        if _result.is_err() {
16520            self.control_handle.shutdown();
16521        }
16522        self.drop_without_shutdown();
16523        _result
16524    }
16525
16526    /// Similar to "send" but does not shutdown the channel if an error occurs.
16527    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
16528        let _result = self.send_raw();
16529        self.drop_without_shutdown();
16530        _result
16531    }
16532
16533    fn send_raw(&self) -> Result<(), fidl::Error> {
16534        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
16535            (),
16536            self.tx_id,
16537            0x6f4dad7af2917665,
16538            fidl::encoding::DynamicFlags::empty(),
16539        )
16540    }
16541}
16542
16543#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
16544pub struct StreamSourceMarker;
16545
16546impl fidl::endpoints::ProtocolMarker for StreamSourceMarker {
16547    type Proxy = StreamSourceProxy;
16548    type RequestStream = StreamSourceRequestStream;
16549    #[cfg(target_os = "fuchsia")]
16550    type SynchronousProxy = StreamSourceSynchronousProxy;
16551
16552    const DEBUG_NAME: &'static str = "(anonymous) StreamSource";
16553}
16554
16555pub trait StreamSourceProxyInterface: Send + Sync {
16556    fn r#release_packet(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
16557    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
16558    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
16559    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
16560}
16561#[derive(Debug)]
16562#[cfg(target_os = "fuchsia")]
16563pub struct StreamSourceSynchronousProxy {
16564    client: fidl::client::sync::Client,
16565}
16566
16567#[cfg(target_os = "fuchsia")]
16568impl fidl::endpoints::SynchronousProxy for StreamSourceSynchronousProxy {
16569    type Proxy = StreamSourceProxy;
16570    type Protocol = StreamSourceMarker;
16571
16572    fn from_channel(inner: fidl::Channel) -> Self {
16573        Self::new(inner)
16574    }
16575
16576    fn into_channel(self) -> fidl::Channel {
16577        self.client.into_channel()
16578    }
16579
16580    fn as_channel(&self) -> &fidl::Channel {
16581        self.client.as_channel()
16582    }
16583}
16584
16585#[cfg(target_os = "fuchsia")]
16586impl StreamSourceSynchronousProxy {
16587    pub fn new(channel: fidl::Channel) -> Self {
16588        Self { client: fidl::client::sync::Client::new(channel) }
16589    }
16590
16591    pub fn into_channel(self) -> fidl::Channel {
16592        self.client.into_channel()
16593    }
16594
16595    /// Waits until an event arrives and returns it. It is safe for other
16596    /// threads to make concurrent requests while waiting for an event.
16597    pub fn wait_for_event(
16598        &self,
16599        deadline: zx::MonotonicInstant,
16600    ) -> Result<StreamSourceEvent, fidl::Error> {
16601        StreamSourceEvent::decode(self.client.wait_for_event::<StreamSourceMarker>(deadline)?)
16602    }
16603
16604    /// Releases payload memory associated with a packet previously delivered
16605    /// via `OnPacketProduced`.
16606    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16607        self.client.send::<StreamSourceReleasePacketRequest>(
16608            (packet,),
16609            0x7a7b57f0f7d9e4bb,
16610            fidl::encoding::DynamicFlags::empty(),
16611        )
16612    }
16613
16614    pub fn r#discard_all_packets(
16615        &self,
16616        ___deadline: zx::MonotonicInstant,
16617    ) -> Result<(), fidl::Error> {
16618        let _response = self.client.send_query::<
16619            fidl::encoding::EmptyPayload,
16620            fidl::encoding::EmptyPayload,
16621            StreamSourceMarker,
16622        >(
16623            (),
16624            0x27afd605e97b09d2,
16625            fidl::encoding::DynamicFlags::empty(),
16626            ___deadline,
16627        )?;
16628        Ok(_response)
16629    }
16630
16631    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16632        self.client.send::<fidl::encoding::EmptyPayload>(
16633            (),
16634            0x35f9d721e905b831,
16635            fidl::encoding::DynamicFlags::empty(),
16636        )
16637    }
16638}
16639
16640#[cfg(target_os = "fuchsia")]
16641impl From<StreamSourceSynchronousProxy> for zx::NullableHandle {
16642    fn from(value: StreamSourceSynchronousProxy) -> Self {
16643        value.into_channel().into()
16644    }
16645}
16646
16647#[cfg(target_os = "fuchsia")]
16648impl From<fidl::Channel> for StreamSourceSynchronousProxy {
16649    fn from(value: fidl::Channel) -> Self {
16650        Self::new(value)
16651    }
16652}
16653
16654#[cfg(target_os = "fuchsia")]
16655impl fidl::endpoints::FromClient for StreamSourceSynchronousProxy {
16656    type Protocol = StreamSourceMarker;
16657
16658    fn from_client(value: fidl::endpoints::ClientEnd<StreamSourceMarker>) -> Self {
16659        Self::new(value.into_channel())
16660    }
16661}
16662
16663#[derive(Debug, Clone)]
16664pub struct StreamSourceProxy {
16665    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
16666}
16667
16668impl fidl::endpoints::Proxy for StreamSourceProxy {
16669    type Protocol = StreamSourceMarker;
16670
16671    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
16672        Self::new(inner)
16673    }
16674
16675    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
16676        self.client.into_channel().map_err(|client| Self { client })
16677    }
16678
16679    fn as_channel(&self) -> &::fidl::AsyncChannel {
16680        self.client.as_channel()
16681    }
16682}
16683
16684impl StreamSourceProxy {
16685    /// Create a new Proxy for fuchsia.media/StreamSource.
16686    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
16687        let protocol_name = <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
16688        Self { client: fidl::client::Client::new(channel, protocol_name) }
16689    }
16690
16691    /// Get a Stream of events from the remote end of the protocol.
16692    ///
16693    /// # Panics
16694    ///
16695    /// Panics if the event stream was already taken.
16696    pub fn take_event_stream(&self) -> StreamSourceEventStream {
16697        StreamSourceEventStream { event_receiver: self.client.take_event_receiver() }
16698    }
16699
16700    /// Releases payload memory associated with a packet previously delivered
16701    /// via `OnPacketProduced`.
16702    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16703        StreamSourceProxyInterface::r#release_packet(self, packet)
16704    }
16705
16706    pub fn r#discard_all_packets(
16707        &self,
16708    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
16709        StreamSourceProxyInterface::r#discard_all_packets(self)
16710    }
16711
16712    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16713        StreamSourceProxyInterface::r#discard_all_packets_no_reply(self)
16714    }
16715}
16716
16717impl StreamSourceProxyInterface for StreamSourceProxy {
16718    fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16719        self.client.send::<StreamSourceReleasePacketRequest>(
16720            (packet,),
16721            0x7a7b57f0f7d9e4bb,
16722            fidl::encoding::DynamicFlags::empty(),
16723        )
16724    }
16725
16726    type DiscardAllPacketsResponseFut =
16727        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
16728    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
16729        fn _decode(
16730            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
16731        ) -> Result<(), fidl::Error> {
16732            let _response = fidl::client::decode_transaction_body::<
16733                fidl::encoding::EmptyPayload,
16734                fidl::encoding::DefaultFuchsiaResourceDialect,
16735                0x27afd605e97b09d2,
16736            >(_buf?)?;
16737            Ok(_response)
16738        }
16739        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
16740            (),
16741            0x27afd605e97b09d2,
16742            fidl::encoding::DynamicFlags::empty(),
16743            _decode,
16744        )
16745    }
16746
16747    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16748        self.client.send::<fidl::encoding::EmptyPayload>(
16749            (),
16750            0x35f9d721e905b831,
16751            fidl::encoding::DynamicFlags::empty(),
16752        )
16753    }
16754}
16755
16756pub struct StreamSourceEventStream {
16757    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
16758}
16759
16760impl std::marker::Unpin for StreamSourceEventStream {}
16761
16762impl futures::stream::FusedStream for StreamSourceEventStream {
16763    fn is_terminated(&self) -> bool {
16764        self.event_receiver.is_terminated()
16765    }
16766}
16767
16768impl futures::Stream for StreamSourceEventStream {
16769    type Item = Result<StreamSourceEvent, fidl::Error>;
16770
16771    fn poll_next(
16772        mut self: std::pin::Pin<&mut Self>,
16773        cx: &mut std::task::Context<'_>,
16774    ) -> std::task::Poll<Option<Self::Item>> {
16775        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
16776            &mut self.event_receiver,
16777            cx
16778        )?) {
16779            Some(buf) => std::task::Poll::Ready(Some(StreamSourceEvent::decode(buf))),
16780            None => std::task::Poll::Ready(None),
16781        }
16782    }
16783}
16784
16785#[derive(Debug)]
16786pub enum StreamSourceEvent {
16787    OnPacketProduced { packet: StreamPacket },
16788    OnEndOfStream {},
16789}
16790
16791impl StreamSourceEvent {
16792    #[allow(irrefutable_let_patterns)]
16793    pub fn into_on_packet_produced(self) -> Option<StreamPacket> {
16794        if let StreamSourceEvent::OnPacketProduced { packet } = self {
16795            Some((packet))
16796        } else {
16797            None
16798        }
16799    }
16800    #[allow(irrefutable_let_patterns)]
16801    pub fn into_on_end_of_stream(self) -> Option<()> {
16802        if let StreamSourceEvent::OnEndOfStream {} = self { Some(()) } else { None }
16803    }
16804
16805    /// Decodes a message buffer as a [`StreamSourceEvent`].
16806    fn decode(
16807        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
16808    ) -> Result<StreamSourceEvent, fidl::Error> {
16809        let (bytes, _handles) = buf.split_mut();
16810        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16811        debug_assert_eq!(tx_header.tx_id, 0);
16812        match tx_header.ordinal {
16813            0x6bbe69746a3c8bd9 => {
16814                let mut out = fidl::new_empty!(
16815                    StreamSourceOnPacketProducedRequest,
16816                    fidl::encoding::DefaultFuchsiaResourceDialect
16817                );
16818                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16819                Ok((StreamSourceEvent::OnPacketProduced { packet: out.packet }))
16820            }
16821            0x550e69b41d03e2c2 => {
16822                let mut out = fidl::new_empty!(
16823                    fidl::encoding::EmptyPayload,
16824                    fidl::encoding::DefaultFuchsiaResourceDialect
16825                );
16826                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
16827                Ok((StreamSourceEvent::OnEndOfStream {}))
16828            }
16829            _ => Err(fidl::Error::UnknownOrdinal {
16830                ordinal: tx_header.ordinal,
16831                protocol_name: <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16832            }),
16833        }
16834    }
16835}
16836
16837/// A Stream of incoming requests for fuchsia.media/StreamSource.
16838pub struct StreamSourceRequestStream {
16839    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16840    is_terminated: bool,
16841}
16842
16843impl std::marker::Unpin for StreamSourceRequestStream {}
16844
16845impl futures::stream::FusedStream for StreamSourceRequestStream {
16846    fn is_terminated(&self) -> bool {
16847        self.is_terminated
16848    }
16849}
16850
16851impl fidl::endpoints::RequestStream for StreamSourceRequestStream {
16852    type Protocol = StreamSourceMarker;
16853    type ControlHandle = StreamSourceControlHandle;
16854
16855    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
16856        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
16857    }
16858
16859    fn control_handle(&self) -> Self::ControlHandle {
16860        StreamSourceControlHandle { inner: self.inner.clone() }
16861    }
16862
16863    fn into_inner(
16864        self,
16865    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
16866    {
16867        (self.inner, self.is_terminated)
16868    }
16869
16870    fn from_inner(
16871        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16872        is_terminated: bool,
16873    ) -> Self {
16874        Self { inner, is_terminated }
16875    }
16876}
16877
16878impl futures::Stream for StreamSourceRequestStream {
16879    type Item = Result<StreamSourceRequest, fidl::Error>;
16880
16881    fn poll_next(
16882        mut self: std::pin::Pin<&mut Self>,
16883        cx: &mut std::task::Context<'_>,
16884    ) -> std::task::Poll<Option<Self::Item>> {
16885        let this = &mut *self;
16886        if this.inner.check_shutdown(cx) {
16887            this.is_terminated = true;
16888            return std::task::Poll::Ready(None);
16889        }
16890        if this.is_terminated {
16891            panic!("polled StreamSourceRequestStream after completion");
16892        }
16893        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
16894            |bytes, handles| {
16895                match this.inner.channel().read_etc(cx, bytes, handles) {
16896                    std::task::Poll::Ready(Ok(())) => {}
16897                    std::task::Poll::Pending => return std::task::Poll::Pending,
16898                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
16899                        this.is_terminated = true;
16900                        return std::task::Poll::Ready(None);
16901                    }
16902                    std::task::Poll::Ready(Err(e)) => {
16903                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
16904                            e.into(),
16905                        ))));
16906                    }
16907                }
16908
16909                // A message has been received from the channel
16910                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16911
16912                std::task::Poll::Ready(Some(match header.ordinal {
16913                    0x7a7b57f0f7d9e4bb => {
16914                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16915                        let mut req = fidl::new_empty!(
16916                            StreamSourceReleasePacketRequest,
16917                            fidl::encoding::DefaultFuchsiaResourceDialect
16918                        );
16919                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
16920                        let control_handle =
16921                            StreamSourceControlHandle { inner: this.inner.clone() };
16922                        Ok(StreamSourceRequest::ReleasePacket {
16923                            packet: req.packet,
16924
16925                            control_handle,
16926                        })
16927                    }
16928                    0x27afd605e97b09d2 => {
16929                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16930                        let mut req = fidl::new_empty!(
16931                            fidl::encoding::EmptyPayload,
16932                            fidl::encoding::DefaultFuchsiaResourceDialect
16933                        );
16934                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16935                        let control_handle =
16936                            StreamSourceControlHandle { inner: this.inner.clone() };
16937                        Ok(StreamSourceRequest::DiscardAllPackets {
16938                            responder: StreamSourceDiscardAllPacketsResponder {
16939                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16940                                tx_id: header.tx_id,
16941                            },
16942                        })
16943                    }
16944                    0x35f9d721e905b831 => {
16945                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16946                        let mut req = fidl::new_empty!(
16947                            fidl::encoding::EmptyPayload,
16948                            fidl::encoding::DefaultFuchsiaResourceDialect
16949                        );
16950                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16951                        let control_handle =
16952                            StreamSourceControlHandle { inner: this.inner.clone() };
16953                        Ok(StreamSourceRequest::DiscardAllPacketsNoReply { control_handle })
16954                    }
16955                    _ => Err(fidl::Error::UnknownOrdinal {
16956                        ordinal: header.ordinal,
16957                        protocol_name:
16958                            <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16959                    }),
16960                }))
16961            },
16962        )
16963    }
16964}
16965
16966/// Produces a stream of packets. This interface is typically inherited along
16967/// with `StreamBufferSet` to enable the transport of elementary streams from
16968/// services to clients.
16969#[derive(Debug)]
16970pub enum StreamSourceRequest {
16971    /// Releases payload memory associated with a packet previously delivered
16972    /// via `OnPacketProduced`.
16973    ReleasePacket {
16974        packet: StreamPacket,
16975        control_handle: StreamSourceControlHandle,
16976    },
16977    DiscardAllPackets {
16978        responder: StreamSourceDiscardAllPacketsResponder,
16979    },
16980    DiscardAllPacketsNoReply {
16981        control_handle: StreamSourceControlHandle,
16982    },
16983}
16984
16985impl StreamSourceRequest {
16986    #[allow(irrefutable_let_patterns)]
16987    pub fn into_release_packet(self) -> Option<(StreamPacket, StreamSourceControlHandle)> {
16988        if let StreamSourceRequest::ReleasePacket { packet, control_handle } = self {
16989            Some((packet, control_handle))
16990        } else {
16991            None
16992        }
16993    }
16994
16995    #[allow(irrefutable_let_patterns)]
16996    pub fn into_discard_all_packets(self) -> Option<(StreamSourceDiscardAllPacketsResponder)> {
16997        if let StreamSourceRequest::DiscardAllPackets { responder } = self {
16998            Some((responder))
16999        } else {
17000            None
17001        }
17002    }
17003
17004    #[allow(irrefutable_let_patterns)]
17005    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSourceControlHandle)> {
17006        if let StreamSourceRequest::DiscardAllPacketsNoReply { control_handle } = self {
17007            Some((control_handle))
17008        } else {
17009            None
17010        }
17011    }
17012
17013    /// Name of the method defined in FIDL
17014    pub fn method_name(&self) -> &'static str {
17015        match *self {
17016            StreamSourceRequest::ReleasePacket { .. } => "release_packet",
17017            StreamSourceRequest::DiscardAllPackets { .. } => "discard_all_packets",
17018            StreamSourceRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
17019        }
17020    }
17021}
17022
17023#[derive(Debug, Clone)]
17024pub struct StreamSourceControlHandle {
17025    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17026}
17027
17028impl fidl::endpoints::ControlHandle for StreamSourceControlHandle {
17029    fn shutdown(&self) {
17030        self.inner.shutdown()
17031    }
17032
17033    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
17034        self.inner.shutdown_with_epitaph(status)
17035    }
17036
17037    fn is_closed(&self) -> bool {
17038        self.inner.channel().is_closed()
17039    }
17040    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
17041        self.inner.channel().on_closed()
17042    }
17043
17044    #[cfg(target_os = "fuchsia")]
17045    fn signal_peer(
17046        &self,
17047        clear_mask: zx::Signals,
17048        set_mask: zx::Signals,
17049    ) -> Result<(), zx_status::Status> {
17050        use fidl::Peered;
17051        self.inner.channel().signal_peer(clear_mask, set_mask)
17052    }
17053}
17054
17055impl StreamSourceControlHandle {
17056    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
17057        self.inner.send::<StreamSourceOnPacketProducedRequest>(
17058            (packet,),
17059            0,
17060            0x6bbe69746a3c8bd9,
17061            fidl::encoding::DynamicFlags::empty(),
17062        )
17063    }
17064
17065    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
17066        self.inner.send::<fidl::encoding::EmptyPayload>(
17067            (),
17068            0,
17069            0x550e69b41d03e2c2,
17070            fidl::encoding::DynamicFlags::empty(),
17071        )
17072    }
17073}
17074
17075#[must_use = "FIDL methods require a response to be sent"]
17076#[derive(Debug)]
17077pub struct StreamSourceDiscardAllPacketsResponder {
17078    control_handle: std::mem::ManuallyDrop<StreamSourceControlHandle>,
17079    tx_id: u32,
17080}
17081
17082/// Set the the channel to be shutdown (see [`StreamSourceControlHandle::shutdown`])
17083/// if the responder is dropped without sending a response, so that the client
17084/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
17085impl std::ops::Drop for StreamSourceDiscardAllPacketsResponder {
17086    fn drop(&mut self) {
17087        self.control_handle.shutdown();
17088        // Safety: drops once, never accessed again
17089        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17090    }
17091}
17092
17093impl fidl::endpoints::Responder for StreamSourceDiscardAllPacketsResponder {
17094    type ControlHandle = StreamSourceControlHandle;
17095
17096    fn control_handle(&self) -> &StreamSourceControlHandle {
17097        &self.control_handle
17098    }
17099
17100    fn drop_without_shutdown(mut self) {
17101        // Safety: drops once, never accessed again due to mem::forget
17102        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17103        // Prevent Drop from running (which would shut down the channel)
17104        std::mem::forget(self);
17105    }
17106}
17107
17108impl StreamSourceDiscardAllPacketsResponder {
17109    /// Sends a response to the FIDL transaction.
17110    ///
17111    /// Sets the channel to shutdown if an error occurs.
17112    pub fn send(self) -> Result<(), fidl::Error> {
17113        let _result = self.send_raw();
17114        if _result.is_err() {
17115            self.control_handle.shutdown();
17116        }
17117        self.drop_without_shutdown();
17118        _result
17119    }
17120
17121    /// Similar to "send" but does not shutdown the channel if an error occurs.
17122    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
17123        let _result = self.send_raw();
17124        self.drop_without_shutdown();
17125        _result
17126    }
17127
17128    fn send_raw(&self) -> Result<(), fidl::Error> {
17129        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
17130            (),
17131            self.tx_id,
17132            0x27afd605e97b09d2,
17133            fidl::encoding::DynamicFlags::empty(),
17134        )
17135    }
17136}
17137
17138#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17139pub struct Usage2AudioConsumerFactoryMarker;
17140
17141impl fidl::endpoints::ProtocolMarker for Usage2AudioConsumerFactoryMarker {
17142    type Proxy = Usage2AudioConsumerFactoryProxy;
17143    type RequestStream = Usage2AudioConsumerFactoryRequestStream;
17144    #[cfg(target_os = "fuchsia")]
17145    type SynchronousProxy = Usage2AudioConsumerFactorySynchronousProxy;
17146
17147    const DEBUG_NAME: &'static str = "fuchsia.media.Usage2AudioConsumerFactory";
17148}
17149impl fidl::endpoints::DiscoverableProtocolMarker for Usage2AudioConsumerFactoryMarker {}
17150
17151pub trait Usage2AudioConsumerFactoryProxyInterface: Send + Sync {
17152    fn r#create_audio_consumer(
17153        &self,
17154        usage: AudioRenderUsage2,
17155        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17156    ) -> Result<(), fidl::Error>;
17157}
17158#[derive(Debug)]
17159#[cfg(target_os = "fuchsia")]
17160pub struct Usage2AudioConsumerFactorySynchronousProxy {
17161    client: fidl::client::sync::Client,
17162}
17163
17164#[cfg(target_os = "fuchsia")]
17165impl fidl::endpoints::SynchronousProxy for Usage2AudioConsumerFactorySynchronousProxy {
17166    type Proxy = Usage2AudioConsumerFactoryProxy;
17167    type Protocol = Usage2AudioConsumerFactoryMarker;
17168
17169    fn from_channel(inner: fidl::Channel) -> Self {
17170        Self::new(inner)
17171    }
17172
17173    fn into_channel(self) -> fidl::Channel {
17174        self.client.into_channel()
17175    }
17176
17177    fn as_channel(&self) -> &fidl::Channel {
17178        self.client.as_channel()
17179    }
17180}
17181
17182#[cfg(target_os = "fuchsia")]
17183impl Usage2AudioConsumerFactorySynchronousProxy {
17184    pub fn new(channel: fidl::Channel) -> Self {
17185        Self { client: fidl::client::sync::Client::new(channel) }
17186    }
17187
17188    pub fn into_channel(self) -> fidl::Channel {
17189        self.client.into_channel()
17190    }
17191
17192    /// Waits until an event arrives and returns it. It is safe for other
17193    /// threads to make concurrent requests while waiting for an event.
17194    pub fn wait_for_event(
17195        &self,
17196        deadline: zx::MonotonicInstant,
17197    ) -> Result<Usage2AudioConsumerFactoryEvent, fidl::Error> {
17198        Usage2AudioConsumerFactoryEvent::decode(
17199            self.client.wait_for_event::<Usage2AudioConsumerFactoryMarker>(deadline)?,
17200        )
17201    }
17202
17203    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
17204    /// Audio submitted to such a consumer is always rendered locally.
17205    pub fn r#create_audio_consumer(
17206        &self,
17207        mut usage: AudioRenderUsage2,
17208        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17209    ) -> Result<(), fidl::Error> {
17210        self.client.send::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(
17211            (usage, audio_consumer_request),
17212            0x767722302a171873,
17213            fidl::encoding::DynamicFlags::FLEXIBLE,
17214        )
17215    }
17216}
17217
17218#[cfg(target_os = "fuchsia")]
17219impl From<Usage2AudioConsumerFactorySynchronousProxy> for zx::NullableHandle {
17220    fn from(value: Usage2AudioConsumerFactorySynchronousProxy) -> Self {
17221        value.into_channel().into()
17222    }
17223}
17224
17225#[cfg(target_os = "fuchsia")]
17226impl From<fidl::Channel> for Usage2AudioConsumerFactorySynchronousProxy {
17227    fn from(value: fidl::Channel) -> Self {
17228        Self::new(value)
17229    }
17230}
17231
17232#[cfg(target_os = "fuchsia")]
17233impl fidl::endpoints::FromClient for Usage2AudioConsumerFactorySynchronousProxy {
17234    type Protocol = Usage2AudioConsumerFactoryMarker;
17235
17236    fn from_client(value: fidl::endpoints::ClientEnd<Usage2AudioConsumerFactoryMarker>) -> Self {
17237        Self::new(value.into_channel())
17238    }
17239}
17240
17241#[derive(Debug, Clone)]
17242pub struct Usage2AudioConsumerFactoryProxy {
17243    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
17244}
17245
17246impl fidl::endpoints::Proxy for Usage2AudioConsumerFactoryProxy {
17247    type Protocol = Usage2AudioConsumerFactoryMarker;
17248
17249    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
17250        Self::new(inner)
17251    }
17252
17253    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
17254        self.client.into_channel().map_err(|client| Self { client })
17255    }
17256
17257    fn as_channel(&self) -> &::fidl::AsyncChannel {
17258        self.client.as_channel()
17259    }
17260}
17261
17262impl Usage2AudioConsumerFactoryProxy {
17263    /// Create a new Proxy for fuchsia.media/Usage2AudioConsumerFactory.
17264    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
17265        let protocol_name =
17266            <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17267        Self { client: fidl::client::Client::new(channel, protocol_name) }
17268    }
17269
17270    /// Get a Stream of events from the remote end of the protocol.
17271    ///
17272    /// # Panics
17273    ///
17274    /// Panics if the event stream was already taken.
17275    pub fn take_event_stream(&self) -> Usage2AudioConsumerFactoryEventStream {
17276        Usage2AudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
17277    }
17278
17279    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
17280    /// Audio submitted to such a consumer is always rendered locally.
17281    pub fn r#create_audio_consumer(
17282        &self,
17283        mut usage: AudioRenderUsage2,
17284        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17285    ) -> Result<(), fidl::Error> {
17286        Usage2AudioConsumerFactoryProxyInterface::r#create_audio_consumer(
17287            self,
17288            usage,
17289            audio_consumer_request,
17290        )
17291    }
17292}
17293
17294impl Usage2AudioConsumerFactoryProxyInterface for Usage2AudioConsumerFactoryProxy {
17295    fn r#create_audio_consumer(
17296        &self,
17297        mut usage: AudioRenderUsage2,
17298        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17299    ) -> Result<(), fidl::Error> {
17300        self.client.send::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(
17301            (usage, audio_consumer_request),
17302            0x767722302a171873,
17303            fidl::encoding::DynamicFlags::FLEXIBLE,
17304        )
17305    }
17306}
17307
17308pub struct Usage2AudioConsumerFactoryEventStream {
17309    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
17310}
17311
17312impl std::marker::Unpin for Usage2AudioConsumerFactoryEventStream {}
17313
17314impl futures::stream::FusedStream for Usage2AudioConsumerFactoryEventStream {
17315    fn is_terminated(&self) -> bool {
17316        self.event_receiver.is_terminated()
17317    }
17318}
17319
17320impl futures::Stream for Usage2AudioConsumerFactoryEventStream {
17321    type Item = Result<Usage2AudioConsumerFactoryEvent, fidl::Error>;
17322
17323    fn poll_next(
17324        mut self: std::pin::Pin<&mut Self>,
17325        cx: &mut std::task::Context<'_>,
17326    ) -> std::task::Poll<Option<Self::Item>> {
17327        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
17328            &mut self.event_receiver,
17329            cx
17330        )?) {
17331            Some(buf) => std::task::Poll::Ready(Some(Usage2AudioConsumerFactoryEvent::decode(buf))),
17332            None => std::task::Poll::Ready(None),
17333        }
17334    }
17335}
17336
17337#[derive(Debug)]
17338pub enum Usage2AudioConsumerFactoryEvent {
17339    #[non_exhaustive]
17340    _UnknownEvent {
17341        /// Ordinal of the event that was sent.
17342        ordinal: u64,
17343    },
17344}
17345
17346impl Usage2AudioConsumerFactoryEvent {
17347    /// Decodes a message buffer as a [`Usage2AudioConsumerFactoryEvent`].
17348    fn decode(
17349        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
17350    ) -> Result<Usage2AudioConsumerFactoryEvent, fidl::Error> {
17351        let (bytes, _handles) = buf.split_mut();
17352        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17353        debug_assert_eq!(tx_header.tx_id, 0);
17354        match tx_header.ordinal {
17355            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17356                Ok(Usage2AudioConsumerFactoryEvent::_UnknownEvent {
17357                    ordinal: tx_header.ordinal,
17358                })
17359            }
17360            _ => Err(fidl::Error::UnknownOrdinal {
17361                ordinal: tx_header.ordinal,
17362                protocol_name: <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17363            })
17364        }
17365    }
17366}
17367
17368/// A Stream of incoming requests for fuchsia.media/Usage2AudioConsumerFactory.
17369pub struct Usage2AudioConsumerFactoryRequestStream {
17370    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17371    is_terminated: bool,
17372}
17373
17374impl std::marker::Unpin for Usage2AudioConsumerFactoryRequestStream {}
17375
17376impl futures::stream::FusedStream for Usage2AudioConsumerFactoryRequestStream {
17377    fn is_terminated(&self) -> bool {
17378        self.is_terminated
17379    }
17380}
17381
17382impl fidl::endpoints::RequestStream for Usage2AudioConsumerFactoryRequestStream {
17383    type Protocol = Usage2AudioConsumerFactoryMarker;
17384    type ControlHandle = Usage2AudioConsumerFactoryControlHandle;
17385
17386    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
17387        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
17388    }
17389
17390    fn control_handle(&self) -> Self::ControlHandle {
17391        Usage2AudioConsumerFactoryControlHandle { inner: self.inner.clone() }
17392    }
17393
17394    fn into_inner(
17395        self,
17396    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
17397    {
17398        (self.inner, self.is_terminated)
17399    }
17400
17401    fn from_inner(
17402        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17403        is_terminated: bool,
17404    ) -> Self {
17405        Self { inner, is_terminated }
17406    }
17407}
17408
17409impl futures::Stream for Usage2AudioConsumerFactoryRequestStream {
17410    type Item = Result<Usage2AudioConsumerFactoryRequest, fidl::Error>;
17411
17412    fn poll_next(
17413        mut self: std::pin::Pin<&mut Self>,
17414        cx: &mut std::task::Context<'_>,
17415    ) -> std::task::Poll<Option<Self::Item>> {
17416        let this = &mut *self;
17417        if this.inner.check_shutdown(cx) {
17418            this.is_terminated = true;
17419            return std::task::Poll::Ready(None);
17420        }
17421        if this.is_terminated {
17422            panic!("polled Usage2AudioConsumerFactoryRequestStream after completion");
17423        }
17424        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
17425            |bytes, handles| {
17426                match this.inner.channel().read_etc(cx, bytes, handles) {
17427                    std::task::Poll::Ready(Ok(())) => {}
17428                    std::task::Poll::Pending => return std::task::Poll::Pending,
17429                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
17430                        this.is_terminated = true;
17431                        return std::task::Poll::Ready(None);
17432                    }
17433                    std::task::Poll::Ready(Err(e)) => {
17434                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
17435                            e.into(),
17436                        ))));
17437                    }
17438                }
17439
17440                // A message has been received from the channel
17441                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17442
17443                std::task::Poll::Ready(Some(match header.ordinal {
17444                0x767722302a171873 => {
17445                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
17446                    let mut req = fidl::new_empty!(Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
17447                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
17448                    let control_handle = Usage2AudioConsumerFactoryControlHandle {
17449                        inner: this.inner.clone(),
17450                    };
17451                    Ok(Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
17452audio_consumer_request: req.audio_consumer_request,
17453
17454                        control_handle,
17455                    })
17456                }
17457                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17458                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17459                        ordinal: header.ordinal,
17460                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
17461                        method_type: fidl::MethodType::OneWay,
17462                    })
17463                }
17464                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17465                    this.inner.send_framework_err(
17466                        fidl::encoding::FrameworkErr::UnknownMethod,
17467                        header.tx_id,
17468                        header.ordinal,
17469                        header.dynamic_flags(),
17470                        (bytes, handles),
17471                    )?;
17472                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17473                        ordinal: header.ordinal,
17474                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
17475                        method_type: fidl::MethodType::TwoWay,
17476                    })
17477                }
17478                _ => Err(fidl::Error::UnknownOrdinal {
17479                    ordinal: header.ordinal,
17480                    protocol_name: <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17481                }),
17482            }))
17483            },
17484        )
17485    }
17486}
17487
17488/// Interface for creating audio consumers for local rendering.
17489#[derive(Debug)]
17490pub enum Usage2AudioConsumerFactoryRequest {
17491    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
17492    /// Audio submitted to such a consumer is always rendered locally.
17493    CreateAudioConsumer {
17494        usage: AudioRenderUsage2,
17495        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17496        control_handle: Usage2AudioConsumerFactoryControlHandle,
17497    },
17498    /// An interaction was received which does not match any known method.
17499    #[non_exhaustive]
17500    _UnknownMethod {
17501        /// Ordinal of the method that was called.
17502        ordinal: u64,
17503        control_handle: Usage2AudioConsumerFactoryControlHandle,
17504        method_type: fidl::MethodType,
17505    },
17506}
17507
17508impl Usage2AudioConsumerFactoryRequest {
17509    #[allow(irrefutable_let_patterns)]
17510    pub fn into_create_audio_consumer(
17511        self,
17512    ) -> Option<(
17513        AudioRenderUsage2,
17514        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17515        Usage2AudioConsumerFactoryControlHandle,
17516    )> {
17517        if let Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {
17518            usage,
17519            audio_consumer_request,
17520            control_handle,
17521        } = self
17522        {
17523            Some((usage, audio_consumer_request, control_handle))
17524        } else {
17525            None
17526        }
17527    }
17528
17529    /// Name of the method defined in FIDL
17530    pub fn method_name(&self) -> &'static str {
17531        match *self {
17532            Usage2AudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
17533                "create_audio_consumer"
17534            }
17535            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17536                method_type: fidl::MethodType::OneWay,
17537                ..
17538            } => "unknown one-way method",
17539            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17540                method_type: fidl::MethodType::TwoWay,
17541                ..
17542            } => "unknown two-way method",
17543        }
17544    }
17545}
17546
17547#[derive(Debug, Clone)]
17548pub struct Usage2AudioConsumerFactoryControlHandle {
17549    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17550}
17551
17552impl fidl::endpoints::ControlHandle for Usage2AudioConsumerFactoryControlHandle {
17553    fn shutdown(&self) {
17554        self.inner.shutdown()
17555    }
17556
17557    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
17558        self.inner.shutdown_with_epitaph(status)
17559    }
17560
17561    fn is_closed(&self) -> bool {
17562        self.inner.channel().is_closed()
17563    }
17564    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
17565        self.inner.channel().on_closed()
17566    }
17567
17568    #[cfg(target_os = "fuchsia")]
17569    fn signal_peer(
17570        &self,
17571        clear_mask: zx::Signals,
17572        set_mask: zx::Signals,
17573    ) -> Result<(), zx_status::Status> {
17574        use fidl::Peered;
17575        self.inner.channel().signal_peer(clear_mask, set_mask)
17576    }
17577}
17578
17579impl Usage2AudioConsumerFactoryControlHandle {}
17580
17581#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17582pub struct UsageAudioConsumerFactoryMarker;
17583
17584impl fidl::endpoints::ProtocolMarker for UsageAudioConsumerFactoryMarker {
17585    type Proxy = UsageAudioConsumerFactoryProxy;
17586    type RequestStream = UsageAudioConsumerFactoryRequestStream;
17587    #[cfg(target_os = "fuchsia")]
17588    type SynchronousProxy = UsageAudioConsumerFactorySynchronousProxy;
17589
17590    const DEBUG_NAME: &'static str = "fuchsia.media.UsageAudioConsumerFactory";
17591}
17592impl fidl::endpoints::DiscoverableProtocolMarker for UsageAudioConsumerFactoryMarker {}
17593
17594pub trait UsageAudioConsumerFactoryProxyInterface: Send + Sync {
17595    fn r#create_audio_consumer(
17596        &self,
17597        usage: AudioRenderUsage,
17598        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17599    ) -> Result<(), fidl::Error>;
17600}
17601#[derive(Debug)]
17602#[cfg(target_os = "fuchsia")]
17603pub struct UsageAudioConsumerFactorySynchronousProxy {
17604    client: fidl::client::sync::Client,
17605}
17606
17607#[cfg(target_os = "fuchsia")]
17608impl fidl::endpoints::SynchronousProxy for UsageAudioConsumerFactorySynchronousProxy {
17609    type Proxy = UsageAudioConsumerFactoryProxy;
17610    type Protocol = UsageAudioConsumerFactoryMarker;
17611
17612    fn from_channel(inner: fidl::Channel) -> Self {
17613        Self::new(inner)
17614    }
17615
17616    fn into_channel(self) -> fidl::Channel {
17617        self.client.into_channel()
17618    }
17619
17620    fn as_channel(&self) -> &fidl::Channel {
17621        self.client.as_channel()
17622    }
17623}
17624
17625#[cfg(target_os = "fuchsia")]
17626impl UsageAudioConsumerFactorySynchronousProxy {
17627    pub fn new(channel: fidl::Channel) -> Self {
17628        Self { client: fidl::client::sync::Client::new(channel) }
17629    }
17630
17631    pub fn into_channel(self) -> fidl::Channel {
17632        self.client.into_channel()
17633    }
17634
17635    /// Waits until an event arrives and returns it. It is safe for other
17636    /// threads to make concurrent requests while waiting for an event.
17637    pub fn wait_for_event(
17638        &self,
17639        deadline: zx::MonotonicInstant,
17640    ) -> Result<UsageAudioConsumerFactoryEvent, fidl::Error> {
17641        UsageAudioConsumerFactoryEvent::decode(
17642            self.client.wait_for_event::<UsageAudioConsumerFactoryMarker>(deadline)?,
17643        )
17644    }
17645
17646    pub fn r#create_audio_consumer(
17647        &self,
17648        mut usage: AudioRenderUsage,
17649        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17650    ) -> Result<(), fidl::Error> {
17651        self.client.send::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(
17652            (usage, audio_consumer_request),
17653            0x4d975ca9b8f625a3,
17654            fidl::encoding::DynamicFlags::empty(),
17655        )
17656    }
17657}
17658
17659#[cfg(target_os = "fuchsia")]
17660impl From<UsageAudioConsumerFactorySynchronousProxy> for zx::NullableHandle {
17661    fn from(value: UsageAudioConsumerFactorySynchronousProxy) -> Self {
17662        value.into_channel().into()
17663    }
17664}
17665
17666#[cfg(target_os = "fuchsia")]
17667impl From<fidl::Channel> for UsageAudioConsumerFactorySynchronousProxy {
17668    fn from(value: fidl::Channel) -> Self {
17669        Self::new(value)
17670    }
17671}
17672
17673#[cfg(target_os = "fuchsia")]
17674impl fidl::endpoints::FromClient for UsageAudioConsumerFactorySynchronousProxy {
17675    type Protocol = UsageAudioConsumerFactoryMarker;
17676
17677    fn from_client(value: fidl::endpoints::ClientEnd<UsageAudioConsumerFactoryMarker>) -> Self {
17678        Self::new(value.into_channel())
17679    }
17680}
17681
17682#[derive(Debug, Clone)]
17683pub struct UsageAudioConsumerFactoryProxy {
17684    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
17685}
17686
17687impl fidl::endpoints::Proxy for UsageAudioConsumerFactoryProxy {
17688    type Protocol = UsageAudioConsumerFactoryMarker;
17689
17690    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
17691        Self::new(inner)
17692    }
17693
17694    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
17695        self.client.into_channel().map_err(|client| Self { client })
17696    }
17697
17698    fn as_channel(&self) -> &::fidl::AsyncChannel {
17699        self.client.as_channel()
17700    }
17701}
17702
17703impl UsageAudioConsumerFactoryProxy {
17704    /// Create a new Proxy for fuchsia.media/UsageAudioConsumerFactory.
17705    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
17706        let protocol_name =
17707            <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17708        Self { client: fidl::client::Client::new(channel, protocol_name) }
17709    }
17710
17711    /// Get a Stream of events from the remote end of the protocol.
17712    ///
17713    /// # Panics
17714    ///
17715    /// Panics if the event stream was already taken.
17716    pub fn take_event_stream(&self) -> UsageAudioConsumerFactoryEventStream {
17717        UsageAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
17718    }
17719
17720    pub fn r#create_audio_consumer(
17721        &self,
17722        mut usage: AudioRenderUsage,
17723        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17724    ) -> Result<(), fidl::Error> {
17725        UsageAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
17726            self,
17727            usage,
17728            audio_consumer_request,
17729        )
17730    }
17731}
17732
17733impl UsageAudioConsumerFactoryProxyInterface for UsageAudioConsumerFactoryProxy {
17734    fn r#create_audio_consumer(
17735        &self,
17736        mut usage: AudioRenderUsage,
17737        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17738    ) -> Result<(), fidl::Error> {
17739        self.client.send::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(
17740            (usage, audio_consumer_request),
17741            0x4d975ca9b8f625a3,
17742            fidl::encoding::DynamicFlags::empty(),
17743        )
17744    }
17745}
17746
17747pub struct UsageAudioConsumerFactoryEventStream {
17748    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
17749}
17750
17751impl std::marker::Unpin for UsageAudioConsumerFactoryEventStream {}
17752
17753impl futures::stream::FusedStream for UsageAudioConsumerFactoryEventStream {
17754    fn is_terminated(&self) -> bool {
17755        self.event_receiver.is_terminated()
17756    }
17757}
17758
17759impl futures::Stream for UsageAudioConsumerFactoryEventStream {
17760    type Item = Result<UsageAudioConsumerFactoryEvent, fidl::Error>;
17761
17762    fn poll_next(
17763        mut self: std::pin::Pin<&mut Self>,
17764        cx: &mut std::task::Context<'_>,
17765    ) -> std::task::Poll<Option<Self::Item>> {
17766        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
17767            &mut self.event_receiver,
17768            cx
17769        )?) {
17770            Some(buf) => std::task::Poll::Ready(Some(UsageAudioConsumerFactoryEvent::decode(buf))),
17771            None => std::task::Poll::Ready(None),
17772        }
17773    }
17774}
17775
17776#[derive(Debug)]
17777pub enum UsageAudioConsumerFactoryEvent {}
17778
17779impl UsageAudioConsumerFactoryEvent {
17780    /// Decodes a message buffer as a [`UsageAudioConsumerFactoryEvent`].
17781    fn decode(
17782        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
17783    ) -> Result<UsageAudioConsumerFactoryEvent, fidl::Error> {
17784        let (bytes, _handles) = buf.split_mut();
17785        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17786        debug_assert_eq!(tx_header.tx_id, 0);
17787        match tx_header.ordinal {
17788            _ => Err(fidl::Error::UnknownOrdinal {
17789                ordinal: tx_header.ordinal,
17790                protocol_name:
17791                    <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17792            }),
17793        }
17794    }
17795}
17796
17797/// A Stream of incoming requests for fuchsia.media/UsageAudioConsumerFactory.
17798pub struct UsageAudioConsumerFactoryRequestStream {
17799    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17800    is_terminated: bool,
17801}
17802
17803impl std::marker::Unpin for UsageAudioConsumerFactoryRequestStream {}
17804
17805impl futures::stream::FusedStream for UsageAudioConsumerFactoryRequestStream {
17806    fn is_terminated(&self) -> bool {
17807        self.is_terminated
17808    }
17809}
17810
17811impl fidl::endpoints::RequestStream for UsageAudioConsumerFactoryRequestStream {
17812    type Protocol = UsageAudioConsumerFactoryMarker;
17813    type ControlHandle = UsageAudioConsumerFactoryControlHandle;
17814
17815    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
17816        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
17817    }
17818
17819    fn control_handle(&self) -> Self::ControlHandle {
17820        UsageAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
17821    }
17822
17823    fn into_inner(
17824        self,
17825    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
17826    {
17827        (self.inner, self.is_terminated)
17828    }
17829
17830    fn from_inner(
17831        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17832        is_terminated: bool,
17833    ) -> Self {
17834        Self { inner, is_terminated }
17835    }
17836}
17837
17838impl futures::Stream for UsageAudioConsumerFactoryRequestStream {
17839    type Item = Result<UsageAudioConsumerFactoryRequest, fidl::Error>;
17840
17841    fn poll_next(
17842        mut self: std::pin::Pin<&mut Self>,
17843        cx: &mut std::task::Context<'_>,
17844    ) -> std::task::Poll<Option<Self::Item>> {
17845        let this = &mut *self;
17846        if this.inner.check_shutdown(cx) {
17847            this.is_terminated = true;
17848            return std::task::Poll::Ready(None);
17849        }
17850        if this.is_terminated {
17851            panic!("polled UsageAudioConsumerFactoryRequestStream after completion");
17852        }
17853        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
17854            |bytes, handles| {
17855                match this.inner.channel().read_etc(cx, bytes, handles) {
17856                    std::task::Poll::Ready(Ok(())) => {}
17857                    std::task::Poll::Pending => return std::task::Poll::Pending,
17858                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
17859                        this.is_terminated = true;
17860                        return std::task::Poll::Ready(None);
17861                    }
17862                    std::task::Poll::Ready(Err(e)) => {
17863                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
17864                            e.into(),
17865                        ))));
17866                    }
17867                }
17868
17869                // A message has been received from the channel
17870                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17871
17872                std::task::Poll::Ready(Some(match header.ordinal {
17873                0x4d975ca9b8f625a3 => {
17874                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
17875                    let mut req = fidl::new_empty!(UsageAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
17876                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
17877                    let control_handle = UsageAudioConsumerFactoryControlHandle {
17878                        inner: this.inner.clone(),
17879                    };
17880                    Ok(UsageAudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
17881audio_consumer_request: req.audio_consumer_request,
17882
17883                        control_handle,
17884                    })
17885                }
17886                _ => Err(fidl::Error::UnknownOrdinal {
17887                    ordinal: header.ordinal,
17888                    protocol_name: <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17889                }),
17890            }))
17891            },
17892        )
17893    }
17894}
17895
17896/// Interface for creating audio consumers for local rendering.
17897#[derive(Debug)]
17898pub enum UsageAudioConsumerFactoryRequest {
17899    CreateAudioConsumer {
17900        usage: AudioRenderUsage,
17901        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17902        control_handle: UsageAudioConsumerFactoryControlHandle,
17903    },
17904}
17905
17906impl UsageAudioConsumerFactoryRequest {
17907    #[allow(irrefutable_let_patterns)]
17908    pub fn into_create_audio_consumer(
17909        self,
17910    ) -> Option<(
17911        AudioRenderUsage,
17912        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17913        UsageAudioConsumerFactoryControlHandle,
17914    )> {
17915        if let UsageAudioConsumerFactoryRequest::CreateAudioConsumer {
17916            usage,
17917            audio_consumer_request,
17918            control_handle,
17919        } = self
17920        {
17921            Some((usage, audio_consumer_request, control_handle))
17922        } else {
17923            None
17924        }
17925    }
17926
17927    /// Name of the method defined in FIDL
17928    pub fn method_name(&self) -> &'static str {
17929        match *self {
17930            UsageAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => "create_audio_consumer",
17931        }
17932    }
17933}
17934
17935#[derive(Debug, Clone)]
17936pub struct UsageAudioConsumerFactoryControlHandle {
17937    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17938}
17939
17940impl fidl::endpoints::ControlHandle for UsageAudioConsumerFactoryControlHandle {
17941    fn shutdown(&self) {
17942        self.inner.shutdown()
17943    }
17944
17945    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
17946        self.inner.shutdown_with_epitaph(status)
17947    }
17948
17949    fn is_closed(&self) -> bool {
17950        self.inner.channel().is_closed()
17951    }
17952    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
17953        self.inner.channel().on_closed()
17954    }
17955
17956    #[cfg(target_os = "fuchsia")]
17957    fn signal_peer(
17958        &self,
17959        clear_mask: zx::Signals,
17960        set_mask: zx::Signals,
17961    ) -> Result<(), zx_status::Status> {
17962        use fidl::Peered;
17963        self.inner.channel().signal_peer(clear_mask, set_mask)
17964    }
17965}
17966
17967impl UsageAudioConsumerFactoryControlHandle {}
17968
17969#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17970pub struct UsageGainListenerMarker;
17971
17972impl fidl::endpoints::ProtocolMarker for UsageGainListenerMarker {
17973    type Proxy = UsageGainListenerProxy;
17974    type RequestStream = UsageGainListenerRequestStream;
17975    #[cfg(target_os = "fuchsia")]
17976    type SynchronousProxy = UsageGainListenerSynchronousProxy;
17977
17978    const DEBUG_NAME: &'static str = "(anonymous) UsageGainListener";
17979}
17980
17981pub trait UsageGainListenerProxyInterface: Send + Sync {
17982    type OnGainMuteChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
17983    fn r#on_gain_mute_changed(
17984        &self,
17985        muted: bool,
17986        gain_dbfs: f32,
17987    ) -> Self::OnGainMuteChangedResponseFut;
17988}
17989#[derive(Debug)]
17990#[cfg(target_os = "fuchsia")]
17991pub struct UsageGainListenerSynchronousProxy {
17992    client: fidl::client::sync::Client,
17993}
17994
17995#[cfg(target_os = "fuchsia")]
17996impl fidl::endpoints::SynchronousProxy for UsageGainListenerSynchronousProxy {
17997    type Proxy = UsageGainListenerProxy;
17998    type Protocol = UsageGainListenerMarker;
17999
18000    fn from_channel(inner: fidl::Channel) -> Self {
18001        Self::new(inner)
18002    }
18003
18004    fn into_channel(self) -> fidl::Channel {
18005        self.client.into_channel()
18006    }
18007
18008    fn as_channel(&self) -> &fidl::Channel {
18009        self.client.as_channel()
18010    }
18011}
18012
18013#[cfg(target_os = "fuchsia")]
18014impl UsageGainListenerSynchronousProxy {
18015    pub fn new(channel: fidl::Channel) -> Self {
18016        Self { client: fidl::client::sync::Client::new(channel) }
18017    }
18018
18019    pub fn into_channel(self) -> fidl::Channel {
18020        self.client.into_channel()
18021    }
18022
18023    /// Waits until an event arrives and returns it. It is safe for other
18024    /// threads to make concurrent requests while waiting for an event.
18025    pub fn wait_for_event(
18026        &self,
18027        deadline: zx::MonotonicInstant,
18028    ) -> Result<UsageGainListenerEvent, fidl::Error> {
18029        UsageGainListenerEvent::decode(
18030            self.client.wait_for_event::<UsageGainListenerMarker>(deadline)?,
18031        )
18032    }
18033
18034    /// Called immediately on connection and afterward any time
18035    /// the usage gain setting changes.
18036    ///
18037    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
18038    /// events will eventually be disconnected.
18039    ///
18040    /// Note: This API does not have mute reporting implemented; `muted` is always false.
18041    pub fn r#on_gain_mute_changed(
18042        &self,
18043        mut muted: bool,
18044        mut gain_dbfs: f32,
18045        ___deadline: zx::MonotonicInstant,
18046    ) -> Result<(), fidl::Error> {
18047        let _response = self.client.send_query::<
18048            UsageGainListenerOnGainMuteChangedRequest,
18049            fidl::encoding::EmptyPayload,
18050            UsageGainListenerMarker,
18051        >(
18052            (muted, gain_dbfs,),
18053            0x681570258eac3a8d,
18054            fidl::encoding::DynamicFlags::empty(),
18055            ___deadline,
18056        )?;
18057        Ok(_response)
18058    }
18059}
18060
18061#[cfg(target_os = "fuchsia")]
18062impl From<UsageGainListenerSynchronousProxy> for zx::NullableHandle {
18063    fn from(value: UsageGainListenerSynchronousProxy) -> Self {
18064        value.into_channel().into()
18065    }
18066}
18067
18068#[cfg(target_os = "fuchsia")]
18069impl From<fidl::Channel> for UsageGainListenerSynchronousProxy {
18070    fn from(value: fidl::Channel) -> Self {
18071        Self::new(value)
18072    }
18073}
18074
18075#[cfg(target_os = "fuchsia")]
18076impl fidl::endpoints::FromClient for UsageGainListenerSynchronousProxy {
18077    type Protocol = UsageGainListenerMarker;
18078
18079    fn from_client(value: fidl::endpoints::ClientEnd<UsageGainListenerMarker>) -> Self {
18080        Self::new(value.into_channel())
18081    }
18082}
18083
18084#[derive(Debug, Clone)]
18085pub struct UsageGainListenerProxy {
18086    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
18087}
18088
18089impl fidl::endpoints::Proxy for UsageGainListenerProxy {
18090    type Protocol = UsageGainListenerMarker;
18091
18092    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
18093        Self::new(inner)
18094    }
18095
18096    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
18097        self.client.into_channel().map_err(|client| Self { client })
18098    }
18099
18100    fn as_channel(&self) -> &::fidl::AsyncChannel {
18101        self.client.as_channel()
18102    }
18103}
18104
18105impl UsageGainListenerProxy {
18106    /// Create a new Proxy for fuchsia.media/UsageGainListener.
18107    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
18108        let protocol_name =
18109            <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
18110        Self { client: fidl::client::Client::new(channel, protocol_name) }
18111    }
18112
18113    /// Get a Stream of events from the remote end of the protocol.
18114    ///
18115    /// # Panics
18116    ///
18117    /// Panics if the event stream was already taken.
18118    pub fn take_event_stream(&self) -> UsageGainListenerEventStream {
18119        UsageGainListenerEventStream { event_receiver: self.client.take_event_receiver() }
18120    }
18121
18122    /// Called immediately on connection and afterward any time
18123    /// the usage gain setting changes.
18124    ///
18125    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
18126    /// events will eventually be disconnected.
18127    ///
18128    /// Note: This API does not have mute reporting implemented; `muted` is always false.
18129    pub fn r#on_gain_mute_changed(
18130        &self,
18131        mut muted: bool,
18132        mut gain_dbfs: f32,
18133    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
18134        UsageGainListenerProxyInterface::r#on_gain_mute_changed(self, muted, gain_dbfs)
18135    }
18136}
18137
18138impl UsageGainListenerProxyInterface for UsageGainListenerProxy {
18139    type OnGainMuteChangedResponseFut =
18140        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
18141    fn r#on_gain_mute_changed(
18142        &self,
18143        mut muted: bool,
18144        mut gain_dbfs: f32,
18145    ) -> Self::OnGainMuteChangedResponseFut {
18146        fn _decode(
18147            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
18148        ) -> Result<(), fidl::Error> {
18149            let _response = fidl::client::decode_transaction_body::<
18150                fidl::encoding::EmptyPayload,
18151                fidl::encoding::DefaultFuchsiaResourceDialect,
18152                0x681570258eac3a8d,
18153            >(_buf?)?;
18154            Ok(_response)
18155        }
18156        self.client.send_query_and_decode::<UsageGainListenerOnGainMuteChangedRequest, ()>(
18157            (muted, gain_dbfs),
18158            0x681570258eac3a8d,
18159            fidl::encoding::DynamicFlags::empty(),
18160            _decode,
18161        )
18162    }
18163}
18164
18165pub struct UsageGainListenerEventStream {
18166    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
18167}
18168
18169impl std::marker::Unpin for UsageGainListenerEventStream {}
18170
18171impl futures::stream::FusedStream for UsageGainListenerEventStream {
18172    fn is_terminated(&self) -> bool {
18173        self.event_receiver.is_terminated()
18174    }
18175}
18176
18177impl futures::Stream for UsageGainListenerEventStream {
18178    type Item = Result<UsageGainListenerEvent, fidl::Error>;
18179
18180    fn poll_next(
18181        mut self: std::pin::Pin<&mut Self>,
18182        cx: &mut std::task::Context<'_>,
18183    ) -> std::task::Poll<Option<Self::Item>> {
18184        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
18185            &mut self.event_receiver,
18186            cx
18187        )?) {
18188            Some(buf) => std::task::Poll::Ready(Some(UsageGainListenerEvent::decode(buf))),
18189            None => std::task::Poll::Ready(None),
18190        }
18191    }
18192}
18193
18194#[derive(Debug)]
18195pub enum UsageGainListenerEvent {}
18196
18197impl UsageGainListenerEvent {
18198    /// Decodes a message buffer as a [`UsageGainListenerEvent`].
18199    fn decode(
18200        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
18201    ) -> Result<UsageGainListenerEvent, fidl::Error> {
18202        let (bytes, _handles) = buf.split_mut();
18203        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18204        debug_assert_eq!(tx_header.tx_id, 0);
18205        match tx_header.ordinal {
18206            _ => Err(fidl::Error::UnknownOrdinal {
18207                ordinal: tx_header.ordinal,
18208                protocol_name:
18209                    <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18210            }),
18211        }
18212    }
18213}
18214
18215/// A Stream of incoming requests for fuchsia.media/UsageGainListener.
18216pub struct UsageGainListenerRequestStream {
18217    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18218    is_terminated: bool,
18219}
18220
18221impl std::marker::Unpin for UsageGainListenerRequestStream {}
18222
18223impl futures::stream::FusedStream for UsageGainListenerRequestStream {
18224    fn is_terminated(&self) -> bool {
18225        self.is_terminated
18226    }
18227}
18228
18229impl fidl::endpoints::RequestStream for UsageGainListenerRequestStream {
18230    type Protocol = UsageGainListenerMarker;
18231    type ControlHandle = UsageGainListenerControlHandle;
18232
18233    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
18234        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
18235    }
18236
18237    fn control_handle(&self) -> Self::ControlHandle {
18238        UsageGainListenerControlHandle { inner: self.inner.clone() }
18239    }
18240
18241    fn into_inner(
18242        self,
18243    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
18244    {
18245        (self.inner, self.is_terminated)
18246    }
18247
18248    fn from_inner(
18249        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18250        is_terminated: bool,
18251    ) -> Self {
18252        Self { inner, is_terminated }
18253    }
18254}
18255
18256impl futures::Stream for UsageGainListenerRequestStream {
18257    type Item = Result<UsageGainListenerRequest, fidl::Error>;
18258
18259    fn poll_next(
18260        mut self: std::pin::Pin<&mut Self>,
18261        cx: &mut std::task::Context<'_>,
18262    ) -> std::task::Poll<Option<Self::Item>> {
18263        let this = &mut *self;
18264        if this.inner.check_shutdown(cx) {
18265            this.is_terminated = true;
18266            return std::task::Poll::Ready(None);
18267        }
18268        if this.is_terminated {
18269            panic!("polled UsageGainListenerRequestStream after completion");
18270        }
18271        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
18272            |bytes, handles| {
18273                match this.inner.channel().read_etc(cx, bytes, handles) {
18274                    std::task::Poll::Ready(Ok(())) => {}
18275                    std::task::Poll::Pending => return std::task::Poll::Pending,
18276                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
18277                        this.is_terminated = true;
18278                        return std::task::Poll::Ready(None);
18279                    }
18280                    std::task::Poll::Ready(Err(e)) => {
18281                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
18282                            e.into(),
18283                        ))));
18284                    }
18285                }
18286
18287                // A message has been received from the channel
18288                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18289
18290                std::task::Poll::Ready(Some(match header.ordinal {
18291                    0x681570258eac3a8d => {
18292                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
18293                        let mut req = fidl::new_empty!(
18294                            UsageGainListenerOnGainMuteChangedRequest,
18295                            fidl::encoding::DefaultFuchsiaResourceDialect
18296                        );
18297                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainListenerOnGainMuteChangedRequest>(&header, _body_bytes, handles, &mut req)?;
18298                        let control_handle =
18299                            UsageGainListenerControlHandle { inner: this.inner.clone() };
18300                        Ok(UsageGainListenerRequest::OnGainMuteChanged {
18301                            muted: req.muted,
18302                            gain_dbfs: req.gain_dbfs,
18303
18304                            responder: UsageGainListenerOnGainMuteChangedResponder {
18305                                control_handle: std::mem::ManuallyDrop::new(control_handle),
18306                                tx_id: header.tx_id,
18307                            },
18308                        })
18309                    }
18310                    _ => Err(fidl::Error::UnknownOrdinal {
18311                        ordinal: header.ordinal,
18312                        protocol_name:
18313                            <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18314                    }),
18315                }))
18316            },
18317        )
18318    }
18319}
18320
18321/// A protocol for watching changes to usage gain settings.
18322///
18323/// The channel will close when the device is not present.
18324#[derive(Debug)]
18325pub enum UsageGainListenerRequest {
18326    /// Called immediately on connection and afterward any time
18327    /// the usage gain setting changes.
18328    ///
18329    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
18330    /// events will eventually be disconnected.
18331    ///
18332    /// Note: This API does not have mute reporting implemented; `muted` is always false.
18333    OnGainMuteChanged {
18334        muted: bool,
18335        gain_dbfs: f32,
18336        responder: UsageGainListenerOnGainMuteChangedResponder,
18337    },
18338}
18339
18340impl UsageGainListenerRequest {
18341    #[allow(irrefutable_let_patterns)]
18342    pub fn into_on_gain_mute_changed(
18343        self,
18344    ) -> Option<(bool, f32, UsageGainListenerOnGainMuteChangedResponder)> {
18345        if let UsageGainListenerRequest::OnGainMuteChanged { muted, gain_dbfs, responder } = self {
18346            Some((muted, gain_dbfs, responder))
18347        } else {
18348            None
18349        }
18350    }
18351
18352    /// Name of the method defined in FIDL
18353    pub fn method_name(&self) -> &'static str {
18354        match *self {
18355            UsageGainListenerRequest::OnGainMuteChanged { .. } => "on_gain_mute_changed",
18356        }
18357    }
18358}
18359
18360#[derive(Debug, Clone)]
18361pub struct UsageGainListenerControlHandle {
18362    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18363}
18364
18365impl fidl::endpoints::ControlHandle for UsageGainListenerControlHandle {
18366    fn shutdown(&self) {
18367        self.inner.shutdown()
18368    }
18369
18370    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
18371        self.inner.shutdown_with_epitaph(status)
18372    }
18373
18374    fn is_closed(&self) -> bool {
18375        self.inner.channel().is_closed()
18376    }
18377    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
18378        self.inner.channel().on_closed()
18379    }
18380
18381    #[cfg(target_os = "fuchsia")]
18382    fn signal_peer(
18383        &self,
18384        clear_mask: zx::Signals,
18385        set_mask: zx::Signals,
18386    ) -> Result<(), zx_status::Status> {
18387        use fidl::Peered;
18388        self.inner.channel().signal_peer(clear_mask, set_mask)
18389    }
18390}
18391
18392impl UsageGainListenerControlHandle {}
18393
18394#[must_use = "FIDL methods require a response to be sent"]
18395#[derive(Debug)]
18396pub struct UsageGainListenerOnGainMuteChangedResponder {
18397    control_handle: std::mem::ManuallyDrop<UsageGainListenerControlHandle>,
18398    tx_id: u32,
18399}
18400
18401/// Set the the channel to be shutdown (see [`UsageGainListenerControlHandle::shutdown`])
18402/// if the responder is dropped without sending a response, so that the client
18403/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
18404impl std::ops::Drop for UsageGainListenerOnGainMuteChangedResponder {
18405    fn drop(&mut self) {
18406        self.control_handle.shutdown();
18407        // Safety: drops once, never accessed again
18408        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18409    }
18410}
18411
18412impl fidl::endpoints::Responder for UsageGainListenerOnGainMuteChangedResponder {
18413    type ControlHandle = UsageGainListenerControlHandle;
18414
18415    fn control_handle(&self) -> &UsageGainListenerControlHandle {
18416        &self.control_handle
18417    }
18418
18419    fn drop_without_shutdown(mut self) {
18420        // Safety: drops once, never accessed again due to mem::forget
18421        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18422        // Prevent Drop from running (which would shut down the channel)
18423        std::mem::forget(self);
18424    }
18425}
18426
18427impl UsageGainListenerOnGainMuteChangedResponder {
18428    /// Sends a response to the FIDL transaction.
18429    ///
18430    /// Sets the channel to shutdown if an error occurs.
18431    pub fn send(self) -> Result<(), fidl::Error> {
18432        let _result = self.send_raw();
18433        if _result.is_err() {
18434            self.control_handle.shutdown();
18435        }
18436        self.drop_without_shutdown();
18437        _result
18438    }
18439
18440    /// Similar to "send" but does not shutdown the channel if an error occurs.
18441    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
18442        let _result = self.send_raw();
18443        self.drop_without_shutdown();
18444        _result
18445    }
18446
18447    fn send_raw(&self) -> Result<(), fidl::Error> {
18448        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
18449            (),
18450            self.tx_id,
18451            0x681570258eac3a8d,
18452            fidl::encoding::DynamicFlags::empty(),
18453        )
18454    }
18455}
18456
18457#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
18458pub struct UsageGainReporterMarker;
18459
18460impl fidl::endpoints::ProtocolMarker for UsageGainReporterMarker {
18461    type Proxy = UsageGainReporterProxy;
18462    type RequestStream = UsageGainReporterRequestStream;
18463    #[cfg(target_os = "fuchsia")]
18464    type SynchronousProxy = UsageGainReporterSynchronousProxy;
18465
18466    const DEBUG_NAME: &'static str = "fuchsia.media.UsageGainReporter";
18467}
18468impl fidl::endpoints::DiscoverableProtocolMarker for UsageGainReporterMarker {}
18469
18470pub trait UsageGainReporterProxyInterface: Send + Sync {
18471    fn r#register_listener(
18472        &self,
18473        device_unique_id: &str,
18474        usage: &Usage,
18475        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18476    ) -> Result<(), fidl::Error>;
18477    fn r#register_listener2(
18478        &self,
18479        device_unique_id: &str,
18480        usage: &Usage2,
18481        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18482    ) -> Result<(), fidl::Error>;
18483}
18484#[derive(Debug)]
18485#[cfg(target_os = "fuchsia")]
18486pub struct UsageGainReporterSynchronousProxy {
18487    client: fidl::client::sync::Client,
18488}
18489
18490#[cfg(target_os = "fuchsia")]
18491impl fidl::endpoints::SynchronousProxy for UsageGainReporterSynchronousProxy {
18492    type Proxy = UsageGainReporterProxy;
18493    type Protocol = UsageGainReporterMarker;
18494
18495    fn from_channel(inner: fidl::Channel) -> Self {
18496        Self::new(inner)
18497    }
18498
18499    fn into_channel(self) -> fidl::Channel {
18500        self.client.into_channel()
18501    }
18502
18503    fn as_channel(&self) -> &fidl::Channel {
18504        self.client.as_channel()
18505    }
18506}
18507
18508#[cfg(target_os = "fuchsia")]
18509impl UsageGainReporterSynchronousProxy {
18510    pub fn new(channel: fidl::Channel) -> Self {
18511        Self { client: fidl::client::sync::Client::new(channel) }
18512    }
18513
18514    pub fn into_channel(self) -> fidl::Channel {
18515        self.client.into_channel()
18516    }
18517
18518    /// Waits until an event arrives and returns it. It is safe for other
18519    /// threads to make concurrent requests while waiting for an event.
18520    pub fn wait_for_event(
18521        &self,
18522        deadline: zx::MonotonicInstant,
18523    ) -> Result<UsageGainReporterEvent, fidl::Error> {
18524        UsageGainReporterEvent::decode(
18525            self.client.wait_for_event::<UsageGainReporterMarker>(deadline)?,
18526        )
18527    }
18528
18529    /// Connects a listener to a stream of usage gain setting changes
18530    /// for `usage` on the device identified by `device_token`. Usage
18531    /// Gain is not set directly by any client; it is a translation of
18532    /// the usage volume setting for each device, summed with active
18533    /// muting/ducking gain adjustments.
18534    ///
18535    /// Devices may map the same volume level to different dbfs, so
18536    /// a `device_unique_id` is needed to identify the device.
18537    ///
18538    /// `AudioDeviceEnumerator` provides programmatic access to devices
18539    /// and their unique ids if it is necessary for a client to select
18540    /// an id at runtime.
18541    pub fn r#register_listener(
18542        &self,
18543        mut device_unique_id: &str,
18544        mut usage: &Usage,
18545        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18546    ) -> Result<(), fidl::Error> {
18547        self.client.send::<UsageGainReporterRegisterListenerRequest>(
18548            (device_unique_id, usage, usage_gain_listener),
18549            0x767107c168c226af,
18550            fidl::encoding::DynamicFlags::empty(),
18551        )
18552    }
18553
18554    /// Connects a listener to a stream of usage gain setting changes
18555    /// for `usage` on the device identified by `device_token`. Usage
18556    /// Gain is not set directly by any client; it is a translation of
18557    /// the usage volume setting for each device, summed with active
18558    /// muting/ducking gain adjustments.
18559    ///
18560    /// Devices may map the same volume level to different dbfs, so
18561    /// a `device_unique_id` is needed to identify the device.
18562    ///
18563    /// `AudioDeviceEnumerator` provides programmatic access to devices
18564    /// and their unique ids if it is necessary for a client to select
18565    /// an id at runtime.
18566    pub fn r#register_listener2(
18567        &self,
18568        mut device_unique_id: &str,
18569        mut usage: &Usage2,
18570        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18571    ) -> Result<(), fidl::Error> {
18572        self.client.send::<UsageGainReporterRegisterListener2Request>(
18573            (device_unique_id, usage, usage_gain_listener),
18574            0x760a8e1c5873629c,
18575            fidl::encoding::DynamicFlags::FLEXIBLE,
18576        )
18577    }
18578}
18579
18580#[cfg(target_os = "fuchsia")]
18581impl From<UsageGainReporterSynchronousProxy> for zx::NullableHandle {
18582    fn from(value: UsageGainReporterSynchronousProxy) -> Self {
18583        value.into_channel().into()
18584    }
18585}
18586
18587#[cfg(target_os = "fuchsia")]
18588impl From<fidl::Channel> for UsageGainReporterSynchronousProxy {
18589    fn from(value: fidl::Channel) -> Self {
18590        Self::new(value)
18591    }
18592}
18593
18594#[cfg(target_os = "fuchsia")]
18595impl fidl::endpoints::FromClient for UsageGainReporterSynchronousProxy {
18596    type Protocol = UsageGainReporterMarker;
18597
18598    fn from_client(value: fidl::endpoints::ClientEnd<UsageGainReporterMarker>) -> Self {
18599        Self::new(value.into_channel())
18600    }
18601}
18602
18603#[derive(Debug, Clone)]
18604pub struct UsageGainReporterProxy {
18605    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
18606}
18607
18608impl fidl::endpoints::Proxy for UsageGainReporterProxy {
18609    type Protocol = UsageGainReporterMarker;
18610
18611    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
18612        Self::new(inner)
18613    }
18614
18615    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
18616        self.client.into_channel().map_err(|client| Self { client })
18617    }
18618
18619    fn as_channel(&self) -> &::fidl::AsyncChannel {
18620        self.client.as_channel()
18621    }
18622}
18623
18624impl UsageGainReporterProxy {
18625    /// Create a new Proxy for fuchsia.media/UsageGainReporter.
18626    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
18627        let protocol_name =
18628            <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
18629        Self { client: fidl::client::Client::new(channel, protocol_name) }
18630    }
18631
18632    /// Get a Stream of events from the remote end of the protocol.
18633    ///
18634    /// # Panics
18635    ///
18636    /// Panics if the event stream was already taken.
18637    pub fn take_event_stream(&self) -> UsageGainReporterEventStream {
18638        UsageGainReporterEventStream { event_receiver: self.client.take_event_receiver() }
18639    }
18640
18641    /// Connects a listener to a stream of usage gain setting changes
18642    /// for `usage` on the device identified by `device_token`. Usage
18643    /// Gain is not set directly by any client; it is a translation of
18644    /// the usage volume setting for each device, summed with active
18645    /// muting/ducking gain adjustments.
18646    ///
18647    /// Devices may map the same volume level to different dbfs, so
18648    /// a `device_unique_id` is needed to identify the device.
18649    ///
18650    /// `AudioDeviceEnumerator` provides programmatic access to devices
18651    /// and their unique ids if it is necessary for a client to select
18652    /// an id at runtime.
18653    pub fn r#register_listener(
18654        &self,
18655        mut device_unique_id: &str,
18656        mut usage: &Usage,
18657        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18658    ) -> Result<(), fidl::Error> {
18659        UsageGainReporterProxyInterface::r#register_listener(
18660            self,
18661            device_unique_id,
18662            usage,
18663            usage_gain_listener,
18664        )
18665    }
18666
18667    /// Connects a listener to a stream of usage gain setting changes
18668    /// for `usage` on the device identified by `device_token`. Usage
18669    /// Gain is not set directly by any client; it is a translation of
18670    /// the usage volume setting for each device, summed with active
18671    /// muting/ducking gain adjustments.
18672    ///
18673    /// Devices may map the same volume level to different dbfs, so
18674    /// a `device_unique_id` is needed to identify the device.
18675    ///
18676    /// `AudioDeviceEnumerator` provides programmatic access to devices
18677    /// and their unique ids if it is necessary for a client to select
18678    /// an id at runtime.
18679    pub fn r#register_listener2(
18680        &self,
18681        mut device_unique_id: &str,
18682        mut usage: &Usage2,
18683        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18684    ) -> Result<(), fidl::Error> {
18685        UsageGainReporterProxyInterface::r#register_listener2(
18686            self,
18687            device_unique_id,
18688            usage,
18689            usage_gain_listener,
18690        )
18691    }
18692}
18693
18694impl UsageGainReporterProxyInterface for UsageGainReporterProxy {
18695    fn r#register_listener(
18696        &self,
18697        mut device_unique_id: &str,
18698        mut usage: &Usage,
18699        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18700    ) -> Result<(), fidl::Error> {
18701        self.client.send::<UsageGainReporterRegisterListenerRequest>(
18702            (device_unique_id, usage, usage_gain_listener),
18703            0x767107c168c226af,
18704            fidl::encoding::DynamicFlags::empty(),
18705        )
18706    }
18707
18708    fn r#register_listener2(
18709        &self,
18710        mut device_unique_id: &str,
18711        mut usage: &Usage2,
18712        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18713    ) -> Result<(), fidl::Error> {
18714        self.client.send::<UsageGainReporterRegisterListener2Request>(
18715            (device_unique_id, usage, usage_gain_listener),
18716            0x760a8e1c5873629c,
18717            fidl::encoding::DynamicFlags::FLEXIBLE,
18718        )
18719    }
18720}
18721
18722pub struct UsageGainReporterEventStream {
18723    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
18724}
18725
18726impl std::marker::Unpin for UsageGainReporterEventStream {}
18727
18728impl futures::stream::FusedStream for UsageGainReporterEventStream {
18729    fn is_terminated(&self) -> bool {
18730        self.event_receiver.is_terminated()
18731    }
18732}
18733
18734impl futures::Stream for UsageGainReporterEventStream {
18735    type Item = Result<UsageGainReporterEvent, fidl::Error>;
18736
18737    fn poll_next(
18738        mut self: std::pin::Pin<&mut Self>,
18739        cx: &mut std::task::Context<'_>,
18740    ) -> std::task::Poll<Option<Self::Item>> {
18741        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
18742            &mut self.event_receiver,
18743            cx
18744        )?) {
18745            Some(buf) => std::task::Poll::Ready(Some(UsageGainReporterEvent::decode(buf))),
18746            None => std::task::Poll::Ready(None),
18747        }
18748    }
18749}
18750
18751#[derive(Debug)]
18752pub enum UsageGainReporterEvent {
18753    #[non_exhaustive]
18754    _UnknownEvent {
18755        /// Ordinal of the event that was sent.
18756        ordinal: u64,
18757    },
18758}
18759
18760impl UsageGainReporterEvent {
18761    /// Decodes a message buffer as a [`UsageGainReporterEvent`].
18762    fn decode(
18763        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
18764    ) -> Result<UsageGainReporterEvent, fidl::Error> {
18765        let (bytes, _handles) = buf.split_mut();
18766        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18767        debug_assert_eq!(tx_header.tx_id, 0);
18768        match tx_header.ordinal {
18769            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
18770                Ok(UsageGainReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
18771            }
18772            _ => Err(fidl::Error::UnknownOrdinal {
18773                ordinal: tx_header.ordinal,
18774                protocol_name:
18775                    <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18776            }),
18777        }
18778    }
18779}
18780
18781/// A Stream of incoming requests for fuchsia.media/UsageGainReporter.
18782pub struct UsageGainReporterRequestStream {
18783    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18784    is_terminated: bool,
18785}
18786
18787impl std::marker::Unpin for UsageGainReporterRequestStream {}
18788
18789impl futures::stream::FusedStream for UsageGainReporterRequestStream {
18790    fn is_terminated(&self) -> bool {
18791        self.is_terminated
18792    }
18793}
18794
18795impl fidl::endpoints::RequestStream for UsageGainReporterRequestStream {
18796    type Protocol = UsageGainReporterMarker;
18797    type ControlHandle = UsageGainReporterControlHandle;
18798
18799    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
18800        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
18801    }
18802
18803    fn control_handle(&self) -> Self::ControlHandle {
18804        UsageGainReporterControlHandle { inner: self.inner.clone() }
18805    }
18806
18807    fn into_inner(
18808        self,
18809    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
18810    {
18811        (self.inner, self.is_terminated)
18812    }
18813
18814    fn from_inner(
18815        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18816        is_terminated: bool,
18817    ) -> Self {
18818        Self { inner, is_terminated }
18819    }
18820}
18821
18822impl futures::Stream for UsageGainReporterRequestStream {
18823    type Item = Result<UsageGainReporterRequest, fidl::Error>;
18824
18825    fn poll_next(
18826        mut self: std::pin::Pin<&mut Self>,
18827        cx: &mut std::task::Context<'_>,
18828    ) -> std::task::Poll<Option<Self::Item>> {
18829        let this = &mut *self;
18830        if this.inner.check_shutdown(cx) {
18831            this.is_terminated = true;
18832            return std::task::Poll::Ready(None);
18833        }
18834        if this.is_terminated {
18835            panic!("polled UsageGainReporterRequestStream after completion");
18836        }
18837        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
18838            |bytes, handles| {
18839                match this.inner.channel().read_etc(cx, bytes, handles) {
18840                    std::task::Poll::Ready(Ok(())) => {}
18841                    std::task::Poll::Pending => return std::task::Poll::Pending,
18842                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
18843                        this.is_terminated = true;
18844                        return std::task::Poll::Ready(None);
18845                    }
18846                    std::task::Poll::Ready(Err(e)) => {
18847                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
18848                            e.into(),
18849                        ))));
18850                    }
18851                }
18852
18853                // A message has been received from the channel
18854                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18855
18856                std::task::Poll::Ready(Some(match header.ordinal {
18857                    0x767107c168c226af => {
18858                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
18859                        let mut req = fidl::new_empty!(
18860                            UsageGainReporterRegisterListenerRequest,
18861                            fidl::encoding::DefaultFuchsiaResourceDialect
18862                        );
18863                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainReporterRegisterListenerRequest>(&header, _body_bytes, handles, &mut req)?;
18864                        let control_handle =
18865                            UsageGainReporterControlHandle { inner: this.inner.clone() };
18866                        Ok(UsageGainReporterRequest::RegisterListener {
18867                            device_unique_id: req.device_unique_id,
18868                            usage: req.usage,
18869                            usage_gain_listener: req.usage_gain_listener,
18870
18871                            control_handle,
18872                        })
18873                    }
18874                    0x760a8e1c5873629c => {
18875                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
18876                        let mut req = fidl::new_empty!(
18877                            UsageGainReporterRegisterListener2Request,
18878                            fidl::encoding::DefaultFuchsiaResourceDialect
18879                        );
18880                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainReporterRegisterListener2Request>(&header, _body_bytes, handles, &mut req)?;
18881                        let control_handle =
18882                            UsageGainReporterControlHandle { inner: this.inner.clone() };
18883                        Ok(UsageGainReporterRequest::RegisterListener2 {
18884                            device_unique_id: req.device_unique_id,
18885                            usage: req.usage,
18886                            usage_gain_listener: req.usage_gain_listener,
18887
18888                            control_handle,
18889                        })
18890                    }
18891                    _ if header.tx_id == 0
18892                        && header
18893                            .dynamic_flags()
18894                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
18895                    {
18896                        Ok(UsageGainReporterRequest::_UnknownMethod {
18897                            ordinal: header.ordinal,
18898                            control_handle: UsageGainReporterControlHandle {
18899                                inner: this.inner.clone(),
18900                            },
18901                            method_type: fidl::MethodType::OneWay,
18902                        })
18903                    }
18904                    _ if header
18905                        .dynamic_flags()
18906                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
18907                    {
18908                        this.inner.send_framework_err(
18909                            fidl::encoding::FrameworkErr::UnknownMethod,
18910                            header.tx_id,
18911                            header.ordinal,
18912                            header.dynamic_flags(),
18913                            (bytes, handles),
18914                        )?;
18915                        Ok(UsageGainReporterRequest::_UnknownMethod {
18916                            ordinal: header.ordinal,
18917                            control_handle: UsageGainReporterControlHandle {
18918                                inner: this.inner.clone(),
18919                            },
18920                            method_type: fidl::MethodType::TwoWay,
18921                        })
18922                    }
18923                    _ => Err(fidl::Error::UnknownOrdinal {
18924                        ordinal: header.ordinal,
18925                        protocol_name:
18926                            <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18927                    }),
18928                }))
18929            },
18930        )
18931    }
18932}
18933
18934/// A protocol for setting up watchers of usage gain.
18935#[derive(Debug)]
18936pub enum UsageGainReporterRequest {
18937    /// Connects a listener to a stream of usage gain setting changes
18938    /// for `usage` on the device identified by `device_token`. Usage
18939    /// Gain is not set directly by any client; it is a translation of
18940    /// the usage volume setting for each device, summed with active
18941    /// muting/ducking gain adjustments.
18942    ///
18943    /// Devices may map the same volume level to different dbfs, so
18944    /// a `device_unique_id` is needed to identify the device.
18945    ///
18946    /// `AudioDeviceEnumerator` provides programmatic access to devices
18947    /// and their unique ids if it is necessary for a client to select
18948    /// an id at runtime.
18949    RegisterListener {
18950        device_unique_id: String,
18951        usage: Usage,
18952        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18953        control_handle: UsageGainReporterControlHandle,
18954    },
18955    /// Connects a listener to a stream of usage gain setting changes
18956    /// for `usage` on the device identified by `device_token`. Usage
18957    /// Gain is not set directly by any client; it is a translation of
18958    /// the usage volume setting for each device, summed with active
18959    /// muting/ducking gain adjustments.
18960    ///
18961    /// Devices may map the same volume level to different dbfs, so
18962    /// a `device_unique_id` is needed to identify the device.
18963    ///
18964    /// `AudioDeviceEnumerator` provides programmatic access to devices
18965    /// and their unique ids if it is necessary for a client to select
18966    /// an id at runtime.
18967    RegisterListener2 {
18968        device_unique_id: String,
18969        usage: Usage2,
18970        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18971        control_handle: UsageGainReporterControlHandle,
18972    },
18973    /// An interaction was received which does not match any known method.
18974    #[non_exhaustive]
18975    _UnknownMethod {
18976        /// Ordinal of the method that was called.
18977        ordinal: u64,
18978        control_handle: UsageGainReporterControlHandle,
18979        method_type: fidl::MethodType,
18980    },
18981}
18982
18983impl UsageGainReporterRequest {
18984    #[allow(irrefutable_let_patterns)]
18985    pub fn into_register_listener(
18986        self,
18987    ) -> Option<(
18988        String,
18989        Usage,
18990        fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18991        UsageGainReporterControlHandle,
18992    )> {
18993        if let UsageGainReporterRequest::RegisterListener {
18994            device_unique_id,
18995            usage,
18996            usage_gain_listener,
18997            control_handle,
18998        } = self
18999        {
19000            Some((device_unique_id, usage, usage_gain_listener, control_handle))
19001        } else {
19002            None
19003        }
19004    }
19005
19006    #[allow(irrefutable_let_patterns)]
19007    pub fn into_register_listener2(
19008        self,
19009    ) -> Option<(
19010        String,
19011        Usage2,
19012        fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
19013        UsageGainReporterControlHandle,
19014    )> {
19015        if let UsageGainReporterRequest::RegisterListener2 {
19016            device_unique_id,
19017            usage,
19018            usage_gain_listener,
19019            control_handle,
19020        } = self
19021        {
19022            Some((device_unique_id, usage, usage_gain_listener, control_handle))
19023        } else {
19024            None
19025        }
19026    }
19027
19028    /// Name of the method defined in FIDL
19029    pub fn method_name(&self) -> &'static str {
19030        match *self {
19031            UsageGainReporterRequest::RegisterListener { .. } => "register_listener",
19032            UsageGainReporterRequest::RegisterListener2 { .. } => "register_listener2",
19033            UsageGainReporterRequest::_UnknownMethod {
19034                method_type: fidl::MethodType::OneWay,
19035                ..
19036            } => "unknown one-way method",
19037            UsageGainReporterRequest::_UnknownMethod {
19038                method_type: fidl::MethodType::TwoWay,
19039                ..
19040            } => "unknown two-way method",
19041        }
19042    }
19043}
19044
19045#[derive(Debug, Clone)]
19046pub struct UsageGainReporterControlHandle {
19047    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19048}
19049
19050impl fidl::endpoints::ControlHandle for UsageGainReporterControlHandle {
19051    fn shutdown(&self) {
19052        self.inner.shutdown()
19053    }
19054
19055    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
19056        self.inner.shutdown_with_epitaph(status)
19057    }
19058
19059    fn is_closed(&self) -> bool {
19060        self.inner.channel().is_closed()
19061    }
19062    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
19063        self.inner.channel().on_closed()
19064    }
19065
19066    #[cfg(target_os = "fuchsia")]
19067    fn signal_peer(
19068        &self,
19069        clear_mask: zx::Signals,
19070        set_mask: zx::Signals,
19071    ) -> Result<(), zx_status::Status> {
19072        use fidl::Peered;
19073        self.inner.channel().signal_peer(clear_mask, set_mask)
19074    }
19075}
19076
19077impl UsageGainReporterControlHandle {}
19078
19079#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
19080pub struct UsageReporterMarker;
19081
19082impl fidl::endpoints::ProtocolMarker for UsageReporterMarker {
19083    type Proxy = UsageReporterProxy;
19084    type RequestStream = UsageReporterRequestStream;
19085    #[cfg(target_os = "fuchsia")]
19086    type SynchronousProxy = UsageReporterSynchronousProxy;
19087
19088    const DEBUG_NAME: &'static str = "fuchsia.media.UsageReporter";
19089}
19090impl fidl::endpoints::DiscoverableProtocolMarker for UsageReporterMarker {}
19091
19092pub trait UsageReporterProxyInterface: Send + Sync {
19093    fn r#watch(
19094        &self,
19095        usage: &Usage,
19096        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19097    ) -> Result<(), fidl::Error>;
19098    fn r#watch2(
19099        &self,
19100        usage: &Usage2,
19101        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19102    ) -> Result<(), fidl::Error>;
19103}
19104#[derive(Debug)]
19105#[cfg(target_os = "fuchsia")]
19106pub struct UsageReporterSynchronousProxy {
19107    client: fidl::client::sync::Client,
19108}
19109
19110#[cfg(target_os = "fuchsia")]
19111impl fidl::endpoints::SynchronousProxy for UsageReporterSynchronousProxy {
19112    type Proxy = UsageReporterProxy;
19113    type Protocol = UsageReporterMarker;
19114
19115    fn from_channel(inner: fidl::Channel) -> Self {
19116        Self::new(inner)
19117    }
19118
19119    fn into_channel(self) -> fidl::Channel {
19120        self.client.into_channel()
19121    }
19122
19123    fn as_channel(&self) -> &fidl::Channel {
19124        self.client.as_channel()
19125    }
19126}
19127
19128#[cfg(target_os = "fuchsia")]
19129impl UsageReporterSynchronousProxy {
19130    pub fn new(channel: fidl::Channel) -> Self {
19131        Self { client: fidl::client::sync::Client::new(channel) }
19132    }
19133
19134    pub fn into_channel(self) -> fidl::Channel {
19135        self.client.into_channel()
19136    }
19137
19138    /// Waits until an event arrives and returns it. It is safe for other
19139    /// threads to make concurrent requests while waiting for an event.
19140    pub fn wait_for_event(
19141        &self,
19142        deadline: zx::MonotonicInstant,
19143    ) -> Result<UsageReporterEvent, fidl::Error> {
19144        UsageReporterEvent::decode(self.client.wait_for_event::<UsageReporterMarker>(deadline)?)
19145    }
19146
19147    pub fn r#watch(
19148        &self,
19149        mut usage: &Usage,
19150        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19151    ) -> Result<(), fidl::Error> {
19152        self.client.send::<UsageReporterWatchRequest>(
19153            (usage, usage_watcher),
19154            0x769e6fb17075c959,
19155            fidl::encoding::DynamicFlags::empty(),
19156        )
19157    }
19158
19159    pub fn r#watch2(
19160        &self,
19161        mut usage: &Usage2,
19162        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19163    ) -> Result<(), fidl::Error> {
19164        self.client.send::<UsageReporterWatch2Request>(
19165            (usage, usage_watcher),
19166            0x4a43c4c82f5d8ce8,
19167            fidl::encoding::DynamicFlags::FLEXIBLE,
19168        )
19169    }
19170}
19171
19172#[cfg(target_os = "fuchsia")]
19173impl From<UsageReporterSynchronousProxy> for zx::NullableHandle {
19174    fn from(value: UsageReporterSynchronousProxy) -> Self {
19175        value.into_channel().into()
19176    }
19177}
19178
19179#[cfg(target_os = "fuchsia")]
19180impl From<fidl::Channel> for UsageReporterSynchronousProxy {
19181    fn from(value: fidl::Channel) -> Self {
19182        Self::new(value)
19183    }
19184}
19185
19186#[cfg(target_os = "fuchsia")]
19187impl fidl::endpoints::FromClient for UsageReporterSynchronousProxy {
19188    type Protocol = UsageReporterMarker;
19189
19190    fn from_client(value: fidl::endpoints::ClientEnd<UsageReporterMarker>) -> Self {
19191        Self::new(value.into_channel())
19192    }
19193}
19194
19195#[derive(Debug, Clone)]
19196pub struct UsageReporterProxy {
19197    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
19198}
19199
19200impl fidl::endpoints::Proxy for UsageReporterProxy {
19201    type Protocol = UsageReporterMarker;
19202
19203    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
19204        Self::new(inner)
19205    }
19206
19207    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
19208        self.client.into_channel().map_err(|client| Self { client })
19209    }
19210
19211    fn as_channel(&self) -> &::fidl::AsyncChannel {
19212        self.client.as_channel()
19213    }
19214}
19215
19216impl UsageReporterProxy {
19217    /// Create a new Proxy for fuchsia.media/UsageReporter.
19218    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
19219        let protocol_name = <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19220        Self { client: fidl::client::Client::new(channel, protocol_name) }
19221    }
19222
19223    /// Get a Stream of events from the remote end of the protocol.
19224    ///
19225    /// # Panics
19226    ///
19227    /// Panics if the event stream was already taken.
19228    pub fn take_event_stream(&self) -> UsageReporterEventStream {
19229        UsageReporterEventStream { event_receiver: self.client.take_event_receiver() }
19230    }
19231
19232    pub fn r#watch(
19233        &self,
19234        mut usage: &Usage,
19235        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19236    ) -> Result<(), fidl::Error> {
19237        UsageReporterProxyInterface::r#watch(self, usage, usage_watcher)
19238    }
19239
19240    pub fn r#watch2(
19241        &self,
19242        mut usage: &Usage2,
19243        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19244    ) -> Result<(), fidl::Error> {
19245        UsageReporterProxyInterface::r#watch2(self, usage, usage_watcher)
19246    }
19247}
19248
19249impl UsageReporterProxyInterface for UsageReporterProxy {
19250    fn r#watch(
19251        &self,
19252        mut usage: &Usage,
19253        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19254    ) -> Result<(), fidl::Error> {
19255        self.client.send::<UsageReporterWatchRequest>(
19256            (usage, usage_watcher),
19257            0x769e6fb17075c959,
19258            fidl::encoding::DynamicFlags::empty(),
19259        )
19260    }
19261
19262    fn r#watch2(
19263        &self,
19264        mut usage: &Usage2,
19265        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19266    ) -> Result<(), fidl::Error> {
19267        self.client.send::<UsageReporterWatch2Request>(
19268            (usage, usage_watcher),
19269            0x4a43c4c82f5d8ce8,
19270            fidl::encoding::DynamicFlags::FLEXIBLE,
19271        )
19272    }
19273}
19274
19275pub struct UsageReporterEventStream {
19276    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
19277}
19278
19279impl std::marker::Unpin for UsageReporterEventStream {}
19280
19281impl futures::stream::FusedStream for UsageReporterEventStream {
19282    fn is_terminated(&self) -> bool {
19283        self.event_receiver.is_terminated()
19284    }
19285}
19286
19287impl futures::Stream for UsageReporterEventStream {
19288    type Item = Result<UsageReporterEvent, fidl::Error>;
19289
19290    fn poll_next(
19291        mut self: std::pin::Pin<&mut Self>,
19292        cx: &mut std::task::Context<'_>,
19293    ) -> std::task::Poll<Option<Self::Item>> {
19294        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
19295            &mut self.event_receiver,
19296            cx
19297        )?) {
19298            Some(buf) => std::task::Poll::Ready(Some(UsageReporterEvent::decode(buf))),
19299            None => std::task::Poll::Ready(None),
19300        }
19301    }
19302}
19303
19304#[derive(Debug)]
19305pub enum UsageReporterEvent {
19306    #[non_exhaustive]
19307    _UnknownEvent {
19308        /// Ordinal of the event that was sent.
19309        ordinal: u64,
19310    },
19311}
19312
19313impl UsageReporterEvent {
19314    /// Decodes a message buffer as a [`UsageReporterEvent`].
19315    fn decode(
19316        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
19317    ) -> Result<UsageReporterEvent, fidl::Error> {
19318        let (bytes, _handles) = buf.split_mut();
19319        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19320        debug_assert_eq!(tx_header.tx_id, 0);
19321        match tx_header.ordinal {
19322            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
19323                Ok(UsageReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
19324            }
19325            _ => Err(fidl::Error::UnknownOrdinal {
19326                ordinal: tx_header.ordinal,
19327                protocol_name: <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19328            }),
19329        }
19330    }
19331}
19332
19333/// A Stream of incoming requests for fuchsia.media/UsageReporter.
19334pub struct UsageReporterRequestStream {
19335    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19336    is_terminated: bool,
19337}
19338
19339impl std::marker::Unpin for UsageReporterRequestStream {}
19340
19341impl futures::stream::FusedStream for UsageReporterRequestStream {
19342    fn is_terminated(&self) -> bool {
19343        self.is_terminated
19344    }
19345}
19346
19347impl fidl::endpoints::RequestStream for UsageReporterRequestStream {
19348    type Protocol = UsageReporterMarker;
19349    type ControlHandle = UsageReporterControlHandle;
19350
19351    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
19352        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
19353    }
19354
19355    fn control_handle(&self) -> Self::ControlHandle {
19356        UsageReporterControlHandle { inner: self.inner.clone() }
19357    }
19358
19359    fn into_inner(
19360        self,
19361    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
19362    {
19363        (self.inner, self.is_terminated)
19364    }
19365
19366    fn from_inner(
19367        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19368        is_terminated: bool,
19369    ) -> Self {
19370        Self { inner, is_terminated }
19371    }
19372}
19373
19374impl futures::Stream for UsageReporterRequestStream {
19375    type Item = Result<UsageReporterRequest, fidl::Error>;
19376
19377    fn poll_next(
19378        mut self: std::pin::Pin<&mut Self>,
19379        cx: &mut std::task::Context<'_>,
19380    ) -> std::task::Poll<Option<Self::Item>> {
19381        let this = &mut *self;
19382        if this.inner.check_shutdown(cx) {
19383            this.is_terminated = true;
19384            return std::task::Poll::Ready(None);
19385        }
19386        if this.is_terminated {
19387            panic!("polled UsageReporterRequestStream after completion");
19388        }
19389        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
19390            |bytes, handles| {
19391                match this.inner.channel().read_etc(cx, bytes, handles) {
19392                    std::task::Poll::Ready(Ok(())) => {}
19393                    std::task::Poll::Pending => return std::task::Poll::Pending,
19394                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
19395                        this.is_terminated = true;
19396                        return std::task::Poll::Ready(None);
19397                    }
19398                    std::task::Poll::Ready(Err(e)) => {
19399                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
19400                            e.into(),
19401                        ))));
19402                    }
19403                }
19404
19405                // A message has been received from the channel
19406                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19407
19408                std::task::Poll::Ready(Some(match header.ordinal {
19409                    0x769e6fb17075c959 => {
19410                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
19411                        let mut req = fidl::new_empty!(
19412                            UsageReporterWatchRequest,
19413                            fidl::encoding::DefaultFuchsiaResourceDialect
19414                        );
19415                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageReporterWatchRequest>(&header, _body_bytes, handles, &mut req)?;
19416                        let control_handle =
19417                            UsageReporterControlHandle { inner: this.inner.clone() };
19418                        Ok(UsageReporterRequest::Watch {
19419                            usage: req.usage,
19420                            usage_watcher: req.usage_watcher,
19421
19422                            control_handle,
19423                        })
19424                    }
19425                    0x4a43c4c82f5d8ce8 => {
19426                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
19427                        let mut req = fidl::new_empty!(
19428                            UsageReporterWatch2Request,
19429                            fidl::encoding::DefaultFuchsiaResourceDialect
19430                        );
19431                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageReporterWatch2Request>(&header, _body_bytes, handles, &mut req)?;
19432                        let control_handle =
19433                            UsageReporterControlHandle { inner: this.inner.clone() };
19434                        Ok(UsageReporterRequest::Watch2 {
19435                            usage: req.usage,
19436                            usage_watcher: req.usage_watcher,
19437
19438                            control_handle,
19439                        })
19440                    }
19441                    _ if header.tx_id == 0
19442                        && header
19443                            .dynamic_flags()
19444                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
19445                    {
19446                        Ok(UsageReporterRequest::_UnknownMethod {
19447                            ordinal: header.ordinal,
19448                            control_handle: UsageReporterControlHandle {
19449                                inner: this.inner.clone(),
19450                            },
19451                            method_type: fidl::MethodType::OneWay,
19452                        })
19453                    }
19454                    _ if header
19455                        .dynamic_flags()
19456                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
19457                    {
19458                        this.inner.send_framework_err(
19459                            fidl::encoding::FrameworkErr::UnknownMethod,
19460                            header.tx_id,
19461                            header.ordinal,
19462                            header.dynamic_flags(),
19463                            (bytes, handles),
19464                        )?;
19465                        Ok(UsageReporterRequest::_UnknownMethod {
19466                            ordinal: header.ordinal,
19467                            control_handle: UsageReporterControlHandle {
19468                                inner: this.inner.clone(),
19469                            },
19470                            method_type: fidl::MethodType::TwoWay,
19471                        })
19472                    }
19473                    _ => Err(fidl::Error::UnknownOrdinal {
19474                        ordinal: header.ordinal,
19475                        protocol_name:
19476                            <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19477                    }),
19478                }))
19479            },
19480        )
19481    }
19482}
19483
19484/// A protocol for setting up watchers of audio usages.
19485#[derive(Debug)]
19486pub enum UsageReporterRequest {
19487    Watch {
19488        usage: Usage,
19489        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19490        control_handle: UsageReporterControlHandle,
19491    },
19492    Watch2 {
19493        usage: Usage2,
19494        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19495        control_handle: UsageReporterControlHandle,
19496    },
19497    /// An interaction was received which does not match any known method.
19498    #[non_exhaustive]
19499    _UnknownMethod {
19500        /// Ordinal of the method that was called.
19501        ordinal: u64,
19502        control_handle: UsageReporterControlHandle,
19503        method_type: fidl::MethodType,
19504    },
19505}
19506
19507impl UsageReporterRequest {
19508    #[allow(irrefutable_let_patterns)]
19509    pub fn into_watch(
19510        self,
19511    ) -> Option<(Usage, fidl::endpoints::ClientEnd<UsageWatcherMarker>, UsageReporterControlHandle)>
19512    {
19513        if let UsageReporterRequest::Watch { usage, usage_watcher, control_handle } = self {
19514            Some((usage, usage_watcher, control_handle))
19515        } else {
19516            None
19517        }
19518    }
19519
19520    #[allow(irrefutable_let_patterns)]
19521    pub fn into_watch2(
19522        self,
19523    ) -> Option<(Usage2, fidl::endpoints::ClientEnd<UsageWatcher2Marker>, UsageReporterControlHandle)>
19524    {
19525        if let UsageReporterRequest::Watch2 { usage, usage_watcher, control_handle } = self {
19526            Some((usage, usage_watcher, control_handle))
19527        } else {
19528            None
19529        }
19530    }
19531
19532    /// Name of the method defined in FIDL
19533    pub fn method_name(&self) -> &'static str {
19534        match *self {
19535            UsageReporterRequest::Watch { .. } => "watch",
19536            UsageReporterRequest::Watch2 { .. } => "watch2",
19537            UsageReporterRequest::_UnknownMethod {
19538                method_type: fidl::MethodType::OneWay, ..
19539            } => "unknown one-way method",
19540            UsageReporterRequest::_UnknownMethod {
19541                method_type: fidl::MethodType::TwoWay, ..
19542            } => "unknown two-way method",
19543        }
19544    }
19545}
19546
19547#[derive(Debug, Clone)]
19548pub struct UsageReporterControlHandle {
19549    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19550}
19551
19552impl fidl::endpoints::ControlHandle for UsageReporterControlHandle {
19553    fn shutdown(&self) {
19554        self.inner.shutdown()
19555    }
19556
19557    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
19558        self.inner.shutdown_with_epitaph(status)
19559    }
19560
19561    fn is_closed(&self) -> bool {
19562        self.inner.channel().is_closed()
19563    }
19564    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
19565        self.inner.channel().on_closed()
19566    }
19567
19568    #[cfg(target_os = "fuchsia")]
19569    fn signal_peer(
19570        &self,
19571        clear_mask: zx::Signals,
19572        set_mask: zx::Signals,
19573    ) -> Result<(), zx_status::Status> {
19574        use fidl::Peered;
19575        self.inner.channel().signal_peer(clear_mask, set_mask)
19576    }
19577}
19578
19579impl UsageReporterControlHandle {}
19580
19581#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
19582pub struct UsageWatcherMarker;
19583
19584impl fidl::endpoints::ProtocolMarker for UsageWatcherMarker {
19585    type Proxy = UsageWatcherProxy;
19586    type RequestStream = UsageWatcherRequestStream;
19587    #[cfg(target_os = "fuchsia")]
19588    type SynchronousProxy = UsageWatcherSynchronousProxy;
19589
19590    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher";
19591}
19592
19593pub trait UsageWatcherProxyInterface: Send + Sync {
19594    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
19595    fn r#on_state_changed(
19596        &self,
19597        usage: &Usage,
19598        state: &UsageState,
19599    ) -> Self::OnStateChangedResponseFut;
19600}
19601#[derive(Debug)]
19602#[cfg(target_os = "fuchsia")]
19603pub struct UsageWatcherSynchronousProxy {
19604    client: fidl::client::sync::Client,
19605}
19606
19607#[cfg(target_os = "fuchsia")]
19608impl fidl::endpoints::SynchronousProxy for UsageWatcherSynchronousProxy {
19609    type Proxy = UsageWatcherProxy;
19610    type Protocol = UsageWatcherMarker;
19611
19612    fn from_channel(inner: fidl::Channel) -> Self {
19613        Self::new(inner)
19614    }
19615
19616    fn into_channel(self) -> fidl::Channel {
19617        self.client.into_channel()
19618    }
19619
19620    fn as_channel(&self) -> &fidl::Channel {
19621        self.client.as_channel()
19622    }
19623}
19624
19625#[cfg(target_os = "fuchsia")]
19626impl UsageWatcherSynchronousProxy {
19627    pub fn new(channel: fidl::Channel) -> Self {
19628        Self { client: fidl::client::sync::Client::new(channel) }
19629    }
19630
19631    pub fn into_channel(self) -> fidl::Channel {
19632        self.client.into_channel()
19633    }
19634
19635    /// Waits until an event arrives and returns it. It is safe for other
19636    /// threads to make concurrent requests while waiting for an event.
19637    pub fn wait_for_event(
19638        &self,
19639        deadline: zx::MonotonicInstant,
19640    ) -> Result<UsageWatcherEvent, fidl::Error> {
19641        UsageWatcherEvent::decode(self.client.wait_for_event::<UsageWatcherMarker>(deadline)?)
19642    }
19643
19644    /// Called on first connection and whenever the watched usage changes. The provided
19645    /// usage will always be the bound usage; it is provided so that an implementation of
19646    /// this protocol may be bound to more than one usage.
19647    ///
19648    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
19649    /// events will eventually be disconnected.
19650    pub fn r#on_state_changed(
19651        &self,
19652        mut usage: &Usage,
19653        mut state: &UsageState,
19654        ___deadline: zx::MonotonicInstant,
19655    ) -> Result<(), fidl::Error> {
19656        let _response = self.client.send_query::<
19657            UsageWatcherOnStateChangedRequest,
19658            fidl::encoding::EmptyPayload,
19659            UsageWatcherMarker,
19660        >(
19661            (usage, state,),
19662            0x5b955c5768ec75c5,
19663            fidl::encoding::DynamicFlags::empty(),
19664            ___deadline,
19665        )?;
19666        Ok(_response)
19667    }
19668}
19669
19670#[cfg(target_os = "fuchsia")]
19671impl From<UsageWatcherSynchronousProxy> for zx::NullableHandle {
19672    fn from(value: UsageWatcherSynchronousProxy) -> Self {
19673        value.into_channel().into()
19674    }
19675}
19676
19677#[cfg(target_os = "fuchsia")]
19678impl From<fidl::Channel> for UsageWatcherSynchronousProxy {
19679    fn from(value: fidl::Channel) -> Self {
19680        Self::new(value)
19681    }
19682}
19683
19684#[cfg(target_os = "fuchsia")]
19685impl fidl::endpoints::FromClient for UsageWatcherSynchronousProxy {
19686    type Protocol = UsageWatcherMarker;
19687
19688    fn from_client(value: fidl::endpoints::ClientEnd<UsageWatcherMarker>) -> Self {
19689        Self::new(value.into_channel())
19690    }
19691}
19692
19693#[derive(Debug, Clone)]
19694pub struct UsageWatcherProxy {
19695    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
19696}
19697
19698impl fidl::endpoints::Proxy for UsageWatcherProxy {
19699    type Protocol = UsageWatcherMarker;
19700
19701    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
19702        Self::new(inner)
19703    }
19704
19705    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
19706        self.client.into_channel().map_err(|client| Self { client })
19707    }
19708
19709    fn as_channel(&self) -> &::fidl::AsyncChannel {
19710        self.client.as_channel()
19711    }
19712}
19713
19714impl UsageWatcherProxy {
19715    /// Create a new Proxy for fuchsia.media/UsageWatcher.
19716    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
19717        let protocol_name = <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19718        Self { client: fidl::client::Client::new(channel, protocol_name) }
19719    }
19720
19721    /// Get a Stream of events from the remote end of the protocol.
19722    ///
19723    /// # Panics
19724    ///
19725    /// Panics if the event stream was already taken.
19726    pub fn take_event_stream(&self) -> UsageWatcherEventStream {
19727        UsageWatcherEventStream { event_receiver: self.client.take_event_receiver() }
19728    }
19729
19730    /// Called on first connection and whenever the watched usage changes. The provided
19731    /// usage will always be the bound usage; it is provided so that an implementation of
19732    /// this protocol may be bound to more than one usage.
19733    ///
19734    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
19735    /// events will eventually be disconnected.
19736    pub fn r#on_state_changed(
19737        &self,
19738        mut usage: &Usage,
19739        mut state: &UsageState,
19740    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
19741        UsageWatcherProxyInterface::r#on_state_changed(self, usage, state)
19742    }
19743}
19744
19745impl UsageWatcherProxyInterface for UsageWatcherProxy {
19746    type OnStateChangedResponseFut =
19747        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
19748    fn r#on_state_changed(
19749        &self,
19750        mut usage: &Usage,
19751        mut state: &UsageState,
19752    ) -> Self::OnStateChangedResponseFut {
19753        fn _decode(
19754            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
19755        ) -> Result<(), fidl::Error> {
19756            let _response = fidl::client::decode_transaction_body::<
19757                fidl::encoding::EmptyPayload,
19758                fidl::encoding::DefaultFuchsiaResourceDialect,
19759                0x5b955c5768ec75c5,
19760            >(_buf?)?;
19761            Ok(_response)
19762        }
19763        self.client.send_query_and_decode::<UsageWatcherOnStateChangedRequest, ()>(
19764            (usage, state),
19765            0x5b955c5768ec75c5,
19766            fidl::encoding::DynamicFlags::empty(),
19767            _decode,
19768        )
19769    }
19770}
19771
19772pub struct UsageWatcherEventStream {
19773    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
19774}
19775
19776impl std::marker::Unpin for UsageWatcherEventStream {}
19777
19778impl futures::stream::FusedStream for UsageWatcherEventStream {
19779    fn is_terminated(&self) -> bool {
19780        self.event_receiver.is_terminated()
19781    }
19782}
19783
19784impl futures::Stream for UsageWatcherEventStream {
19785    type Item = Result<UsageWatcherEvent, fidl::Error>;
19786
19787    fn poll_next(
19788        mut self: std::pin::Pin<&mut Self>,
19789        cx: &mut std::task::Context<'_>,
19790    ) -> std::task::Poll<Option<Self::Item>> {
19791        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
19792            &mut self.event_receiver,
19793            cx
19794        )?) {
19795            Some(buf) => std::task::Poll::Ready(Some(UsageWatcherEvent::decode(buf))),
19796            None => std::task::Poll::Ready(None),
19797        }
19798    }
19799}
19800
19801#[derive(Debug)]
19802pub enum UsageWatcherEvent {}
19803
19804impl UsageWatcherEvent {
19805    /// Decodes a message buffer as a [`UsageWatcherEvent`].
19806    fn decode(
19807        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
19808    ) -> Result<UsageWatcherEvent, fidl::Error> {
19809        let (bytes, _handles) = buf.split_mut();
19810        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19811        debug_assert_eq!(tx_header.tx_id, 0);
19812        match tx_header.ordinal {
19813            _ => Err(fidl::Error::UnknownOrdinal {
19814                ordinal: tx_header.ordinal,
19815                protocol_name: <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19816            }),
19817        }
19818    }
19819}
19820
19821/// A Stream of incoming requests for fuchsia.media/UsageWatcher.
19822pub struct UsageWatcherRequestStream {
19823    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19824    is_terminated: bool,
19825}
19826
19827impl std::marker::Unpin for UsageWatcherRequestStream {}
19828
19829impl futures::stream::FusedStream for UsageWatcherRequestStream {
19830    fn is_terminated(&self) -> bool {
19831        self.is_terminated
19832    }
19833}
19834
19835impl fidl::endpoints::RequestStream for UsageWatcherRequestStream {
19836    type Protocol = UsageWatcherMarker;
19837    type ControlHandle = UsageWatcherControlHandle;
19838
19839    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
19840        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
19841    }
19842
19843    fn control_handle(&self) -> Self::ControlHandle {
19844        UsageWatcherControlHandle { inner: self.inner.clone() }
19845    }
19846
19847    fn into_inner(
19848        self,
19849    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
19850    {
19851        (self.inner, self.is_terminated)
19852    }
19853
19854    fn from_inner(
19855        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19856        is_terminated: bool,
19857    ) -> Self {
19858        Self { inner, is_terminated }
19859    }
19860}
19861
19862impl futures::Stream for UsageWatcherRequestStream {
19863    type Item = Result<UsageWatcherRequest, fidl::Error>;
19864
19865    fn poll_next(
19866        mut self: std::pin::Pin<&mut Self>,
19867        cx: &mut std::task::Context<'_>,
19868    ) -> std::task::Poll<Option<Self::Item>> {
19869        let this = &mut *self;
19870        if this.inner.check_shutdown(cx) {
19871            this.is_terminated = true;
19872            return std::task::Poll::Ready(None);
19873        }
19874        if this.is_terminated {
19875            panic!("polled UsageWatcherRequestStream after completion");
19876        }
19877        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
19878            |bytes, handles| {
19879                match this.inner.channel().read_etc(cx, bytes, handles) {
19880                    std::task::Poll::Ready(Ok(())) => {}
19881                    std::task::Poll::Pending => return std::task::Poll::Pending,
19882                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
19883                        this.is_terminated = true;
19884                        return std::task::Poll::Ready(None);
19885                    }
19886                    std::task::Poll::Ready(Err(e)) => {
19887                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
19888                            e.into(),
19889                        ))));
19890                    }
19891                }
19892
19893                // A message has been received from the channel
19894                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19895
19896                std::task::Poll::Ready(Some(match header.ordinal {
19897                    0x5b955c5768ec75c5 => {
19898                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
19899                        let mut req = fidl::new_empty!(
19900                            UsageWatcherOnStateChangedRequest,
19901                            fidl::encoding::DefaultFuchsiaResourceDialect
19902                        );
19903                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageWatcherOnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
19904                        let control_handle =
19905                            UsageWatcherControlHandle { inner: this.inner.clone() };
19906                        Ok(UsageWatcherRequest::OnStateChanged {
19907                            usage: req.usage,
19908                            state: req.state,
19909
19910                            responder: UsageWatcherOnStateChangedResponder {
19911                                control_handle: std::mem::ManuallyDrop::new(control_handle),
19912                                tx_id: header.tx_id,
19913                            },
19914                        })
19915                    }
19916                    _ => Err(fidl::Error::UnknownOrdinal {
19917                        ordinal: header.ordinal,
19918                        protocol_name:
19919                            <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19920                    }),
19921                }))
19922            },
19923        )
19924    }
19925}
19926
19927/// A protocol for listening to changes to the policy state of an audio usage.
19928///
19929/// User actions, such as lowering the volume or muting a stream, are not reflected in this API.
19930#[derive(Debug)]
19931pub enum UsageWatcherRequest {
19932    /// Called on first connection and whenever the watched usage changes. The provided
19933    /// usage will always be the bound usage; it is provided so that an implementation of
19934    /// this protocol may be bound to more than one usage.
19935    ///
19936    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
19937    /// events will eventually be disconnected.
19938    OnStateChanged {
19939        usage: Usage,
19940        state: UsageState,
19941        responder: UsageWatcherOnStateChangedResponder,
19942    },
19943}
19944
19945impl UsageWatcherRequest {
19946    #[allow(irrefutable_let_patterns)]
19947    pub fn into_on_state_changed(
19948        self,
19949    ) -> Option<(Usage, UsageState, UsageWatcherOnStateChangedResponder)> {
19950        if let UsageWatcherRequest::OnStateChanged { usage, state, responder } = self {
19951            Some((usage, state, responder))
19952        } else {
19953            None
19954        }
19955    }
19956
19957    /// Name of the method defined in FIDL
19958    pub fn method_name(&self) -> &'static str {
19959        match *self {
19960            UsageWatcherRequest::OnStateChanged { .. } => "on_state_changed",
19961        }
19962    }
19963}
19964
19965#[derive(Debug, Clone)]
19966pub struct UsageWatcherControlHandle {
19967    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19968}
19969
19970impl fidl::endpoints::ControlHandle for UsageWatcherControlHandle {
19971    fn shutdown(&self) {
19972        self.inner.shutdown()
19973    }
19974
19975    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
19976        self.inner.shutdown_with_epitaph(status)
19977    }
19978
19979    fn is_closed(&self) -> bool {
19980        self.inner.channel().is_closed()
19981    }
19982    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
19983        self.inner.channel().on_closed()
19984    }
19985
19986    #[cfg(target_os = "fuchsia")]
19987    fn signal_peer(
19988        &self,
19989        clear_mask: zx::Signals,
19990        set_mask: zx::Signals,
19991    ) -> Result<(), zx_status::Status> {
19992        use fidl::Peered;
19993        self.inner.channel().signal_peer(clear_mask, set_mask)
19994    }
19995}
19996
19997impl UsageWatcherControlHandle {}
19998
19999#[must_use = "FIDL methods require a response to be sent"]
20000#[derive(Debug)]
20001pub struct UsageWatcherOnStateChangedResponder {
20002    control_handle: std::mem::ManuallyDrop<UsageWatcherControlHandle>,
20003    tx_id: u32,
20004}
20005
20006/// Set the the channel to be shutdown (see [`UsageWatcherControlHandle::shutdown`])
20007/// if the responder is dropped without sending a response, so that the client
20008/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
20009impl std::ops::Drop for UsageWatcherOnStateChangedResponder {
20010    fn drop(&mut self) {
20011        self.control_handle.shutdown();
20012        // Safety: drops once, never accessed again
20013        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
20014    }
20015}
20016
20017impl fidl::endpoints::Responder for UsageWatcherOnStateChangedResponder {
20018    type ControlHandle = UsageWatcherControlHandle;
20019
20020    fn control_handle(&self) -> &UsageWatcherControlHandle {
20021        &self.control_handle
20022    }
20023
20024    fn drop_without_shutdown(mut self) {
20025        // Safety: drops once, never accessed again due to mem::forget
20026        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
20027        // Prevent Drop from running (which would shut down the channel)
20028        std::mem::forget(self);
20029    }
20030}
20031
20032impl UsageWatcherOnStateChangedResponder {
20033    /// Sends a response to the FIDL transaction.
20034    ///
20035    /// Sets the channel to shutdown if an error occurs.
20036    pub fn send(self) -> Result<(), fidl::Error> {
20037        let _result = self.send_raw();
20038        if _result.is_err() {
20039            self.control_handle.shutdown();
20040        }
20041        self.drop_without_shutdown();
20042        _result
20043    }
20044
20045    /// Similar to "send" but does not shutdown the channel if an error occurs.
20046    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
20047        let _result = self.send_raw();
20048        self.drop_without_shutdown();
20049        _result
20050    }
20051
20052    fn send_raw(&self) -> Result<(), fidl::Error> {
20053        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
20054            (),
20055            self.tx_id,
20056            0x5b955c5768ec75c5,
20057            fidl::encoding::DynamicFlags::empty(),
20058        )
20059    }
20060}
20061
20062#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
20063pub struct UsageWatcher2Marker;
20064
20065impl fidl::endpoints::ProtocolMarker for UsageWatcher2Marker {
20066    type Proxy = UsageWatcher2Proxy;
20067    type RequestStream = UsageWatcher2RequestStream;
20068    #[cfg(target_os = "fuchsia")]
20069    type SynchronousProxy = UsageWatcher2SynchronousProxy;
20070
20071    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher2";
20072}
20073
20074pub trait UsageWatcher2ProxyInterface: Send + Sync {
20075    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
20076    fn r#on_state_changed(
20077        &self,
20078        usage: &Usage2,
20079        state: &UsageState,
20080    ) -> Self::OnStateChangedResponseFut;
20081}
20082#[derive(Debug)]
20083#[cfg(target_os = "fuchsia")]
20084pub struct UsageWatcher2SynchronousProxy {
20085    client: fidl::client::sync::Client,
20086}
20087
20088#[cfg(target_os = "fuchsia")]
20089impl fidl::endpoints::SynchronousProxy for UsageWatcher2SynchronousProxy {
20090    type Proxy = UsageWatcher2Proxy;
20091    type Protocol = UsageWatcher2Marker;
20092
20093    fn from_channel(inner: fidl::Channel) -> Self {
20094        Self::new(inner)
20095    }
20096
20097    fn into_channel(self) -> fidl::Channel {
20098        self.client.into_channel()
20099    }
20100
20101    fn as_channel(&self) -> &fidl::Channel {
20102        self.client.as_channel()
20103    }
20104}
20105
20106#[cfg(target_os = "fuchsia")]
20107impl UsageWatcher2SynchronousProxy {
20108    pub fn new(channel: fidl::Channel) -> Self {
20109        Self { client: fidl::client::sync::Client::new(channel) }
20110    }
20111
20112    pub fn into_channel(self) -> fidl::Channel {
20113        self.client.into_channel()
20114    }
20115
20116    /// Waits until an event arrives and returns it. It is safe for other
20117    /// threads to make concurrent requests while waiting for an event.
20118    pub fn wait_for_event(
20119        &self,
20120        deadline: zx::MonotonicInstant,
20121    ) -> Result<UsageWatcher2Event, fidl::Error> {
20122        UsageWatcher2Event::decode(self.client.wait_for_event::<UsageWatcher2Marker>(deadline)?)
20123    }
20124
20125    /// Called on first connection and whenever the watched usage changes. The provided
20126    /// usage will always be the bound usage; it is provided so that an implementation of
20127    /// this protocol may be bound to more than one usage.
20128    ///
20129    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20130    /// events will eventually be disconnected.
20131    pub fn r#on_state_changed(
20132        &self,
20133        mut usage: &Usage2,
20134        mut state: &UsageState,
20135        ___deadline: zx::MonotonicInstant,
20136    ) -> Result<(), fidl::Error> {
20137        let _response = self.client.send_query::<
20138            UsageWatcher2OnStateChangedRequest,
20139            fidl::encoding::EmptyPayload,
20140            UsageWatcher2Marker,
20141        >(
20142            (usage, state,),
20143            0xca31a8b13c324d4,
20144            fidl::encoding::DynamicFlags::empty(),
20145            ___deadline,
20146        )?;
20147        Ok(_response)
20148    }
20149}
20150
20151#[cfg(target_os = "fuchsia")]
20152impl From<UsageWatcher2SynchronousProxy> for zx::NullableHandle {
20153    fn from(value: UsageWatcher2SynchronousProxy) -> Self {
20154        value.into_channel().into()
20155    }
20156}
20157
20158#[cfg(target_os = "fuchsia")]
20159impl From<fidl::Channel> for UsageWatcher2SynchronousProxy {
20160    fn from(value: fidl::Channel) -> Self {
20161        Self::new(value)
20162    }
20163}
20164
20165#[cfg(target_os = "fuchsia")]
20166impl fidl::endpoints::FromClient for UsageWatcher2SynchronousProxy {
20167    type Protocol = UsageWatcher2Marker;
20168
20169    fn from_client(value: fidl::endpoints::ClientEnd<UsageWatcher2Marker>) -> Self {
20170        Self::new(value.into_channel())
20171    }
20172}
20173
20174#[derive(Debug, Clone)]
20175pub struct UsageWatcher2Proxy {
20176    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
20177}
20178
20179impl fidl::endpoints::Proxy for UsageWatcher2Proxy {
20180    type Protocol = UsageWatcher2Marker;
20181
20182    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
20183        Self::new(inner)
20184    }
20185
20186    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
20187        self.client.into_channel().map_err(|client| Self { client })
20188    }
20189
20190    fn as_channel(&self) -> &::fidl::AsyncChannel {
20191        self.client.as_channel()
20192    }
20193}
20194
20195impl UsageWatcher2Proxy {
20196    /// Create a new Proxy for fuchsia.media/UsageWatcher2.
20197    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
20198        let protocol_name = <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
20199        Self { client: fidl::client::Client::new(channel, protocol_name) }
20200    }
20201
20202    /// Get a Stream of events from the remote end of the protocol.
20203    ///
20204    /// # Panics
20205    ///
20206    /// Panics if the event stream was already taken.
20207    pub fn take_event_stream(&self) -> UsageWatcher2EventStream {
20208        UsageWatcher2EventStream { event_receiver: self.client.take_event_receiver() }
20209    }
20210
20211    /// Called on first connection and whenever the watched usage changes. The provided
20212    /// usage will always be the bound usage; it is provided so that an implementation of
20213    /// this protocol may be bound to more than one usage.
20214    ///
20215    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20216    /// events will eventually be disconnected.
20217    pub fn r#on_state_changed(
20218        &self,
20219        mut usage: &Usage2,
20220        mut state: &UsageState,
20221    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
20222        UsageWatcher2ProxyInterface::r#on_state_changed(self, usage, state)
20223    }
20224}
20225
20226impl UsageWatcher2ProxyInterface for UsageWatcher2Proxy {
20227    type OnStateChangedResponseFut =
20228        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
20229    fn r#on_state_changed(
20230        &self,
20231        mut usage: &Usage2,
20232        mut state: &UsageState,
20233    ) -> Self::OnStateChangedResponseFut {
20234        fn _decode(
20235            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
20236        ) -> Result<(), fidl::Error> {
20237            let _response = fidl::client::decode_transaction_body::<
20238                fidl::encoding::EmptyPayload,
20239                fidl::encoding::DefaultFuchsiaResourceDialect,
20240                0xca31a8b13c324d4,
20241            >(_buf?)?;
20242            Ok(_response)
20243        }
20244        self.client.send_query_and_decode::<UsageWatcher2OnStateChangedRequest, ()>(
20245            (usage, state),
20246            0xca31a8b13c324d4,
20247            fidl::encoding::DynamicFlags::empty(),
20248            _decode,
20249        )
20250    }
20251}
20252
20253pub struct UsageWatcher2EventStream {
20254    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
20255}
20256
20257impl std::marker::Unpin for UsageWatcher2EventStream {}
20258
20259impl futures::stream::FusedStream for UsageWatcher2EventStream {
20260    fn is_terminated(&self) -> bool {
20261        self.event_receiver.is_terminated()
20262    }
20263}
20264
20265impl futures::Stream for UsageWatcher2EventStream {
20266    type Item = Result<UsageWatcher2Event, fidl::Error>;
20267
20268    fn poll_next(
20269        mut self: std::pin::Pin<&mut Self>,
20270        cx: &mut std::task::Context<'_>,
20271    ) -> std::task::Poll<Option<Self::Item>> {
20272        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
20273            &mut self.event_receiver,
20274            cx
20275        )?) {
20276            Some(buf) => std::task::Poll::Ready(Some(UsageWatcher2Event::decode(buf))),
20277            None => std::task::Poll::Ready(None),
20278        }
20279    }
20280}
20281
20282#[derive(Debug)]
20283pub enum UsageWatcher2Event {}
20284
20285impl UsageWatcher2Event {
20286    /// Decodes a message buffer as a [`UsageWatcher2Event`].
20287    fn decode(
20288        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
20289    ) -> Result<UsageWatcher2Event, fidl::Error> {
20290        let (bytes, _handles) = buf.split_mut();
20291        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
20292        debug_assert_eq!(tx_header.tx_id, 0);
20293        match tx_header.ordinal {
20294            _ => Err(fidl::Error::UnknownOrdinal {
20295                ordinal: tx_header.ordinal,
20296                protocol_name: <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
20297            }),
20298        }
20299    }
20300}
20301
20302/// A Stream of incoming requests for fuchsia.media/UsageWatcher2.
20303pub struct UsageWatcher2RequestStream {
20304    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20305    is_terminated: bool,
20306}
20307
20308impl std::marker::Unpin for UsageWatcher2RequestStream {}
20309
20310impl futures::stream::FusedStream for UsageWatcher2RequestStream {
20311    fn is_terminated(&self) -> bool {
20312        self.is_terminated
20313    }
20314}
20315
20316impl fidl::endpoints::RequestStream for UsageWatcher2RequestStream {
20317    type Protocol = UsageWatcher2Marker;
20318    type ControlHandle = UsageWatcher2ControlHandle;
20319
20320    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
20321        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
20322    }
20323
20324    fn control_handle(&self) -> Self::ControlHandle {
20325        UsageWatcher2ControlHandle { inner: self.inner.clone() }
20326    }
20327
20328    fn into_inner(
20329        self,
20330    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
20331    {
20332        (self.inner, self.is_terminated)
20333    }
20334
20335    fn from_inner(
20336        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20337        is_terminated: bool,
20338    ) -> Self {
20339        Self { inner, is_terminated }
20340    }
20341}
20342
20343impl futures::Stream for UsageWatcher2RequestStream {
20344    type Item = Result<UsageWatcher2Request, fidl::Error>;
20345
20346    fn poll_next(
20347        mut self: std::pin::Pin<&mut Self>,
20348        cx: &mut std::task::Context<'_>,
20349    ) -> std::task::Poll<Option<Self::Item>> {
20350        let this = &mut *self;
20351        if this.inner.check_shutdown(cx) {
20352            this.is_terminated = true;
20353            return std::task::Poll::Ready(None);
20354        }
20355        if this.is_terminated {
20356            panic!("polled UsageWatcher2RequestStream after completion");
20357        }
20358        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
20359            |bytes, handles| {
20360                match this.inner.channel().read_etc(cx, bytes, handles) {
20361                    std::task::Poll::Ready(Ok(())) => {}
20362                    std::task::Poll::Pending => return std::task::Poll::Pending,
20363                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
20364                        this.is_terminated = true;
20365                        return std::task::Poll::Ready(None);
20366                    }
20367                    std::task::Poll::Ready(Err(e)) => {
20368                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
20369                            e.into(),
20370                        ))));
20371                    }
20372                }
20373
20374                // A message has been received from the channel
20375                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
20376
20377                std::task::Poll::Ready(Some(match header.ordinal {
20378                    0xca31a8b13c324d4 => {
20379                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
20380                        let mut req = fidl::new_empty!(
20381                            UsageWatcher2OnStateChangedRequest,
20382                            fidl::encoding::DefaultFuchsiaResourceDialect
20383                        );
20384                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageWatcher2OnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
20385                        let control_handle =
20386                            UsageWatcher2ControlHandle { inner: this.inner.clone() };
20387                        Ok(UsageWatcher2Request::OnStateChanged {
20388                            usage: req.usage,
20389                            state: req.state,
20390
20391                            responder: UsageWatcher2OnStateChangedResponder {
20392                                control_handle: std::mem::ManuallyDrop::new(control_handle),
20393                                tx_id: header.tx_id,
20394                            },
20395                        })
20396                    }
20397                    _ => Err(fidl::Error::UnknownOrdinal {
20398                        ordinal: header.ordinal,
20399                        protocol_name:
20400                            <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
20401                    }),
20402                }))
20403            },
20404        )
20405    }
20406}
20407
20408#[derive(Debug)]
20409pub enum UsageWatcher2Request {
20410    /// Called on first connection and whenever the watched usage changes. The provided
20411    /// usage will always be the bound usage; it is provided so that an implementation of
20412    /// this protocol may be bound to more than one usage.
20413    ///
20414    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20415    /// events will eventually be disconnected.
20416    OnStateChanged {
20417        usage: Usage2,
20418        state: UsageState,
20419        responder: UsageWatcher2OnStateChangedResponder,
20420    },
20421}
20422
20423impl UsageWatcher2Request {
20424    #[allow(irrefutable_let_patterns)]
20425    pub fn into_on_state_changed(
20426        self,
20427    ) -> Option<(Usage2, UsageState, UsageWatcher2OnStateChangedResponder)> {
20428        if let UsageWatcher2Request::OnStateChanged { usage, state, responder } = self {
20429            Some((usage, state, responder))
20430        } else {
20431            None
20432        }
20433    }
20434
20435    /// Name of the method defined in FIDL
20436    pub fn method_name(&self) -> &'static str {
20437        match *self {
20438            UsageWatcher2Request::OnStateChanged { .. } => "on_state_changed",
20439        }
20440    }
20441}
20442
20443#[derive(Debug, Clone)]
20444pub struct UsageWatcher2ControlHandle {
20445    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20446}
20447
20448impl fidl::endpoints::ControlHandle for UsageWatcher2ControlHandle {
20449    fn shutdown(&self) {
20450        self.inner.shutdown()
20451    }
20452
20453    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
20454        self.inner.shutdown_with_epitaph(status)
20455    }
20456
20457    fn is_closed(&self) -> bool {
20458        self.inner.channel().is_closed()
20459    }
20460    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
20461        self.inner.channel().on_closed()
20462    }
20463
20464    #[cfg(target_os = "fuchsia")]
20465    fn signal_peer(
20466        &self,
20467        clear_mask: zx::Signals,
20468        set_mask: zx::Signals,
20469    ) -> Result<(), zx_status::Status> {
20470        use fidl::Peered;
20471        self.inner.channel().signal_peer(clear_mask, set_mask)
20472    }
20473}
20474
20475impl UsageWatcher2ControlHandle {}
20476
20477#[must_use = "FIDL methods require a response to be sent"]
20478#[derive(Debug)]
20479pub struct UsageWatcher2OnStateChangedResponder {
20480    control_handle: std::mem::ManuallyDrop<UsageWatcher2ControlHandle>,
20481    tx_id: u32,
20482}
20483
20484/// Set the the channel to be shutdown (see [`UsageWatcher2ControlHandle::shutdown`])
20485/// if the responder is dropped without sending a response, so that the client
20486/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
20487impl std::ops::Drop for UsageWatcher2OnStateChangedResponder {
20488    fn drop(&mut self) {
20489        self.control_handle.shutdown();
20490        // Safety: drops once, never accessed again
20491        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
20492    }
20493}
20494
20495impl fidl::endpoints::Responder for UsageWatcher2OnStateChangedResponder {
20496    type ControlHandle = UsageWatcher2ControlHandle;
20497
20498    fn control_handle(&self) -> &UsageWatcher2ControlHandle {
20499        &self.control_handle
20500    }
20501
20502    fn drop_without_shutdown(mut self) {
20503        // Safety: drops once, never accessed again due to mem::forget
20504        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
20505        // Prevent Drop from running (which would shut down the channel)
20506        std::mem::forget(self);
20507    }
20508}
20509
20510impl UsageWatcher2OnStateChangedResponder {
20511    /// Sends a response to the FIDL transaction.
20512    ///
20513    /// Sets the channel to shutdown if an error occurs.
20514    pub fn send(self) -> Result<(), fidl::Error> {
20515        let _result = self.send_raw();
20516        if _result.is_err() {
20517            self.control_handle.shutdown();
20518        }
20519        self.drop_without_shutdown();
20520        _result
20521    }
20522
20523    /// Similar to "send" but does not shutdown the channel if an error occurs.
20524    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
20525        let _result = self.send_raw();
20526        self.drop_without_shutdown();
20527        _result
20528    }
20529
20530    fn send_raw(&self) -> Result<(), fidl::Error> {
20531        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
20532            (),
20533            self.tx_id,
20534            0xca31a8b13c324d4,
20535            fidl::encoding::DynamicFlags::empty(),
20536        )
20537    }
20538}
20539
20540mod internal {
20541    use super::*;
20542
20543    impl fidl::encoding::ResourceTypeMarker for AudioCapturerBindGainControlRequest {
20544        type Borrowed<'a> = &'a mut Self;
20545        fn take_or_borrow<'a>(
20546            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20547        ) -> Self::Borrowed<'a> {
20548            value
20549        }
20550    }
20551
20552    unsafe impl fidl::encoding::TypeMarker for AudioCapturerBindGainControlRequest {
20553        type Owned = Self;
20554
20555        #[inline(always)]
20556        fn inline_align(_context: fidl::encoding::Context) -> usize {
20557            4
20558        }
20559
20560        #[inline(always)]
20561        fn inline_size(_context: fidl::encoding::Context) -> usize {
20562            4
20563        }
20564    }
20565
20566    unsafe impl
20567        fidl::encoding::Encode<
20568            AudioCapturerBindGainControlRequest,
20569            fidl::encoding::DefaultFuchsiaResourceDialect,
20570        > for &mut AudioCapturerBindGainControlRequest
20571    {
20572        #[inline]
20573        unsafe fn encode(
20574            self,
20575            encoder: &mut fidl::encoding::Encoder<
20576                '_,
20577                fidl::encoding::DefaultFuchsiaResourceDialect,
20578            >,
20579            offset: usize,
20580            _depth: fidl::encoding::Depth,
20581        ) -> fidl::Result<()> {
20582            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
20583            // Delegate to tuple encoding.
20584            fidl::encoding::Encode::<
20585                AudioCapturerBindGainControlRequest,
20586                fidl::encoding::DefaultFuchsiaResourceDialect,
20587            >::encode(
20588                (<fidl::encoding::Endpoint<
20589                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20590                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20591                    &mut self.gain_control_request,
20592                ),),
20593                encoder,
20594                offset,
20595                _depth,
20596            )
20597        }
20598    }
20599    unsafe impl<
20600        T0: fidl::encoding::Encode<
20601                fidl::encoding::Endpoint<
20602                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20603                >,
20604                fidl::encoding::DefaultFuchsiaResourceDialect,
20605            >,
20606    >
20607        fidl::encoding::Encode<
20608            AudioCapturerBindGainControlRequest,
20609            fidl::encoding::DefaultFuchsiaResourceDialect,
20610        > for (T0,)
20611    {
20612        #[inline]
20613        unsafe fn encode(
20614            self,
20615            encoder: &mut fidl::encoding::Encoder<
20616                '_,
20617                fidl::encoding::DefaultFuchsiaResourceDialect,
20618            >,
20619            offset: usize,
20620            depth: fidl::encoding::Depth,
20621        ) -> fidl::Result<()> {
20622            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
20623            // Zero out padding regions. There's no need to apply masks
20624            // because the unmasked parts will be overwritten by fields.
20625            // Write the fields.
20626            self.0.encode(encoder, offset + 0, depth)?;
20627            Ok(())
20628        }
20629    }
20630
20631    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20632        for AudioCapturerBindGainControlRequest
20633    {
20634        #[inline(always)]
20635        fn new_empty() -> Self {
20636            Self {
20637                gain_control_request: fidl::new_empty!(
20638                    fidl::encoding::Endpoint<
20639                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20640                    >,
20641                    fidl::encoding::DefaultFuchsiaResourceDialect
20642                ),
20643            }
20644        }
20645
20646        #[inline]
20647        unsafe fn decode(
20648            &mut self,
20649            decoder: &mut fidl::encoding::Decoder<
20650                '_,
20651                fidl::encoding::DefaultFuchsiaResourceDialect,
20652            >,
20653            offset: usize,
20654            _depth: fidl::encoding::Depth,
20655        ) -> fidl::Result<()> {
20656            decoder.debug_check_bounds::<Self>(offset);
20657            // Verify that padding bytes are zero.
20658            fidl::decode!(
20659                fidl::encoding::Endpoint<
20660                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20661                >,
20662                fidl::encoding::DefaultFuchsiaResourceDialect,
20663                &mut self.gain_control_request,
20664                decoder,
20665                offset + 0,
20666                _depth
20667            )?;
20668            Ok(())
20669        }
20670    }
20671
20672    impl fidl::encoding::ResourceTypeMarker for AudioCapturerGetReferenceClockResponse {
20673        type Borrowed<'a> = &'a mut Self;
20674        fn take_or_borrow<'a>(
20675            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20676        ) -> Self::Borrowed<'a> {
20677            value
20678        }
20679    }
20680
20681    unsafe impl fidl::encoding::TypeMarker for AudioCapturerGetReferenceClockResponse {
20682        type Owned = Self;
20683
20684        #[inline(always)]
20685        fn inline_align(_context: fidl::encoding::Context) -> usize {
20686            4
20687        }
20688
20689        #[inline(always)]
20690        fn inline_size(_context: fidl::encoding::Context) -> usize {
20691            4
20692        }
20693    }
20694
20695    unsafe impl
20696        fidl::encoding::Encode<
20697            AudioCapturerGetReferenceClockResponse,
20698            fidl::encoding::DefaultFuchsiaResourceDialect,
20699        > for &mut AudioCapturerGetReferenceClockResponse
20700    {
20701        #[inline]
20702        unsafe fn encode(
20703            self,
20704            encoder: &mut fidl::encoding::Encoder<
20705                '_,
20706                fidl::encoding::DefaultFuchsiaResourceDialect,
20707            >,
20708            offset: usize,
20709            _depth: fidl::encoding::Depth,
20710        ) -> fidl::Result<()> {
20711            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
20712            // Delegate to tuple encoding.
20713            fidl::encoding::Encode::<
20714                AudioCapturerGetReferenceClockResponse,
20715                fidl::encoding::DefaultFuchsiaResourceDialect,
20716            >::encode(
20717                (<fidl::encoding::HandleType<
20718                    fidl::Clock,
20719                    { fidl::ObjectType::CLOCK.into_raw() },
20720                    2147483648,
20721                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20722                    &mut self.reference_clock,
20723                ),),
20724                encoder,
20725                offset,
20726                _depth,
20727            )
20728        }
20729    }
20730    unsafe impl<
20731        T0: fidl::encoding::Encode<
20732                fidl::encoding::HandleType<
20733                    fidl::Clock,
20734                    { fidl::ObjectType::CLOCK.into_raw() },
20735                    2147483648,
20736                >,
20737                fidl::encoding::DefaultFuchsiaResourceDialect,
20738            >,
20739    >
20740        fidl::encoding::Encode<
20741            AudioCapturerGetReferenceClockResponse,
20742            fidl::encoding::DefaultFuchsiaResourceDialect,
20743        > for (T0,)
20744    {
20745        #[inline]
20746        unsafe fn encode(
20747            self,
20748            encoder: &mut fidl::encoding::Encoder<
20749                '_,
20750                fidl::encoding::DefaultFuchsiaResourceDialect,
20751            >,
20752            offset: usize,
20753            depth: fidl::encoding::Depth,
20754        ) -> fidl::Result<()> {
20755            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
20756            // Zero out padding regions. There's no need to apply masks
20757            // because the unmasked parts will be overwritten by fields.
20758            // Write the fields.
20759            self.0.encode(encoder, offset + 0, depth)?;
20760            Ok(())
20761        }
20762    }
20763
20764    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20765        for AudioCapturerGetReferenceClockResponse
20766    {
20767        #[inline(always)]
20768        fn new_empty() -> Self {
20769            Self {
20770                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
20771            }
20772        }
20773
20774        #[inline]
20775        unsafe fn decode(
20776            &mut self,
20777            decoder: &mut fidl::encoding::Decoder<
20778                '_,
20779                fidl::encoding::DefaultFuchsiaResourceDialect,
20780            >,
20781            offset: usize,
20782            _depth: fidl::encoding::Depth,
20783        ) -> fidl::Result<()> {
20784            decoder.debug_check_bounds::<Self>(offset);
20785            // Verify that padding bytes are zero.
20786            fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
20787            Ok(())
20788        }
20789    }
20790
20791    impl fidl::encoding::ResourceTypeMarker for AudioCapturerSetReferenceClockRequest {
20792        type Borrowed<'a> = &'a mut Self;
20793        fn take_or_borrow<'a>(
20794            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20795        ) -> Self::Borrowed<'a> {
20796            value
20797        }
20798    }
20799
20800    unsafe impl fidl::encoding::TypeMarker for AudioCapturerSetReferenceClockRequest {
20801        type Owned = Self;
20802
20803        #[inline(always)]
20804        fn inline_align(_context: fidl::encoding::Context) -> usize {
20805            4
20806        }
20807
20808        #[inline(always)]
20809        fn inline_size(_context: fidl::encoding::Context) -> usize {
20810            4
20811        }
20812    }
20813
20814    unsafe impl
20815        fidl::encoding::Encode<
20816            AudioCapturerSetReferenceClockRequest,
20817            fidl::encoding::DefaultFuchsiaResourceDialect,
20818        > for &mut AudioCapturerSetReferenceClockRequest
20819    {
20820        #[inline]
20821        unsafe fn encode(
20822            self,
20823            encoder: &mut fidl::encoding::Encoder<
20824                '_,
20825                fidl::encoding::DefaultFuchsiaResourceDialect,
20826            >,
20827            offset: usize,
20828            _depth: fidl::encoding::Depth,
20829        ) -> fidl::Result<()> {
20830            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
20831            // Delegate to tuple encoding.
20832            fidl::encoding::Encode::<
20833                AudioCapturerSetReferenceClockRequest,
20834                fidl::encoding::DefaultFuchsiaResourceDialect,
20835            >::encode(
20836                (<fidl::encoding::Optional<
20837                    fidl::encoding::HandleType<
20838                        fidl::Clock,
20839                        { fidl::ObjectType::CLOCK.into_raw() },
20840                        2147483648,
20841                    >,
20842                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20843                    &mut self.reference_clock,
20844                ),),
20845                encoder,
20846                offset,
20847                _depth,
20848            )
20849        }
20850    }
20851    unsafe impl<
20852        T0: fidl::encoding::Encode<
20853                fidl::encoding::Optional<
20854                    fidl::encoding::HandleType<
20855                        fidl::Clock,
20856                        { fidl::ObjectType::CLOCK.into_raw() },
20857                        2147483648,
20858                    >,
20859                >,
20860                fidl::encoding::DefaultFuchsiaResourceDialect,
20861            >,
20862    >
20863        fidl::encoding::Encode<
20864            AudioCapturerSetReferenceClockRequest,
20865            fidl::encoding::DefaultFuchsiaResourceDialect,
20866        > for (T0,)
20867    {
20868        #[inline]
20869        unsafe fn encode(
20870            self,
20871            encoder: &mut fidl::encoding::Encoder<
20872                '_,
20873                fidl::encoding::DefaultFuchsiaResourceDialect,
20874            >,
20875            offset: usize,
20876            depth: fidl::encoding::Depth,
20877        ) -> fidl::Result<()> {
20878            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
20879            // Zero out padding regions. There's no need to apply masks
20880            // because the unmasked parts will be overwritten by fields.
20881            // Write the fields.
20882            self.0.encode(encoder, offset + 0, depth)?;
20883            Ok(())
20884        }
20885    }
20886
20887    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20888        for AudioCapturerSetReferenceClockRequest
20889    {
20890        #[inline(always)]
20891        fn new_empty() -> Self {
20892            Self {
20893                reference_clock: fidl::new_empty!(
20894                    fidl::encoding::Optional<
20895                        fidl::encoding::HandleType<
20896                            fidl::Clock,
20897                            { fidl::ObjectType::CLOCK.into_raw() },
20898                            2147483648,
20899                        >,
20900                    >,
20901                    fidl::encoding::DefaultFuchsiaResourceDialect
20902                ),
20903            }
20904        }
20905
20906        #[inline]
20907        unsafe fn decode(
20908            &mut self,
20909            decoder: &mut fidl::encoding::Decoder<
20910                '_,
20911                fidl::encoding::DefaultFuchsiaResourceDialect,
20912            >,
20913            offset: usize,
20914            _depth: fidl::encoding::Depth,
20915        ) -> fidl::Result<()> {
20916            decoder.debug_check_bounds::<Self>(offset);
20917            // Verify that padding bytes are zero.
20918            fidl::decode!(
20919                fidl::encoding::Optional<
20920                    fidl::encoding::HandleType<
20921                        fidl::Clock,
20922                        { fidl::ObjectType::CLOCK.into_raw() },
20923                        2147483648,
20924                    >,
20925                >,
20926                fidl::encoding::DefaultFuchsiaResourceDialect,
20927                &mut self.reference_clock,
20928                decoder,
20929                offset + 0,
20930                _depth
20931            )?;
20932            Ok(())
20933        }
20934    }
20935
20936    impl fidl::encoding::ResourceTypeMarker for AudioConsumerBindVolumeControlRequest {
20937        type Borrowed<'a> = &'a mut Self;
20938        fn take_or_borrow<'a>(
20939            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20940        ) -> Self::Borrowed<'a> {
20941            value
20942        }
20943    }
20944
20945    unsafe impl fidl::encoding::TypeMarker for AudioConsumerBindVolumeControlRequest {
20946        type Owned = Self;
20947
20948        #[inline(always)]
20949        fn inline_align(_context: fidl::encoding::Context) -> usize {
20950            4
20951        }
20952
20953        #[inline(always)]
20954        fn inline_size(_context: fidl::encoding::Context) -> usize {
20955            4
20956        }
20957    }
20958
20959    unsafe impl
20960        fidl::encoding::Encode<
20961            AudioConsumerBindVolumeControlRequest,
20962            fidl::encoding::DefaultFuchsiaResourceDialect,
20963        > for &mut AudioConsumerBindVolumeControlRequest
20964    {
20965        #[inline]
20966        unsafe fn encode(
20967            self,
20968            encoder: &mut fidl::encoding::Encoder<
20969                '_,
20970                fidl::encoding::DefaultFuchsiaResourceDialect,
20971            >,
20972            offset: usize,
20973            _depth: fidl::encoding::Depth,
20974        ) -> fidl::Result<()> {
20975            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
20976            // Delegate to tuple encoding.
20977            fidl::encoding::Encode::<
20978                AudioConsumerBindVolumeControlRequest,
20979                fidl::encoding::DefaultFuchsiaResourceDialect,
20980            >::encode(
20981                (<fidl::encoding::Endpoint<
20982                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
20983                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20984                    &mut self.volume_control_request,
20985                ),),
20986                encoder,
20987                offset,
20988                _depth,
20989            )
20990        }
20991    }
20992    unsafe impl<
20993        T0: fidl::encoding::Encode<
20994                fidl::encoding::Endpoint<
20995                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
20996                >,
20997                fidl::encoding::DefaultFuchsiaResourceDialect,
20998            >,
20999    >
21000        fidl::encoding::Encode<
21001            AudioConsumerBindVolumeControlRequest,
21002            fidl::encoding::DefaultFuchsiaResourceDialect,
21003        > for (T0,)
21004    {
21005        #[inline]
21006        unsafe fn encode(
21007            self,
21008            encoder: &mut fidl::encoding::Encoder<
21009                '_,
21010                fidl::encoding::DefaultFuchsiaResourceDialect,
21011            >,
21012            offset: usize,
21013            depth: fidl::encoding::Depth,
21014        ) -> fidl::Result<()> {
21015            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
21016            // Zero out padding regions. There's no need to apply masks
21017            // because the unmasked parts will be overwritten by fields.
21018            // Write the fields.
21019            self.0.encode(encoder, offset + 0, depth)?;
21020            Ok(())
21021        }
21022    }
21023
21024    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21025        for AudioConsumerBindVolumeControlRequest
21026    {
21027        #[inline(always)]
21028        fn new_empty() -> Self {
21029            Self {
21030                volume_control_request: fidl::new_empty!(
21031                    fidl::encoding::Endpoint<
21032                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21033                    >,
21034                    fidl::encoding::DefaultFuchsiaResourceDialect
21035                ),
21036            }
21037        }
21038
21039        #[inline]
21040        unsafe fn decode(
21041            &mut self,
21042            decoder: &mut fidl::encoding::Decoder<
21043                '_,
21044                fidl::encoding::DefaultFuchsiaResourceDialect,
21045            >,
21046            offset: usize,
21047            _depth: fidl::encoding::Depth,
21048        ) -> fidl::Result<()> {
21049            decoder.debug_check_bounds::<Self>(offset);
21050            // Verify that padding bytes are zero.
21051            fidl::decode!(
21052                fidl::encoding::Endpoint<
21053                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21054                >,
21055                fidl::encoding::DefaultFuchsiaResourceDialect,
21056                &mut self.volume_control_request,
21057                decoder,
21058                offset + 0,
21059                _depth
21060            )?;
21061            Ok(())
21062        }
21063    }
21064
21065    impl fidl::encoding::ResourceTypeMarker for AudioConsumerCreateStreamSinkRequest {
21066        type Borrowed<'a> = &'a mut Self;
21067        fn take_or_borrow<'a>(
21068            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21069        ) -> Self::Borrowed<'a> {
21070            value
21071        }
21072    }
21073
21074    unsafe impl fidl::encoding::TypeMarker for AudioConsumerCreateStreamSinkRequest {
21075        type Owned = Self;
21076
21077        #[inline(always)]
21078        fn inline_align(_context: fidl::encoding::Context) -> usize {
21079            8
21080        }
21081
21082        #[inline(always)]
21083        fn inline_size(_context: fidl::encoding::Context) -> usize {
21084            48
21085        }
21086    }
21087
21088    unsafe impl
21089        fidl::encoding::Encode<
21090            AudioConsumerCreateStreamSinkRequest,
21091            fidl::encoding::DefaultFuchsiaResourceDialect,
21092        > for &mut AudioConsumerCreateStreamSinkRequest
21093    {
21094        #[inline]
21095        unsafe fn encode(
21096            self,
21097            encoder: &mut fidl::encoding::Encoder<
21098                '_,
21099                fidl::encoding::DefaultFuchsiaResourceDialect,
21100            >,
21101            offset: usize,
21102            _depth: fidl::encoding::Depth,
21103        ) -> fidl::Result<()> {
21104            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
21105            // Delegate to tuple encoding.
21106            fidl::encoding::Encode::<AudioConsumerCreateStreamSinkRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21107                (
21108                    <fidl::encoding::Vector<fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, 16> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffers),
21109                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
21110                    <fidl::encoding::Boxed<Compression> as fidl::encoding::ValueTypeMarker>::borrow(&self.compression),
21111                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.stream_sink_request),
21112                ),
21113                encoder, offset, _depth
21114            )
21115        }
21116    }
21117    unsafe impl<
21118        T0: fidl::encoding::Encode<
21119                fidl::encoding::Vector<
21120                    fidl::encoding::HandleType<
21121                        fidl::Vmo,
21122                        { fidl::ObjectType::VMO.into_raw() },
21123                        2147483648,
21124                    >,
21125                    16,
21126                >,
21127                fidl::encoding::DefaultFuchsiaResourceDialect,
21128            >,
21129        T1: fidl::encoding::Encode<AudioStreamType, fidl::encoding::DefaultFuchsiaResourceDialect>,
21130        T2: fidl::encoding::Encode<
21131                fidl::encoding::Boxed<Compression>,
21132                fidl::encoding::DefaultFuchsiaResourceDialect,
21133            >,
21134        T3: fidl::encoding::Encode<
21135                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
21136                fidl::encoding::DefaultFuchsiaResourceDialect,
21137            >,
21138    >
21139        fidl::encoding::Encode<
21140            AudioConsumerCreateStreamSinkRequest,
21141            fidl::encoding::DefaultFuchsiaResourceDialect,
21142        > for (T0, T1, T2, T3)
21143    {
21144        #[inline]
21145        unsafe fn encode(
21146            self,
21147            encoder: &mut fidl::encoding::Encoder<
21148                '_,
21149                fidl::encoding::DefaultFuchsiaResourceDialect,
21150            >,
21151            offset: usize,
21152            depth: fidl::encoding::Depth,
21153        ) -> fidl::Result<()> {
21154            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
21155            // Zero out padding regions. There's no need to apply masks
21156            // because the unmasked parts will be overwritten by fields.
21157            unsafe {
21158                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
21159                (ptr as *mut u64).write_unaligned(0);
21160            }
21161            unsafe {
21162                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
21163                (ptr as *mut u64).write_unaligned(0);
21164            }
21165            // Write the fields.
21166            self.0.encode(encoder, offset + 0, depth)?;
21167            self.1.encode(encoder, offset + 16, depth)?;
21168            self.2.encode(encoder, offset + 32, depth)?;
21169            self.3.encode(encoder, offset + 40, depth)?;
21170            Ok(())
21171        }
21172    }
21173
21174    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21175        for AudioConsumerCreateStreamSinkRequest
21176    {
21177        #[inline(always)]
21178        fn new_empty() -> Self {
21179            Self {
21180                buffers: fidl::new_empty!(
21181                    fidl::encoding::Vector<
21182                        fidl::encoding::HandleType<
21183                            fidl::Vmo,
21184                            { fidl::ObjectType::VMO.into_raw() },
21185                            2147483648,
21186                        >,
21187                        16,
21188                    >,
21189                    fidl::encoding::DefaultFuchsiaResourceDialect
21190                ),
21191                stream_type: fidl::new_empty!(
21192                    AudioStreamType,
21193                    fidl::encoding::DefaultFuchsiaResourceDialect
21194                ),
21195                compression: fidl::new_empty!(
21196                    fidl::encoding::Boxed<Compression>,
21197                    fidl::encoding::DefaultFuchsiaResourceDialect
21198                ),
21199                stream_sink_request: fidl::new_empty!(
21200                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
21201                    fidl::encoding::DefaultFuchsiaResourceDialect
21202                ),
21203            }
21204        }
21205
21206        #[inline]
21207        unsafe fn decode(
21208            &mut self,
21209            decoder: &mut fidl::encoding::Decoder<
21210                '_,
21211                fidl::encoding::DefaultFuchsiaResourceDialect,
21212            >,
21213            offset: usize,
21214            _depth: fidl::encoding::Depth,
21215        ) -> fidl::Result<()> {
21216            decoder.debug_check_bounds::<Self>(offset);
21217            // Verify that padding bytes are zero.
21218            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
21219            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21220            let mask = 0xffffffff00000000u64;
21221            let maskedval = padval & mask;
21222            if maskedval != 0 {
21223                return Err(fidl::Error::NonZeroPadding {
21224                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
21225                });
21226            }
21227            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
21228            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21229            let mask = 0xffffffff00000000u64;
21230            let maskedval = padval & mask;
21231            if maskedval != 0 {
21232                return Err(fidl::Error::NonZeroPadding {
21233                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
21234                });
21235            }
21236            fidl::decode!(
21237                fidl::encoding::Vector<
21238                    fidl::encoding::HandleType<
21239                        fidl::Vmo,
21240                        { fidl::ObjectType::VMO.into_raw() },
21241                        2147483648,
21242                    >,
21243                    16,
21244                >,
21245                fidl::encoding::DefaultFuchsiaResourceDialect,
21246                &mut self.buffers,
21247                decoder,
21248                offset + 0,
21249                _depth
21250            )?;
21251            fidl::decode!(
21252                AudioStreamType,
21253                fidl::encoding::DefaultFuchsiaResourceDialect,
21254                &mut self.stream_type,
21255                decoder,
21256                offset + 16,
21257                _depth
21258            )?;
21259            fidl::decode!(
21260                fidl::encoding::Boxed<Compression>,
21261                fidl::encoding::DefaultFuchsiaResourceDialect,
21262                &mut self.compression,
21263                decoder,
21264                offset + 32,
21265                _depth
21266            )?;
21267            fidl::decode!(
21268                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
21269                fidl::encoding::DefaultFuchsiaResourceDialect,
21270                &mut self.stream_sink_request,
21271                decoder,
21272                offset + 40,
21273                _depth
21274            )?;
21275            Ok(())
21276        }
21277    }
21278
21279    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControl2Request {
21280        type Borrowed<'a> = &'a mut Self;
21281        fn take_or_borrow<'a>(
21282            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21283        ) -> Self::Borrowed<'a> {
21284            value
21285        }
21286    }
21287
21288    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControl2Request {
21289        type Owned = Self;
21290
21291        #[inline(always)]
21292        fn inline_align(_context: fidl::encoding::Context) -> usize {
21293            8
21294        }
21295
21296        #[inline(always)]
21297        fn inline_size(_context: fidl::encoding::Context) -> usize {
21298            24
21299        }
21300    }
21301
21302    unsafe impl
21303        fidl::encoding::Encode<
21304            AudioCoreBindUsageVolumeControl2Request,
21305            fidl::encoding::DefaultFuchsiaResourceDialect,
21306        > for &mut AudioCoreBindUsageVolumeControl2Request
21307    {
21308        #[inline]
21309        unsafe fn encode(
21310            self,
21311            encoder: &mut fidl::encoding::Encoder<
21312                '_,
21313                fidl::encoding::DefaultFuchsiaResourceDialect,
21314            >,
21315            offset: usize,
21316            _depth: fidl::encoding::Depth,
21317        ) -> fidl::Result<()> {
21318            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
21319            // Delegate to tuple encoding.
21320            fidl::encoding::Encode::<
21321                AudioCoreBindUsageVolumeControl2Request,
21322                fidl::encoding::DefaultFuchsiaResourceDialect,
21323            >::encode(
21324                (
21325                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21326                    <fidl::encoding::Endpoint<
21327                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21328                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
21329                        &mut self.volume_control,
21330                    ),
21331                ),
21332                encoder,
21333                offset,
21334                _depth,
21335            )
21336        }
21337    }
21338    unsafe impl<
21339        T0: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
21340        T1: fidl::encoding::Encode<
21341                fidl::encoding::Endpoint<
21342                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21343                >,
21344                fidl::encoding::DefaultFuchsiaResourceDialect,
21345            >,
21346    >
21347        fidl::encoding::Encode<
21348            AudioCoreBindUsageVolumeControl2Request,
21349            fidl::encoding::DefaultFuchsiaResourceDialect,
21350        > for (T0, T1)
21351    {
21352        #[inline]
21353        unsafe fn encode(
21354            self,
21355            encoder: &mut fidl::encoding::Encoder<
21356                '_,
21357                fidl::encoding::DefaultFuchsiaResourceDialect,
21358            >,
21359            offset: usize,
21360            depth: fidl::encoding::Depth,
21361        ) -> fidl::Result<()> {
21362            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
21363            // Zero out padding regions. There's no need to apply masks
21364            // because the unmasked parts will be overwritten by fields.
21365            unsafe {
21366                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
21367                (ptr as *mut u64).write_unaligned(0);
21368            }
21369            // Write the fields.
21370            self.0.encode(encoder, offset + 0, depth)?;
21371            self.1.encode(encoder, offset + 16, depth)?;
21372            Ok(())
21373        }
21374    }
21375
21376    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21377        for AudioCoreBindUsageVolumeControl2Request
21378    {
21379        #[inline(always)]
21380        fn new_empty() -> Self {
21381            Self {
21382                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
21383                volume_control: fidl::new_empty!(
21384                    fidl::encoding::Endpoint<
21385                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21386                    >,
21387                    fidl::encoding::DefaultFuchsiaResourceDialect
21388                ),
21389            }
21390        }
21391
21392        #[inline]
21393        unsafe fn decode(
21394            &mut self,
21395            decoder: &mut fidl::encoding::Decoder<
21396                '_,
21397                fidl::encoding::DefaultFuchsiaResourceDialect,
21398            >,
21399            offset: usize,
21400            _depth: fidl::encoding::Depth,
21401        ) -> fidl::Result<()> {
21402            decoder.debug_check_bounds::<Self>(offset);
21403            // Verify that padding bytes are zero.
21404            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
21405            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21406            let mask = 0xffffffff00000000u64;
21407            let maskedval = padval & mask;
21408            if maskedval != 0 {
21409                return Err(fidl::Error::NonZeroPadding {
21410                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
21411                });
21412            }
21413            fidl::decode!(
21414                Usage2,
21415                fidl::encoding::DefaultFuchsiaResourceDialect,
21416                &mut self.usage,
21417                decoder,
21418                offset + 0,
21419                _depth
21420            )?;
21421            fidl::decode!(
21422                fidl::encoding::Endpoint<
21423                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21424                >,
21425                fidl::encoding::DefaultFuchsiaResourceDialect,
21426                &mut self.volume_control,
21427                decoder,
21428                offset + 16,
21429                _depth
21430            )?;
21431            Ok(())
21432        }
21433    }
21434
21435    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControlRequest {
21436        type Borrowed<'a> = &'a mut Self;
21437        fn take_or_borrow<'a>(
21438            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21439        ) -> Self::Borrowed<'a> {
21440            value
21441        }
21442    }
21443
21444    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControlRequest {
21445        type Owned = Self;
21446
21447        #[inline(always)]
21448        fn inline_align(_context: fidl::encoding::Context) -> usize {
21449            8
21450        }
21451
21452        #[inline(always)]
21453        fn inline_size(_context: fidl::encoding::Context) -> usize {
21454            24
21455        }
21456    }
21457
21458    unsafe impl
21459        fidl::encoding::Encode<
21460            AudioCoreBindUsageVolumeControlRequest,
21461            fidl::encoding::DefaultFuchsiaResourceDialect,
21462        > for &mut AudioCoreBindUsageVolumeControlRequest
21463    {
21464        #[inline]
21465        unsafe fn encode(
21466            self,
21467            encoder: &mut fidl::encoding::Encoder<
21468                '_,
21469                fidl::encoding::DefaultFuchsiaResourceDialect,
21470            >,
21471            offset: usize,
21472            _depth: fidl::encoding::Depth,
21473        ) -> fidl::Result<()> {
21474            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
21475            // Delegate to tuple encoding.
21476            fidl::encoding::Encode::<
21477                AudioCoreBindUsageVolumeControlRequest,
21478                fidl::encoding::DefaultFuchsiaResourceDialect,
21479            >::encode(
21480                (
21481                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21482                    <fidl::encoding::Endpoint<
21483                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21484                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
21485                        &mut self.volume_control,
21486                    ),
21487                ),
21488                encoder,
21489                offset,
21490                _depth,
21491            )
21492        }
21493    }
21494    unsafe impl<
21495        T0: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
21496        T1: fidl::encoding::Encode<
21497                fidl::encoding::Endpoint<
21498                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21499                >,
21500                fidl::encoding::DefaultFuchsiaResourceDialect,
21501            >,
21502    >
21503        fidl::encoding::Encode<
21504            AudioCoreBindUsageVolumeControlRequest,
21505            fidl::encoding::DefaultFuchsiaResourceDialect,
21506        > for (T0, T1)
21507    {
21508        #[inline]
21509        unsafe fn encode(
21510            self,
21511            encoder: &mut fidl::encoding::Encoder<
21512                '_,
21513                fidl::encoding::DefaultFuchsiaResourceDialect,
21514            >,
21515            offset: usize,
21516            depth: fidl::encoding::Depth,
21517        ) -> fidl::Result<()> {
21518            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
21519            // Zero out padding regions. There's no need to apply masks
21520            // because the unmasked parts will be overwritten by fields.
21521            unsafe {
21522                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
21523                (ptr as *mut u64).write_unaligned(0);
21524            }
21525            // Write the fields.
21526            self.0.encode(encoder, offset + 0, depth)?;
21527            self.1.encode(encoder, offset + 16, depth)?;
21528            Ok(())
21529        }
21530    }
21531
21532    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21533        for AudioCoreBindUsageVolumeControlRequest
21534    {
21535        #[inline(always)]
21536        fn new_empty() -> Self {
21537            Self {
21538                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
21539                volume_control: fidl::new_empty!(
21540                    fidl::encoding::Endpoint<
21541                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21542                    >,
21543                    fidl::encoding::DefaultFuchsiaResourceDialect
21544                ),
21545            }
21546        }
21547
21548        #[inline]
21549        unsafe fn decode(
21550            &mut self,
21551            decoder: &mut fidl::encoding::Decoder<
21552                '_,
21553                fidl::encoding::DefaultFuchsiaResourceDialect,
21554            >,
21555            offset: usize,
21556            _depth: fidl::encoding::Depth,
21557        ) -> fidl::Result<()> {
21558            decoder.debug_check_bounds::<Self>(offset);
21559            // Verify that padding bytes are zero.
21560            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
21561            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21562            let mask = 0xffffffff00000000u64;
21563            let maskedval = padval & mask;
21564            if maskedval != 0 {
21565                return Err(fidl::Error::NonZeroPadding {
21566                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
21567                });
21568            }
21569            fidl::decode!(
21570                Usage,
21571                fidl::encoding::DefaultFuchsiaResourceDialect,
21572                &mut self.usage,
21573                decoder,
21574                offset + 0,
21575                _depth
21576            )?;
21577            fidl::decode!(
21578                fidl::encoding::Endpoint<
21579                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21580                >,
21581                fidl::encoding::DefaultFuchsiaResourceDialect,
21582                &mut self.volume_control,
21583                decoder,
21584                offset + 16,
21585                _depth
21586            )?;
21587            Ok(())
21588        }
21589    }
21590
21591    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerRequest {
21592        type Borrowed<'a> = &'a mut Self;
21593        fn take_or_borrow<'a>(
21594            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21595        ) -> Self::Borrowed<'a> {
21596            value
21597        }
21598    }
21599
21600    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerRequest {
21601        type Owned = Self;
21602
21603        #[inline(always)]
21604        fn inline_align(_context: fidl::encoding::Context) -> usize {
21605            4
21606        }
21607
21608        #[inline(always)]
21609        fn inline_size(_context: fidl::encoding::Context) -> usize {
21610            8
21611        }
21612    }
21613
21614    unsafe impl
21615        fidl::encoding::Encode<
21616            AudioCoreCreateAudioCapturerRequest,
21617            fidl::encoding::DefaultFuchsiaResourceDialect,
21618        > for &mut AudioCoreCreateAudioCapturerRequest
21619    {
21620        #[inline]
21621        unsafe fn encode(
21622            self,
21623            encoder: &mut fidl::encoding::Encoder<
21624                '_,
21625                fidl::encoding::DefaultFuchsiaResourceDialect,
21626            >,
21627            offset: usize,
21628            _depth: fidl::encoding::Depth,
21629        ) -> fidl::Result<()> {
21630            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
21631            // Delegate to tuple encoding.
21632            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21633                (
21634                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
21635                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_in_request),
21636                ),
21637                encoder, offset, _depth
21638            )
21639        }
21640    }
21641    unsafe impl<
21642        T0: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
21643        T1: fidl::encoding::Encode<
21644                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21645                fidl::encoding::DefaultFuchsiaResourceDialect,
21646            >,
21647    >
21648        fidl::encoding::Encode<
21649            AudioCoreCreateAudioCapturerRequest,
21650            fidl::encoding::DefaultFuchsiaResourceDialect,
21651        > for (T0, T1)
21652    {
21653        #[inline]
21654        unsafe fn encode(
21655            self,
21656            encoder: &mut fidl::encoding::Encoder<
21657                '_,
21658                fidl::encoding::DefaultFuchsiaResourceDialect,
21659            >,
21660            offset: usize,
21661            depth: fidl::encoding::Depth,
21662        ) -> fidl::Result<()> {
21663            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
21664            // Zero out padding regions. There's no need to apply masks
21665            // because the unmasked parts will be overwritten by fields.
21666            unsafe {
21667                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
21668                (ptr as *mut u32).write_unaligned(0);
21669            }
21670            // Write the fields.
21671            self.0.encode(encoder, offset + 0, depth)?;
21672            self.1.encode(encoder, offset + 4, depth)?;
21673            Ok(())
21674        }
21675    }
21676
21677    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21678        for AudioCoreCreateAudioCapturerRequest
21679    {
21680        #[inline(always)]
21681        fn new_empty() -> Self {
21682            Self {
21683                loopback: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
21684                audio_in_request: fidl::new_empty!(
21685                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21686                    fidl::encoding::DefaultFuchsiaResourceDialect
21687                ),
21688            }
21689        }
21690
21691        #[inline]
21692        unsafe fn decode(
21693            &mut self,
21694            decoder: &mut fidl::encoding::Decoder<
21695                '_,
21696                fidl::encoding::DefaultFuchsiaResourceDialect,
21697            >,
21698            offset: usize,
21699            _depth: fidl::encoding::Depth,
21700        ) -> fidl::Result<()> {
21701            decoder.debug_check_bounds::<Self>(offset);
21702            // Verify that padding bytes are zero.
21703            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
21704            let padval = unsafe { (ptr as *const u32).read_unaligned() };
21705            let mask = 0xffffff00u32;
21706            let maskedval = padval & mask;
21707            if maskedval != 0 {
21708                return Err(fidl::Error::NonZeroPadding {
21709                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
21710                });
21711            }
21712            fidl::decode!(
21713                bool,
21714                fidl::encoding::DefaultFuchsiaResourceDialect,
21715                &mut self.loopback,
21716                decoder,
21717                offset + 0,
21718                _depth
21719            )?;
21720            fidl::decode!(
21721                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21722                fidl::encoding::DefaultFuchsiaResourceDialect,
21723                &mut self.audio_in_request,
21724                decoder,
21725                offset + 4,
21726                _depth
21727            )?;
21728            Ok(())
21729        }
21730    }
21731
21732    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
21733        type Borrowed<'a> = &'a mut Self;
21734        fn take_or_borrow<'a>(
21735            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21736        ) -> Self::Borrowed<'a> {
21737            value
21738        }
21739    }
21740
21741    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
21742        type Owned = Self;
21743
21744        #[inline(always)]
21745        fn inline_align(_context: fidl::encoding::Context) -> usize {
21746            8
21747        }
21748
21749        #[inline(always)]
21750        fn inline_size(_context: fidl::encoding::Context) -> usize {
21751            40
21752        }
21753    }
21754
21755    unsafe impl
21756        fidl::encoding::Encode<
21757            AudioCoreCreateAudioCapturerWithConfigurationRequest,
21758            fidl::encoding::DefaultFuchsiaResourceDialect,
21759        > for &mut AudioCoreCreateAudioCapturerWithConfigurationRequest
21760    {
21761        #[inline]
21762        unsafe fn encode(
21763            self,
21764            encoder: &mut fidl::encoding::Encoder<
21765                '_,
21766                fidl::encoding::DefaultFuchsiaResourceDialect,
21767            >,
21768            offset: usize,
21769            _depth: fidl::encoding::Depth,
21770        ) -> fidl::Result<()> {
21771            encoder
21772                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
21773            // Delegate to tuple encoding.
21774            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerWithConfigurationRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21775                (
21776                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
21777                    <AudioCapturerConfiguration as fidl::encoding::ValueTypeMarker>::borrow(&self.configuration),
21778                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
21779                ),
21780                encoder, offset, _depth
21781            )
21782        }
21783    }
21784    unsafe impl<
21785        T0: fidl::encoding::Encode<AudioStreamType, fidl::encoding::DefaultFuchsiaResourceDialect>,
21786        T1: fidl::encoding::Encode<
21787                AudioCapturerConfiguration,
21788                fidl::encoding::DefaultFuchsiaResourceDialect,
21789            >,
21790        T2: fidl::encoding::Encode<
21791                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21792                fidl::encoding::DefaultFuchsiaResourceDialect,
21793            >,
21794    >
21795        fidl::encoding::Encode<
21796            AudioCoreCreateAudioCapturerWithConfigurationRequest,
21797            fidl::encoding::DefaultFuchsiaResourceDialect,
21798        > for (T0, T1, T2)
21799    {
21800        #[inline]
21801        unsafe fn encode(
21802            self,
21803            encoder: &mut fidl::encoding::Encoder<
21804                '_,
21805                fidl::encoding::DefaultFuchsiaResourceDialect,
21806            >,
21807            offset: usize,
21808            depth: fidl::encoding::Depth,
21809        ) -> fidl::Result<()> {
21810            encoder
21811                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
21812            // Zero out padding regions. There's no need to apply masks
21813            // because the unmasked parts will be overwritten by fields.
21814            unsafe {
21815                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
21816                (ptr as *mut u64).write_unaligned(0);
21817            }
21818            unsafe {
21819                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
21820                (ptr as *mut u64).write_unaligned(0);
21821            }
21822            // Write the fields.
21823            self.0.encode(encoder, offset + 0, depth)?;
21824            self.1.encode(encoder, offset + 16, depth)?;
21825            self.2.encode(encoder, offset + 32, depth)?;
21826            Ok(())
21827        }
21828    }
21829
21830    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21831        for AudioCoreCreateAudioCapturerWithConfigurationRequest
21832    {
21833        #[inline(always)]
21834        fn new_empty() -> Self {
21835            Self {
21836                stream_type: fidl::new_empty!(
21837                    AudioStreamType,
21838                    fidl::encoding::DefaultFuchsiaResourceDialect
21839                ),
21840                configuration: fidl::new_empty!(
21841                    AudioCapturerConfiguration,
21842                    fidl::encoding::DefaultFuchsiaResourceDialect
21843                ),
21844                audio_capturer_request: fidl::new_empty!(
21845                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21846                    fidl::encoding::DefaultFuchsiaResourceDialect
21847                ),
21848            }
21849        }
21850
21851        #[inline]
21852        unsafe fn decode(
21853            &mut self,
21854            decoder: &mut fidl::encoding::Decoder<
21855                '_,
21856                fidl::encoding::DefaultFuchsiaResourceDialect,
21857            >,
21858            offset: usize,
21859            _depth: fidl::encoding::Depth,
21860        ) -> fidl::Result<()> {
21861            decoder.debug_check_bounds::<Self>(offset);
21862            // Verify that padding bytes are zero.
21863            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
21864            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21865            let mask = 0xffffffff00000000u64;
21866            let maskedval = padval & mask;
21867            if maskedval != 0 {
21868                return Err(fidl::Error::NonZeroPadding {
21869                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
21870                });
21871            }
21872            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
21873            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21874            let mask = 0xffffffff00000000u64;
21875            let maskedval = padval & mask;
21876            if maskedval != 0 {
21877                return Err(fidl::Error::NonZeroPadding {
21878                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
21879                });
21880            }
21881            fidl::decode!(
21882                AudioStreamType,
21883                fidl::encoding::DefaultFuchsiaResourceDialect,
21884                &mut self.stream_type,
21885                decoder,
21886                offset + 0,
21887                _depth
21888            )?;
21889            fidl::decode!(
21890                AudioCapturerConfiguration,
21891                fidl::encoding::DefaultFuchsiaResourceDialect,
21892                &mut self.configuration,
21893                decoder,
21894                offset + 16,
21895                _depth
21896            )?;
21897            fidl::decode!(
21898                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21899                fidl::encoding::DefaultFuchsiaResourceDialect,
21900                &mut self.audio_capturer_request,
21901                decoder,
21902                offset + 32,
21903                _depth
21904            )?;
21905            Ok(())
21906        }
21907    }
21908
21909    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioRendererRequest {
21910        type Borrowed<'a> = &'a mut Self;
21911        fn take_or_borrow<'a>(
21912            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21913        ) -> Self::Borrowed<'a> {
21914            value
21915        }
21916    }
21917
21918    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioRendererRequest {
21919        type Owned = Self;
21920
21921        #[inline(always)]
21922        fn inline_align(_context: fidl::encoding::Context) -> usize {
21923            4
21924        }
21925
21926        #[inline(always)]
21927        fn inline_size(_context: fidl::encoding::Context) -> usize {
21928            4
21929        }
21930    }
21931
21932    unsafe impl
21933        fidl::encoding::Encode<
21934            AudioCoreCreateAudioRendererRequest,
21935            fidl::encoding::DefaultFuchsiaResourceDialect,
21936        > for &mut AudioCoreCreateAudioRendererRequest
21937    {
21938        #[inline]
21939        unsafe fn encode(
21940            self,
21941            encoder: &mut fidl::encoding::Encoder<
21942                '_,
21943                fidl::encoding::DefaultFuchsiaResourceDialect,
21944            >,
21945            offset: usize,
21946            _depth: fidl::encoding::Depth,
21947        ) -> fidl::Result<()> {
21948            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
21949            // Delegate to tuple encoding.
21950            fidl::encoding::Encode::<AudioCoreCreateAudioRendererRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21951                (
21952                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_out_request),
21953                ),
21954                encoder, offset, _depth
21955            )
21956        }
21957    }
21958    unsafe impl<
21959        T0: fidl::encoding::Encode<
21960                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
21961                fidl::encoding::DefaultFuchsiaResourceDialect,
21962            >,
21963    >
21964        fidl::encoding::Encode<
21965            AudioCoreCreateAudioRendererRequest,
21966            fidl::encoding::DefaultFuchsiaResourceDialect,
21967        > for (T0,)
21968    {
21969        #[inline]
21970        unsafe fn encode(
21971            self,
21972            encoder: &mut fidl::encoding::Encoder<
21973                '_,
21974                fidl::encoding::DefaultFuchsiaResourceDialect,
21975            >,
21976            offset: usize,
21977            depth: fidl::encoding::Depth,
21978        ) -> fidl::Result<()> {
21979            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
21980            // Zero out padding regions. There's no need to apply masks
21981            // because the unmasked parts will be overwritten by fields.
21982            // Write the fields.
21983            self.0.encode(encoder, offset + 0, depth)?;
21984            Ok(())
21985        }
21986    }
21987
21988    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21989        for AudioCoreCreateAudioRendererRequest
21990    {
21991        #[inline(always)]
21992        fn new_empty() -> Self {
21993            Self {
21994                audio_out_request: fidl::new_empty!(
21995                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
21996                    fidl::encoding::DefaultFuchsiaResourceDialect
21997                ),
21998            }
21999        }
22000
22001        #[inline]
22002        unsafe fn decode(
22003            &mut self,
22004            decoder: &mut fidl::encoding::Decoder<
22005                '_,
22006                fidl::encoding::DefaultFuchsiaResourceDialect,
22007            >,
22008            offset: usize,
22009            _depth: fidl::encoding::Depth,
22010        ) -> fidl::Result<()> {
22011            decoder.debug_check_bounds::<Self>(offset);
22012            // Verify that padding bytes are zero.
22013            fidl::decode!(
22014                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
22015                fidl::encoding::DefaultFuchsiaResourceDialect,
22016                &mut self.audio_out_request,
22017                decoder,
22018                offset + 0,
22019                _depth
22020            )?;
22021            Ok(())
22022        }
22023    }
22024
22025    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioCapturerRequest {
22026        type Borrowed<'a> = &'a mut Self;
22027        fn take_or_borrow<'a>(
22028            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22029        ) -> Self::Borrowed<'a> {
22030            value
22031        }
22032    }
22033
22034    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioCapturerRequest {
22035        type Owned = Self;
22036
22037        #[inline(always)]
22038        fn inline_align(_context: fidl::encoding::Context) -> usize {
22039            4
22040        }
22041
22042        #[inline(always)]
22043        fn inline_size(_context: fidl::encoding::Context) -> usize {
22044            8
22045        }
22046    }
22047
22048    unsafe impl
22049        fidl::encoding::Encode<
22050            AudioCreateAudioCapturerRequest,
22051            fidl::encoding::DefaultFuchsiaResourceDialect,
22052        > for &mut AudioCreateAudioCapturerRequest
22053    {
22054        #[inline]
22055        unsafe fn encode(
22056            self,
22057            encoder: &mut fidl::encoding::Encoder<
22058                '_,
22059                fidl::encoding::DefaultFuchsiaResourceDialect,
22060            >,
22061            offset: usize,
22062            _depth: fidl::encoding::Depth,
22063        ) -> fidl::Result<()> {
22064            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
22065            // Delegate to tuple encoding.
22066            fidl::encoding::Encode::<AudioCreateAudioCapturerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
22067                (
22068                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
22069                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
22070                ),
22071                encoder, offset, _depth
22072            )
22073        }
22074    }
22075    unsafe impl<
22076        T0: fidl::encoding::Encode<
22077                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
22078                fidl::encoding::DefaultFuchsiaResourceDialect,
22079            >,
22080        T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
22081    >
22082        fidl::encoding::Encode<
22083            AudioCreateAudioCapturerRequest,
22084            fidl::encoding::DefaultFuchsiaResourceDialect,
22085        > for (T0, T1)
22086    {
22087        #[inline]
22088        unsafe fn encode(
22089            self,
22090            encoder: &mut fidl::encoding::Encoder<
22091                '_,
22092                fidl::encoding::DefaultFuchsiaResourceDialect,
22093            >,
22094            offset: usize,
22095            depth: fidl::encoding::Depth,
22096        ) -> fidl::Result<()> {
22097            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
22098            // Zero out padding regions. There's no need to apply masks
22099            // because the unmasked parts will be overwritten by fields.
22100            unsafe {
22101                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
22102                (ptr as *mut u32).write_unaligned(0);
22103            }
22104            // Write the fields.
22105            self.0.encode(encoder, offset + 0, depth)?;
22106            self.1.encode(encoder, offset + 4, depth)?;
22107            Ok(())
22108        }
22109    }
22110
22111    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22112        for AudioCreateAudioCapturerRequest
22113    {
22114        #[inline(always)]
22115        fn new_empty() -> Self {
22116            Self {
22117                audio_capturer_request: fidl::new_empty!(
22118                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
22119                    fidl::encoding::DefaultFuchsiaResourceDialect
22120                ),
22121                loopback: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
22122            }
22123        }
22124
22125        #[inline]
22126        unsafe fn decode(
22127            &mut self,
22128            decoder: &mut fidl::encoding::Decoder<
22129                '_,
22130                fidl::encoding::DefaultFuchsiaResourceDialect,
22131            >,
22132            offset: usize,
22133            _depth: fidl::encoding::Depth,
22134        ) -> fidl::Result<()> {
22135            decoder.debug_check_bounds::<Self>(offset);
22136            // Verify that padding bytes are zero.
22137            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(4) };
22138            let padval = unsafe { (ptr as *const u32).read_unaligned() };
22139            let mask = 0xffffff00u32;
22140            let maskedval = padval & mask;
22141            if maskedval != 0 {
22142                return Err(fidl::Error::NonZeroPadding {
22143                    padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
22144                });
22145            }
22146            fidl::decode!(
22147                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
22148                fidl::encoding::DefaultFuchsiaResourceDialect,
22149                &mut self.audio_capturer_request,
22150                decoder,
22151                offset + 0,
22152                _depth
22153            )?;
22154            fidl::decode!(
22155                bool,
22156                fidl::encoding::DefaultFuchsiaResourceDialect,
22157                &mut self.loopback,
22158                decoder,
22159                offset + 4,
22160                _depth
22161            )?;
22162            Ok(())
22163        }
22164    }
22165
22166    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioRendererRequest {
22167        type Borrowed<'a> = &'a mut Self;
22168        fn take_or_borrow<'a>(
22169            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22170        ) -> Self::Borrowed<'a> {
22171            value
22172        }
22173    }
22174
22175    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioRendererRequest {
22176        type Owned = Self;
22177
22178        #[inline(always)]
22179        fn inline_align(_context: fidl::encoding::Context) -> usize {
22180            4
22181        }
22182
22183        #[inline(always)]
22184        fn inline_size(_context: fidl::encoding::Context) -> usize {
22185            4
22186        }
22187    }
22188
22189    unsafe impl
22190        fidl::encoding::Encode<
22191            AudioCreateAudioRendererRequest,
22192            fidl::encoding::DefaultFuchsiaResourceDialect,
22193        > for &mut AudioCreateAudioRendererRequest
22194    {
22195        #[inline]
22196        unsafe fn encode(
22197            self,
22198            encoder: &mut fidl::encoding::Encoder<
22199                '_,
22200                fidl::encoding::DefaultFuchsiaResourceDialect,
22201            >,
22202            offset: usize,
22203            _depth: fidl::encoding::Depth,
22204        ) -> fidl::Result<()> {
22205            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
22206            // Delegate to tuple encoding.
22207            fidl::encoding::Encode::<AudioCreateAudioRendererRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
22208                (
22209                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_renderer_request),
22210                ),
22211                encoder, offset, _depth
22212            )
22213        }
22214    }
22215    unsafe impl<
22216        T0: fidl::encoding::Encode<
22217                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
22218                fidl::encoding::DefaultFuchsiaResourceDialect,
22219            >,
22220    >
22221        fidl::encoding::Encode<
22222            AudioCreateAudioRendererRequest,
22223            fidl::encoding::DefaultFuchsiaResourceDialect,
22224        > for (T0,)
22225    {
22226        #[inline]
22227        unsafe fn encode(
22228            self,
22229            encoder: &mut fidl::encoding::Encoder<
22230                '_,
22231                fidl::encoding::DefaultFuchsiaResourceDialect,
22232            >,
22233            offset: usize,
22234            depth: fidl::encoding::Depth,
22235        ) -> fidl::Result<()> {
22236            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
22237            // Zero out padding regions. There's no need to apply masks
22238            // because the unmasked parts will be overwritten by fields.
22239            // Write the fields.
22240            self.0.encode(encoder, offset + 0, depth)?;
22241            Ok(())
22242        }
22243    }
22244
22245    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22246        for AudioCreateAudioRendererRequest
22247    {
22248        #[inline(always)]
22249        fn new_empty() -> Self {
22250            Self {
22251                audio_renderer_request: fidl::new_empty!(
22252                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
22253                    fidl::encoding::DefaultFuchsiaResourceDialect
22254                ),
22255            }
22256        }
22257
22258        #[inline]
22259        unsafe fn decode(
22260            &mut self,
22261            decoder: &mut fidl::encoding::Decoder<
22262                '_,
22263                fidl::encoding::DefaultFuchsiaResourceDialect,
22264            >,
22265            offset: usize,
22266            _depth: fidl::encoding::Depth,
22267        ) -> fidl::Result<()> {
22268            decoder.debug_check_bounds::<Self>(offset);
22269            // Verify that padding bytes are zero.
22270            fidl::decode!(
22271                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
22272                fidl::encoding::DefaultFuchsiaResourceDialect,
22273                &mut self.audio_renderer_request,
22274                decoder,
22275                offset + 0,
22276                _depth
22277            )?;
22278            Ok(())
22279        }
22280    }
22281
22282    impl fidl::encoding::ResourceTypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
22283        type Borrowed<'a> = &'a mut Self;
22284        fn take_or_borrow<'a>(
22285            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22286        ) -> Self::Borrowed<'a> {
22287            value
22288        }
22289    }
22290
22291    unsafe impl fidl::encoding::TypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
22292        type Owned = Self;
22293
22294        #[inline(always)]
22295        fn inline_align(_context: fidl::encoding::Context) -> usize {
22296            8
22297        }
22298
22299        #[inline(always)]
22300        fn inline_size(_context: fidl::encoding::Context) -> usize {
22301            24
22302        }
22303    }
22304
22305    unsafe impl
22306        fidl::encoding::Encode<
22307            AudioDeviceEnumeratorAddDeviceByChannelRequest,
22308            fidl::encoding::DefaultFuchsiaResourceDialect,
22309        > for &mut AudioDeviceEnumeratorAddDeviceByChannelRequest
22310    {
22311        #[inline]
22312        unsafe fn encode(
22313            self,
22314            encoder: &mut fidl::encoding::Encoder<
22315                '_,
22316                fidl::encoding::DefaultFuchsiaResourceDialect,
22317            >,
22318            offset: usize,
22319            _depth: fidl::encoding::Depth,
22320        ) -> fidl::Result<()> {
22321            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
22322            // Delegate to tuple encoding.
22323            fidl::encoding::Encode::<
22324                AudioDeviceEnumeratorAddDeviceByChannelRequest,
22325                fidl::encoding::DefaultFuchsiaResourceDialect,
22326            >::encode(
22327                (
22328                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow(
22329                        &self.device_name,
22330                    ),
22331                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.is_input),
22332                    <fidl::encoding::Endpoint<
22333                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22334                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22335                        &mut self.channel
22336                    ),
22337                ),
22338                encoder,
22339                offset,
22340                _depth,
22341            )
22342        }
22343    }
22344    unsafe impl<
22345        T0: fidl::encoding::Encode<
22346                fidl::encoding::BoundedString<256>,
22347                fidl::encoding::DefaultFuchsiaResourceDialect,
22348            >,
22349        T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
22350        T2: fidl::encoding::Encode<
22351                fidl::encoding::Endpoint<
22352                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22353                >,
22354                fidl::encoding::DefaultFuchsiaResourceDialect,
22355            >,
22356    >
22357        fidl::encoding::Encode<
22358            AudioDeviceEnumeratorAddDeviceByChannelRequest,
22359            fidl::encoding::DefaultFuchsiaResourceDialect,
22360        > for (T0, T1, T2)
22361    {
22362        #[inline]
22363        unsafe fn encode(
22364            self,
22365            encoder: &mut fidl::encoding::Encoder<
22366                '_,
22367                fidl::encoding::DefaultFuchsiaResourceDialect,
22368            >,
22369            offset: usize,
22370            depth: fidl::encoding::Depth,
22371        ) -> fidl::Result<()> {
22372            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
22373            // Zero out padding regions. There's no need to apply masks
22374            // because the unmasked parts will be overwritten by fields.
22375            unsafe {
22376                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
22377                (ptr as *mut u64).write_unaligned(0);
22378            }
22379            // Write the fields.
22380            self.0.encode(encoder, offset + 0, depth)?;
22381            self.1.encode(encoder, offset + 16, depth)?;
22382            self.2.encode(encoder, offset + 20, depth)?;
22383            Ok(())
22384        }
22385    }
22386
22387    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22388        for AudioDeviceEnumeratorAddDeviceByChannelRequest
22389    {
22390        #[inline(always)]
22391        fn new_empty() -> Self {
22392            Self {
22393                device_name: fidl::new_empty!(
22394                    fidl::encoding::BoundedString<256>,
22395                    fidl::encoding::DefaultFuchsiaResourceDialect
22396                ),
22397                is_input: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
22398                channel: fidl::new_empty!(
22399                    fidl::encoding::Endpoint<
22400                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22401                    >,
22402                    fidl::encoding::DefaultFuchsiaResourceDialect
22403                ),
22404            }
22405        }
22406
22407        #[inline]
22408        unsafe fn decode(
22409            &mut self,
22410            decoder: &mut fidl::encoding::Decoder<
22411                '_,
22412                fidl::encoding::DefaultFuchsiaResourceDialect,
22413            >,
22414            offset: usize,
22415            _depth: fidl::encoding::Depth,
22416        ) -> fidl::Result<()> {
22417            decoder.debug_check_bounds::<Self>(offset);
22418            // Verify that padding bytes are zero.
22419            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
22420            let padval = unsafe { (ptr as *const u64).read_unaligned() };
22421            let mask = 0xffffff00u64;
22422            let maskedval = padval & mask;
22423            if maskedval != 0 {
22424                return Err(fidl::Error::NonZeroPadding {
22425                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
22426                });
22427            }
22428            fidl::decode!(
22429                fidl::encoding::BoundedString<256>,
22430                fidl::encoding::DefaultFuchsiaResourceDialect,
22431                &mut self.device_name,
22432                decoder,
22433                offset + 0,
22434                _depth
22435            )?;
22436            fidl::decode!(
22437                bool,
22438                fidl::encoding::DefaultFuchsiaResourceDialect,
22439                &mut self.is_input,
22440                decoder,
22441                offset + 16,
22442                _depth
22443            )?;
22444            fidl::decode!(
22445                fidl::encoding::Endpoint<
22446                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22447                >,
22448                fidl::encoding::DefaultFuchsiaResourceDialect,
22449                &mut self.channel,
22450                decoder,
22451                offset + 20,
22452                _depth
22453            )?;
22454            Ok(())
22455        }
22456    }
22457
22458    impl fidl::encoding::ResourceTypeMarker for AudioRendererBindGainControlRequest {
22459        type Borrowed<'a> = &'a mut Self;
22460        fn take_or_borrow<'a>(
22461            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22462        ) -> Self::Borrowed<'a> {
22463            value
22464        }
22465    }
22466
22467    unsafe impl fidl::encoding::TypeMarker for AudioRendererBindGainControlRequest {
22468        type Owned = Self;
22469
22470        #[inline(always)]
22471        fn inline_align(_context: fidl::encoding::Context) -> usize {
22472            4
22473        }
22474
22475        #[inline(always)]
22476        fn inline_size(_context: fidl::encoding::Context) -> usize {
22477            4
22478        }
22479    }
22480
22481    unsafe impl
22482        fidl::encoding::Encode<
22483            AudioRendererBindGainControlRequest,
22484            fidl::encoding::DefaultFuchsiaResourceDialect,
22485        > for &mut AudioRendererBindGainControlRequest
22486    {
22487        #[inline]
22488        unsafe fn encode(
22489            self,
22490            encoder: &mut fidl::encoding::Encoder<
22491                '_,
22492                fidl::encoding::DefaultFuchsiaResourceDialect,
22493            >,
22494            offset: usize,
22495            _depth: fidl::encoding::Depth,
22496        ) -> fidl::Result<()> {
22497            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
22498            // Delegate to tuple encoding.
22499            fidl::encoding::Encode::<
22500                AudioRendererBindGainControlRequest,
22501                fidl::encoding::DefaultFuchsiaResourceDialect,
22502            >::encode(
22503                (<fidl::encoding::Endpoint<
22504                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22505                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22506                    &mut self.gain_control_request,
22507                ),),
22508                encoder,
22509                offset,
22510                _depth,
22511            )
22512        }
22513    }
22514    unsafe impl<
22515        T0: fidl::encoding::Encode<
22516                fidl::encoding::Endpoint<
22517                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22518                >,
22519                fidl::encoding::DefaultFuchsiaResourceDialect,
22520            >,
22521    >
22522        fidl::encoding::Encode<
22523            AudioRendererBindGainControlRequest,
22524            fidl::encoding::DefaultFuchsiaResourceDialect,
22525        > for (T0,)
22526    {
22527        #[inline]
22528        unsafe fn encode(
22529            self,
22530            encoder: &mut fidl::encoding::Encoder<
22531                '_,
22532                fidl::encoding::DefaultFuchsiaResourceDialect,
22533            >,
22534            offset: usize,
22535            depth: fidl::encoding::Depth,
22536        ) -> fidl::Result<()> {
22537            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
22538            // Zero out padding regions. There's no need to apply masks
22539            // because the unmasked parts will be overwritten by fields.
22540            // Write the fields.
22541            self.0.encode(encoder, offset + 0, depth)?;
22542            Ok(())
22543        }
22544    }
22545
22546    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22547        for AudioRendererBindGainControlRequest
22548    {
22549        #[inline(always)]
22550        fn new_empty() -> Self {
22551            Self {
22552                gain_control_request: fidl::new_empty!(
22553                    fidl::encoding::Endpoint<
22554                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22555                    >,
22556                    fidl::encoding::DefaultFuchsiaResourceDialect
22557                ),
22558            }
22559        }
22560
22561        #[inline]
22562        unsafe fn decode(
22563            &mut self,
22564            decoder: &mut fidl::encoding::Decoder<
22565                '_,
22566                fidl::encoding::DefaultFuchsiaResourceDialect,
22567            >,
22568            offset: usize,
22569            _depth: fidl::encoding::Depth,
22570        ) -> fidl::Result<()> {
22571            decoder.debug_check_bounds::<Self>(offset);
22572            // Verify that padding bytes are zero.
22573            fidl::decode!(
22574                fidl::encoding::Endpoint<
22575                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22576                >,
22577                fidl::encoding::DefaultFuchsiaResourceDialect,
22578                &mut self.gain_control_request,
22579                decoder,
22580                offset + 0,
22581                _depth
22582            )?;
22583            Ok(())
22584        }
22585    }
22586
22587    impl fidl::encoding::ResourceTypeMarker for AudioRendererGetReferenceClockResponse {
22588        type Borrowed<'a> = &'a mut Self;
22589        fn take_or_borrow<'a>(
22590            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22591        ) -> Self::Borrowed<'a> {
22592            value
22593        }
22594    }
22595
22596    unsafe impl fidl::encoding::TypeMarker for AudioRendererGetReferenceClockResponse {
22597        type Owned = Self;
22598
22599        #[inline(always)]
22600        fn inline_align(_context: fidl::encoding::Context) -> usize {
22601            4
22602        }
22603
22604        #[inline(always)]
22605        fn inline_size(_context: fidl::encoding::Context) -> usize {
22606            4
22607        }
22608    }
22609
22610    unsafe impl
22611        fidl::encoding::Encode<
22612            AudioRendererGetReferenceClockResponse,
22613            fidl::encoding::DefaultFuchsiaResourceDialect,
22614        > for &mut AudioRendererGetReferenceClockResponse
22615    {
22616        #[inline]
22617        unsafe fn encode(
22618            self,
22619            encoder: &mut fidl::encoding::Encoder<
22620                '_,
22621                fidl::encoding::DefaultFuchsiaResourceDialect,
22622            >,
22623            offset: usize,
22624            _depth: fidl::encoding::Depth,
22625        ) -> fidl::Result<()> {
22626            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
22627            // Delegate to tuple encoding.
22628            fidl::encoding::Encode::<
22629                AudioRendererGetReferenceClockResponse,
22630                fidl::encoding::DefaultFuchsiaResourceDialect,
22631            >::encode(
22632                (<fidl::encoding::HandleType<
22633                    fidl::Clock,
22634                    { fidl::ObjectType::CLOCK.into_raw() },
22635                    2147483648,
22636                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22637                    &mut self.reference_clock,
22638                ),),
22639                encoder,
22640                offset,
22641                _depth,
22642            )
22643        }
22644    }
22645    unsafe impl<
22646        T0: fidl::encoding::Encode<
22647                fidl::encoding::HandleType<
22648                    fidl::Clock,
22649                    { fidl::ObjectType::CLOCK.into_raw() },
22650                    2147483648,
22651                >,
22652                fidl::encoding::DefaultFuchsiaResourceDialect,
22653            >,
22654    >
22655        fidl::encoding::Encode<
22656            AudioRendererGetReferenceClockResponse,
22657            fidl::encoding::DefaultFuchsiaResourceDialect,
22658        > for (T0,)
22659    {
22660        #[inline]
22661        unsafe fn encode(
22662            self,
22663            encoder: &mut fidl::encoding::Encoder<
22664                '_,
22665                fidl::encoding::DefaultFuchsiaResourceDialect,
22666            >,
22667            offset: usize,
22668            depth: fidl::encoding::Depth,
22669        ) -> fidl::Result<()> {
22670            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
22671            // Zero out padding regions. There's no need to apply masks
22672            // because the unmasked parts will be overwritten by fields.
22673            // Write the fields.
22674            self.0.encode(encoder, offset + 0, depth)?;
22675            Ok(())
22676        }
22677    }
22678
22679    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22680        for AudioRendererGetReferenceClockResponse
22681    {
22682        #[inline(always)]
22683        fn new_empty() -> Self {
22684            Self {
22685                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
22686            }
22687        }
22688
22689        #[inline]
22690        unsafe fn decode(
22691            &mut self,
22692            decoder: &mut fidl::encoding::Decoder<
22693                '_,
22694                fidl::encoding::DefaultFuchsiaResourceDialect,
22695            >,
22696            offset: usize,
22697            _depth: fidl::encoding::Depth,
22698        ) -> fidl::Result<()> {
22699            decoder.debug_check_bounds::<Self>(offset);
22700            // Verify that padding bytes are zero.
22701            fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
22702            Ok(())
22703        }
22704    }
22705
22706    impl fidl::encoding::ResourceTypeMarker for AudioRendererSetReferenceClockRequest {
22707        type Borrowed<'a> = &'a mut Self;
22708        fn take_or_borrow<'a>(
22709            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22710        ) -> Self::Borrowed<'a> {
22711            value
22712        }
22713    }
22714
22715    unsafe impl fidl::encoding::TypeMarker for AudioRendererSetReferenceClockRequest {
22716        type Owned = Self;
22717
22718        #[inline(always)]
22719        fn inline_align(_context: fidl::encoding::Context) -> usize {
22720            4
22721        }
22722
22723        #[inline(always)]
22724        fn inline_size(_context: fidl::encoding::Context) -> usize {
22725            4
22726        }
22727    }
22728
22729    unsafe impl
22730        fidl::encoding::Encode<
22731            AudioRendererSetReferenceClockRequest,
22732            fidl::encoding::DefaultFuchsiaResourceDialect,
22733        > for &mut AudioRendererSetReferenceClockRequest
22734    {
22735        #[inline]
22736        unsafe fn encode(
22737            self,
22738            encoder: &mut fidl::encoding::Encoder<
22739                '_,
22740                fidl::encoding::DefaultFuchsiaResourceDialect,
22741            >,
22742            offset: usize,
22743            _depth: fidl::encoding::Depth,
22744        ) -> fidl::Result<()> {
22745            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
22746            // Delegate to tuple encoding.
22747            fidl::encoding::Encode::<
22748                AudioRendererSetReferenceClockRequest,
22749                fidl::encoding::DefaultFuchsiaResourceDialect,
22750            >::encode(
22751                (<fidl::encoding::Optional<
22752                    fidl::encoding::HandleType<
22753                        fidl::Clock,
22754                        { fidl::ObjectType::CLOCK.into_raw() },
22755                        2147483648,
22756                    >,
22757                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22758                    &mut self.reference_clock,
22759                ),),
22760                encoder,
22761                offset,
22762                _depth,
22763            )
22764        }
22765    }
22766    unsafe impl<
22767        T0: fidl::encoding::Encode<
22768                fidl::encoding::Optional<
22769                    fidl::encoding::HandleType<
22770                        fidl::Clock,
22771                        { fidl::ObjectType::CLOCK.into_raw() },
22772                        2147483648,
22773                    >,
22774                >,
22775                fidl::encoding::DefaultFuchsiaResourceDialect,
22776            >,
22777    >
22778        fidl::encoding::Encode<
22779            AudioRendererSetReferenceClockRequest,
22780            fidl::encoding::DefaultFuchsiaResourceDialect,
22781        > for (T0,)
22782    {
22783        #[inline]
22784        unsafe fn encode(
22785            self,
22786            encoder: &mut fidl::encoding::Encoder<
22787                '_,
22788                fidl::encoding::DefaultFuchsiaResourceDialect,
22789            >,
22790            offset: usize,
22791            depth: fidl::encoding::Depth,
22792        ) -> fidl::Result<()> {
22793            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
22794            // Zero out padding regions. There's no need to apply masks
22795            // because the unmasked parts will be overwritten by fields.
22796            // Write the fields.
22797            self.0.encode(encoder, offset + 0, depth)?;
22798            Ok(())
22799        }
22800    }
22801
22802    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22803        for AudioRendererSetReferenceClockRequest
22804    {
22805        #[inline(always)]
22806        fn new_empty() -> Self {
22807            Self {
22808                reference_clock: fidl::new_empty!(
22809                    fidl::encoding::Optional<
22810                        fidl::encoding::HandleType<
22811                            fidl::Clock,
22812                            { fidl::ObjectType::CLOCK.into_raw() },
22813                            2147483648,
22814                        >,
22815                    >,
22816                    fidl::encoding::DefaultFuchsiaResourceDialect
22817                ),
22818            }
22819        }
22820
22821        #[inline]
22822        unsafe fn decode(
22823            &mut self,
22824            decoder: &mut fidl::encoding::Decoder<
22825                '_,
22826                fidl::encoding::DefaultFuchsiaResourceDialect,
22827            >,
22828            offset: usize,
22829            _depth: fidl::encoding::Depth,
22830        ) -> fidl::Result<()> {
22831            decoder.debug_check_bounds::<Self>(offset);
22832            // Verify that padding bytes are zero.
22833            fidl::decode!(
22834                fidl::encoding::Optional<
22835                    fidl::encoding::HandleType<
22836                        fidl::Clock,
22837                        { fidl::ObjectType::CLOCK.into_raw() },
22838                        2147483648,
22839                    >,
22840                >,
22841                fidl::encoding::DefaultFuchsiaResourceDialect,
22842                &mut self.reference_clock,
22843                decoder,
22844                offset + 0,
22845                _depth
22846            )?;
22847            Ok(())
22848        }
22849    }
22850
22851    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
22852        type Borrowed<'a> = &'a mut Self;
22853        fn take_or_borrow<'a>(
22854            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22855        ) -> Self::Borrowed<'a> {
22856            value
22857        }
22858    }
22859
22860    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
22861        type Owned = Self;
22862
22863        #[inline(always)]
22864        fn inline_align(_context: fidl::encoding::Context) -> usize {
22865            8
22866        }
22867
22868        #[inline(always)]
22869        fn inline_size(_context: fidl::encoding::Context) -> usize {
22870            40
22871        }
22872    }
22873
22874    unsafe impl
22875        fidl::encoding::Encode<
22876            ProfileProviderRegisterHandlerWithCapacityRequest,
22877            fidl::encoding::DefaultFuchsiaResourceDialect,
22878        > for &mut ProfileProviderRegisterHandlerWithCapacityRequest
22879    {
22880        #[inline]
22881        unsafe fn encode(
22882            self,
22883            encoder: &mut fidl::encoding::Encoder<
22884                '_,
22885                fidl::encoding::DefaultFuchsiaResourceDialect,
22886            >,
22887            offset: usize,
22888            _depth: fidl::encoding::Depth,
22889        ) -> fidl::Result<()> {
22890            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
22891            // Delegate to tuple encoding.
22892            fidl::encoding::Encode::<
22893                ProfileProviderRegisterHandlerWithCapacityRequest,
22894                fidl::encoding::DefaultFuchsiaResourceDialect,
22895            >::encode(
22896                (
22897                    <fidl::encoding::HandleType<
22898                        fidl::Thread,
22899                        { fidl::ObjectType::THREAD.into_raw() },
22900                        2147483648,
22901                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22902                        &mut self.thread_handle,
22903                    ),
22904                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
22905                        &self.name,
22906                    ),
22907                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.period),
22908                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.capacity),
22909                ),
22910                encoder,
22911                offset,
22912                _depth,
22913            )
22914        }
22915    }
22916    unsafe impl<
22917        T0: fidl::encoding::Encode<
22918                fidl::encoding::HandleType<
22919                    fidl::Thread,
22920                    { fidl::ObjectType::THREAD.into_raw() },
22921                    2147483648,
22922                >,
22923                fidl::encoding::DefaultFuchsiaResourceDialect,
22924            >,
22925        T1: fidl::encoding::Encode<
22926                fidl::encoding::BoundedString<64>,
22927                fidl::encoding::DefaultFuchsiaResourceDialect,
22928            >,
22929        T2: fidl::encoding::Encode<i64, fidl::encoding::DefaultFuchsiaResourceDialect>,
22930        T3: fidl::encoding::Encode<f32, fidl::encoding::DefaultFuchsiaResourceDialect>,
22931    >
22932        fidl::encoding::Encode<
22933            ProfileProviderRegisterHandlerWithCapacityRequest,
22934            fidl::encoding::DefaultFuchsiaResourceDialect,
22935        > for (T0, T1, T2, T3)
22936    {
22937        #[inline]
22938        unsafe fn encode(
22939            self,
22940            encoder: &mut fidl::encoding::Encoder<
22941                '_,
22942                fidl::encoding::DefaultFuchsiaResourceDialect,
22943            >,
22944            offset: usize,
22945            depth: fidl::encoding::Depth,
22946        ) -> fidl::Result<()> {
22947            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
22948            // Zero out padding regions. There's no need to apply masks
22949            // because the unmasked parts will be overwritten by fields.
22950            unsafe {
22951                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
22952                (ptr as *mut u64).write_unaligned(0);
22953            }
22954            unsafe {
22955                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
22956                (ptr as *mut u64).write_unaligned(0);
22957            }
22958            // Write the fields.
22959            self.0.encode(encoder, offset + 0, depth)?;
22960            self.1.encode(encoder, offset + 8, depth)?;
22961            self.2.encode(encoder, offset + 24, depth)?;
22962            self.3.encode(encoder, offset + 32, depth)?;
22963            Ok(())
22964        }
22965    }
22966
22967    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22968        for ProfileProviderRegisterHandlerWithCapacityRequest
22969    {
22970        #[inline(always)]
22971        fn new_empty() -> Self {
22972            Self {
22973                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
22974                name: fidl::new_empty!(
22975                    fidl::encoding::BoundedString<64>,
22976                    fidl::encoding::DefaultFuchsiaResourceDialect
22977                ),
22978                period: fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect),
22979                capacity: fidl::new_empty!(f32, fidl::encoding::DefaultFuchsiaResourceDialect),
22980            }
22981        }
22982
22983        #[inline]
22984        unsafe fn decode(
22985            &mut self,
22986            decoder: &mut fidl::encoding::Decoder<
22987                '_,
22988                fidl::encoding::DefaultFuchsiaResourceDialect,
22989            >,
22990            offset: usize,
22991            _depth: fidl::encoding::Depth,
22992        ) -> fidl::Result<()> {
22993            decoder.debug_check_bounds::<Self>(offset);
22994            // Verify that padding bytes are zero.
22995            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
22996            let padval = unsafe { (ptr as *const u64).read_unaligned() };
22997            let mask = 0xffffffff00000000u64;
22998            let maskedval = padval & mask;
22999            if maskedval != 0 {
23000                return Err(fidl::Error::NonZeroPadding {
23001                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
23002                });
23003            }
23004            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
23005            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23006            let mask = 0xffffffff00000000u64;
23007            let maskedval = padval & mask;
23008            if maskedval != 0 {
23009                return Err(fidl::Error::NonZeroPadding {
23010                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
23011                });
23012            }
23013            fidl::decode!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
23014            fidl::decode!(
23015                fidl::encoding::BoundedString<64>,
23016                fidl::encoding::DefaultFuchsiaResourceDialect,
23017                &mut self.name,
23018                decoder,
23019                offset + 8,
23020                _depth
23021            )?;
23022            fidl::decode!(
23023                i64,
23024                fidl::encoding::DefaultFuchsiaResourceDialect,
23025                &mut self.period,
23026                decoder,
23027                offset + 24,
23028                _depth
23029            )?;
23030            fidl::decode!(
23031                f32,
23032                fidl::encoding::DefaultFuchsiaResourceDialect,
23033                &mut self.capacity,
23034                decoder,
23035                offset + 32,
23036                _depth
23037            )?;
23038            Ok(())
23039        }
23040    }
23041
23042    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterMemoryRangeRequest {
23043        type Borrowed<'a> = &'a mut Self;
23044        fn take_or_borrow<'a>(
23045            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23046        ) -> Self::Borrowed<'a> {
23047            value
23048        }
23049    }
23050
23051    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterMemoryRangeRequest {
23052        type Owned = Self;
23053
23054        #[inline(always)]
23055        fn inline_align(_context: fidl::encoding::Context) -> usize {
23056            8
23057        }
23058
23059        #[inline(always)]
23060        fn inline_size(_context: fidl::encoding::Context) -> usize {
23061            24
23062        }
23063    }
23064
23065    unsafe impl
23066        fidl::encoding::Encode<
23067            ProfileProviderRegisterMemoryRangeRequest,
23068            fidl::encoding::DefaultFuchsiaResourceDialect,
23069        > for &mut ProfileProviderRegisterMemoryRangeRequest
23070    {
23071        #[inline]
23072        unsafe fn encode(
23073            self,
23074            encoder: &mut fidl::encoding::Encoder<
23075                '_,
23076                fidl::encoding::DefaultFuchsiaResourceDialect,
23077            >,
23078            offset: usize,
23079            _depth: fidl::encoding::Depth,
23080        ) -> fidl::Result<()> {
23081            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
23082            // Delegate to tuple encoding.
23083            fidl::encoding::Encode::<
23084                ProfileProviderRegisterMemoryRangeRequest,
23085                fidl::encoding::DefaultFuchsiaResourceDialect,
23086            >::encode(
23087                (
23088                    <fidl::encoding::HandleType<
23089                        fidl::Vmar,
23090                        { fidl::ObjectType::VMAR.into_raw() },
23091                        2147483648,
23092                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23093                        &mut self.vmar_handle
23094                    ),
23095                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
23096                        &self.name,
23097                    ),
23098                ),
23099                encoder,
23100                offset,
23101                _depth,
23102            )
23103        }
23104    }
23105    unsafe impl<
23106        T0: fidl::encoding::Encode<
23107                fidl::encoding::HandleType<
23108                    fidl::Vmar,
23109                    { fidl::ObjectType::VMAR.into_raw() },
23110                    2147483648,
23111                >,
23112                fidl::encoding::DefaultFuchsiaResourceDialect,
23113            >,
23114        T1: fidl::encoding::Encode<
23115                fidl::encoding::BoundedString<64>,
23116                fidl::encoding::DefaultFuchsiaResourceDialect,
23117            >,
23118    >
23119        fidl::encoding::Encode<
23120            ProfileProviderRegisterMemoryRangeRequest,
23121            fidl::encoding::DefaultFuchsiaResourceDialect,
23122        > for (T0, T1)
23123    {
23124        #[inline]
23125        unsafe fn encode(
23126            self,
23127            encoder: &mut fidl::encoding::Encoder<
23128                '_,
23129                fidl::encoding::DefaultFuchsiaResourceDialect,
23130            >,
23131            offset: usize,
23132            depth: fidl::encoding::Depth,
23133        ) -> fidl::Result<()> {
23134            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
23135            // Zero out padding regions. There's no need to apply masks
23136            // because the unmasked parts will be overwritten by fields.
23137            unsafe {
23138                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
23139                (ptr as *mut u64).write_unaligned(0);
23140            }
23141            // Write the fields.
23142            self.0.encode(encoder, offset + 0, depth)?;
23143            self.1.encode(encoder, offset + 8, depth)?;
23144            Ok(())
23145        }
23146    }
23147
23148    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23149        for ProfileProviderRegisterMemoryRangeRequest
23150    {
23151        #[inline(always)]
23152        fn new_empty() -> Self {
23153            Self {
23154                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23155                name: fidl::new_empty!(
23156                    fidl::encoding::BoundedString<64>,
23157                    fidl::encoding::DefaultFuchsiaResourceDialect
23158                ),
23159            }
23160        }
23161
23162        #[inline]
23163        unsafe fn decode(
23164            &mut self,
23165            decoder: &mut fidl::encoding::Decoder<
23166                '_,
23167                fidl::encoding::DefaultFuchsiaResourceDialect,
23168            >,
23169            offset: usize,
23170            _depth: fidl::encoding::Depth,
23171        ) -> fidl::Result<()> {
23172            decoder.debug_check_bounds::<Self>(offset);
23173            // Verify that padding bytes are zero.
23174            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
23175            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23176            let mask = 0xffffffff00000000u64;
23177            let maskedval = padval & mask;
23178            if maskedval != 0 {
23179                return Err(fidl::Error::NonZeroPadding {
23180                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
23181                });
23182            }
23183            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
23184            fidl::decode!(
23185                fidl::encoding::BoundedString<64>,
23186                fidl::encoding::DefaultFuchsiaResourceDialect,
23187                &mut self.name,
23188                decoder,
23189                offset + 8,
23190                _depth
23191            )?;
23192            Ok(())
23193        }
23194    }
23195
23196    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterHandlerRequest {
23197        type Borrowed<'a> = &'a mut Self;
23198        fn take_or_borrow<'a>(
23199            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23200        ) -> Self::Borrowed<'a> {
23201            value
23202        }
23203    }
23204
23205    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterHandlerRequest {
23206        type Owned = Self;
23207
23208        #[inline(always)]
23209        fn inline_align(_context: fidl::encoding::Context) -> usize {
23210            8
23211        }
23212
23213        #[inline(always)]
23214        fn inline_size(_context: fidl::encoding::Context) -> usize {
23215            24
23216        }
23217    }
23218
23219    unsafe impl
23220        fidl::encoding::Encode<
23221            ProfileProviderUnregisterHandlerRequest,
23222            fidl::encoding::DefaultFuchsiaResourceDialect,
23223        > for &mut ProfileProviderUnregisterHandlerRequest
23224    {
23225        #[inline]
23226        unsafe fn encode(
23227            self,
23228            encoder: &mut fidl::encoding::Encoder<
23229                '_,
23230                fidl::encoding::DefaultFuchsiaResourceDialect,
23231            >,
23232            offset: usize,
23233            _depth: fidl::encoding::Depth,
23234        ) -> fidl::Result<()> {
23235            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
23236            // Delegate to tuple encoding.
23237            fidl::encoding::Encode::<
23238                ProfileProviderUnregisterHandlerRequest,
23239                fidl::encoding::DefaultFuchsiaResourceDialect,
23240            >::encode(
23241                (
23242                    <fidl::encoding::HandleType<
23243                        fidl::Thread,
23244                        { fidl::ObjectType::THREAD.into_raw() },
23245                        2147483648,
23246                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23247                        &mut self.thread_handle,
23248                    ),
23249                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
23250                        &self.name,
23251                    ),
23252                ),
23253                encoder,
23254                offset,
23255                _depth,
23256            )
23257        }
23258    }
23259    unsafe impl<
23260        T0: fidl::encoding::Encode<
23261                fidl::encoding::HandleType<
23262                    fidl::Thread,
23263                    { fidl::ObjectType::THREAD.into_raw() },
23264                    2147483648,
23265                >,
23266                fidl::encoding::DefaultFuchsiaResourceDialect,
23267            >,
23268        T1: fidl::encoding::Encode<
23269                fidl::encoding::BoundedString<64>,
23270                fidl::encoding::DefaultFuchsiaResourceDialect,
23271            >,
23272    >
23273        fidl::encoding::Encode<
23274            ProfileProviderUnregisterHandlerRequest,
23275            fidl::encoding::DefaultFuchsiaResourceDialect,
23276        > for (T0, T1)
23277    {
23278        #[inline]
23279        unsafe fn encode(
23280            self,
23281            encoder: &mut fidl::encoding::Encoder<
23282                '_,
23283                fidl::encoding::DefaultFuchsiaResourceDialect,
23284            >,
23285            offset: usize,
23286            depth: fidl::encoding::Depth,
23287        ) -> fidl::Result<()> {
23288            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
23289            // Zero out padding regions. There's no need to apply masks
23290            // because the unmasked parts will be overwritten by fields.
23291            unsafe {
23292                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
23293                (ptr as *mut u64).write_unaligned(0);
23294            }
23295            // Write the fields.
23296            self.0.encode(encoder, offset + 0, depth)?;
23297            self.1.encode(encoder, offset + 8, depth)?;
23298            Ok(())
23299        }
23300    }
23301
23302    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23303        for ProfileProviderUnregisterHandlerRequest
23304    {
23305        #[inline(always)]
23306        fn new_empty() -> Self {
23307            Self {
23308                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23309                name: fidl::new_empty!(
23310                    fidl::encoding::BoundedString<64>,
23311                    fidl::encoding::DefaultFuchsiaResourceDialect
23312                ),
23313            }
23314        }
23315
23316        #[inline]
23317        unsafe fn decode(
23318            &mut self,
23319            decoder: &mut fidl::encoding::Decoder<
23320                '_,
23321                fidl::encoding::DefaultFuchsiaResourceDialect,
23322            >,
23323            offset: usize,
23324            _depth: fidl::encoding::Depth,
23325        ) -> fidl::Result<()> {
23326            decoder.debug_check_bounds::<Self>(offset);
23327            // Verify that padding bytes are zero.
23328            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
23329            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23330            let mask = 0xffffffff00000000u64;
23331            let maskedval = padval & mask;
23332            if maskedval != 0 {
23333                return Err(fidl::Error::NonZeroPadding {
23334                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
23335                });
23336            }
23337            fidl::decode!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
23338            fidl::decode!(
23339                fidl::encoding::BoundedString<64>,
23340                fidl::encoding::DefaultFuchsiaResourceDialect,
23341                &mut self.name,
23342                decoder,
23343                offset + 8,
23344                _depth
23345            )?;
23346            Ok(())
23347        }
23348    }
23349
23350    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
23351        type Borrowed<'a> = &'a mut Self;
23352        fn take_or_borrow<'a>(
23353            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23354        ) -> Self::Borrowed<'a> {
23355            value
23356        }
23357    }
23358
23359    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
23360        type Owned = Self;
23361
23362        #[inline(always)]
23363        fn inline_align(_context: fidl::encoding::Context) -> usize {
23364            4
23365        }
23366
23367        #[inline(always)]
23368        fn inline_size(_context: fidl::encoding::Context) -> usize {
23369            4
23370        }
23371    }
23372
23373    unsafe impl
23374        fidl::encoding::Encode<
23375            ProfileProviderUnregisterMemoryRangeRequest,
23376            fidl::encoding::DefaultFuchsiaResourceDialect,
23377        > for &mut ProfileProviderUnregisterMemoryRangeRequest
23378    {
23379        #[inline]
23380        unsafe fn encode(
23381            self,
23382            encoder: &mut fidl::encoding::Encoder<
23383                '_,
23384                fidl::encoding::DefaultFuchsiaResourceDialect,
23385            >,
23386            offset: usize,
23387            _depth: fidl::encoding::Depth,
23388        ) -> fidl::Result<()> {
23389            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
23390            // Delegate to tuple encoding.
23391            fidl::encoding::Encode::<
23392                ProfileProviderUnregisterMemoryRangeRequest,
23393                fidl::encoding::DefaultFuchsiaResourceDialect,
23394            >::encode(
23395                (<fidl::encoding::HandleType<
23396                    fidl::Vmar,
23397                    { fidl::ObjectType::VMAR.into_raw() },
23398                    2147483648,
23399                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23400                    &mut self.vmar_handle
23401                ),),
23402                encoder,
23403                offset,
23404                _depth,
23405            )
23406        }
23407    }
23408    unsafe impl<
23409        T0: fidl::encoding::Encode<
23410                fidl::encoding::HandleType<
23411                    fidl::Vmar,
23412                    { fidl::ObjectType::VMAR.into_raw() },
23413                    2147483648,
23414                >,
23415                fidl::encoding::DefaultFuchsiaResourceDialect,
23416            >,
23417    >
23418        fidl::encoding::Encode<
23419            ProfileProviderUnregisterMemoryRangeRequest,
23420            fidl::encoding::DefaultFuchsiaResourceDialect,
23421        > for (T0,)
23422    {
23423        #[inline]
23424        unsafe fn encode(
23425            self,
23426            encoder: &mut fidl::encoding::Encoder<
23427                '_,
23428                fidl::encoding::DefaultFuchsiaResourceDialect,
23429            >,
23430            offset: usize,
23431            depth: fidl::encoding::Depth,
23432        ) -> fidl::Result<()> {
23433            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
23434            // Zero out padding regions. There's no need to apply masks
23435            // because the unmasked parts will be overwritten by fields.
23436            // Write the fields.
23437            self.0.encode(encoder, offset + 0, depth)?;
23438            Ok(())
23439        }
23440    }
23441
23442    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23443        for ProfileProviderUnregisterMemoryRangeRequest
23444    {
23445        #[inline(always)]
23446        fn new_empty() -> Self {
23447            Self {
23448                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23449            }
23450        }
23451
23452        #[inline]
23453        unsafe fn decode(
23454            &mut self,
23455            decoder: &mut fidl::encoding::Decoder<
23456                '_,
23457                fidl::encoding::DefaultFuchsiaResourceDialect,
23458            >,
23459            offset: usize,
23460            _depth: fidl::encoding::Depth,
23461        ) -> fidl::Result<()> {
23462            decoder.debug_check_bounds::<Self>(offset);
23463            // Verify that padding bytes are zero.
23464            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
23465            Ok(())
23466        }
23467    }
23468
23469    impl fidl::encoding::ResourceTypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
23470        type Borrowed<'a> = &'a mut Self;
23471        fn take_or_borrow<'a>(
23472            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23473        ) -> Self::Borrowed<'a> {
23474            value
23475        }
23476    }
23477
23478    unsafe impl fidl::encoding::TypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
23479        type Owned = Self;
23480
23481        #[inline(always)]
23482        fn inline_align(_context: fidl::encoding::Context) -> usize {
23483            8
23484        }
23485
23486        #[inline(always)]
23487        fn inline_size(_context: fidl::encoding::Context) -> usize {
23488            16
23489        }
23490    }
23491
23492    unsafe impl
23493        fidl::encoding::Encode<
23494            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
23495            fidl::encoding::DefaultFuchsiaResourceDialect,
23496        > for &mut SessionAudioConsumerFactoryCreateAudioConsumerRequest
23497    {
23498        #[inline]
23499        unsafe fn encode(
23500            self,
23501            encoder: &mut fidl::encoding::Encoder<
23502                '_,
23503                fidl::encoding::DefaultFuchsiaResourceDialect,
23504            >,
23505            offset: usize,
23506            _depth: fidl::encoding::Depth,
23507        ) -> fidl::Result<()> {
23508            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
23509                offset,
23510            );
23511            // Delegate to tuple encoding.
23512            fidl::encoding::Encode::<SessionAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23513                (
23514                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.session_id),
23515                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
23516                ),
23517                encoder, offset, _depth
23518            )
23519        }
23520    }
23521    unsafe impl<
23522        T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
23523        T1: fidl::encoding::Encode<
23524                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23525                fidl::encoding::DefaultFuchsiaResourceDialect,
23526            >,
23527    >
23528        fidl::encoding::Encode<
23529            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
23530            fidl::encoding::DefaultFuchsiaResourceDialect,
23531        > for (T0, T1)
23532    {
23533        #[inline]
23534        unsafe fn encode(
23535            self,
23536            encoder: &mut fidl::encoding::Encoder<
23537                '_,
23538                fidl::encoding::DefaultFuchsiaResourceDialect,
23539            >,
23540            offset: usize,
23541            depth: fidl::encoding::Depth,
23542        ) -> fidl::Result<()> {
23543            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
23544                offset,
23545            );
23546            // Zero out padding regions. There's no need to apply masks
23547            // because the unmasked parts will be overwritten by fields.
23548            unsafe {
23549                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
23550                (ptr as *mut u64).write_unaligned(0);
23551            }
23552            // Write the fields.
23553            self.0.encode(encoder, offset + 0, depth)?;
23554            self.1.encode(encoder, offset + 8, depth)?;
23555            Ok(())
23556        }
23557    }
23558
23559    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23560        for SessionAudioConsumerFactoryCreateAudioConsumerRequest
23561    {
23562        #[inline(always)]
23563        fn new_empty() -> Self {
23564            Self {
23565                session_id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
23566                audio_consumer_request: fidl::new_empty!(
23567                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23568                    fidl::encoding::DefaultFuchsiaResourceDialect
23569                ),
23570            }
23571        }
23572
23573        #[inline]
23574        unsafe fn decode(
23575            &mut self,
23576            decoder: &mut fidl::encoding::Decoder<
23577                '_,
23578                fidl::encoding::DefaultFuchsiaResourceDialect,
23579            >,
23580            offset: usize,
23581            _depth: fidl::encoding::Depth,
23582        ) -> fidl::Result<()> {
23583            decoder.debug_check_bounds::<Self>(offset);
23584            // Verify that padding bytes are zero.
23585            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
23586            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23587            let mask = 0xffffffff00000000u64;
23588            let maskedval = padval & mask;
23589            if maskedval != 0 {
23590                return Err(fidl::Error::NonZeroPadding {
23591                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
23592                });
23593            }
23594            fidl::decode!(
23595                u64,
23596                fidl::encoding::DefaultFuchsiaResourceDialect,
23597                &mut self.session_id,
23598                decoder,
23599                offset + 0,
23600                _depth
23601            )?;
23602            fidl::decode!(
23603                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23604                fidl::encoding::DefaultFuchsiaResourceDialect,
23605                &mut self.audio_consumer_request,
23606                decoder,
23607                offset + 8,
23608                _depth
23609            )?;
23610            Ok(())
23611        }
23612    }
23613
23614    impl fidl::encoding::ResourceTypeMarker for StreamBufferSetAddPayloadBufferRequest {
23615        type Borrowed<'a> = &'a mut Self;
23616        fn take_or_borrow<'a>(
23617            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23618        ) -> Self::Borrowed<'a> {
23619            value
23620        }
23621    }
23622
23623    unsafe impl fidl::encoding::TypeMarker for StreamBufferSetAddPayloadBufferRequest {
23624        type Owned = Self;
23625
23626        #[inline(always)]
23627        fn inline_align(_context: fidl::encoding::Context) -> usize {
23628            4
23629        }
23630
23631        #[inline(always)]
23632        fn inline_size(_context: fidl::encoding::Context) -> usize {
23633            8
23634        }
23635    }
23636
23637    unsafe impl
23638        fidl::encoding::Encode<
23639            StreamBufferSetAddPayloadBufferRequest,
23640            fidl::encoding::DefaultFuchsiaResourceDialect,
23641        > for &mut StreamBufferSetAddPayloadBufferRequest
23642    {
23643        #[inline]
23644        unsafe fn encode(
23645            self,
23646            encoder: &mut fidl::encoding::Encoder<
23647                '_,
23648                fidl::encoding::DefaultFuchsiaResourceDialect,
23649            >,
23650            offset: usize,
23651            _depth: fidl::encoding::Depth,
23652        ) -> fidl::Result<()> {
23653            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
23654            // Delegate to tuple encoding.
23655            fidl::encoding::Encode::<
23656                StreamBufferSetAddPayloadBufferRequest,
23657                fidl::encoding::DefaultFuchsiaResourceDialect,
23658            >::encode(
23659                (
23660                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
23661                    <fidl::encoding::HandleType<
23662                        fidl::Vmo,
23663                        { fidl::ObjectType::VMO.into_raw() },
23664                        2147483648,
23665                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23666                        &mut self.payload_buffer,
23667                    ),
23668                ),
23669                encoder,
23670                offset,
23671                _depth,
23672            )
23673        }
23674    }
23675    unsafe impl<
23676        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
23677        T1: fidl::encoding::Encode<
23678                fidl::encoding::HandleType<
23679                    fidl::Vmo,
23680                    { fidl::ObjectType::VMO.into_raw() },
23681                    2147483648,
23682                >,
23683                fidl::encoding::DefaultFuchsiaResourceDialect,
23684            >,
23685    >
23686        fidl::encoding::Encode<
23687            StreamBufferSetAddPayloadBufferRequest,
23688            fidl::encoding::DefaultFuchsiaResourceDialect,
23689        > for (T0, T1)
23690    {
23691        #[inline]
23692        unsafe fn encode(
23693            self,
23694            encoder: &mut fidl::encoding::Encoder<
23695                '_,
23696                fidl::encoding::DefaultFuchsiaResourceDialect,
23697            >,
23698            offset: usize,
23699            depth: fidl::encoding::Depth,
23700        ) -> fidl::Result<()> {
23701            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
23702            // Zero out padding regions. There's no need to apply masks
23703            // because the unmasked parts will be overwritten by fields.
23704            // Write the fields.
23705            self.0.encode(encoder, offset + 0, depth)?;
23706            self.1.encode(encoder, offset + 4, depth)?;
23707            Ok(())
23708        }
23709    }
23710
23711    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23712        for StreamBufferSetAddPayloadBufferRequest
23713    {
23714        #[inline(always)]
23715        fn new_empty() -> Self {
23716            Self {
23717                id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
23718                payload_buffer: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23719            }
23720        }
23721
23722        #[inline]
23723        unsafe fn decode(
23724            &mut self,
23725            decoder: &mut fidl::encoding::Decoder<
23726                '_,
23727                fidl::encoding::DefaultFuchsiaResourceDialect,
23728            >,
23729            offset: usize,
23730            _depth: fidl::encoding::Depth,
23731        ) -> fidl::Result<()> {
23732            decoder.debug_check_bounds::<Self>(offset);
23733            // Verify that padding bytes are zero.
23734            fidl::decode!(
23735                u32,
23736                fidl::encoding::DefaultFuchsiaResourceDialect,
23737                &mut self.id,
23738                decoder,
23739                offset + 0,
23740                _depth
23741            )?;
23742            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.payload_buffer, decoder, offset + 4, _depth)?;
23743            Ok(())
23744        }
23745    }
23746
23747    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
23748        type Borrowed<'a> = &'a mut Self;
23749        fn take_or_borrow<'a>(
23750            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23751        ) -> Self::Borrowed<'a> {
23752            value
23753        }
23754    }
23755
23756    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
23757        type Owned = Self;
23758
23759        #[inline(always)]
23760        fn inline_align(_context: fidl::encoding::Context) -> usize {
23761            8
23762        }
23763
23764        #[inline(always)]
23765        fn inline_size(_context: fidl::encoding::Context) -> usize {
23766            16
23767        }
23768    }
23769
23770    unsafe impl
23771        fidl::encoding::Encode<
23772            StreamProcessorSetInputBufferPartialSettingsRequest,
23773            fidl::encoding::DefaultFuchsiaResourceDialect,
23774        > for &mut StreamProcessorSetInputBufferPartialSettingsRequest
23775    {
23776        #[inline]
23777        unsafe fn encode(
23778            self,
23779            encoder: &mut fidl::encoding::Encoder<
23780                '_,
23781                fidl::encoding::DefaultFuchsiaResourceDialect,
23782            >,
23783            offset: usize,
23784            _depth: fidl::encoding::Depth,
23785        ) -> fidl::Result<()> {
23786            encoder
23787                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
23788            // Delegate to tuple encoding.
23789            fidl::encoding::Encode::<StreamProcessorSetInputBufferPartialSettingsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23790                (
23791                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.input_settings),
23792                ),
23793                encoder, offset, _depth
23794            )
23795        }
23796    }
23797    unsafe impl<
23798        T0: fidl::encoding::Encode<
23799                StreamBufferPartialSettings,
23800                fidl::encoding::DefaultFuchsiaResourceDialect,
23801            >,
23802    >
23803        fidl::encoding::Encode<
23804            StreamProcessorSetInputBufferPartialSettingsRequest,
23805            fidl::encoding::DefaultFuchsiaResourceDialect,
23806        > for (T0,)
23807    {
23808        #[inline]
23809        unsafe fn encode(
23810            self,
23811            encoder: &mut fidl::encoding::Encoder<
23812                '_,
23813                fidl::encoding::DefaultFuchsiaResourceDialect,
23814            >,
23815            offset: usize,
23816            depth: fidl::encoding::Depth,
23817        ) -> fidl::Result<()> {
23818            encoder
23819                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
23820            // Zero out padding regions. There's no need to apply masks
23821            // because the unmasked parts will be overwritten by fields.
23822            // Write the fields.
23823            self.0.encode(encoder, offset + 0, depth)?;
23824            Ok(())
23825        }
23826    }
23827
23828    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23829        for StreamProcessorSetInputBufferPartialSettingsRequest
23830    {
23831        #[inline(always)]
23832        fn new_empty() -> Self {
23833            Self {
23834                input_settings: fidl::new_empty!(
23835                    StreamBufferPartialSettings,
23836                    fidl::encoding::DefaultFuchsiaResourceDialect
23837                ),
23838            }
23839        }
23840
23841        #[inline]
23842        unsafe fn decode(
23843            &mut self,
23844            decoder: &mut fidl::encoding::Decoder<
23845                '_,
23846                fidl::encoding::DefaultFuchsiaResourceDialect,
23847            >,
23848            offset: usize,
23849            _depth: fidl::encoding::Depth,
23850        ) -> fidl::Result<()> {
23851            decoder.debug_check_bounds::<Self>(offset);
23852            // Verify that padding bytes are zero.
23853            fidl::decode!(
23854                StreamBufferPartialSettings,
23855                fidl::encoding::DefaultFuchsiaResourceDialect,
23856                &mut self.input_settings,
23857                decoder,
23858                offset + 0,
23859                _depth
23860            )?;
23861            Ok(())
23862        }
23863    }
23864
23865    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
23866        type Borrowed<'a> = &'a mut Self;
23867        fn take_or_borrow<'a>(
23868            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23869        ) -> Self::Borrowed<'a> {
23870            value
23871        }
23872    }
23873
23874    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
23875        type Owned = Self;
23876
23877        #[inline(always)]
23878        fn inline_align(_context: fidl::encoding::Context) -> usize {
23879            8
23880        }
23881
23882        #[inline(always)]
23883        fn inline_size(_context: fidl::encoding::Context) -> usize {
23884            16
23885        }
23886    }
23887
23888    unsafe impl
23889        fidl::encoding::Encode<
23890            StreamProcessorSetOutputBufferPartialSettingsRequest,
23891            fidl::encoding::DefaultFuchsiaResourceDialect,
23892        > for &mut StreamProcessorSetOutputBufferPartialSettingsRequest
23893    {
23894        #[inline]
23895        unsafe fn encode(
23896            self,
23897            encoder: &mut fidl::encoding::Encoder<
23898                '_,
23899                fidl::encoding::DefaultFuchsiaResourceDialect,
23900            >,
23901            offset: usize,
23902            _depth: fidl::encoding::Depth,
23903        ) -> fidl::Result<()> {
23904            encoder
23905                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
23906            // Delegate to tuple encoding.
23907            fidl::encoding::Encode::<StreamProcessorSetOutputBufferPartialSettingsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23908                (
23909                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.output_settings),
23910                ),
23911                encoder, offset, _depth
23912            )
23913        }
23914    }
23915    unsafe impl<
23916        T0: fidl::encoding::Encode<
23917                StreamBufferPartialSettings,
23918                fidl::encoding::DefaultFuchsiaResourceDialect,
23919            >,
23920    >
23921        fidl::encoding::Encode<
23922            StreamProcessorSetOutputBufferPartialSettingsRequest,
23923            fidl::encoding::DefaultFuchsiaResourceDialect,
23924        > for (T0,)
23925    {
23926        #[inline]
23927        unsafe fn encode(
23928            self,
23929            encoder: &mut fidl::encoding::Encoder<
23930                '_,
23931                fidl::encoding::DefaultFuchsiaResourceDialect,
23932            >,
23933            offset: usize,
23934            depth: fidl::encoding::Depth,
23935        ) -> fidl::Result<()> {
23936            encoder
23937                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
23938            // Zero out padding regions. There's no need to apply masks
23939            // because the unmasked parts will be overwritten by fields.
23940            // Write the fields.
23941            self.0.encode(encoder, offset + 0, depth)?;
23942            Ok(())
23943        }
23944    }
23945
23946    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23947        for StreamProcessorSetOutputBufferPartialSettingsRequest
23948    {
23949        #[inline(always)]
23950        fn new_empty() -> Self {
23951            Self {
23952                output_settings: fidl::new_empty!(
23953                    StreamBufferPartialSettings,
23954                    fidl::encoding::DefaultFuchsiaResourceDialect
23955                ),
23956            }
23957        }
23958
23959        #[inline]
23960        unsafe fn decode(
23961            &mut self,
23962            decoder: &mut fidl::encoding::Decoder<
23963                '_,
23964                fidl::encoding::DefaultFuchsiaResourceDialect,
23965            >,
23966            offset: usize,
23967            _depth: fidl::encoding::Depth,
23968        ) -> fidl::Result<()> {
23969            decoder.debug_check_bounds::<Self>(offset);
23970            // Verify that padding bytes are zero.
23971            fidl::decode!(
23972                StreamBufferPartialSettings,
23973                fidl::encoding::DefaultFuchsiaResourceDialect,
23974                &mut self.output_settings,
23975                decoder,
23976                offset + 0,
23977                _depth
23978            )?;
23979            Ok(())
23980        }
23981    }
23982
23983    impl fidl::encoding::ResourceTypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
23984        type Borrowed<'a> = &'a mut Self;
23985        fn take_or_borrow<'a>(
23986            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23987        ) -> Self::Borrowed<'a> {
23988            value
23989        }
23990    }
23991
23992    unsafe impl fidl::encoding::TypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
23993        type Owned = Self;
23994
23995        #[inline(always)]
23996        fn inline_align(_context: fidl::encoding::Context) -> usize {
23997            4
23998        }
23999
24000        #[inline(always)]
24001        fn inline_size(_context: fidl::encoding::Context) -> usize {
24002            8
24003        }
24004    }
24005
24006    unsafe impl
24007        fidl::encoding::Encode<
24008            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
24009            fidl::encoding::DefaultFuchsiaResourceDialect,
24010        > for &mut Usage2AudioConsumerFactoryCreateAudioConsumerRequest
24011    {
24012        #[inline]
24013        unsafe fn encode(
24014            self,
24015            encoder: &mut fidl::encoding::Encoder<
24016                '_,
24017                fidl::encoding::DefaultFuchsiaResourceDialect,
24018            >,
24019            offset: usize,
24020            _depth: fidl::encoding::Depth,
24021        ) -> fidl::Result<()> {
24022            encoder
24023                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
24024            // Delegate to tuple encoding.
24025            fidl::encoding::Encode::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24026                (
24027                    <AudioRenderUsage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24028                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
24029                ),
24030                encoder, offset, _depth
24031            )
24032        }
24033    }
24034    unsafe impl<
24035        T0: fidl::encoding::Encode<AudioRenderUsage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
24036        T1: fidl::encoding::Encode<
24037                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24038                fidl::encoding::DefaultFuchsiaResourceDialect,
24039            >,
24040    >
24041        fidl::encoding::Encode<
24042            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
24043            fidl::encoding::DefaultFuchsiaResourceDialect,
24044        > for (T0, T1)
24045    {
24046        #[inline]
24047        unsafe fn encode(
24048            self,
24049            encoder: &mut fidl::encoding::Encoder<
24050                '_,
24051                fidl::encoding::DefaultFuchsiaResourceDialect,
24052            >,
24053            offset: usize,
24054            depth: fidl::encoding::Depth,
24055        ) -> fidl::Result<()> {
24056            encoder
24057                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
24058            // Zero out padding regions. There's no need to apply masks
24059            // because the unmasked parts will be overwritten by fields.
24060            // Write the fields.
24061            self.0.encode(encoder, offset + 0, depth)?;
24062            self.1.encode(encoder, offset + 4, depth)?;
24063            Ok(())
24064        }
24065    }
24066
24067    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24068        for Usage2AudioConsumerFactoryCreateAudioConsumerRequest
24069    {
24070        #[inline(always)]
24071        fn new_empty() -> Self {
24072            Self {
24073                usage: fidl::new_empty!(
24074                    AudioRenderUsage2,
24075                    fidl::encoding::DefaultFuchsiaResourceDialect
24076                ),
24077                audio_consumer_request: fidl::new_empty!(
24078                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24079                    fidl::encoding::DefaultFuchsiaResourceDialect
24080                ),
24081            }
24082        }
24083
24084        #[inline]
24085        unsafe fn decode(
24086            &mut self,
24087            decoder: &mut fidl::encoding::Decoder<
24088                '_,
24089                fidl::encoding::DefaultFuchsiaResourceDialect,
24090            >,
24091            offset: usize,
24092            _depth: fidl::encoding::Depth,
24093        ) -> fidl::Result<()> {
24094            decoder.debug_check_bounds::<Self>(offset);
24095            // Verify that padding bytes are zero.
24096            fidl::decode!(
24097                AudioRenderUsage2,
24098                fidl::encoding::DefaultFuchsiaResourceDialect,
24099                &mut self.usage,
24100                decoder,
24101                offset + 0,
24102                _depth
24103            )?;
24104            fidl::decode!(
24105                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24106                fidl::encoding::DefaultFuchsiaResourceDialect,
24107                &mut self.audio_consumer_request,
24108                decoder,
24109                offset + 4,
24110                _depth
24111            )?;
24112            Ok(())
24113        }
24114    }
24115
24116    impl fidl::encoding::ResourceTypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
24117        type Borrowed<'a> = &'a mut Self;
24118        fn take_or_borrow<'a>(
24119            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24120        ) -> Self::Borrowed<'a> {
24121            value
24122        }
24123    }
24124
24125    unsafe impl fidl::encoding::TypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
24126        type Owned = Self;
24127
24128        #[inline(always)]
24129        fn inline_align(_context: fidl::encoding::Context) -> usize {
24130            4
24131        }
24132
24133        #[inline(always)]
24134        fn inline_size(_context: fidl::encoding::Context) -> usize {
24135            8
24136        }
24137    }
24138
24139    unsafe impl
24140        fidl::encoding::Encode<
24141            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
24142            fidl::encoding::DefaultFuchsiaResourceDialect,
24143        > for &mut UsageAudioConsumerFactoryCreateAudioConsumerRequest
24144    {
24145        #[inline]
24146        unsafe fn encode(
24147            self,
24148            encoder: &mut fidl::encoding::Encoder<
24149                '_,
24150                fidl::encoding::DefaultFuchsiaResourceDialect,
24151            >,
24152            offset: usize,
24153            _depth: fidl::encoding::Depth,
24154        ) -> fidl::Result<()> {
24155            encoder
24156                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
24157            // Delegate to tuple encoding.
24158            fidl::encoding::Encode::<UsageAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24159                (
24160                    <AudioRenderUsage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24161                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
24162                ),
24163                encoder, offset, _depth
24164            )
24165        }
24166    }
24167    unsafe impl<
24168        T0: fidl::encoding::Encode<AudioRenderUsage, fidl::encoding::DefaultFuchsiaResourceDialect>,
24169        T1: fidl::encoding::Encode<
24170                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24171                fidl::encoding::DefaultFuchsiaResourceDialect,
24172            >,
24173    >
24174        fidl::encoding::Encode<
24175            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
24176            fidl::encoding::DefaultFuchsiaResourceDialect,
24177        > for (T0, T1)
24178    {
24179        #[inline]
24180        unsafe fn encode(
24181            self,
24182            encoder: &mut fidl::encoding::Encoder<
24183                '_,
24184                fidl::encoding::DefaultFuchsiaResourceDialect,
24185            >,
24186            offset: usize,
24187            depth: fidl::encoding::Depth,
24188        ) -> fidl::Result<()> {
24189            encoder
24190                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
24191            // Zero out padding regions. There's no need to apply masks
24192            // because the unmasked parts will be overwritten by fields.
24193            // Write the fields.
24194            self.0.encode(encoder, offset + 0, depth)?;
24195            self.1.encode(encoder, offset + 4, depth)?;
24196            Ok(())
24197        }
24198    }
24199
24200    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24201        for UsageAudioConsumerFactoryCreateAudioConsumerRequest
24202    {
24203        #[inline(always)]
24204        fn new_empty() -> Self {
24205            Self {
24206                usage: fidl::new_empty!(
24207                    AudioRenderUsage,
24208                    fidl::encoding::DefaultFuchsiaResourceDialect
24209                ),
24210                audio_consumer_request: fidl::new_empty!(
24211                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24212                    fidl::encoding::DefaultFuchsiaResourceDialect
24213                ),
24214            }
24215        }
24216
24217        #[inline]
24218        unsafe fn decode(
24219            &mut self,
24220            decoder: &mut fidl::encoding::Decoder<
24221                '_,
24222                fidl::encoding::DefaultFuchsiaResourceDialect,
24223            >,
24224            offset: usize,
24225            _depth: fidl::encoding::Depth,
24226        ) -> fidl::Result<()> {
24227            decoder.debug_check_bounds::<Self>(offset);
24228            // Verify that padding bytes are zero.
24229            fidl::decode!(
24230                AudioRenderUsage,
24231                fidl::encoding::DefaultFuchsiaResourceDialect,
24232                &mut self.usage,
24233                decoder,
24234                offset + 0,
24235                _depth
24236            )?;
24237            fidl::decode!(
24238                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24239                fidl::encoding::DefaultFuchsiaResourceDialect,
24240                &mut self.audio_consumer_request,
24241                decoder,
24242                offset + 4,
24243                _depth
24244            )?;
24245            Ok(())
24246        }
24247    }
24248
24249    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListener2Request {
24250        type Borrowed<'a> = &'a mut Self;
24251        fn take_or_borrow<'a>(
24252            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24253        ) -> Self::Borrowed<'a> {
24254            value
24255        }
24256    }
24257
24258    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListener2Request {
24259        type Owned = Self;
24260
24261        #[inline(always)]
24262        fn inline_align(_context: fidl::encoding::Context) -> usize {
24263            8
24264        }
24265
24266        #[inline(always)]
24267        fn inline_size(_context: fidl::encoding::Context) -> usize {
24268            40
24269        }
24270    }
24271
24272    unsafe impl
24273        fidl::encoding::Encode<
24274            UsageGainReporterRegisterListener2Request,
24275            fidl::encoding::DefaultFuchsiaResourceDialect,
24276        > for &mut UsageGainReporterRegisterListener2Request
24277    {
24278        #[inline]
24279        unsafe fn encode(
24280            self,
24281            encoder: &mut fidl::encoding::Encoder<
24282                '_,
24283                fidl::encoding::DefaultFuchsiaResourceDialect,
24284            >,
24285            offset: usize,
24286            _depth: fidl::encoding::Depth,
24287        ) -> fidl::Result<()> {
24288            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
24289            // Delegate to tuple encoding.
24290            fidl::encoding::Encode::<UsageGainReporterRegisterListener2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24291                (
24292                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(&self.device_unique_id),
24293                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24294                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_gain_listener),
24295                ),
24296                encoder, offset, _depth
24297            )
24298        }
24299    }
24300    unsafe impl<
24301        T0: fidl::encoding::Encode<
24302                fidl::encoding::BoundedString<36>,
24303                fidl::encoding::DefaultFuchsiaResourceDialect,
24304            >,
24305        T1: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
24306        T2: fidl::encoding::Encode<
24307                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24308                fidl::encoding::DefaultFuchsiaResourceDialect,
24309            >,
24310    >
24311        fidl::encoding::Encode<
24312            UsageGainReporterRegisterListener2Request,
24313            fidl::encoding::DefaultFuchsiaResourceDialect,
24314        > for (T0, T1, T2)
24315    {
24316        #[inline]
24317        unsafe fn encode(
24318            self,
24319            encoder: &mut fidl::encoding::Encoder<
24320                '_,
24321                fidl::encoding::DefaultFuchsiaResourceDialect,
24322            >,
24323            offset: usize,
24324            depth: fidl::encoding::Depth,
24325        ) -> fidl::Result<()> {
24326            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
24327            // Zero out padding regions. There's no need to apply masks
24328            // because the unmasked parts will be overwritten by fields.
24329            unsafe {
24330                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
24331                (ptr as *mut u64).write_unaligned(0);
24332            }
24333            // Write the fields.
24334            self.0.encode(encoder, offset + 0, depth)?;
24335            self.1.encode(encoder, offset + 16, depth)?;
24336            self.2.encode(encoder, offset + 32, depth)?;
24337            Ok(())
24338        }
24339    }
24340
24341    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24342        for UsageGainReporterRegisterListener2Request
24343    {
24344        #[inline(always)]
24345        fn new_empty() -> Self {
24346            Self {
24347                device_unique_id: fidl::new_empty!(
24348                    fidl::encoding::BoundedString<36>,
24349                    fidl::encoding::DefaultFuchsiaResourceDialect
24350                ),
24351                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
24352                usage_gain_listener: fidl::new_empty!(
24353                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24354                    fidl::encoding::DefaultFuchsiaResourceDialect
24355                ),
24356            }
24357        }
24358
24359        #[inline]
24360        unsafe fn decode(
24361            &mut self,
24362            decoder: &mut fidl::encoding::Decoder<
24363                '_,
24364                fidl::encoding::DefaultFuchsiaResourceDialect,
24365            >,
24366            offset: usize,
24367            _depth: fidl::encoding::Depth,
24368        ) -> fidl::Result<()> {
24369            decoder.debug_check_bounds::<Self>(offset);
24370            // Verify that padding bytes are zero.
24371            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
24372            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24373            let mask = 0xffffffff00000000u64;
24374            let maskedval = padval & mask;
24375            if maskedval != 0 {
24376                return Err(fidl::Error::NonZeroPadding {
24377                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
24378                });
24379            }
24380            fidl::decode!(
24381                fidl::encoding::BoundedString<36>,
24382                fidl::encoding::DefaultFuchsiaResourceDialect,
24383                &mut self.device_unique_id,
24384                decoder,
24385                offset + 0,
24386                _depth
24387            )?;
24388            fidl::decode!(
24389                Usage2,
24390                fidl::encoding::DefaultFuchsiaResourceDialect,
24391                &mut self.usage,
24392                decoder,
24393                offset + 16,
24394                _depth
24395            )?;
24396            fidl::decode!(
24397                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24398                fidl::encoding::DefaultFuchsiaResourceDialect,
24399                &mut self.usage_gain_listener,
24400                decoder,
24401                offset + 32,
24402                _depth
24403            )?;
24404            Ok(())
24405        }
24406    }
24407
24408    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListenerRequest {
24409        type Borrowed<'a> = &'a mut Self;
24410        fn take_or_borrow<'a>(
24411            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24412        ) -> Self::Borrowed<'a> {
24413            value
24414        }
24415    }
24416
24417    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListenerRequest {
24418        type Owned = Self;
24419
24420        #[inline(always)]
24421        fn inline_align(_context: fidl::encoding::Context) -> usize {
24422            8
24423        }
24424
24425        #[inline(always)]
24426        fn inline_size(_context: fidl::encoding::Context) -> usize {
24427            40
24428        }
24429    }
24430
24431    unsafe impl
24432        fidl::encoding::Encode<
24433            UsageGainReporterRegisterListenerRequest,
24434            fidl::encoding::DefaultFuchsiaResourceDialect,
24435        > for &mut UsageGainReporterRegisterListenerRequest
24436    {
24437        #[inline]
24438        unsafe fn encode(
24439            self,
24440            encoder: &mut fidl::encoding::Encoder<
24441                '_,
24442                fidl::encoding::DefaultFuchsiaResourceDialect,
24443            >,
24444            offset: usize,
24445            _depth: fidl::encoding::Depth,
24446        ) -> fidl::Result<()> {
24447            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
24448            // Delegate to tuple encoding.
24449            fidl::encoding::Encode::<UsageGainReporterRegisterListenerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24450                (
24451                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(&self.device_unique_id),
24452                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24453                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_gain_listener),
24454                ),
24455                encoder, offset, _depth
24456            )
24457        }
24458    }
24459    unsafe impl<
24460        T0: fidl::encoding::Encode<
24461                fidl::encoding::BoundedString<36>,
24462                fidl::encoding::DefaultFuchsiaResourceDialect,
24463            >,
24464        T1: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
24465        T2: fidl::encoding::Encode<
24466                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24467                fidl::encoding::DefaultFuchsiaResourceDialect,
24468            >,
24469    >
24470        fidl::encoding::Encode<
24471            UsageGainReporterRegisterListenerRequest,
24472            fidl::encoding::DefaultFuchsiaResourceDialect,
24473        > for (T0, T1, T2)
24474    {
24475        #[inline]
24476        unsafe fn encode(
24477            self,
24478            encoder: &mut fidl::encoding::Encoder<
24479                '_,
24480                fidl::encoding::DefaultFuchsiaResourceDialect,
24481            >,
24482            offset: usize,
24483            depth: fidl::encoding::Depth,
24484        ) -> fidl::Result<()> {
24485            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
24486            // Zero out padding regions. There's no need to apply masks
24487            // because the unmasked parts will be overwritten by fields.
24488            unsafe {
24489                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
24490                (ptr as *mut u64).write_unaligned(0);
24491            }
24492            // Write the fields.
24493            self.0.encode(encoder, offset + 0, depth)?;
24494            self.1.encode(encoder, offset + 16, depth)?;
24495            self.2.encode(encoder, offset + 32, depth)?;
24496            Ok(())
24497        }
24498    }
24499
24500    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24501        for UsageGainReporterRegisterListenerRequest
24502    {
24503        #[inline(always)]
24504        fn new_empty() -> Self {
24505            Self {
24506                device_unique_id: fidl::new_empty!(
24507                    fidl::encoding::BoundedString<36>,
24508                    fidl::encoding::DefaultFuchsiaResourceDialect
24509                ),
24510                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
24511                usage_gain_listener: fidl::new_empty!(
24512                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24513                    fidl::encoding::DefaultFuchsiaResourceDialect
24514                ),
24515            }
24516        }
24517
24518        #[inline]
24519        unsafe fn decode(
24520            &mut self,
24521            decoder: &mut fidl::encoding::Decoder<
24522                '_,
24523                fidl::encoding::DefaultFuchsiaResourceDialect,
24524            >,
24525            offset: usize,
24526            _depth: fidl::encoding::Depth,
24527        ) -> fidl::Result<()> {
24528            decoder.debug_check_bounds::<Self>(offset);
24529            // Verify that padding bytes are zero.
24530            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
24531            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24532            let mask = 0xffffffff00000000u64;
24533            let maskedval = padval & mask;
24534            if maskedval != 0 {
24535                return Err(fidl::Error::NonZeroPadding {
24536                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
24537                });
24538            }
24539            fidl::decode!(
24540                fidl::encoding::BoundedString<36>,
24541                fidl::encoding::DefaultFuchsiaResourceDialect,
24542                &mut self.device_unique_id,
24543                decoder,
24544                offset + 0,
24545                _depth
24546            )?;
24547            fidl::decode!(
24548                Usage,
24549                fidl::encoding::DefaultFuchsiaResourceDialect,
24550                &mut self.usage,
24551                decoder,
24552                offset + 16,
24553                _depth
24554            )?;
24555            fidl::decode!(
24556                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24557                fidl::encoding::DefaultFuchsiaResourceDialect,
24558                &mut self.usage_gain_listener,
24559                decoder,
24560                offset + 32,
24561                _depth
24562            )?;
24563            Ok(())
24564        }
24565    }
24566
24567    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatch2Request {
24568        type Borrowed<'a> = &'a mut Self;
24569        fn take_or_borrow<'a>(
24570            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24571        ) -> Self::Borrowed<'a> {
24572            value
24573        }
24574    }
24575
24576    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatch2Request {
24577        type Owned = Self;
24578
24579        #[inline(always)]
24580        fn inline_align(_context: fidl::encoding::Context) -> usize {
24581            8
24582        }
24583
24584        #[inline(always)]
24585        fn inline_size(_context: fidl::encoding::Context) -> usize {
24586            24
24587        }
24588    }
24589
24590    unsafe impl
24591        fidl::encoding::Encode<
24592            UsageReporterWatch2Request,
24593            fidl::encoding::DefaultFuchsiaResourceDialect,
24594        > for &mut UsageReporterWatch2Request
24595    {
24596        #[inline]
24597        unsafe fn encode(
24598            self,
24599            encoder: &mut fidl::encoding::Encoder<
24600                '_,
24601                fidl::encoding::DefaultFuchsiaResourceDialect,
24602            >,
24603            offset: usize,
24604            _depth: fidl::encoding::Depth,
24605        ) -> fidl::Result<()> {
24606            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
24607            // Delegate to tuple encoding.
24608            fidl::encoding::Encode::<UsageReporterWatch2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24609                (
24610                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24611                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
24612                ),
24613                encoder, offset, _depth
24614            )
24615        }
24616    }
24617    unsafe impl<
24618        T0: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
24619        T1: fidl::encoding::Encode<
24620                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
24621                fidl::encoding::DefaultFuchsiaResourceDialect,
24622            >,
24623    >
24624        fidl::encoding::Encode<
24625            UsageReporterWatch2Request,
24626            fidl::encoding::DefaultFuchsiaResourceDialect,
24627        > for (T0, T1)
24628    {
24629        #[inline]
24630        unsafe fn encode(
24631            self,
24632            encoder: &mut fidl::encoding::Encoder<
24633                '_,
24634                fidl::encoding::DefaultFuchsiaResourceDialect,
24635            >,
24636            offset: usize,
24637            depth: fidl::encoding::Depth,
24638        ) -> fidl::Result<()> {
24639            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
24640            // Zero out padding regions. There's no need to apply masks
24641            // because the unmasked parts will be overwritten by fields.
24642            unsafe {
24643                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
24644                (ptr as *mut u64).write_unaligned(0);
24645            }
24646            // Write the fields.
24647            self.0.encode(encoder, offset + 0, depth)?;
24648            self.1.encode(encoder, offset + 16, depth)?;
24649            Ok(())
24650        }
24651    }
24652
24653    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24654        for UsageReporterWatch2Request
24655    {
24656        #[inline(always)]
24657        fn new_empty() -> Self {
24658            Self {
24659                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
24660                usage_watcher: fidl::new_empty!(
24661                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
24662                    fidl::encoding::DefaultFuchsiaResourceDialect
24663                ),
24664            }
24665        }
24666
24667        #[inline]
24668        unsafe fn decode(
24669            &mut self,
24670            decoder: &mut fidl::encoding::Decoder<
24671                '_,
24672                fidl::encoding::DefaultFuchsiaResourceDialect,
24673            >,
24674            offset: usize,
24675            _depth: fidl::encoding::Depth,
24676        ) -> fidl::Result<()> {
24677            decoder.debug_check_bounds::<Self>(offset);
24678            // Verify that padding bytes are zero.
24679            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
24680            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24681            let mask = 0xffffffff00000000u64;
24682            let maskedval = padval & mask;
24683            if maskedval != 0 {
24684                return Err(fidl::Error::NonZeroPadding {
24685                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
24686                });
24687            }
24688            fidl::decode!(
24689                Usage2,
24690                fidl::encoding::DefaultFuchsiaResourceDialect,
24691                &mut self.usage,
24692                decoder,
24693                offset + 0,
24694                _depth
24695            )?;
24696            fidl::decode!(
24697                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
24698                fidl::encoding::DefaultFuchsiaResourceDialect,
24699                &mut self.usage_watcher,
24700                decoder,
24701                offset + 16,
24702                _depth
24703            )?;
24704            Ok(())
24705        }
24706    }
24707
24708    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatchRequest {
24709        type Borrowed<'a> = &'a mut Self;
24710        fn take_or_borrow<'a>(
24711            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24712        ) -> Self::Borrowed<'a> {
24713            value
24714        }
24715    }
24716
24717    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatchRequest {
24718        type Owned = Self;
24719
24720        #[inline(always)]
24721        fn inline_align(_context: fidl::encoding::Context) -> usize {
24722            8
24723        }
24724
24725        #[inline(always)]
24726        fn inline_size(_context: fidl::encoding::Context) -> usize {
24727            24
24728        }
24729    }
24730
24731    unsafe impl
24732        fidl::encoding::Encode<
24733            UsageReporterWatchRequest,
24734            fidl::encoding::DefaultFuchsiaResourceDialect,
24735        > for &mut UsageReporterWatchRequest
24736    {
24737        #[inline]
24738        unsafe fn encode(
24739            self,
24740            encoder: &mut fidl::encoding::Encoder<
24741                '_,
24742                fidl::encoding::DefaultFuchsiaResourceDialect,
24743            >,
24744            offset: usize,
24745            _depth: fidl::encoding::Depth,
24746        ) -> fidl::Result<()> {
24747            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
24748            // Delegate to tuple encoding.
24749            fidl::encoding::Encode::<UsageReporterWatchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24750                (
24751                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24752                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
24753                ),
24754                encoder, offset, _depth
24755            )
24756        }
24757    }
24758    unsafe impl<
24759        T0: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
24760        T1: fidl::encoding::Encode<
24761                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
24762                fidl::encoding::DefaultFuchsiaResourceDialect,
24763            >,
24764    >
24765        fidl::encoding::Encode<
24766            UsageReporterWatchRequest,
24767            fidl::encoding::DefaultFuchsiaResourceDialect,
24768        > for (T0, T1)
24769    {
24770        #[inline]
24771        unsafe fn encode(
24772            self,
24773            encoder: &mut fidl::encoding::Encoder<
24774                '_,
24775                fidl::encoding::DefaultFuchsiaResourceDialect,
24776            >,
24777            offset: usize,
24778            depth: fidl::encoding::Depth,
24779        ) -> fidl::Result<()> {
24780            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
24781            // Zero out padding regions. There's no need to apply masks
24782            // because the unmasked parts will be overwritten by fields.
24783            unsafe {
24784                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
24785                (ptr as *mut u64).write_unaligned(0);
24786            }
24787            // Write the fields.
24788            self.0.encode(encoder, offset + 0, depth)?;
24789            self.1.encode(encoder, offset + 16, depth)?;
24790            Ok(())
24791        }
24792    }
24793
24794    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24795        for UsageReporterWatchRequest
24796    {
24797        #[inline(always)]
24798        fn new_empty() -> Self {
24799            Self {
24800                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
24801                usage_watcher: fidl::new_empty!(
24802                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
24803                    fidl::encoding::DefaultFuchsiaResourceDialect
24804                ),
24805            }
24806        }
24807
24808        #[inline]
24809        unsafe fn decode(
24810            &mut self,
24811            decoder: &mut fidl::encoding::Decoder<
24812                '_,
24813                fidl::encoding::DefaultFuchsiaResourceDialect,
24814            >,
24815            offset: usize,
24816            _depth: fidl::encoding::Depth,
24817        ) -> fidl::Result<()> {
24818            decoder.debug_check_bounds::<Self>(offset);
24819            // Verify that padding bytes are zero.
24820            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
24821            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24822            let mask = 0xffffffff00000000u64;
24823            let maskedval = padval & mask;
24824            if maskedval != 0 {
24825                return Err(fidl::Error::NonZeroPadding {
24826                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
24827                });
24828            }
24829            fidl::decode!(
24830                Usage,
24831                fidl::encoding::DefaultFuchsiaResourceDialect,
24832                &mut self.usage,
24833                decoder,
24834                offset + 0,
24835                _depth
24836            )?;
24837            fidl::decode!(
24838                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
24839                fidl::encoding::DefaultFuchsiaResourceDialect,
24840                &mut self.usage_watcher,
24841                decoder,
24842                offset + 16,
24843                _depth
24844            )?;
24845            Ok(())
24846        }
24847    }
24848
24849    impl StreamBufferPartialSettings {
24850        #[inline(always)]
24851        fn max_ordinal_present(&self) -> u64 {
24852            if let Some(_) = self.sysmem2_token {
24853                return 7;
24854            }
24855            if let Some(_) = self.sysmem_token {
24856                return 6;
24857            }
24858            if let Some(_) = self.packet_count_for_client {
24859                return 5;
24860            }
24861            if let Some(_) = self.packet_count_for_server {
24862                return 4;
24863            }
24864            if let Some(_) = self.single_buffer_mode {
24865                return 3;
24866            }
24867            if let Some(_) = self.buffer_constraints_version_ordinal {
24868                return 2;
24869            }
24870            if let Some(_) = self.buffer_lifetime_ordinal {
24871                return 1;
24872            }
24873            0
24874        }
24875    }
24876
24877    impl fidl::encoding::ResourceTypeMarker for StreamBufferPartialSettings {
24878        type Borrowed<'a> = &'a mut Self;
24879        fn take_or_borrow<'a>(
24880            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24881        ) -> Self::Borrowed<'a> {
24882            value
24883        }
24884    }
24885
24886    unsafe impl fidl::encoding::TypeMarker for StreamBufferPartialSettings {
24887        type Owned = Self;
24888
24889        #[inline(always)]
24890        fn inline_align(_context: fidl::encoding::Context) -> usize {
24891            8
24892        }
24893
24894        #[inline(always)]
24895        fn inline_size(_context: fidl::encoding::Context) -> usize {
24896            16
24897        }
24898    }
24899
24900    unsafe impl
24901        fidl::encoding::Encode<
24902            StreamBufferPartialSettings,
24903            fidl::encoding::DefaultFuchsiaResourceDialect,
24904        > for &mut StreamBufferPartialSettings
24905    {
24906        unsafe fn encode(
24907            self,
24908            encoder: &mut fidl::encoding::Encoder<
24909                '_,
24910                fidl::encoding::DefaultFuchsiaResourceDialect,
24911            >,
24912            offset: usize,
24913            mut depth: fidl::encoding::Depth,
24914        ) -> fidl::Result<()> {
24915            encoder.debug_check_bounds::<StreamBufferPartialSettings>(offset);
24916            // Vector header
24917            let max_ordinal: u64 = self.max_ordinal_present();
24918            encoder.write_num(max_ordinal, offset);
24919            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
24920            // Calling encoder.out_of_line_offset(0) is not allowed.
24921            if max_ordinal == 0 {
24922                return Ok(());
24923            }
24924            depth.increment()?;
24925            let envelope_size = 8;
24926            let bytes_len = max_ordinal as usize * envelope_size;
24927            #[allow(unused_variables)]
24928            let offset = encoder.out_of_line_offset(bytes_len);
24929            let mut _prev_end_offset: usize = 0;
24930            if 1 > max_ordinal {
24931                return Ok(());
24932            }
24933
24934            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24935            // are envelope_size bytes.
24936            let cur_offset: usize = (1 - 1) * envelope_size;
24937
24938            // Zero reserved fields.
24939            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24940
24941            // Safety:
24942            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24943            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24944            //   envelope_size bytes, there is always sufficient room.
24945            fidl::encoding::encode_in_envelope_optional::<
24946                u64,
24947                fidl::encoding::DefaultFuchsiaResourceDialect,
24948            >(
24949                self.buffer_lifetime_ordinal
24950                    .as_ref()
24951                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
24952                encoder,
24953                offset + cur_offset,
24954                depth,
24955            )?;
24956
24957            _prev_end_offset = cur_offset + envelope_size;
24958            if 2 > max_ordinal {
24959                return Ok(());
24960            }
24961
24962            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24963            // are envelope_size bytes.
24964            let cur_offset: usize = (2 - 1) * envelope_size;
24965
24966            // Zero reserved fields.
24967            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24968
24969            // Safety:
24970            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24971            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24972            //   envelope_size bytes, there is always sufficient room.
24973            fidl::encoding::encode_in_envelope_optional::<
24974                u64,
24975                fidl::encoding::DefaultFuchsiaResourceDialect,
24976            >(
24977                self.buffer_constraints_version_ordinal
24978                    .as_ref()
24979                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
24980                encoder,
24981                offset + cur_offset,
24982                depth,
24983            )?;
24984
24985            _prev_end_offset = cur_offset + envelope_size;
24986            if 3 > max_ordinal {
24987                return Ok(());
24988            }
24989
24990            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24991            // are envelope_size bytes.
24992            let cur_offset: usize = (3 - 1) * envelope_size;
24993
24994            // Zero reserved fields.
24995            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24996
24997            // Safety:
24998            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24999            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
25000            //   envelope_size bytes, there is always sufficient room.
25001            fidl::encoding::encode_in_envelope_optional::<
25002                bool,
25003                fidl::encoding::DefaultFuchsiaResourceDialect,
25004            >(
25005                self.single_buffer_mode
25006                    .as_ref()
25007                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
25008                encoder,
25009                offset + cur_offset,
25010                depth,
25011            )?;
25012
25013            _prev_end_offset = cur_offset + envelope_size;
25014            if 4 > max_ordinal {
25015                return Ok(());
25016            }
25017
25018            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
25019            // are envelope_size bytes.
25020            let cur_offset: usize = (4 - 1) * envelope_size;
25021
25022            // Zero reserved fields.
25023            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
25024
25025            // Safety:
25026            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
25027            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
25028            //   envelope_size bytes, there is always sufficient room.
25029            fidl::encoding::encode_in_envelope_optional::<
25030                u32,
25031                fidl::encoding::DefaultFuchsiaResourceDialect,
25032            >(
25033                self.packet_count_for_server
25034                    .as_ref()
25035                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
25036                encoder,
25037                offset + cur_offset,
25038                depth,
25039            )?;
25040
25041            _prev_end_offset = cur_offset + envelope_size;
25042            if 5 > max_ordinal {
25043                return Ok(());
25044            }
25045
25046            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
25047            // are envelope_size bytes.
25048            let cur_offset: usize = (5 - 1) * envelope_size;
25049
25050            // Zero reserved fields.
25051            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
25052
25053            // Safety:
25054            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
25055            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
25056            //   envelope_size bytes, there is always sufficient room.
25057            fidl::encoding::encode_in_envelope_optional::<
25058                u32,
25059                fidl::encoding::DefaultFuchsiaResourceDialect,
25060            >(
25061                self.packet_count_for_client
25062                    .as_ref()
25063                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
25064                encoder,
25065                offset + cur_offset,
25066                depth,
25067            )?;
25068
25069            _prev_end_offset = cur_offset + envelope_size;
25070            if 6 > max_ordinal {
25071                return Ok(());
25072            }
25073
25074            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
25075            // are envelope_size bytes.
25076            let cur_offset: usize = (6 - 1) * envelope_size;
25077
25078            // Zero reserved fields.
25079            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
25080
25081            // Safety:
25082            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
25083            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
25084            //   envelope_size bytes, there is always sufficient room.
25085            fidl::encoding::encode_in_envelope_optional::<
25086                fidl::encoding::Endpoint<
25087                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
25088                >,
25089                fidl::encoding::DefaultFuchsiaResourceDialect,
25090            >(
25091                self.sysmem_token.as_mut().map(
25092                    <fidl::encoding::Endpoint<
25093                        fidl::endpoints::ClientEnd<
25094                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
25095                        >,
25096                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
25097                ),
25098                encoder,
25099                offset + cur_offset,
25100                depth,
25101            )?;
25102
25103            _prev_end_offset = cur_offset + envelope_size;
25104            if 7 > max_ordinal {
25105                return Ok(());
25106            }
25107
25108            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
25109            // are envelope_size bytes.
25110            let cur_offset: usize = (7 - 1) * envelope_size;
25111
25112            // Zero reserved fields.
25113            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
25114
25115            // Safety:
25116            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
25117            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
25118            //   envelope_size bytes, there is always sufficient room.
25119            fidl::encoding::encode_in_envelope_optional::<
25120                fidl::encoding::Endpoint<
25121                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
25122                >,
25123                fidl::encoding::DefaultFuchsiaResourceDialect,
25124            >(
25125                self.sysmem2_token.as_mut().map(
25126                    <fidl::encoding::Endpoint<
25127                        fidl::endpoints::ClientEnd<
25128                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
25129                        >,
25130                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
25131                ),
25132                encoder,
25133                offset + cur_offset,
25134                depth,
25135            )?;
25136
25137            _prev_end_offset = cur_offset + envelope_size;
25138
25139            Ok(())
25140        }
25141    }
25142
25143    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25144        for StreamBufferPartialSettings
25145    {
25146        #[inline(always)]
25147        fn new_empty() -> Self {
25148            Self::default()
25149        }
25150
25151        unsafe fn decode(
25152            &mut self,
25153            decoder: &mut fidl::encoding::Decoder<
25154                '_,
25155                fidl::encoding::DefaultFuchsiaResourceDialect,
25156            >,
25157            offset: usize,
25158            mut depth: fidl::encoding::Depth,
25159        ) -> fidl::Result<()> {
25160            decoder.debug_check_bounds::<Self>(offset);
25161            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
25162                None => return Err(fidl::Error::NotNullable),
25163                Some(len) => len,
25164            };
25165            // Calling decoder.out_of_line_offset(0) is not allowed.
25166            if len == 0 {
25167                return Ok(());
25168            };
25169            depth.increment()?;
25170            let envelope_size = 8;
25171            let bytes_len = len * envelope_size;
25172            let offset = decoder.out_of_line_offset(bytes_len)?;
25173            // Decode the envelope for each type.
25174            let mut _next_ordinal_to_read = 0;
25175            let mut next_offset = offset;
25176            let end_offset = offset + bytes_len;
25177            _next_ordinal_to_read += 1;
25178            if next_offset >= end_offset {
25179                return Ok(());
25180            }
25181
25182            // Decode unknown envelopes for gaps in ordinals.
25183            while _next_ordinal_to_read < 1 {
25184                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25185                _next_ordinal_to_read += 1;
25186                next_offset += envelope_size;
25187            }
25188
25189            let next_out_of_line = decoder.next_out_of_line();
25190            let handles_before = decoder.remaining_handles();
25191            if let Some((inlined, num_bytes, num_handles)) =
25192                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25193            {
25194                let member_inline_size =
25195                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25196                if inlined != (member_inline_size <= 4) {
25197                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25198                }
25199                let inner_offset;
25200                let mut inner_depth = depth.clone();
25201                if inlined {
25202                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25203                    inner_offset = next_offset;
25204                } else {
25205                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25206                    inner_depth.increment()?;
25207                }
25208                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
25209                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
25210                });
25211                fidl::decode!(
25212                    u64,
25213                    fidl::encoding::DefaultFuchsiaResourceDialect,
25214                    val_ref,
25215                    decoder,
25216                    inner_offset,
25217                    inner_depth
25218                )?;
25219                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25220                {
25221                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25222                }
25223                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25224                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25225                }
25226            }
25227
25228            next_offset += envelope_size;
25229            _next_ordinal_to_read += 1;
25230            if next_offset >= end_offset {
25231                return Ok(());
25232            }
25233
25234            // Decode unknown envelopes for gaps in ordinals.
25235            while _next_ordinal_to_read < 2 {
25236                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25237                _next_ordinal_to_read += 1;
25238                next_offset += envelope_size;
25239            }
25240
25241            let next_out_of_line = decoder.next_out_of_line();
25242            let handles_before = decoder.remaining_handles();
25243            if let Some((inlined, num_bytes, num_handles)) =
25244                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25245            {
25246                let member_inline_size =
25247                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25248                if inlined != (member_inline_size <= 4) {
25249                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25250                }
25251                let inner_offset;
25252                let mut inner_depth = depth.clone();
25253                if inlined {
25254                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25255                    inner_offset = next_offset;
25256                } else {
25257                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25258                    inner_depth.increment()?;
25259                }
25260                let val_ref = self.buffer_constraints_version_ordinal.get_or_insert_with(|| {
25261                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
25262                });
25263                fidl::decode!(
25264                    u64,
25265                    fidl::encoding::DefaultFuchsiaResourceDialect,
25266                    val_ref,
25267                    decoder,
25268                    inner_offset,
25269                    inner_depth
25270                )?;
25271                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25272                {
25273                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25274                }
25275                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25276                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25277                }
25278            }
25279
25280            next_offset += envelope_size;
25281            _next_ordinal_to_read += 1;
25282            if next_offset >= end_offset {
25283                return Ok(());
25284            }
25285
25286            // Decode unknown envelopes for gaps in ordinals.
25287            while _next_ordinal_to_read < 3 {
25288                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25289                _next_ordinal_to_read += 1;
25290                next_offset += envelope_size;
25291            }
25292
25293            let next_out_of_line = decoder.next_out_of_line();
25294            let handles_before = decoder.remaining_handles();
25295            if let Some((inlined, num_bytes, num_handles)) =
25296                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25297            {
25298                let member_inline_size =
25299                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25300                if inlined != (member_inline_size <= 4) {
25301                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25302                }
25303                let inner_offset;
25304                let mut inner_depth = depth.clone();
25305                if inlined {
25306                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25307                    inner_offset = next_offset;
25308                } else {
25309                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25310                    inner_depth.increment()?;
25311                }
25312                let val_ref = self.single_buffer_mode.get_or_insert_with(|| {
25313                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
25314                });
25315                fidl::decode!(
25316                    bool,
25317                    fidl::encoding::DefaultFuchsiaResourceDialect,
25318                    val_ref,
25319                    decoder,
25320                    inner_offset,
25321                    inner_depth
25322                )?;
25323                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25324                {
25325                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25326                }
25327                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25328                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25329                }
25330            }
25331
25332            next_offset += envelope_size;
25333            _next_ordinal_to_read += 1;
25334            if next_offset >= end_offset {
25335                return Ok(());
25336            }
25337
25338            // Decode unknown envelopes for gaps in ordinals.
25339            while _next_ordinal_to_read < 4 {
25340                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25341                _next_ordinal_to_read += 1;
25342                next_offset += envelope_size;
25343            }
25344
25345            let next_out_of_line = decoder.next_out_of_line();
25346            let handles_before = decoder.remaining_handles();
25347            if let Some((inlined, num_bytes, num_handles)) =
25348                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25349            {
25350                let member_inline_size =
25351                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25352                if inlined != (member_inline_size <= 4) {
25353                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25354                }
25355                let inner_offset;
25356                let mut inner_depth = depth.clone();
25357                if inlined {
25358                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25359                    inner_offset = next_offset;
25360                } else {
25361                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25362                    inner_depth.increment()?;
25363                }
25364                let val_ref = self.packet_count_for_server.get_or_insert_with(|| {
25365                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
25366                });
25367                fidl::decode!(
25368                    u32,
25369                    fidl::encoding::DefaultFuchsiaResourceDialect,
25370                    val_ref,
25371                    decoder,
25372                    inner_offset,
25373                    inner_depth
25374                )?;
25375                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25376                {
25377                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25378                }
25379                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25380                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25381                }
25382            }
25383
25384            next_offset += envelope_size;
25385            _next_ordinal_to_read += 1;
25386            if next_offset >= end_offset {
25387                return Ok(());
25388            }
25389
25390            // Decode unknown envelopes for gaps in ordinals.
25391            while _next_ordinal_to_read < 5 {
25392                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25393                _next_ordinal_to_read += 1;
25394                next_offset += envelope_size;
25395            }
25396
25397            let next_out_of_line = decoder.next_out_of_line();
25398            let handles_before = decoder.remaining_handles();
25399            if let Some((inlined, num_bytes, num_handles)) =
25400                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25401            {
25402                let member_inline_size =
25403                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25404                if inlined != (member_inline_size <= 4) {
25405                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25406                }
25407                let inner_offset;
25408                let mut inner_depth = depth.clone();
25409                if inlined {
25410                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25411                    inner_offset = next_offset;
25412                } else {
25413                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25414                    inner_depth.increment()?;
25415                }
25416                let val_ref = self.packet_count_for_client.get_or_insert_with(|| {
25417                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
25418                });
25419                fidl::decode!(
25420                    u32,
25421                    fidl::encoding::DefaultFuchsiaResourceDialect,
25422                    val_ref,
25423                    decoder,
25424                    inner_offset,
25425                    inner_depth
25426                )?;
25427                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25428                {
25429                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25430                }
25431                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25432                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25433                }
25434            }
25435
25436            next_offset += envelope_size;
25437            _next_ordinal_to_read += 1;
25438            if next_offset >= end_offset {
25439                return Ok(());
25440            }
25441
25442            // Decode unknown envelopes for gaps in ordinals.
25443            while _next_ordinal_to_read < 6 {
25444                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25445                _next_ordinal_to_read += 1;
25446                next_offset += envelope_size;
25447            }
25448
25449            let next_out_of_line = decoder.next_out_of_line();
25450            let handles_before = decoder.remaining_handles();
25451            if let Some((inlined, num_bytes, num_handles)) =
25452                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25453            {
25454                let member_inline_size = <fidl::encoding::Endpoint<
25455                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
25456                > as fidl::encoding::TypeMarker>::inline_size(
25457                    decoder.context
25458                );
25459                if inlined != (member_inline_size <= 4) {
25460                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25461                }
25462                let inner_offset;
25463                let mut inner_depth = depth.clone();
25464                if inlined {
25465                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25466                    inner_offset = next_offset;
25467                } else {
25468                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25469                    inner_depth.increment()?;
25470                }
25471                let val_ref = self.sysmem_token.get_or_insert_with(|| {
25472                    fidl::new_empty!(
25473                        fidl::encoding::Endpoint<
25474                            fidl::endpoints::ClientEnd<
25475                                fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
25476                            >,
25477                        >,
25478                        fidl::encoding::DefaultFuchsiaResourceDialect
25479                    )
25480                });
25481                fidl::decode!(
25482                    fidl::encoding::Endpoint<
25483                        fidl::endpoints::ClientEnd<
25484                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
25485                        >,
25486                    >,
25487                    fidl::encoding::DefaultFuchsiaResourceDialect,
25488                    val_ref,
25489                    decoder,
25490                    inner_offset,
25491                    inner_depth
25492                )?;
25493                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25494                {
25495                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25496                }
25497                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25498                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25499                }
25500            }
25501
25502            next_offset += envelope_size;
25503            _next_ordinal_to_read += 1;
25504            if next_offset >= end_offset {
25505                return Ok(());
25506            }
25507
25508            // Decode unknown envelopes for gaps in ordinals.
25509            while _next_ordinal_to_read < 7 {
25510                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25511                _next_ordinal_to_read += 1;
25512                next_offset += envelope_size;
25513            }
25514
25515            let next_out_of_line = decoder.next_out_of_line();
25516            let handles_before = decoder.remaining_handles();
25517            if let Some((inlined, num_bytes, num_handles)) =
25518                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25519            {
25520                let member_inline_size = <fidl::encoding::Endpoint<
25521                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
25522                > as fidl::encoding::TypeMarker>::inline_size(
25523                    decoder.context
25524                );
25525                if inlined != (member_inline_size <= 4) {
25526                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25527                }
25528                let inner_offset;
25529                let mut inner_depth = depth.clone();
25530                if inlined {
25531                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25532                    inner_offset = next_offset;
25533                } else {
25534                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25535                    inner_depth.increment()?;
25536                }
25537                let val_ref = self.sysmem2_token.get_or_insert_with(|| {
25538                    fidl::new_empty!(
25539                        fidl::encoding::Endpoint<
25540                            fidl::endpoints::ClientEnd<
25541                                fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
25542                            >,
25543                        >,
25544                        fidl::encoding::DefaultFuchsiaResourceDialect
25545                    )
25546                });
25547                fidl::decode!(
25548                    fidl::encoding::Endpoint<
25549                        fidl::endpoints::ClientEnd<
25550                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
25551                        >,
25552                    >,
25553                    fidl::encoding::DefaultFuchsiaResourceDialect,
25554                    val_ref,
25555                    decoder,
25556                    inner_offset,
25557                    inner_depth
25558                )?;
25559                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25560                {
25561                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25562                }
25563                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25564                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25565                }
25566            }
25567
25568            next_offset += envelope_size;
25569
25570            // Decode the remaining unknown envelopes.
25571            while next_offset < end_offset {
25572                _next_ordinal_to_read += 1;
25573                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25574                next_offset += envelope_size;
25575            }
25576
25577            Ok(())
25578        }
25579    }
25580}