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        let protocol_name = <ActivityReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
446        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
447    }
448
449    pub fn into_channel(self) -> fidl::Channel {
450        self.client.into_channel()
451    }
452
453    /// Waits until an event arrives and returns it. It is safe for other
454    /// threads to make concurrent requests while waiting for an event.
455    pub fn wait_for_event(
456        &self,
457        deadline: zx::MonotonicInstant,
458    ) -> Result<ActivityReporterEvent, fidl::Error> {
459        ActivityReporterEvent::decode(self.client.wait_for_event(deadline)?)
460    }
461
462    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
463    /// It returns immediately the first time that it is called.
464    pub fn r#watch_render_activity(
465        &self,
466        ___deadline: zx::MonotonicInstant,
467    ) -> Result<Vec<AudioRenderUsage>, fidl::Error> {
468        let _response = self.client.send_query::<
469            fidl::encoding::EmptyPayload,
470            ActivityReporterWatchRenderActivityResponse,
471        >(
472            (),
473            0x2974e9f5880b2f1f,
474            fidl::encoding::DynamicFlags::empty(),
475            ___deadline,
476        )?;
477        Ok(_response.active_usages)
478    }
479
480    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
481    /// It returns immediately the first time that it is called.
482    pub fn r#watch_render_activity2(
483        &self,
484        ___deadline: zx::MonotonicInstant,
485    ) -> Result<Vec<AudioRenderUsage2>, fidl::Error> {
486        let _response = self.client.send_query::<
487            fidl::encoding::EmptyPayload,
488            fidl::encoding::FlexibleType<ActivityReporterWatchRenderActivity2Response>,
489        >(
490            (),
491            0x484236fc11b363e6,
492            fidl::encoding::DynamicFlags::FLEXIBLE,
493            ___deadline,
494        )?
495        .into_result::<ActivityReporterMarker>("watch_render_activity2")?;
496        Ok(_response.active_usages)
497    }
498
499    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
500    /// It returns immediately the first time that it is called.
501    pub fn r#watch_capture_activity(
502        &self,
503        ___deadline: zx::MonotonicInstant,
504    ) -> Result<Vec<AudioCaptureUsage>, fidl::Error> {
505        let _response = self.client.send_query::<
506            fidl::encoding::EmptyPayload,
507            ActivityReporterWatchCaptureActivityResponse,
508        >(
509            (),
510            0x70e7038e9658e128,
511            fidl::encoding::DynamicFlags::empty(),
512            ___deadline,
513        )?;
514        Ok(_response.active_usages)
515    }
516
517    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
518    /// It returns immediately the first time that it is called.
519    pub fn r#watch_capture_activity2(
520        &self,
521        ___deadline: zx::MonotonicInstant,
522    ) -> Result<Vec<AudioCaptureUsage2>, fidl::Error> {
523        let _response = self.client.send_query::<
524            fidl::encoding::EmptyPayload,
525            fidl::encoding::FlexibleType<ActivityReporterWatchCaptureActivity2Response>,
526        >(
527            (),
528            0x3d137e0364f9d550,
529            fidl::encoding::DynamicFlags::FLEXIBLE,
530            ___deadline,
531        )?
532        .into_result::<ActivityReporterMarker>("watch_capture_activity2")?;
533        Ok(_response.active_usages)
534    }
535}
536
537#[cfg(target_os = "fuchsia")]
538impl From<ActivityReporterSynchronousProxy> for zx::Handle {
539    fn from(value: ActivityReporterSynchronousProxy) -> Self {
540        value.into_channel().into()
541    }
542}
543
544#[cfg(target_os = "fuchsia")]
545impl From<fidl::Channel> for ActivityReporterSynchronousProxy {
546    fn from(value: fidl::Channel) -> Self {
547        Self::new(value)
548    }
549}
550
551#[cfg(target_os = "fuchsia")]
552impl fidl::endpoints::FromClient for ActivityReporterSynchronousProxy {
553    type Protocol = ActivityReporterMarker;
554
555    fn from_client(value: fidl::endpoints::ClientEnd<ActivityReporterMarker>) -> Self {
556        Self::new(value.into_channel())
557    }
558}
559
560#[derive(Debug, Clone)]
561pub struct ActivityReporterProxy {
562    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
563}
564
565impl fidl::endpoints::Proxy for ActivityReporterProxy {
566    type Protocol = ActivityReporterMarker;
567
568    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
569        Self::new(inner)
570    }
571
572    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
573        self.client.into_channel().map_err(|client| Self { client })
574    }
575
576    fn as_channel(&self) -> &::fidl::AsyncChannel {
577        self.client.as_channel()
578    }
579}
580
581impl ActivityReporterProxy {
582    /// Create a new Proxy for fuchsia.media/ActivityReporter.
583    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
584        let protocol_name = <ActivityReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
585        Self { client: fidl::client::Client::new(channel, protocol_name) }
586    }
587
588    /// Get a Stream of events from the remote end of the protocol.
589    ///
590    /// # Panics
591    ///
592    /// Panics if the event stream was already taken.
593    pub fn take_event_stream(&self) -> ActivityReporterEventStream {
594        ActivityReporterEventStream { event_receiver: self.client.take_event_receiver() }
595    }
596
597    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
598    /// It returns immediately the first time that it is called.
599    pub fn r#watch_render_activity(
600        &self,
601    ) -> fidl::client::QueryResponseFut<
602        Vec<AudioRenderUsage>,
603        fidl::encoding::DefaultFuchsiaResourceDialect,
604    > {
605        ActivityReporterProxyInterface::r#watch_render_activity(self)
606    }
607
608    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
609    /// It returns immediately the first time that it is called.
610    pub fn r#watch_render_activity2(
611        &self,
612    ) -> fidl::client::QueryResponseFut<
613        Vec<AudioRenderUsage2>,
614        fidl::encoding::DefaultFuchsiaResourceDialect,
615    > {
616        ActivityReporterProxyInterface::r#watch_render_activity2(self)
617    }
618
619    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
620    /// It returns immediately the first time that it is called.
621    pub fn r#watch_capture_activity(
622        &self,
623    ) -> fidl::client::QueryResponseFut<
624        Vec<AudioCaptureUsage>,
625        fidl::encoding::DefaultFuchsiaResourceDialect,
626    > {
627        ActivityReporterProxyInterface::r#watch_capture_activity(self)
628    }
629
630    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
631    /// It returns immediately the first time that it is called.
632    pub fn r#watch_capture_activity2(
633        &self,
634    ) -> fidl::client::QueryResponseFut<
635        Vec<AudioCaptureUsage2>,
636        fidl::encoding::DefaultFuchsiaResourceDialect,
637    > {
638        ActivityReporterProxyInterface::r#watch_capture_activity2(self)
639    }
640}
641
642impl ActivityReporterProxyInterface for ActivityReporterProxy {
643    type WatchRenderActivityResponseFut = fidl::client::QueryResponseFut<
644        Vec<AudioRenderUsage>,
645        fidl::encoding::DefaultFuchsiaResourceDialect,
646    >;
647    fn r#watch_render_activity(&self) -> Self::WatchRenderActivityResponseFut {
648        fn _decode(
649            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
650        ) -> Result<Vec<AudioRenderUsage>, fidl::Error> {
651            let _response = fidl::client::decode_transaction_body::<
652                ActivityReporterWatchRenderActivityResponse,
653                fidl::encoding::DefaultFuchsiaResourceDialect,
654                0x2974e9f5880b2f1f,
655            >(_buf?)?;
656            Ok(_response.active_usages)
657        }
658        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioRenderUsage>>(
659            (),
660            0x2974e9f5880b2f1f,
661            fidl::encoding::DynamicFlags::empty(),
662            _decode,
663        )
664    }
665
666    type WatchRenderActivity2ResponseFut = fidl::client::QueryResponseFut<
667        Vec<AudioRenderUsage2>,
668        fidl::encoding::DefaultFuchsiaResourceDialect,
669    >;
670    fn r#watch_render_activity2(&self) -> Self::WatchRenderActivity2ResponseFut {
671        fn _decode(
672            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
673        ) -> Result<Vec<AudioRenderUsage2>, fidl::Error> {
674            let _response = fidl::client::decode_transaction_body::<
675                fidl::encoding::FlexibleType<ActivityReporterWatchRenderActivity2Response>,
676                fidl::encoding::DefaultFuchsiaResourceDialect,
677                0x484236fc11b363e6,
678            >(_buf?)?
679            .into_result::<ActivityReporterMarker>("watch_render_activity2")?;
680            Ok(_response.active_usages)
681        }
682        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioRenderUsage2>>(
683            (),
684            0x484236fc11b363e6,
685            fidl::encoding::DynamicFlags::FLEXIBLE,
686            _decode,
687        )
688    }
689
690    type WatchCaptureActivityResponseFut = fidl::client::QueryResponseFut<
691        Vec<AudioCaptureUsage>,
692        fidl::encoding::DefaultFuchsiaResourceDialect,
693    >;
694    fn r#watch_capture_activity(&self) -> Self::WatchCaptureActivityResponseFut {
695        fn _decode(
696            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
697        ) -> Result<Vec<AudioCaptureUsage>, fidl::Error> {
698            let _response = fidl::client::decode_transaction_body::<
699                ActivityReporterWatchCaptureActivityResponse,
700                fidl::encoding::DefaultFuchsiaResourceDialect,
701                0x70e7038e9658e128,
702            >(_buf?)?;
703            Ok(_response.active_usages)
704        }
705        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioCaptureUsage>>(
706            (),
707            0x70e7038e9658e128,
708            fidl::encoding::DynamicFlags::empty(),
709            _decode,
710        )
711    }
712
713    type WatchCaptureActivity2ResponseFut = fidl::client::QueryResponseFut<
714        Vec<AudioCaptureUsage2>,
715        fidl::encoding::DefaultFuchsiaResourceDialect,
716    >;
717    fn r#watch_capture_activity2(&self) -> Self::WatchCaptureActivity2ResponseFut {
718        fn _decode(
719            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
720        ) -> Result<Vec<AudioCaptureUsage2>, fidl::Error> {
721            let _response = fidl::client::decode_transaction_body::<
722                fidl::encoding::FlexibleType<ActivityReporterWatchCaptureActivity2Response>,
723                fidl::encoding::DefaultFuchsiaResourceDialect,
724                0x3d137e0364f9d550,
725            >(_buf?)?
726            .into_result::<ActivityReporterMarker>("watch_capture_activity2")?;
727            Ok(_response.active_usages)
728        }
729        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioCaptureUsage2>>(
730            (),
731            0x3d137e0364f9d550,
732            fidl::encoding::DynamicFlags::FLEXIBLE,
733            _decode,
734        )
735    }
736}
737
738pub struct ActivityReporterEventStream {
739    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
740}
741
742impl std::marker::Unpin for ActivityReporterEventStream {}
743
744impl futures::stream::FusedStream for ActivityReporterEventStream {
745    fn is_terminated(&self) -> bool {
746        self.event_receiver.is_terminated()
747    }
748}
749
750impl futures::Stream for ActivityReporterEventStream {
751    type Item = Result<ActivityReporterEvent, fidl::Error>;
752
753    fn poll_next(
754        mut self: std::pin::Pin<&mut Self>,
755        cx: &mut std::task::Context<'_>,
756    ) -> std::task::Poll<Option<Self::Item>> {
757        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
758            &mut self.event_receiver,
759            cx
760        )?) {
761            Some(buf) => std::task::Poll::Ready(Some(ActivityReporterEvent::decode(buf))),
762            None => std::task::Poll::Ready(None),
763        }
764    }
765}
766
767#[derive(Debug)]
768pub enum ActivityReporterEvent {
769    #[non_exhaustive]
770    _UnknownEvent {
771        /// Ordinal of the event that was sent.
772        ordinal: u64,
773    },
774}
775
776impl ActivityReporterEvent {
777    /// Decodes a message buffer as a [`ActivityReporterEvent`].
778    fn decode(
779        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
780    ) -> Result<ActivityReporterEvent, fidl::Error> {
781        let (bytes, _handles) = buf.split_mut();
782        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
783        debug_assert_eq!(tx_header.tx_id, 0);
784        match tx_header.ordinal {
785            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
786                Ok(ActivityReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
787            }
788            _ => Err(fidl::Error::UnknownOrdinal {
789                ordinal: tx_header.ordinal,
790                protocol_name:
791                    <ActivityReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
792            }),
793        }
794    }
795}
796
797/// A Stream of incoming requests for fuchsia.media/ActivityReporter.
798pub struct ActivityReporterRequestStream {
799    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
800    is_terminated: bool,
801}
802
803impl std::marker::Unpin for ActivityReporterRequestStream {}
804
805impl futures::stream::FusedStream for ActivityReporterRequestStream {
806    fn is_terminated(&self) -> bool {
807        self.is_terminated
808    }
809}
810
811impl fidl::endpoints::RequestStream for ActivityReporterRequestStream {
812    type Protocol = ActivityReporterMarker;
813    type ControlHandle = ActivityReporterControlHandle;
814
815    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
816        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
817    }
818
819    fn control_handle(&self) -> Self::ControlHandle {
820        ActivityReporterControlHandle { inner: self.inner.clone() }
821    }
822
823    fn into_inner(
824        self,
825    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
826    {
827        (self.inner, self.is_terminated)
828    }
829
830    fn from_inner(
831        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
832        is_terminated: bool,
833    ) -> Self {
834        Self { inner, is_terminated }
835    }
836}
837
838impl futures::Stream for ActivityReporterRequestStream {
839    type Item = Result<ActivityReporterRequest, fidl::Error>;
840
841    fn poll_next(
842        mut self: std::pin::Pin<&mut Self>,
843        cx: &mut std::task::Context<'_>,
844    ) -> std::task::Poll<Option<Self::Item>> {
845        let this = &mut *self;
846        if this.inner.check_shutdown(cx) {
847            this.is_terminated = true;
848            return std::task::Poll::Ready(None);
849        }
850        if this.is_terminated {
851            panic!("polled ActivityReporterRequestStream after completion");
852        }
853        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
854            |bytes, handles| {
855                match this.inner.channel().read_etc(cx, bytes, handles) {
856                    std::task::Poll::Ready(Ok(())) => {}
857                    std::task::Poll::Pending => return std::task::Poll::Pending,
858                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
859                        this.is_terminated = true;
860                        return std::task::Poll::Ready(None);
861                    }
862                    std::task::Poll::Ready(Err(e)) => {
863                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
864                            e.into(),
865                        ))))
866                    }
867                }
868
869                // A message has been received from the channel
870                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
871
872                std::task::Poll::Ready(Some(match header.ordinal {
873                    0x2974e9f5880b2f1f => {
874                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
875                        let mut req = fidl::new_empty!(
876                            fidl::encoding::EmptyPayload,
877                            fidl::encoding::DefaultFuchsiaResourceDialect
878                        );
879                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
880                        let control_handle =
881                            ActivityReporterControlHandle { inner: this.inner.clone() };
882                        Ok(ActivityReporterRequest::WatchRenderActivity {
883                            responder: ActivityReporterWatchRenderActivityResponder {
884                                control_handle: std::mem::ManuallyDrop::new(control_handle),
885                                tx_id: header.tx_id,
886                            },
887                        })
888                    }
889                    0x484236fc11b363e6 => {
890                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
891                        let mut req = fidl::new_empty!(
892                            fidl::encoding::EmptyPayload,
893                            fidl::encoding::DefaultFuchsiaResourceDialect
894                        );
895                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
896                        let control_handle =
897                            ActivityReporterControlHandle { inner: this.inner.clone() };
898                        Ok(ActivityReporterRequest::WatchRenderActivity2 {
899                            responder: ActivityReporterWatchRenderActivity2Responder {
900                                control_handle: std::mem::ManuallyDrop::new(control_handle),
901                                tx_id: header.tx_id,
902                            },
903                        })
904                    }
905                    0x70e7038e9658e128 => {
906                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
907                        let mut req = fidl::new_empty!(
908                            fidl::encoding::EmptyPayload,
909                            fidl::encoding::DefaultFuchsiaResourceDialect
910                        );
911                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
912                        let control_handle =
913                            ActivityReporterControlHandle { inner: this.inner.clone() };
914                        Ok(ActivityReporterRequest::WatchCaptureActivity {
915                            responder: ActivityReporterWatchCaptureActivityResponder {
916                                control_handle: std::mem::ManuallyDrop::new(control_handle),
917                                tx_id: header.tx_id,
918                            },
919                        })
920                    }
921                    0x3d137e0364f9d550 => {
922                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
923                        let mut req = fidl::new_empty!(
924                            fidl::encoding::EmptyPayload,
925                            fidl::encoding::DefaultFuchsiaResourceDialect
926                        );
927                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
928                        let control_handle =
929                            ActivityReporterControlHandle { inner: this.inner.clone() };
930                        Ok(ActivityReporterRequest::WatchCaptureActivity2 {
931                            responder: ActivityReporterWatchCaptureActivity2Responder {
932                                control_handle: std::mem::ManuallyDrop::new(control_handle),
933                                tx_id: header.tx_id,
934                            },
935                        })
936                    }
937                    _ if header.tx_id == 0
938                        && header
939                            .dynamic_flags()
940                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
941                    {
942                        Ok(ActivityReporterRequest::_UnknownMethod {
943                            ordinal: header.ordinal,
944                            control_handle: ActivityReporterControlHandle {
945                                inner: this.inner.clone(),
946                            },
947                            method_type: fidl::MethodType::OneWay,
948                        })
949                    }
950                    _ if header
951                        .dynamic_flags()
952                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
953                    {
954                        this.inner.send_framework_err(
955                            fidl::encoding::FrameworkErr::UnknownMethod,
956                            header.tx_id,
957                            header.ordinal,
958                            header.dynamic_flags(),
959                            (bytes, handles),
960                        )?;
961                        Ok(ActivityReporterRequest::_UnknownMethod {
962                            ordinal: header.ordinal,
963                            control_handle: ActivityReporterControlHandle {
964                                inner: this.inner.clone(),
965                            },
966                            method_type: fidl::MethodType::TwoWay,
967                        })
968                    }
969                    _ => Err(fidl::Error::UnknownOrdinal {
970                        ordinal: header.ordinal,
971                        protocol_name:
972                            <ActivityReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
973                    }),
974                }))
975            },
976        )
977    }
978}
979
980/// A protocol for monitoring the usage activity of the AudioRenderers and AudioCapturers.
981#[derive(Debug)]
982pub enum ActivityReporterRequest {
983    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
984    /// It returns immediately the first time that it is called.
985    WatchRenderActivity { responder: ActivityReporterWatchRenderActivityResponder },
986    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
987    /// It returns immediately the first time that it is called.
988    WatchRenderActivity2 { responder: ActivityReporterWatchRenderActivity2Responder },
989    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
990    /// It returns immediately the first time that it is called.
991    WatchCaptureActivity { responder: ActivityReporterWatchCaptureActivityResponder },
992    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
993    /// It returns immediately the first time that it is called.
994    WatchCaptureActivity2 { responder: ActivityReporterWatchCaptureActivity2Responder },
995    /// An interaction was received which does not match any known method.
996    #[non_exhaustive]
997    _UnknownMethod {
998        /// Ordinal of the method that was called.
999        ordinal: u64,
1000        control_handle: ActivityReporterControlHandle,
1001        method_type: fidl::MethodType,
1002    },
1003}
1004
1005impl ActivityReporterRequest {
1006    #[allow(irrefutable_let_patterns)]
1007    pub fn into_watch_render_activity(
1008        self,
1009    ) -> Option<(ActivityReporterWatchRenderActivityResponder)> {
1010        if let ActivityReporterRequest::WatchRenderActivity { responder } = self {
1011            Some((responder))
1012        } else {
1013            None
1014        }
1015    }
1016
1017    #[allow(irrefutable_let_patterns)]
1018    pub fn into_watch_render_activity2(
1019        self,
1020    ) -> Option<(ActivityReporterWatchRenderActivity2Responder)> {
1021        if let ActivityReporterRequest::WatchRenderActivity2 { responder } = self {
1022            Some((responder))
1023        } else {
1024            None
1025        }
1026    }
1027
1028    #[allow(irrefutable_let_patterns)]
1029    pub fn into_watch_capture_activity(
1030        self,
1031    ) -> Option<(ActivityReporterWatchCaptureActivityResponder)> {
1032        if let ActivityReporterRequest::WatchCaptureActivity { responder } = self {
1033            Some((responder))
1034        } else {
1035            None
1036        }
1037    }
1038
1039    #[allow(irrefutable_let_patterns)]
1040    pub fn into_watch_capture_activity2(
1041        self,
1042    ) -> Option<(ActivityReporterWatchCaptureActivity2Responder)> {
1043        if let ActivityReporterRequest::WatchCaptureActivity2 { responder } = self {
1044            Some((responder))
1045        } else {
1046            None
1047        }
1048    }
1049
1050    /// Name of the method defined in FIDL
1051    pub fn method_name(&self) -> &'static str {
1052        match *self {
1053            ActivityReporterRequest::WatchRenderActivity { .. } => "watch_render_activity",
1054            ActivityReporterRequest::WatchRenderActivity2 { .. } => "watch_render_activity2",
1055            ActivityReporterRequest::WatchCaptureActivity { .. } => "watch_capture_activity",
1056            ActivityReporterRequest::WatchCaptureActivity2 { .. } => "watch_capture_activity2",
1057            ActivityReporterRequest::_UnknownMethod {
1058                method_type: fidl::MethodType::OneWay,
1059                ..
1060            } => "unknown one-way method",
1061            ActivityReporterRequest::_UnknownMethod {
1062                method_type: fidl::MethodType::TwoWay,
1063                ..
1064            } => "unknown two-way method",
1065        }
1066    }
1067}
1068
1069#[derive(Debug, Clone)]
1070pub struct ActivityReporterControlHandle {
1071    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1072}
1073
1074impl fidl::endpoints::ControlHandle for ActivityReporterControlHandle {
1075    fn shutdown(&self) {
1076        self.inner.shutdown()
1077    }
1078    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1079        self.inner.shutdown_with_epitaph(status)
1080    }
1081
1082    fn is_closed(&self) -> bool {
1083        self.inner.channel().is_closed()
1084    }
1085    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1086        self.inner.channel().on_closed()
1087    }
1088
1089    #[cfg(target_os = "fuchsia")]
1090    fn signal_peer(
1091        &self,
1092        clear_mask: zx::Signals,
1093        set_mask: zx::Signals,
1094    ) -> Result<(), zx_status::Status> {
1095        use fidl::Peered;
1096        self.inner.channel().signal_peer(clear_mask, set_mask)
1097    }
1098}
1099
1100impl ActivityReporterControlHandle {}
1101
1102#[must_use = "FIDL methods require a response to be sent"]
1103#[derive(Debug)]
1104pub struct ActivityReporterWatchRenderActivityResponder {
1105    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1106    tx_id: u32,
1107}
1108
1109/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1110/// if the responder is dropped without sending a response, so that the client
1111/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1112impl std::ops::Drop for ActivityReporterWatchRenderActivityResponder {
1113    fn drop(&mut self) {
1114        self.control_handle.shutdown();
1115        // Safety: drops once, never accessed again
1116        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1117    }
1118}
1119
1120impl fidl::endpoints::Responder for ActivityReporterWatchRenderActivityResponder {
1121    type ControlHandle = ActivityReporterControlHandle;
1122
1123    fn control_handle(&self) -> &ActivityReporterControlHandle {
1124        &self.control_handle
1125    }
1126
1127    fn drop_without_shutdown(mut self) {
1128        // Safety: drops once, never accessed again due to mem::forget
1129        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1130        // Prevent Drop from running (which would shut down the channel)
1131        std::mem::forget(self);
1132    }
1133}
1134
1135impl ActivityReporterWatchRenderActivityResponder {
1136    /// Sends a response to the FIDL transaction.
1137    ///
1138    /// Sets the channel to shutdown if an error occurs.
1139    pub fn send(self, mut active_usages: &[AudioRenderUsage]) -> Result<(), fidl::Error> {
1140        let _result = self.send_raw(active_usages);
1141        if _result.is_err() {
1142            self.control_handle.shutdown();
1143        }
1144        self.drop_without_shutdown();
1145        _result
1146    }
1147
1148    /// Similar to "send" but does not shutdown the channel if an error occurs.
1149    pub fn send_no_shutdown_on_err(
1150        self,
1151        mut active_usages: &[AudioRenderUsage],
1152    ) -> Result<(), fidl::Error> {
1153        let _result = self.send_raw(active_usages);
1154        self.drop_without_shutdown();
1155        _result
1156    }
1157
1158    fn send_raw(&self, mut active_usages: &[AudioRenderUsage]) -> Result<(), fidl::Error> {
1159        self.control_handle.inner.send::<ActivityReporterWatchRenderActivityResponse>(
1160            (active_usages,),
1161            self.tx_id,
1162            0x2974e9f5880b2f1f,
1163            fidl::encoding::DynamicFlags::empty(),
1164        )
1165    }
1166}
1167
1168#[must_use = "FIDL methods require a response to be sent"]
1169#[derive(Debug)]
1170pub struct ActivityReporterWatchRenderActivity2Responder {
1171    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1172    tx_id: u32,
1173}
1174
1175/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1176/// if the responder is dropped without sending a response, so that the client
1177/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1178impl std::ops::Drop for ActivityReporterWatchRenderActivity2Responder {
1179    fn drop(&mut self) {
1180        self.control_handle.shutdown();
1181        // Safety: drops once, never accessed again
1182        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1183    }
1184}
1185
1186impl fidl::endpoints::Responder for ActivityReporterWatchRenderActivity2Responder {
1187    type ControlHandle = ActivityReporterControlHandle;
1188
1189    fn control_handle(&self) -> &ActivityReporterControlHandle {
1190        &self.control_handle
1191    }
1192
1193    fn drop_without_shutdown(mut self) {
1194        // Safety: drops once, never accessed again due to mem::forget
1195        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1196        // Prevent Drop from running (which would shut down the channel)
1197        std::mem::forget(self);
1198    }
1199}
1200
1201impl ActivityReporterWatchRenderActivity2Responder {
1202    /// Sends a response to the FIDL transaction.
1203    ///
1204    /// Sets the channel to shutdown if an error occurs.
1205    pub fn send(self, mut active_usages: &[AudioRenderUsage2]) -> Result<(), fidl::Error> {
1206        let _result = self.send_raw(active_usages);
1207        if _result.is_err() {
1208            self.control_handle.shutdown();
1209        }
1210        self.drop_without_shutdown();
1211        _result
1212    }
1213
1214    /// Similar to "send" but does not shutdown the channel if an error occurs.
1215    pub fn send_no_shutdown_on_err(
1216        self,
1217        mut active_usages: &[AudioRenderUsage2],
1218    ) -> Result<(), fidl::Error> {
1219        let _result = self.send_raw(active_usages);
1220        self.drop_without_shutdown();
1221        _result
1222    }
1223
1224    fn send_raw(&self, mut active_usages: &[AudioRenderUsage2]) -> Result<(), fidl::Error> {
1225        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1226            ActivityReporterWatchRenderActivity2Response,
1227        >>(
1228            fidl::encoding::Flexible::new((active_usages,)),
1229            self.tx_id,
1230            0x484236fc11b363e6,
1231            fidl::encoding::DynamicFlags::FLEXIBLE,
1232        )
1233    }
1234}
1235
1236#[must_use = "FIDL methods require a response to be sent"]
1237#[derive(Debug)]
1238pub struct ActivityReporterWatchCaptureActivityResponder {
1239    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1240    tx_id: u32,
1241}
1242
1243/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1244/// if the responder is dropped without sending a response, so that the client
1245/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1246impl std::ops::Drop for ActivityReporterWatchCaptureActivityResponder {
1247    fn drop(&mut self) {
1248        self.control_handle.shutdown();
1249        // Safety: drops once, never accessed again
1250        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1251    }
1252}
1253
1254impl fidl::endpoints::Responder for ActivityReporterWatchCaptureActivityResponder {
1255    type ControlHandle = ActivityReporterControlHandle;
1256
1257    fn control_handle(&self) -> &ActivityReporterControlHandle {
1258        &self.control_handle
1259    }
1260
1261    fn drop_without_shutdown(mut self) {
1262        // Safety: drops once, never accessed again due to mem::forget
1263        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1264        // Prevent Drop from running (which would shut down the channel)
1265        std::mem::forget(self);
1266    }
1267}
1268
1269impl ActivityReporterWatchCaptureActivityResponder {
1270    /// Sends a response to the FIDL transaction.
1271    ///
1272    /// Sets the channel to shutdown if an error occurs.
1273    pub fn send(self, mut active_usages: &[AudioCaptureUsage]) -> Result<(), fidl::Error> {
1274        let _result = self.send_raw(active_usages);
1275        if _result.is_err() {
1276            self.control_handle.shutdown();
1277        }
1278        self.drop_without_shutdown();
1279        _result
1280    }
1281
1282    /// Similar to "send" but does not shutdown the channel if an error occurs.
1283    pub fn send_no_shutdown_on_err(
1284        self,
1285        mut active_usages: &[AudioCaptureUsage],
1286    ) -> Result<(), fidl::Error> {
1287        let _result = self.send_raw(active_usages);
1288        self.drop_without_shutdown();
1289        _result
1290    }
1291
1292    fn send_raw(&self, mut active_usages: &[AudioCaptureUsage]) -> Result<(), fidl::Error> {
1293        self.control_handle.inner.send::<ActivityReporterWatchCaptureActivityResponse>(
1294            (active_usages,),
1295            self.tx_id,
1296            0x70e7038e9658e128,
1297            fidl::encoding::DynamicFlags::empty(),
1298        )
1299    }
1300}
1301
1302#[must_use = "FIDL methods require a response to be sent"]
1303#[derive(Debug)]
1304pub struct ActivityReporterWatchCaptureActivity2Responder {
1305    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1306    tx_id: u32,
1307}
1308
1309/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1310/// if the responder is dropped without sending a response, so that the client
1311/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1312impl std::ops::Drop for ActivityReporterWatchCaptureActivity2Responder {
1313    fn drop(&mut self) {
1314        self.control_handle.shutdown();
1315        // Safety: drops once, never accessed again
1316        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1317    }
1318}
1319
1320impl fidl::endpoints::Responder for ActivityReporterWatchCaptureActivity2Responder {
1321    type ControlHandle = ActivityReporterControlHandle;
1322
1323    fn control_handle(&self) -> &ActivityReporterControlHandle {
1324        &self.control_handle
1325    }
1326
1327    fn drop_without_shutdown(mut self) {
1328        // Safety: drops once, never accessed again due to mem::forget
1329        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1330        // Prevent Drop from running (which would shut down the channel)
1331        std::mem::forget(self);
1332    }
1333}
1334
1335impl ActivityReporterWatchCaptureActivity2Responder {
1336    /// Sends a response to the FIDL transaction.
1337    ///
1338    /// Sets the channel to shutdown if an error occurs.
1339    pub fn send(self, mut active_usages: &[AudioCaptureUsage2]) -> Result<(), fidl::Error> {
1340        let _result = self.send_raw(active_usages);
1341        if _result.is_err() {
1342            self.control_handle.shutdown();
1343        }
1344        self.drop_without_shutdown();
1345        _result
1346    }
1347
1348    /// Similar to "send" but does not shutdown the channel if an error occurs.
1349    pub fn send_no_shutdown_on_err(
1350        self,
1351        mut active_usages: &[AudioCaptureUsage2],
1352    ) -> Result<(), fidl::Error> {
1353        let _result = self.send_raw(active_usages);
1354        self.drop_without_shutdown();
1355        _result
1356    }
1357
1358    fn send_raw(&self, mut active_usages: &[AudioCaptureUsage2]) -> Result<(), fidl::Error> {
1359        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1360            ActivityReporterWatchCaptureActivity2Response,
1361        >>(
1362            fidl::encoding::Flexible::new((active_usages,)),
1363            self.tx_id,
1364            0x3d137e0364f9d550,
1365            fidl::encoding::DynamicFlags::FLEXIBLE,
1366        )
1367    }
1368}
1369
1370#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1371pub struct AudioMarker;
1372
1373impl fidl::endpoints::ProtocolMarker for AudioMarker {
1374    type Proxy = AudioProxy;
1375    type RequestStream = AudioRequestStream;
1376    #[cfg(target_os = "fuchsia")]
1377    type SynchronousProxy = AudioSynchronousProxy;
1378
1379    const DEBUG_NAME: &'static str = "fuchsia.media.Audio";
1380}
1381impl fidl::endpoints::DiscoverableProtocolMarker for AudioMarker {}
1382
1383pub trait AudioProxyInterface: Send + Sync {
1384    fn r#create_audio_renderer(
1385        &self,
1386        audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1387    ) -> Result<(), fidl::Error>;
1388    fn r#create_audio_capturer(
1389        &self,
1390        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1391        loopback: bool,
1392    ) -> Result<(), fidl::Error>;
1393}
1394#[derive(Debug)]
1395#[cfg(target_os = "fuchsia")]
1396pub struct AudioSynchronousProxy {
1397    client: fidl::client::sync::Client,
1398}
1399
1400#[cfg(target_os = "fuchsia")]
1401impl fidl::endpoints::SynchronousProxy for AudioSynchronousProxy {
1402    type Proxy = AudioProxy;
1403    type Protocol = AudioMarker;
1404
1405    fn from_channel(inner: fidl::Channel) -> Self {
1406        Self::new(inner)
1407    }
1408
1409    fn into_channel(self) -> fidl::Channel {
1410        self.client.into_channel()
1411    }
1412
1413    fn as_channel(&self) -> &fidl::Channel {
1414        self.client.as_channel()
1415    }
1416}
1417
1418#[cfg(target_os = "fuchsia")]
1419impl AudioSynchronousProxy {
1420    pub fn new(channel: fidl::Channel) -> Self {
1421        let protocol_name = <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1422        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1423    }
1424
1425    pub fn into_channel(self) -> fidl::Channel {
1426        self.client.into_channel()
1427    }
1428
1429    /// Waits until an event arrives and returns it. It is safe for other
1430    /// threads to make concurrent requests while waiting for an event.
1431    pub fn wait_for_event(
1432        &self,
1433        deadline: zx::MonotonicInstant,
1434    ) -> Result<AudioEvent, fidl::Error> {
1435        AudioEvent::decode(self.client.wait_for_event(deadline)?)
1436    }
1437
1438    pub fn r#create_audio_renderer(
1439        &self,
1440        mut audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1441    ) -> Result<(), fidl::Error> {
1442        self.client.send::<AudioCreateAudioRendererRequest>(
1443            (audio_renderer_request,),
1444            0x572f413566fd58f1,
1445            fidl::encoding::DynamicFlags::empty(),
1446        )
1447    }
1448
1449    /// Creates an AudioCapturer which either captures from the current default
1450    /// audio input device, or loops-back from the current default audio output
1451    /// device based on value passed for the loopback flag.
1452    pub fn r#create_audio_capturer(
1453        &self,
1454        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1455        mut loopback: bool,
1456    ) -> Result<(), fidl::Error> {
1457        self.client.send::<AudioCreateAudioCapturerRequest>(
1458            (audio_capturer_request, loopback),
1459            0x44660fc63a6202f,
1460            fidl::encoding::DynamicFlags::empty(),
1461        )
1462    }
1463}
1464
1465#[cfg(target_os = "fuchsia")]
1466impl From<AudioSynchronousProxy> for zx::Handle {
1467    fn from(value: AudioSynchronousProxy) -> Self {
1468        value.into_channel().into()
1469    }
1470}
1471
1472#[cfg(target_os = "fuchsia")]
1473impl From<fidl::Channel> for AudioSynchronousProxy {
1474    fn from(value: fidl::Channel) -> Self {
1475        Self::new(value)
1476    }
1477}
1478
1479#[cfg(target_os = "fuchsia")]
1480impl fidl::endpoints::FromClient for AudioSynchronousProxy {
1481    type Protocol = AudioMarker;
1482
1483    fn from_client(value: fidl::endpoints::ClientEnd<AudioMarker>) -> Self {
1484        Self::new(value.into_channel())
1485    }
1486}
1487
1488#[derive(Debug, Clone)]
1489pub struct AudioProxy {
1490    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1491}
1492
1493impl fidl::endpoints::Proxy for AudioProxy {
1494    type Protocol = AudioMarker;
1495
1496    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1497        Self::new(inner)
1498    }
1499
1500    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1501        self.client.into_channel().map_err(|client| Self { client })
1502    }
1503
1504    fn as_channel(&self) -> &::fidl::AsyncChannel {
1505        self.client.as_channel()
1506    }
1507}
1508
1509impl AudioProxy {
1510    /// Create a new Proxy for fuchsia.media/Audio.
1511    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1512        let protocol_name = <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1513        Self { client: fidl::client::Client::new(channel, protocol_name) }
1514    }
1515
1516    /// Get a Stream of events from the remote end of the protocol.
1517    ///
1518    /// # Panics
1519    ///
1520    /// Panics if the event stream was already taken.
1521    pub fn take_event_stream(&self) -> AudioEventStream {
1522        AudioEventStream { event_receiver: self.client.take_event_receiver() }
1523    }
1524
1525    pub fn r#create_audio_renderer(
1526        &self,
1527        mut audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1528    ) -> Result<(), fidl::Error> {
1529        AudioProxyInterface::r#create_audio_renderer(self, audio_renderer_request)
1530    }
1531
1532    /// Creates an AudioCapturer which either captures from the current default
1533    /// audio input device, or loops-back from the current default audio output
1534    /// device based on value passed for the loopback flag.
1535    pub fn r#create_audio_capturer(
1536        &self,
1537        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1538        mut loopback: bool,
1539    ) -> Result<(), fidl::Error> {
1540        AudioProxyInterface::r#create_audio_capturer(self, audio_capturer_request, loopback)
1541    }
1542}
1543
1544impl AudioProxyInterface for AudioProxy {
1545    fn r#create_audio_renderer(
1546        &self,
1547        mut audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1548    ) -> Result<(), fidl::Error> {
1549        self.client.send::<AudioCreateAudioRendererRequest>(
1550            (audio_renderer_request,),
1551            0x572f413566fd58f1,
1552            fidl::encoding::DynamicFlags::empty(),
1553        )
1554    }
1555
1556    fn r#create_audio_capturer(
1557        &self,
1558        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1559        mut loopback: bool,
1560    ) -> Result<(), fidl::Error> {
1561        self.client.send::<AudioCreateAudioCapturerRequest>(
1562            (audio_capturer_request, loopback),
1563            0x44660fc63a6202f,
1564            fidl::encoding::DynamicFlags::empty(),
1565        )
1566    }
1567}
1568
1569pub struct AudioEventStream {
1570    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1571}
1572
1573impl std::marker::Unpin for AudioEventStream {}
1574
1575impl futures::stream::FusedStream for AudioEventStream {
1576    fn is_terminated(&self) -> bool {
1577        self.event_receiver.is_terminated()
1578    }
1579}
1580
1581impl futures::Stream for AudioEventStream {
1582    type Item = Result<AudioEvent, fidl::Error>;
1583
1584    fn poll_next(
1585        mut self: std::pin::Pin<&mut Self>,
1586        cx: &mut std::task::Context<'_>,
1587    ) -> std::task::Poll<Option<Self::Item>> {
1588        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1589            &mut self.event_receiver,
1590            cx
1591        )?) {
1592            Some(buf) => std::task::Poll::Ready(Some(AudioEvent::decode(buf))),
1593            None => std::task::Poll::Ready(None),
1594        }
1595    }
1596}
1597
1598#[derive(Debug)]
1599pub enum AudioEvent {}
1600
1601impl AudioEvent {
1602    /// Decodes a message buffer as a [`AudioEvent`].
1603    fn decode(
1604        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1605    ) -> Result<AudioEvent, fidl::Error> {
1606        let (bytes, _handles) = buf.split_mut();
1607        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1608        debug_assert_eq!(tx_header.tx_id, 0);
1609        match tx_header.ordinal {
1610            _ => Err(fidl::Error::UnknownOrdinal {
1611                ordinal: tx_header.ordinal,
1612                protocol_name: <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1613            }),
1614        }
1615    }
1616}
1617
1618/// A Stream of incoming requests for fuchsia.media/Audio.
1619pub struct AudioRequestStream {
1620    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1621    is_terminated: bool,
1622}
1623
1624impl std::marker::Unpin for AudioRequestStream {}
1625
1626impl futures::stream::FusedStream for AudioRequestStream {
1627    fn is_terminated(&self) -> bool {
1628        self.is_terminated
1629    }
1630}
1631
1632impl fidl::endpoints::RequestStream for AudioRequestStream {
1633    type Protocol = AudioMarker;
1634    type ControlHandle = AudioControlHandle;
1635
1636    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1637        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1638    }
1639
1640    fn control_handle(&self) -> Self::ControlHandle {
1641        AudioControlHandle { inner: self.inner.clone() }
1642    }
1643
1644    fn into_inner(
1645        self,
1646    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1647    {
1648        (self.inner, self.is_terminated)
1649    }
1650
1651    fn from_inner(
1652        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1653        is_terminated: bool,
1654    ) -> Self {
1655        Self { inner, is_terminated }
1656    }
1657}
1658
1659impl futures::Stream for AudioRequestStream {
1660    type Item = Result<AudioRequest, fidl::Error>;
1661
1662    fn poll_next(
1663        mut self: std::pin::Pin<&mut Self>,
1664        cx: &mut std::task::Context<'_>,
1665    ) -> std::task::Poll<Option<Self::Item>> {
1666        let this = &mut *self;
1667        if this.inner.check_shutdown(cx) {
1668            this.is_terminated = true;
1669            return std::task::Poll::Ready(None);
1670        }
1671        if this.is_terminated {
1672            panic!("polled AudioRequestStream after completion");
1673        }
1674        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1675            |bytes, handles| {
1676                match this.inner.channel().read_etc(cx, bytes, handles) {
1677                    std::task::Poll::Ready(Ok(())) => {}
1678                    std::task::Poll::Pending => return std::task::Poll::Pending,
1679                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1680                        this.is_terminated = true;
1681                        return std::task::Poll::Ready(None);
1682                    }
1683                    std::task::Poll::Ready(Err(e)) => {
1684                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1685                            e.into(),
1686                        ))))
1687                    }
1688                }
1689
1690                // A message has been received from the channel
1691                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1692
1693                std::task::Poll::Ready(Some(match header.ordinal {
1694                    0x572f413566fd58f1 => {
1695                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1696                        let mut req = fidl::new_empty!(
1697                            AudioCreateAudioRendererRequest,
1698                            fidl::encoding::DefaultFuchsiaResourceDialect
1699                        );
1700                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCreateAudioRendererRequest>(&header, _body_bytes, handles, &mut req)?;
1701                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
1702                        Ok(AudioRequest::CreateAudioRenderer {
1703                            audio_renderer_request: req.audio_renderer_request,
1704
1705                            control_handle,
1706                        })
1707                    }
1708                    0x44660fc63a6202f => {
1709                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1710                        let mut req = fidl::new_empty!(
1711                            AudioCreateAudioCapturerRequest,
1712                            fidl::encoding::DefaultFuchsiaResourceDialect
1713                        );
1714                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCreateAudioCapturerRequest>(&header, _body_bytes, handles, &mut req)?;
1715                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
1716                        Ok(AudioRequest::CreateAudioCapturer {
1717                            audio_capturer_request: req.audio_capturer_request,
1718                            loopback: req.loopback,
1719
1720                            control_handle,
1721                        })
1722                    }
1723                    _ => Err(fidl::Error::UnknownOrdinal {
1724                        ordinal: header.ordinal,
1725                        protocol_name: <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1726                    }),
1727                }))
1728            },
1729        )
1730    }
1731}
1732
1733#[derive(Debug)]
1734pub enum AudioRequest {
1735    CreateAudioRenderer {
1736        audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1737        control_handle: AudioControlHandle,
1738    },
1739    /// Creates an AudioCapturer which either captures from the current default
1740    /// audio input device, or loops-back from the current default audio output
1741    /// device based on value passed for the loopback flag.
1742    CreateAudioCapturer {
1743        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1744        loopback: bool,
1745        control_handle: AudioControlHandle,
1746    },
1747}
1748
1749impl AudioRequest {
1750    #[allow(irrefutable_let_patterns)]
1751    pub fn into_create_audio_renderer(
1752        self,
1753    ) -> Option<(fidl::endpoints::ServerEnd<AudioRendererMarker>, AudioControlHandle)> {
1754        if let AudioRequest::CreateAudioRenderer { audio_renderer_request, control_handle } = self {
1755            Some((audio_renderer_request, control_handle))
1756        } else {
1757            None
1758        }
1759    }
1760
1761    #[allow(irrefutable_let_patterns)]
1762    pub fn into_create_audio_capturer(
1763        self,
1764    ) -> Option<(fidl::endpoints::ServerEnd<AudioCapturerMarker>, bool, AudioControlHandle)> {
1765        if let AudioRequest::CreateAudioCapturer {
1766            audio_capturer_request,
1767            loopback,
1768            control_handle,
1769        } = self
1770        {
1771            Some((audio_capturer_request, loopback, control_handle))
1772        } else {
1773            None
1774        }
1775    }
1776
1777    /// Name of the method defined in FIDL
1778    pub fn method_name(&self) -> &'static str {
1779        match *self {
1780            AudioRequest::CreateAudioRenderer { .. } => "create_audio_renderer",
1781            AudioRequest::CreateAudioCapturer { .. } => "create_audio_capturer",
1782        }
1783    }
1784}
1785
1786#[derive(Debug, Clone)]
1787pub struct AudioControlHandle {
1788    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1789}
1790
1791impl fidl::endpoints::ControlHandle for AudioControlHandle {
1792    fn shutdown(&self) {
1793        self.inner.shutdown()
1794    }
1795    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1796        self.inner.shutdown_with_epitaph(status)
1797    }
1798
1799    fn is_closed(&self) -> bool {
1800        self.inner.channel().is_closed()
1801    }
1802    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1803        self.inner.channel().on_closed()
1804    }
1805
1806    #[cfg(target_os = "fuchsia")]
1807    fn signal_peer(
1808        &self,
1809        clear_mask: zx::Signals,
1810        set_mask: zx::Signals,
1811    ) -> Result<(), zx_status::Status> {
1812        use fidl::Peered;
1813        self.inner.channel().signal_peer(clear_mask, set_mask)
1814    }
1815}
1816
1817impl AudioControlHandle {}
1818
1819#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1820pub struct AudioCapturerMarker;
1821
1822impl fidl::endpoints::ProtocolMarker for AudioCapturerMarker {
1823    type Proxy = AudioCapturerProxy;
1824    type RequestStream = AudioCapturerRequestStream;
1825    #[cfg(target_os = "fuchsia")]
1826    type SynchronousProxy = AudioCapturerSynchronousProxy;
1827
1828    const DEBUG_NAME: &'static str = "fuchsia.media.AudioCapturer";
1829}
1830impl fidl::endpoints::DiscoverableProtocolMarker for AudioCapturerMarker {}
1831
1832pub trait AudioCapturerProxyInterface: Send + Sync {
1833    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
1834    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
1835    fn r#release_packet(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
1836    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1837    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
1838    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
1839    fn r#set_pcm_stream_type(&self, stream_type: &AudioStreamType) -> Result<(), fidl::Error>;
1840    type CaptureAtResponseFut: std::future::Future<Output = Result<StreamPacket, fidl::Error>>
1841        + Send;
1842    fn r#capture_at(
1843        &self,
1844        payload_buffer_id: u32,
1845        payload_offset: u32,
1846        frames: u32,
1847    ) -> Self::CaptureAtResponseFut;
1848    fn r#start_async_capture(&self, frames_per_packet: u32) -> Result<(), fidl::Error>;
1849    type StopAsyncCaptureResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1850    fn r#stop_async_capture(&self) -> Self::StopAsyncCaptureResponseFut;
1851    fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error>;
1852    fn r#bind_gain_control(
1853        &self,
1854        gain_control_request: fidl::endpoints::ServerEnd<
1855            fidl_fuchsia_media_audio::GainControlMarker,
1856        >,
1857    ) -> Result<(), fidl::Error>;
1858    type GetReferenceClockResponseFut: std::future::Future<Output = Result<fidl::Clock, fidl::Error>>
1859        + Send;
1860    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
1861    fn r#set_reference_clock(
1862        &self,
1863        reference_clock: Option<fidl::Clock>,
1864    ) -> Result<(), fidl::Error>;
1865    fn r#set_usage(&self, usage: AudioCaptureUsage) -> Result<(), fidl::Error>;
1866    fn r#set_usage2(&self, usage: AudioCaptureUsage2) -> Result<(), fidl::Error>;
1867    type GetStreamTypeResponseFut: std::future::Future<Output = Result<StreamType, fidl::Error>>
1868        + Send;
1869    fn r#get_stream_type(&self) -> Self::GetStreamTypeResponseFut;
1870}
1871#[derive(Debug)]
1872#[cfg(target_os = "fuchsia")]
1873pub struct AudioCapturerSynchronousProxy {
1874    client: fidl::client::sync::Client,
1875}
1876
1877#[cfg(target_os = "fuchsia")]
1878impl fidl::endpoints::SynchronousProxy for AudioCapturerSynchronousProxy {
1879    type Proxy = AudioCapturerProxy;
1880    type Protocol = AudioCapturerMarker;
1881
1882    fn from_channel(inner: fidl::Channel) -> Self {
1883        Self::new(inner)
1884    }
1885
1886    fn into_channel(self) -> fidl::Channel {
1887        self.client.into_channel()
1888    }
1889
1890    fn as_channel(&self) -> &fidl::Channel {
1891        self.client.as_channel()
1892    }
1893}
1894
1895#[cfg(target_os = "fuchsia")]
1896impl AudioCapturerSynchronousProxy {
1897    pub fn new(channel: fidl::Channel) -> Self {
1898        let protocol_name = <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1899        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1900    }
1901
1902    pub fn into_channel(self) -> fidl::Channel {
1903        self.client.into_channel()
1904    }
1905
1906    /// Waits until an event arrives and returns it. It is safe for other
1907    /// threads to make concurrent requests while waiting for an event.
1908    pub fn wait_for_event(
1909        &self,
1910        deadline: zx::MonotonicInstant,
1911    ) -> Result<AudioCapturerEvent, fidl::Error> {
1912        AudioCapturerEvent::decode(self.client.wait_for_event(deadline)?)
1913    }
1914
1915    /// Adds a payload buffer to the current buffer set associated with the
1916    /// connection. A `StreamPacket` struct reference a payload buffer in the
1917    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
1918    ///
1919    /// A buffer with ID `id` must not be in the current set when this method is
1920    /// invoked, otherwise the service will close the connection.
1921    pub fn r#add_payload_buffer(
1922        &self,
1923        mut id: u32,
1924        mut payload_buffer: fidl::Vmo,
1925    ) -> Result<(), fidl::Error> {
1926        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
1927            (id, payload_buffer),
1928            0x3b3a37fc34fe5b56,
1929            fidl::encoding::DynamicFlags::empty(),
1930        )
1931    }
1932
1933    /// Removes a payload buffer from the current buffer set associated with the
1934    /// connection.
1935    ///
1936    /// A buffer with ID `id` must exist in the current set when this method is
1937    /// invoked, otherwise the service will will close the connection.
1938    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
1939        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
1940            (id,),
1941            0x5d1e4f74c3658262,
1942            fidl::encoding::DynamicFlags::empty(),
1943        )
1944    }
1945
1946    /// Releases payload memory associated with a packet previously delivered
1947    /// via `OnPacketProduced`.
1948    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
1949        self.client.send::<StreamSourceReleasePacketRequest>(
1950            (packet,),
1951            0x7a7b57f0f7d9e4bb,
1952            fidl::encoding::DynamicFlags::empty(),
1953        )
1954    }
1955
1956    pub fn r#discard_all_packets(
1957        &self,
1958        ___deadline: zx::MonotonicInstant,
1959    ) -> Result<(), fidl::Error> {
1960        let _response =
1961            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
1962                (),
1963                0x27afd605e97b09d2,
1964                fidl::encoding::DynamicFlags::empty(),
1965                ___deadline,
1966            )?;
1967        Ok(_response)
1968    }
1969
1970    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
1971        self.client.send::<fidl::encoding::EmptyPayload>(
1972            (),
1973            0x35f9d721e905b831,
1974            fidl::encoding::DynamicFlags::empty(),
1975        )
1976    }
1977
1978    /// Sets the stream type of the stream to be delivered. Causes the source
1979    /// material to be reformatted/resampled if needed in order to produce the
1980    /// requested stream type. Must be called before the payload buffer is
1981    /// established.
1982    pub fn r#set_pcm_stream_type(
1983        &self,
1984        mut stream_type: &AudioStreamType,
1985    ) -> Result<(), fidl::Error> {
1986        self.client.send::<AudioCapturerSetPcmStreamTypeRequest>(
1987            (stream_type,),
1988            0x1531ea9ea2c852cd,
1989            fidl::encoding::DynamicFlags::empty(),
1990        )
1991    }
1992
1993    /// Explicitly specifies a region of the shared payload buffer for the audio
1994    /// input to capture into.
1995    pub fn r#capture_at(
1996        &self,
1997        mut payload_buffer_id: u32,
1998        mut payload_offset: u32,
1999        mut frames: u32,
2000        ___deadline: zx::MonotonicInstant,
2001    ) -> Result<StreamPacket, fidl::Error> {
2002        let _response = self
2003            .client
2004            .send_query::<AudioCapturerCaptureAtRequest, AudioCapturerCaptureAtResponse>(
2005                (payload_buffer_id, payload_offset, frames),
2006                0x784e25df72cea780,
2007                fidl::encoding::DynamicFlags::empty(),
2008                ___deadline,
2009            )?;
2010        Ok(_response.captured_packet)
2011    }
2012
2013    /// Places the AudioCapturer into 'async' capture mode and begin to produce
2014    /// packets of exactly 'frames_per_packet' number of frames each. The
2015    /// OnPacketProduced event (of StreamSink) will be used to inform the client
2016    /// of produced packets.
2017    pub fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
2018        self.client.send::<AudioCapturerStartAsyncCaptureRequest>(
2019            (frames_per_packet,),
2020            0x7768adbb1ccfd7a6,
2021            fidl::encoding::DynamicFlags::empty(),
2022        )
2023    }
2024
2025    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
2026    /// that may be used by the client if explicit synchronization is needed.
2027    pub fn r#stop_async_capture(
2028        &self,
2029        ___deadline: zx::MonotonicInstant,
2030    ) -> Result<(), fidl::Error> {
2031        let _response =
2032            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
2033                (),
2034                0x5bfc8790a8cef8cb,
2035                fidl::encoding::DynamicFlags::empty(),
2036                ___deadline,
2037            )?;
2038        Ok(_response)
2039    }
2040
2041    pub fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
2042        self.client.send::<fidl::encoding::EmptyPayload>(
2043            (),
2044            0x33223cb2962c95e3,
2045            fidl::encoding::DynamicFlags::empty(),
2046        )
2047    }
2048
2049    /// Binds to the gain control for this AudioCapturer.
2050    pub fn r#bind_gain_control(
2051        &self,
2052        mut gain_control_request: fidl::endpoints::ServerEnd<
2053            fidl_fuchsia_media_audio::GainControlMarker,
2054        >,
2055    ) -> Result<(), fidl::Error> {
2056        self.client.send::<AudioCapturerBindGainControlRequest>(
2057            (gain_control_request,),
2058            0x658a6a17ddb3a8e0,
2059            fidl::encoding::DynamicFlags::empty(),
2060        )
2061    }
2062
2063    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
2064    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
2065    pub fn r#get_reference_clock(
2066        &self,
2067        ___deadline: zx::MonotonicInstant,
2068    ) -> Result<fidl::Clock, fidl::Error> {
2069        let _response = self
2070            .client
2071            .send_query::<fidl::encoding::EmptyPayload, AudioCapturerGetReferenceClockResponse>(
2072                (),
2073                0x50d037aa5a4b4d71,
2074                fidl::encoding::DynamicFlags::empty(),
2075                ___deadline,
2076            )?;
2077        Ok(_response.reference_clock)
2078    }
2079
2080    /// Sets the reference clock that controls this capturer's playback rate. If the input
2081    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
2082    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
2083    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
2084    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
2085    ///
2086    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
2087    /// added. It also cannot be called a second time (even before capture).
2088    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
2089    /// diverge at some later time, they should create a clone of the monotonic clock, set
2090    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
2091    pub fn r#set_reference_clock(
2092        &self,
2093        mut reference_clock: Option<fidl::Clock>,
2094    ) -> Result<(), fidl::Error> {
2095        self.client.send::<AudioCapturerSetReferenceClockRequest>(
2096            (reference_clock,),
2097            0x732b2c496d521bcf,
2098            fidl::encoding::DynamicFlags::empty(),
2099        )
2100    }
2101
2102    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
2103    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
2104    pub fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2105        self.client.send::<AudioCapturerSetUsageRequest>(
2106            (usage,),
2107            0x42a16f392bd21b25,
2108            fidl::encoding::DynamicFlags::empty(),
2109        )
2110    }
2111
2112    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
2113    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
2114    pub fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2115        self.client.send::<AudioCapturerSetUsage2Request>(
2116            (usage,),
2117            0x7a73e251b8d2382b,
2118            fidl::encoding::DynamicFlags::FLEXIBLE,
2119        )
2120    }
2121
2122    /// Gets the currently configured stream type. Note: for an AudioCapturer
2123    /// which was just created and has not yet had its stream type explicitly
2124    /// set, this will retrieve the stream type -- at the time the AudioCapturer
2125    /// was created -- of the source (input or looped-back output) to which the
2126    /// AudioCapturer is bound. Even if this matches the client's desired format,
2127    /// `SetPcmStreamType` must still be called.
2128    pub fn r#get_stream_type(
2129        &self,
2130        ___deadline: zx::MonotonicInstant,
2131    ) -> Result<StreamType, fidl::Error> {
2132        let _response = self
2133            .client
2134            .send_query::<fidl::encoding::EmptyPayload, AudioCapturerGetStreamTypeResponse>(
2135                (),
2136                0x5dcaaa670b433088,
2137                fidl::encoding::DynamicFlags::empty(),
2138                ___deadline,
2139            )?;
2140        Ok(_response.stream_type)
2141    }
2142}
2143
2144#[cfg(target_os = "fuchsia")]
2145impl From<AudioCapturerSynchronousProxy> for zx::Handle {
2146    fn from(value: AudioCapturerSynchronousProxy) -> Self {
2147        value.into_channel().into()
2148    }
2149}
2150
2151#[cfg(target_os = "fuchsia")]
2152impl From<fidl::Channel> for AudioCapturerSynchronousProxy {
2153    fn from(value: fidl::Channel) -> Self {
2154        Self::new(value)
2155    }
2156}
2157
2158#[cfg(target_os = "fuchsia")]
2159impl fidl::endpoints::FromClient for AudioCapturerSynchronousProxy {
2160    type Protocol = AudioCapturerMarker;
2161
2162    fn from_client(value: fidl::endpoints::ClientEnd<AudioCapturerMarker>) -> Self {
2163        Self::new(value.into_channel())
2164    }
2165}
2166
2167#[derive(Debug, Clone)]
2168pub struct AudioCapturerProxy {
2169    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2170}
2171
2172impl fidl::endpoints::Proxy for AudioCapturerProxy {
2173    type Protocol = AudioCapturerMarker;
2174
2175    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2176        Self::new(inner)
2177    }
2178
2179    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2180        self.client.into_channel().map_err(|client| Self { client })
2181    }
2182
2183    fn as_channel(&self) -> &::fidl::AsyncChannel {
2184        self.client.as_channel()
2185    }
2186}
2187
2188impl AudioCapturerProxy {
2189    /// Create a new Proxy for fuchsia.media/AudioCapturer.
2190    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2191        let protocol_name = <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2192        Self { client: fidl::client::Client::new(channel, protocol_name) }
2193    }
2194
2195    /// Get a Stream of events from the remote end of the protocol.
2196    ///
2197    /// # Panics
2198    ///
2199    /// Panics if the event stream was already taken.
2200    pub fn take_event_stream(&self) -> AudioCapturerEventStream {
2201        AudioCapturerEventStream { event_receiver: self.client.take_event_receiver() }
2202    }
2203
2204    /// Adds a payload buffer to the current buffer set associated with the
2205    /// connection. A `StreamPacket` struct reference a payload buffer in the
2206    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
2207    ///
2208    /// A buffer with ID `id` must not be in the current set when this method is
2209    /// invoked, otherwise the service will close the connection.
2210    pub fn r#add_payload_buffer(
2211        &self,
2212        mut id: u32,
2213        mut payload_buffer: fidl::Vmo,
2214    ) -> Result<(), fidl::Error> {
2215        AudioCapturerProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
2216    }
2217
2218    /// Removes a payload buffer from the current buffer set associated with the
2219    /// connection.
2220    ///
2221    /// A buffer with ID `id` must exist in the current set when this method is
2222    /// invoked, otherwise the service will will close the connection.
2223    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
2224        AudioCapturerProxyInterface::r#remove_payload_buffer(self, id)
2225    }
2226
2227    /// Releases payload memory associated with a packet previously delivered
2228    /// via `OnPacketProduced`.
2229    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
2230        AudioCapturerProxyInterface::r#release_packet(self, packet)
2231    }
2232
2233    pub fn r#discard_all_packets(
2234        &self,
2235    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2236        AudioCapturerProxyInterface::r#discard_all_packets(self)
2237    }
2238
2239    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
2240        AudioCapturerProxyInterface::r#discard_all_packets_no_reply(self)
2241    }
2242
2243    /// Sets the stream type of the stream to be delivered. Causes the source
2244    /// material to be reformatted/resampled if needed in order to produce the
2245    /// requested stream type. Must be called before the payload buffer is
2246    /// established.
2247    pub fn r#set_pcm_stream_type(
2248        &self,
2249        mut stream_type: &AudioStreamType,
2250    ) -> Result<(), fidl::Error> {
2251        AudioCapturerProxyInterface::r#set_pcm_stream_type(self, stream_type)
2252    }
2253
2254    /// Explicitly specifies a region of the shared payload buffer for the audio
2255    /// input to capture into.
2256    pub fn r#capture_at(
2257        &self,
2258        mut payload_buffer_id: u32,
2259        mut payload_offset: u32,
2260        mut frames: u32,
2261    ) -> fidl::client::QueryResponseFut<StreamPacket, fidl::encoding::DefaultFuchsiaResourceDialect>
2262    {
2263        AudioCapturerProxyInterface::r#capture_at(self, payload_buffer_id, payload_offset, frames)
2264    }
2265
2266    /// Places the AudioCapturer into 'async' capture mode and begin to produce
2267    /// packets of exactly 'frames_per_packet' number of frames each. The
2268    /// OnPacketProduced event (of StreamSink) will be used to inform the client
2269    /// of produced packets.
2270    pub fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
2271        AudioCapturerProxyInterface::r#start_async_capture(self, frames_per_packet)
2272    }
2273
2274    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
2275    /// that may be used by the client if explicit synchronization is needed.
2276    pub fn r#stop_async_capture(
2277        &self,
2278    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2279        AudioCapturerProxyInterface::r#stop_async_capture(self)
2280    }
2281
2282    pub fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
2283        AudioCapturerProxyInterface::r#stop_async_capture_no_reply(self)
2284    }
2285
2286    /// Binds to the gain control for this AudioCapturer.
2287    pub fn r#bind_gain_control(
2288        &self,
2289        mut gain_control_request: fidl::endpoints::ServerEnd<
2290            fidl_fuchsia_media_audio::GainControlMarker,
2291        >,
2292    ) -> Result<(), fidl::Error> {
2293        AudioCapturerProxyInterface::r#bind_gain_control(self, gain_control_request)
2294    }
2295
2296    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
2297    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
2298    pub fn r#get_reference_clock(
2299        &self,
2300    ) -> fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>
2301    {
2302        AudioCapturerProxyInterface::r#get_reference_clock(self)
2303    }
2304
2305    /// Sets the reference clock that controls this capturer's playback rate. If the input
2306    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
2307    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
2308    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
2309    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
2310    ///
2311    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
2312    /// added. It also cannot be called a second time (even before capture).
2313    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
2314    /// diverge at some later time, they should create a clone of the monotonic clock, set
2315    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
2316    pub fn r#set_reference_clock(
2317        &self,
2318        mut reference_clock: Option<fidl::Clock>,
2319    ) -> Result<(), fidl::Error> {
2320        AudioCapturerProxyInterface::r#set_reference_clock(self, reference_clock)
2321    }
2322
2323    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
2324    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
2325    pub fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2326        AudioCapturerProxyInterface::r#set_usage(self, usage)
2327    }
2328
2329    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
2330    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
2331    pub fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2332        AudioCapturerProxyInterface::r#set_usage2(self, usage)
2333    }
2334
2335    /// Gets the currently configured stream type. Note: for an AudioCapturer
2336    /// which was just created and has not yet had its stream type explicitly
2337    /// set, this will retrieve the stream type -- at the time the AudioCapturer
2338    /// was created -- of the source (input or looped-back output) to which the
2339    /// AudioCapturer is bound. Even if this matches the client's desired format,
2340    /// `SetPcmStreamType` must still be called.
2341    pub fn r#get_stream_type(
2342        &self,
2343    ) -> fidl::client::QueryResponseFut<StreamType, fidl::encoding::DefaultFuchsiaResourceDialect>
2344    {
2345        AudioCapturerProxyInterface::r#get_stream_type(self)
2346    }
2347}
2348
2349impl AudioCapturerProxyInterface for AudioCapturerProxy {
2350    fn r#add_payload_buffer(
2351        &self,
2352        mut id: u32,
2353        mut payload_buffer: fidl::Vmo,
2354    ) -> Result<(), fidl::Error> {
2355        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
2356            (id, payload_buffer),
2357            0x3b3a37fc34fe5b56,
2358            fidl::encoding::DynamicFlags::empty(),
2359        )
2360    }
2361
2362    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
2363        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
2364            (id,),
2365            0x5d1e4f74c3658262,
2366            fidl::encoding::DynamicFlags::empty(),
2367        )
2368    }
2369
2370    fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
2371        self.client.send::<StreamSourceReleasePacketRequest>(
2372            (packet,),
2373            0x7a7b57f0f7d9e4bb,
2374            fidl::encoding::DynamicFlags::empty(),
2375        )
2376    }
2377
2378    type DiscardAllPacketsResponseFut =
2379        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2380    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
2381        fn _decode(
2382            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2383        ) -> Result<(), fidl::Error> {
2384            let _response = fidl::client::decode_transaction_body::<
2385                fidl::encoding::EmptyPayload,
2386                fidl::encoding::DefaultFuchsiaResourceDialect,
2387                0x27afd605e97b09d2,
2388            >(_buf?)?;
2389            Ok(_response)
2390        }
2391        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2392            (),
2393            0x27afd605e97b09d2,
2394            fidl::encoding::DynamicFlags::empty(),
2395            _decode,
2396        )
2397    }
2398
2399    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
2400        self.client.send::<fidl::encoding::EmptyPayload>(
2401            (),
2402            0x35f9d721e905b831,
2403            fidl::encoding::DynamicFlags::empty(),
2404        )
2405    }
2406
2407    fn r#set_pcm_stream_type(&self, mut stream_type: &AudioStreamType) -> Result<(), fidl::Error> {
2408        self.client.send::<AudioCapturerSetPcmStreamTypeRequest>(
2409            (stream_type,),
2410            0x1531ea9ea2c852cd,
2411            fidl::encoding::DynamicFlags::empty(),
2412        )
2413    }
2414
2415    type CaptureAtResponseFut =
2416        fidl::client::QueryResponseFut<StreamPacket, fidl::encoding::DefaultFuchsiaResourceDialect>;
2417    fn r#capture_at(
2418        &self,
2419        mut payload_buffer_id: u32,
2420        mut payload_offset: u32,
2421        mut frames: u32,
2422    ) -> Self::CaptureAtResponseFut {
2423        fn _decode(
2424            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2425        ) -> Result<StreamPacket, fidl::Error> {
2426            let _response = fidl::client::decode_transaction_body::<
2427                AudioCapturerCaptureAtResponse,
2428                fidl::encoding::DefaultFuchsiaResourceDialect,
2429                0x784e25df72cea780,
2430            >(_buf?)?;
2431            Ok(_response.captured_packet)
2432        }
2433        self.client.send_query_and_decode::<AudioCapturerCaptureAtRequest, StreamPacket>(
2434            (payload_buffer_id, payload_offset, frames),
2435            0x784e25df72cea780,
2436            fidl::encoding::DynamicFlags::empty(),
2437            _decode,
2438        )
2439    }
2440
2441    fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
2442        self.client.send::<AudioCapturerStartAsyncCaptureRequest>(
2443            (frames_per_packet,),
2444            0x7768adbb1ccfd7a6,
2445            fidl::encoding::DynamicFlags::empty(),
2446        )
2447    }
2448
2449    type StopAsyncCaptureResponseFut =
2450        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2451    fn r#stop_async_capture(&self) -> Self::StopAsyncCaptureResponseFut {
2452        fn _decode(
2453            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2454        ) -> Result<(), fidl::Error> {
2455            let _response = fidl::client::decode_transaction_body::<
2456                fidl::encoding::EmptyPayload,
2457                fidl::encoding::DefaultFuchsiaResourceDialect,
2458                0x5bfc8790a8cef8cb,
2459            >(_buf?)?;
2460            Ok(_response)
2461        }
2462        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2463            (),
2464            0x5bfc8790a8cef8cb,
2465            fidl::encoding::DynamicFlags::empty(),
2466            _decode,
2467        )
2468    }
2469
2470    fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
2471        self.client.send::<fidl::encoding::EmptyPayload>(
2472            (),
2473            0x33223cb2962c95e3,
2474            fidl::encoding::DynamicFlags::empty(),
2475        )
2476    }
2477
2478    fn r#bind_gain_control(
2479        &self,
2480        mut gain_control_request: fidl::endpoints::ServerEnd<
2481            fidl_fuchsia_media_audio::GainControlMarker,
2482        >,
2483    ) -> Result<(), fidl::Error> {
2484        self.client.send::<AudioCapturerBindGainControlRequest>(
2485            (gain_control_request,),
2486            0x658a6a17ddb3a8e0,
2487            fidl::encoding::DynamicFlags::empty(),
2488        )
2489    }
2490
2491    type GetReferenceClockResponseFut =
2492        fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>;
2493    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
2494        fn _decode(
2495            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2496        ) -> Result<fidl::Clock, fidl::Error> {
2497            let _response = fidl::client::decode_transaction_body::<
2498                AudioCapturerGetReferenceClockResponse,
2499                fidl::encoding::DefaultFuchsiaResourceDialect,
2500                0x50d037aa5a4b4d71,
2501            >(_buf?)?;
2502            Ok(_response.reference_clock)
2503        }
2504        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Clock>(
2505            (),
2506            0x50d037aa5a4b4d71,
2507            fidl::encoding::DynamicFlags::empty(),
2508            _decode,
2509        )
2510    }
2511
2512    fn r#set_reference_clock(
2513        &self,
2514        mut reference_clock: Option<fidl::Clock>,
2515    ) -> Result<(), fidl::Error> {
2516        self.client.send::<AudioCapturerSetReferenceClockRequest>(
2517            (reference_clock,),
2518            0x732b2c496d521bcf,
2519            fidl::encoding::DynamicFlags::empty(),
2520        )
2521    }
2522
2523    fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2524        self.client.send::<AudioCapturerSetUsageRequest>(
2525            (usage,),
2526            0x42a16f392bd21b25,
2527            fidl::encoding::DynamicFlags::empty(),
2528        )
2529    }
2530
2531    fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2532        self.client.send::<AudioCapturerSetUsage2Request>(
2533            (usage,),
2534            0x7a73e251b8d2382b,
2535            fidl::encoding::DynamicFlags::FLEXIBLE,
2536        )
2537    }
2538
2539    type GetStreamTypeResponseFut =
2540        fidl::client::QueryResponseFut<StreamType, fidl::encoding::DefaultFuchsiaResourceDialect>;
2541    fn r#get_stream_type(&self) -> Self::GetStreamTypeResponseFut {
2542        fn _decode(
2543            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2544        ) -> Result<StreamType, fidl::Error> {
2545            let _response = fidl::client::decode_transaction_body::<
2546                AudioCapturerGetStreamTypeResponse,
2547                fidl::encoding::DefaultFuchsiaResourceDialect,
2548                0x5dcaaa670b433088,
2549            >(_buf?)?;
2550            Ok(_response.stream_type)
2551        }
2552        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, StreamType>(
2553            (),
2554            0x5dcaaa670b433088,
2555            fidl::encoding::DynamicFlags::empty(),
2556            _decode,
2557        )
2558    }
2559}
2560
2561pub struct AudioCapturerEventStream {
2562    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2563}
2564
2565impl std::marker::Unpin for AudioCapturerEventStream {}
2566
2567impl futures::stream::FusedStream for AudioCapturerEventStream {
2568    fn is_terminated(&self) -> bool {
2569        self.event_receiver.is_terminated()
2570    }
2571}
2572
2573impl futures::Stream for AudioCapturerEventStream {
2574    type Item = Result<AudioCapturerEvent, fidl::Error>;
2575
2576    fn poll_next(
2577        mut self: std::pin::Pin<&mut Self>,
2578        cx: &mut std::task::Context<'_>,
2579    ) -> std::task::Poll<Option<Self::Item>> {
2580        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2581            &mut self.event_receiver,
2582            cx
2583        )?) {
2584            Some(buf) => std::task::Poll::Ready(Some(AudioCapturerEvent::decode(buf))),
2585            None => std::task::Poll::Ready(None),
2586        }
2587    }
2588}
2589
2590#[derive(Debug)]
2591pub enum AudioCapturerEvent {
2592    OnPacketProduced {
2593        packet: StreamPacket,
2594    },
2595    OnEndOfStream {},
2596    #[non_exhaustive]
2597    _UnknownEvent {
2598        /// Ordinal of the event that was sent.
2599        ordinal: u64,
2600    },
2601}
2602
2603impl AudioCapturerEvent {
2604    #[allow(irrefutable_let_patterns)]
2605    pub fn into_on_packet_produced(self) -> Option<StreamPacket> {
2606        if let AudioCapturerEvent::OnPacketProduced { packet } = self {
2607            Some((packet))
2608        } else {
2609            None
2610        }
2611    }
2612    #[allow(irrefutable_let_patterns)]
2613    pub fn into_on_end_of_stream(self) -> Option<()> {
2614        if let AudioCapturerEvent::OnEndOfStream {} = self {
2615            Some(())
2616        } else {
2617            None
2618        }
2619    }
2620
2621    /// Decodes a message buffer as a [`AudioCapturerEvent`].
2622    fn decode(
2623        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2624    ) -> Result<AudioCapturerEvent, fidl::Error> {
2625        let (bytes, _handles) = buf.split_mut();
2626        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2627        debug_assert_eq!(tx_header.tx_id, 0);
2628        match tx_header.ordinal {
2629            0x6bbe69746a3c8bd9 => {
2630                let mut out = fidl::new_empty!(
2631                    StreamSourceOnPacketProducedRequest,
2632                    fidl::encoding::DefaultFuchsiaResourceDialect
2633                );
2634                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2635                Ok((AudioCapturerEvent::OnPacketProduced { packet: out.packet }))
2636            }
2637            0x550e69b41d03e2c2 => {
2638                let mut out = fidl::new_empty!(
2639                    fidl::encoding::EmptyPayload,
2640                    fidl::encoding::DefaultFuchsiaResourceDialect
2641                );
2642                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
2643                Ok((AudioCapturerEvent::OnEndOfStream {}))
2644            }
2645            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2646                Ok(AudioCapturerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2647            }
2648            _ => Err(fidl::Error::UnknownOrdinal {
2649                ordinal: tx_header.ordinal,
2650                protocol_name: <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2651            }),
2652        }
2653    }
2654}
2655
2656/// A Stream of incoming requests for fuchsia.media/AudioCapturer.
2657pub struct AudioCapturerRequestStream {
2658    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2659    is_terminated: bool,
2660}
2661
2662impl std::marker::Unpin for AudioCapturerRequestStream {}
2663
2664impl futures::stream::FusedStream for AudioCapturerRequestStream {
2665    fn is_terminated(&self) -> bool {
2666        self.is_terminated
2667    }
2668}
2669
2670impl fidl::endpoints::RequestStream for AudioCapturerRequestStream {
2671    type Protocol = AudioCapturerMarker;
2672    type ControlHandle = AudioCapturerControlHandle;
2673
2674    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2675        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2676    }
2677
2678    fn control_handle(&self) -> Self::ControlHandle {
2679        AudioCapturerControlHandle { inner: self.inner.clone() }
2680    }
2681
2682    fn into_inner(
2683        self,
2684    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2685    {
2686        (self.inner, self.is_terminated)
2687    }
2688
2689    fn from_inner(
2690        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2691        is_terminated: bool,
2692    ) -> Self {
2693        Self { inner, is_terminated }
2694    }
2695}
2696
2697impl futures::Stream for AudioCapturerRequestStream {
2698    type Item = Result<AudioCapturerRequest, fidl::Error>;
2699
2700    fn poll_next(
2701        mut self: std::pin::Pin<&mut Self>,
2702        cx: &mut std::task::Context<'_>,
2703    ) -> std::task::Poll<Option<Self::Item>> {
2704        let this = &mut *self;
2705        if this.inner.check_shutdown(cx) {
2706            this.is_terminated = true;
2707            return std::task::Poll::Ready(None);
2708        }
2709        if this.is_terminated {
2710            panic!("polled AudioCapturerRequestStream after completion");
2711        }
2712        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2713            |bytes, handles| {
2714                match this.inner.channel().read_etc(cx, bytes, handles) {
2715                    std::task::Poll::Ready(Ok(())) => {}
2716                    std::task::Poll::Pending => return std::task::Poll::Pending,
2717                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2718                        this.is_terminated = true;
2719                        return std::task::Poll::Ready(None);
2720                    }
2721                    std::task::Poll::Ready(Err(e)) => {
2722                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2723                            e.into(),
2724                        ))))
2725                    }
2726                }
2727
2728                // A message has been received from the channel
2729                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2730
2731                std::task::Poll::Ready(Some(match header.ordinal {
2732                    0x3b3a37fc34fe5b56 => {
2733                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2734                        let mut req = fidl::new_empty!(
2735                            StreamBufferSetAddPayloadBufferRequest,
2736                            fidl::encoding::DefaultFuchsiaResourceDialect
2737                        );
2738                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
2739                        let control_handle =
2740                            AudioCapturerControlHandle { inner: this.inner.clone() };
2741                        Ok(AudioCapturerRequest::AddPayloadBuffer {
2742                            id: req.id,
2743                            payload_buffer: req.payload_buffer,
2744
2745                            control_handle,
2746                        })
2747                    }
2748                    0x5d1e4f74c3658262 => {
2749                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2750                        let mut req = fidl::new_empty!(
2751                            StreamBufferSetRemovePayloadBufferRequest,
2752                            fidl::encoding::DefaultFuchsiaResourceDialect
2753                        );
2754                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
2755                        let control_handle =
2756                            AudioCapturerControlHandle { inner: this.inner.clone() };
2757                        Ok(AudioCapturerRequest::RemovePayloadBuffer { id: req.id, control_handle })
2758                    }
2759                    0x7a7b57f0f7d9e4bb => {
2760                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2761                        let mut req = fidl::new_empty!(
2762                            StreamSourceReleasePacketRequest,
2763                            fidl::encoding::DefaultFuchsiaResourceDialect
2764                        );
2765                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
2766                        let control_handle =
2767                            AudioCapturerControlHandle { inner: this.inner.clone() };
2768                        Ok(AudioCapturerRequest::ReleasePacket {
2769                            packet: req.packet,
2770
2771                            control_handle,
2772                        })
2773                    }
2774                    0x27afd605e97b09d2 => {
2775                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2776                        let mut req = fidl::new_empty!(
2777                            fidl::encoding::EmptyPayload,
2778                            fidl::encoding::DefaultFuchsiaResourceDialect
2779                        );
2780                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2781                        let control_handle =
2782                            AudioCapturerControlHandle { inner: this.inner.clone() };
2783                        Ok(AudioCapturerRequest::DiscardAllPackets {
2784                            responder: AudioCapturerDiscardAllPacketsResponder {
2785                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2786                                tx_id: header.tx_id,
2787                            },
2788                        })
2789                    }
2790                    0x35f9d721e905b831 => {
2791                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2792                        let mut req = fidl::new_empty!(
2793                            fidl::encoding::EmptyPayload,
2794                            fidl::encoding::DefaultFuchsiaResourceDialect
2795                        );
2796                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2797                        let control_handle =
2798                            AudioCapturerControlHandle { inner: this.inner.clone() };
2799                        Ok(AudioCapturerRequest::DiscardAllPacketsNoReply { control_handle })
2800                    }
2801                    0x1531ea9ea2c852cd => {
2802                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2803                        let mut req = fidl::new_empty!(
2804                            AudioCapturerSetPcmStreamTypeRequest,
2805                            fidl::encoding::DefaultFuchsiaResourceDialect
2806                        );
2807                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetPcmStreamTypeRequest>(&header, _body_bytes, handles, &mut req)?;
2808                        let control_handle =
2809                            AudioCapturerControlHandle { inner: this.inner.clone() };
2810                        Ok(AudioCapturerRequest::SetPcmStreamType {
2811                            stream_type: req.stream_type,
2812
2813                            control_handle,
2814                        })
2815                    }
2816                    0x784e25df72cea780 => {
2817                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2818                        let mut req = fidl::new_empty!(
2819                            AudioCapturerCaptureAtRequest,
2820                            fidl::encoding::DefaultFuchsiaResourceDialect
2821                        );
2822                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerCaptureAtRequest>(&header, _body_bytes, handles, &mut req)?;
2823                        let control_handle =
2824                            AudioCapturerControlHandle { inner: this.inner.clone() };
2825                        Ok(AudioCapturerRequest::CaptureAt {
2826                            payload_buffer_id: req.payload_buffer_id,
2827                            payload_offset: req.payload_offset,
2828                            frames: req.frames,
2829
2830                            responder: AudioCapturerCaptureAtResponder {
2831                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2832                                tx_id: header.tx_id,
2833                            },
2834                        })
2835                    }
2836                    0x7768adbb1ccfd7a6 => {
2837                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2838                        let mut req = fidl::new_empty!(
2839                            AudioCapturerStartAsyncCaptureRequest,
2840                            fidl::encoding::DefaultFuchsiaResourceDialect
2841                        );
2842                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerStartAsyncCaptureRequest>(&header, _body_bytes, handles, &mut req)?;
2843                        let control_handle =
2844                            AudioCapturerControlHandle { inner: this.inner.clone() };
2845                        Ok(AudioCapturerRequest::StartAsyncCapture {
2846                            frames_per_packet: req.frames_per_packet,
2847
2848                            control_handle,
2849                        })
2850                    }
2851                    0x5bfc8790a8cef8cb => {
2852                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2853                        let mut req = fidl::new_empty!(
2854                            fidl::encoding::EmptyPayload,
2855                            fidl::encoding::DefaultFuchsiaResourceDialect
2856                        );
2857                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2858                        let control_handle =
2859                            AudioCapturerControlHandle { inner: this.inner.clone() };
2860                        Ok(AudioCapturerRequest::StopAsyncCapture {
2861                            responder: AudioCapturerStopAsyncCaptureResponder {
2862                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2863                                tx_id: header.tx_id,
2864                            },
2865                        })
2866                    }
2867                    0x33223cb2962c95e3 => {
2868                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2869                        let mut req = fidl::new_empty!(
2870                            fidl::encoding::EmptyPayload,
2871                            fidl::encoding::DefaultFuchsiaResourceDialect
2872                        );
2873                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2874                        let control_handle =
2875                            AudioCapturerControlHandle { inner: this.inner.clone() };
2876                        Ok(AudioCapturerRequest::StopAsyncCaptureNoReply { control_handle })
2877                    }
2878                    0x658a6a17ddb3a8e0 => {
2879                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2880                        let mut req = fidl::new_empty!(
2881                            AudioCapturerBindGainControlRequest,
2882                            fidl::encoding::DefaultFuchsiaResourceDialect
2883                        );
2884                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerBindGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
2885                        let control_handle =
2886                            AudioCapturerControlHandle { inner: this.inner.clone() };
2887                        Ok(AudioCapturerRequest::BindGainControl {
2888                            gain_control_request: req.gain_control_request,
2889
2890                            control_handle,
2891                        })
2892                    }
2893                    0x50d037aa5a4b4d71 => {
2894                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2895                        let mut req = fidl::new_empty!(
2896                            fidl::encoding::EmptyPayload,
2897                            fidl::encoding::DefaultFuchsiaResourceDialect
2898                        );
2899                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2900                        let control_handle =
2901                            AudioCapturerControlHandle { inner: this.inner.clone() };
2902                        Ok(AudioCapturerRequest::GetReferenceClock {
2903                            responder: AudioCapturerGetReferenceClockResponder {
2904                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2905                                tx_id: header.tx_id,
2906                            },
2907                        })
2908                    }
2909                    0x732b2c496d521bcf => {
2910                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2911                        let mut req = fidl::new_empty!(
2912                            AudioCapturerSetReferenceClockRequest,
2913                            fidl::encoding::DefaultFuchsiaResourceDialect
2914                        );
2915                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetReferenceClockRequest>(&header, _body_bytes, handles, &mut req)?;
2916                        let control_handle =
2917                            AudioCapturerControlHandle { inner: this.inner.clone() };
2918                        Ok(AudioCapturerRequest::SetReferenceClock {
2919                            reference_clock: req.reference_clock,
2920
2921                            control_handle,
2922                        })
2923                    }
2924                    0x42a16f392bd21b25 => {
2925                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2926                        let mut req = fidl::new_empty!(
2927                            AudioCapturerSetUsageRequest,
2928                            fidl::encoding::DefaultFuchsiaResourceDialect
2929                        );
2930                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetUsageRequest>(&header, _body_bytes, handles, &mut req)?;
2931                        let control_handle =
2932                            AudioCapturerControlHandle { inner: this.inner.clone() };
2933                        Ok(AudioCapturerRequest::SetUsage { usage: req.usage, control_handle })
2934                    }
2935                    0x7a73e251b8d2382b => {
2936                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2937                        let mut req = fidl::new_empty!(
2938                            AudioCapturerSetUsage2Request,
2939                            fidl::encoding::DefaultFuchsiaResourceDialect
2940                        );
2941                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetUsage2Request>(&header, _body_bytes, handles, &mut req)?;
2942                        let control_handle =
2943                            AudioCapturerControlHandle { inner: this.inner.clone() };
2944                        Ok(AudioCapturerRequest::SetUsage2 { usage: req.usage, control_handle })
2945                    }
2946                    0x5dcaaa670b433088 => {
2947                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2948                        let mut req = fidl::new_empty!(
2949                            fidl::encoding::EmptyPayload,
2950                            fidl::encoding::DefaultFuchsiaResourceDialect
2951                        );
2952                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2953                        let control_handle =
2954                            AudioCapturerControlHandle { inner: this.inner.clone() };
2955                        Ok(AudioCapturerRequest::GetStreamType {
2956                            responder: AudioCapturerGetStreamTypeResponder {
2957                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2958                                tx_id: header.tx_id,
2959                            },
2960                        })
2961                    }
2962                    _ if header.tx_id == 0
2963                        && header
2964                            .dynamic_flags()
2965                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2966                    {
2967                        Ok(AudioCapturerRequest::_UnknownMethod {
2968                            ordinal: header.ordinal,
2969                            control_handle: AudioCapturerControlHandle {
2970                                inner: this.inner.clone(),
2971                            },
2972                            method_type: fidl::MethodType::OneWay,
2973                        })
2974                    }
2975                    _ if header
2976                        .dynamic_flags()
2977                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2978                    {
2979                        this.inner.send_framework_err(
2980                            fidl::encoding::FrameworkErr::UnknownMethod,
2981                            header.tx_id,
2982                            header.ordinal,
2983                            header.dynamic_flags(),
2984                            (bytes, handles),
2985                        )?;
2986                        Ok(AudioCapturerRequest::_UnknownMethod {
2987                            ordinal: header.ordinal,
2988                            control_handle: AudioCapturerControlHandle {
2989                                inner: this.inner.clone(),
2990                            },
2991                            method_type: fidl::MethodType::TwoWay,
2992                        })
2993                    }
2994                    _ => Err(fidl::Error::UnknownOrdinal {
2995                        ordinal: header.ordinal,
2996                        protocol_name:
2997                            <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2998                    }),
2999                }))
3000            },
3001        )
3002    }
3003}
3004
3005/// AudioCapturer
3006///
3007/// An AudioCapturer is an interface returned from an fuchsia.media.Audio's
3008/// CreateAudioCapturer method, which may be used by clients to capture audio
3009/// from either the current default audio input device, or the current default
3010/// audio output device depending on the flags passed during creation.
3011///
3012/// **Format support**
3013///
3014/// See (Get|Set)StreamType below. By default, the captured stream type will be
3015/// initially determined by the currently configured stream type of the source
3016/// that the AudioCapturer was bound to at creation time. Users may either fetch
3017/// this type using GetStreamType, or they may choose to have the media
3018/// resampled or converted to a type of their choosing by calling SetStreamType.
3019/// Note: the stream type may only be set while the system is not running,
3020/// meaning that there are no pending capture regions (specified using CaptureAt)
3021/// and that the system is not currently running in 'async' capture mode.
3022///
3023/// **Buffers and memory management**
3024///
3025/// Audio data is captured into a shared memory buffer (a VMO) supplied by the
3026/// user to the AudioCapturer during the AddPayloadBuffer call. Please note the
3027/// following requirements related to the management of the payload buffer.
3028///
3029/// + The payload buffer must be supplied before any capture operation may
3030///   start. Any attempt to start capture (via either CaptureAt or
3031///   StartAsyncCapture) before a payload buffer has been established is an
3032///   error.
3033/// + The payload buffer may not be changed while there are any capture
3034///   operations pending.
3035/// + The stream type may not be changed after the payload buffer has been set.
3036/// + The payload buffer must be an integral number of audio frame sizes (in
3037///   bytes)
3038/// + When running in 'async' mode (see below), the payload buffer must be at
3039///   least as large as twice the frames_per_packet size specified during
3040///   StartAsyncCapture.
3041/// + The handle to the payload buffer supplied by the user must be readable,
3042///   writable, mappable and transferable.
3043/// + Users should always treat the payload buffer as read-only.
3044///
3045/// **Synchronous vs. Asynchronous capture mode**
3046///
3047/// The AudioCapturer interface can be used in one of two mutually exclusive
3048/// modes: Synchronous and Asynchronous. A description of each mode and their
3049/// tradeoffs is given below.
3050///
3051/// **Synchronous mode**
3052///
3053/// By default, AudioCapturer instances are running in 'sync' mode. They will
3054/// only capture data when a user supplies at least one region to capture into
3055/// using the CaptureAt method. Regions supplied in this way will be filled in
3056/// the order that they are received and returned to the client as StreamPackets
3057/// via the return value of the CaptureAt method. If an AudioCapturer instance
3058/// has data to capture, but no place to put it (because there are no more
3059/// pending regions to fill), the next payload generated will indicate that their
3060/// has been an overflow by setting the Discontinuity flag on the next produced
3061/// StreamPacket. Synchronous mode may not be used in conjunction with
3062/// Asynchronous mode. It is an error to attempt to call StartAsyncCapture while
3063/// the system still regions supplied by CaptureAt waiting to be filled.
3064///
3065/// If a user has supplied regions to be filled by the AudioCapturer instance in
3066/// the past, but wishes to reclaim those regions, they may do so using the
3067/// DiscardAllPackets method. Calling the DiscardAllPackets method will cause
3068/// all pending regions to be returned, but with `NO_TIMESTAMP` as their
3069/// StreamPacket's PTS. See "Timing and Overflows", below, for a discussion of
3070/// timestamps and discontinuity flags. After a DiscardAllPackets operation,
3071/// an OnEndOfStream event will be produced. While an AudioCapturer will never
3072/// overwrite any region of the payload buffer after a completed region is
3073/// returned, it may overwrite the unfilled portions of a partially filled
3074/// buffer which has been returned as a result of a DiscardAllPackets operation.
3075///
3076/// **Asynchronous mode**
3077///
3078/// While running in 'async' mode, clients do not need to explicitly supply
3079/// shared buffer regions to be filled by the AudioCapturer instance. Instead, a
3080/// client enters into 'async' mode by calling StartAsyncCapture and supplying a
3081/// callback interface and the number of frames to capture per-callback. Once
3082/// running in async mode, the AudioCapturer instance will identify which
3083/// payload buffer regions to capture into, capture the specified number of
3084/// frames, then deliver those frames as StreamPackets using the OnPacketCapture
3085/// FIDL event. Users may stop capturing and return the AudioCapturer instance to
3086/// 'sync' mode using the StopAsyncCapture method.
3087///
3088/// It is considered an error to attempt any of the following operations.
3089///
3090/// + To attempt to enter 'async' capture mode when no payload buffer has been
3091///   established.
3092/// + To specify a number of frames to capture per payload which does not permit
3093///   at least two contiguous capture payloads to exist in the established
3094///   shared payload buffer simultaneously.
3095/// + To send a region to capture into using the CaptureAt method while the
3096///   AudioCapturer instance is running in 'async' mode.
3097/// + To attempt to call DiscardAllPackets while the AudioCapturer instance is
3098///   running in 'async' mode.
3099/// + To attempt to re-start 'async' mode capturing without having first
3100///   stopped.
3101/// + To attempt any operation except for SetGain while in the process of
3102///   stopping.
3103///
3104/// **Synchronizing with a StopAsyncCapture operation**
3105///
3106/// Stopping asynchronous capture mode and returning to synchronous capture mode
3107/// is an operation which takes time. Aside from SetGain, users may not call any
3108/// other methods on the AudioCapturer interface after calling StopAsyncCapture
3109/// (including calling StopAsyncCapture again) until after the stop operation has
3110/// completed. Because of this, it is important for users to be able to
3111/// synchronize with the stop operation. Two mechanisms are provided for doing
3112/// so.
3113///
3114/// The first is to use StopAsyncCapture (not the NoReply variant). When the user's
3115/// callback has been called, they can be certain that stop operation is complete
3116/// and that the AudioCapturer instance has returned to synchronous operation
3117/// mode.
3118///
3119/// The second way to determine that a stop operation has completed is to use the
3120/// flags on the packets which get delivered via the user-supplied
3121/// AudioCapturerCallback interface after calling StopAsyncCapture. When
3122/// asked to stop, any partially filled packet will be returned to the user, and
3123/// the final packet returned will always have the end-of-stream flag (kFlagsEos)
3124/// set on it to indicate that this is the final frame in the sequence. If
3125/// there is no partially filled packet to return, the AudioCapturer will
3126/// synthesize an empty packet with no timestamp, and offset/length set to zero,
3127/// in order to deliver a packet with the end-of-stream flag set on it. Once
3128/// users have seen the end-of-stream flag after calling stop, the AudioCapturer
3129/// has finished the stop operation and returned to synchronous operating mode.
3130///
3131/// **Timing and Overflows**
3132///
3133/// All media packets produced by an AudioCapturer instance will have their PTS
3134/// field filled out with the capture time of the audio expressed as a timestamp
3135/// given by the reference clock timeline. Note: this timestamp is actually a
3136/// capture timestamp, not a presentation timestamp (it is more of a CTS than a
3137/// PTS) and is meant to represent the underlying system's best estimate of the
3138/// capture time of the first frame of audio, including all outboard and hardware
3139/// introduced buffering delay. As a result, all timestamps produced by an
3140/// AudioCapturer should be expected to be in the past relative to 'now' on the
3141/// stream's reference clock timeline.
3142///
3143/// The one exception to the "everything has an explicit timestamp" rule is when
3144/// discarding submitted regions while operating in synchronous mode. Discarded
3145/// packets have no data in them, but FIDL demands that all pending
3146/// method-return-value callbacks be executed. Because of this, the regions will
3147/// be returned to the user, but their timestamps will be set to
3148/// `NO_TIMESTAMP`, and their payload sizes will be set to zero. Any
3149/// partially filled payload will have a valid timestamp, but a payload size
3150/// smaller than originally requested. The final discarded payload (if there
3151/// were any to discard) will be followed by an OnEndOfStream event.
3152///
3153/// Two StreamPackets delivered by an AudioCapturer instance are 'continuous' if
3154/// the first frame of audio contained in the second packet was captured exactly
3155/// one nominal frame time after the final frame of audio in the first packet.
3156/// If this relationship does not hold, the second StreamPacket will have the
3157/// `STREAM_PACKET_FLAG_DISCONTINUITY` bit set in its `flags` field.
3158///
3159/// Even though explicit timestamps are provided on every StreamPacket produced,
3160/// users who have very precise timing requirements are encouraged to always
3161/// reason about time by counting frames delivered since the last discontinuity,
3162/// rather than simply using the raw capture timestamps. This is because the
3163/// explicit timestamps written on continuous packets may have a small amount of
3164/// rounding error based on whether or not the units of the capture timeline
3165/// reference clock are divisible by the chosen audio frame rate.
3166///
3167/// Users should always expect the first StreamPacket produced by an
3168/// AudioCapturer to have the discontinuous flag set on it (as there is no
3169/// previous packet to be continuous with). Similarly, the first StreamPacket
3170/// after a DiscardAllPackets or a Stop/Start cycle will always be
3171/// discontinuous. After that, there are only two reasons that a StreamPacket
3172/// will ever be discontinuous:
3173///
3174/// 1. The user is operating in synchronous mode and does not supply regions to
3175///    be filled quickly enough. If the next continuous frame of data has not
3176///    been captured by the time it needs to be purged from the source buffers,
3177///    an overflow has occurred and the AudioCapturer will flag the next captured
3178///    region as discontinuous.
3179/// 2. The user is operating in asynchronous mode and some internal error
3180///    prevents the AudioCapturer instance from capturing the next frame of audio
3181///    in a continuous fashion. This might be high system load or a hardware
3182///    error, but in general it is something which should never normally happen.
3183///    In practice, however, if it does, the next produced packet will be flagged
3184///    as being discontinuous.
3185///
3186/// **Synchronous vs. Asynchronous Trade-offs**
3187///
3188/// The choice of operating in synchronous vs. asynchronous mode is up to the
3189/// user, and depending on the user's requirements, there are some advantages and
3190/// disadvantages to each choice.
3191///
3192/// Synchronous mode requires only a single Zircon channel under the hood and can
3193/// achieve some small savings because of this. In addition, the user has
3194/// complete control over the buffer management. Users specify exactly where
3195/// audio will be captured to and in what order. Because of this, if users do
3196/// not need to always be capturing, it is simple to stop and restart the capture
3197/// later (just by ceasing to supply packets, then resuming later on). Payloads
3198/// do not need to be uniform in size either, clients may specify payloads of
3199/// whatever granularity is appropriate.
3200///
3201/// The primary downside of operating in synchronous mode is that two messages
3202/// will need to be sent for every packet to be captured. One to inform the
3203/// AudioCapturer of the instance to capture into, and one to inform the user
3204/// that the packet has been captured. This may end up increasing overhead and
3205/// potentially complicating client designs.
3206///
3207/// Asynchronous mode has the advantage requiring only 1/2 of the messages,
3208/// however, when operating in 'async' mode, AudioCapturer instances have no way
3209/// of knowing if a user is processing the StreamPackets being sent in a timely
3210/// fashion, and no way of automatically detecting an overflow condition. Users
3211/// of 'async' mode should be careful to use a buffer large enough to ensure that
3212/// they will be able to process their data before an AudioCapturer will be
3213/// forced to overwrite it.
3214#[derive(Debug)]
3215pub enum AudioCapturerRequest {
3216    /// Adds a payload buffer to the current buffer set associated with the
3217    /// connection. A `StreamPacket` struct reference a payload buffer in the
3218    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
3219    ///
3220    /// A buffer with ID `id` must not be in the current set when this method is
3221    /// invoked, otherwise the service will close the connection.
3222    AddPayloadBuffer {
3223        id: u32,
3224        payload_buffer: fidl::Vmo,
3225        control_handle: AudioCapturerControlHandle,
3226    },
3227    /// Removes a payload buffer from the current buffer set associated with the
3228    /// connection.
3229    ///
3230    /// A buffer with ID `id` must exist in the current set when this method is
3231    /// invoked, otherwise the service will will close the connection.
3232    RemovePayloadBuffer {
3233        id: u32,
3234        control_handle: AudioCapturerControlHandle,
3235    },
3236    /// Releases payload memory associated with a packet previously delivered
3237    /// via `OnPacketProduced`.
3238    ReleasePacket {
3239        packet: StreamPacket,
3240        control_handle: AudioCapturerControlHandle,
3241    },
3242    DiscardAllPackets {
3243        responder: AudioCapturerDiscardAllPacketsResponder,
3244    },
3245    DiscardAllPacketsNoReply {
3246        control_handle: AudioCapturerControlHandle,
3247    },
3248    /// Sets the stream type of the stream to be delivered. Causes the source
3249    /// material to be reformatted/resampled if needed in order to produce the
3250    /// requested stream type. Must be called before the payload buffer is
3251    /// established.
3252    SetPcmStreamType {
3253        stream_type: AudioStreamType,
3254        control_handle: AudioCapturerControlHandle,
3255    },
3256    /// Explicitly specifies a region of the shared payload buffer for the audio
3257    /// input to capture into.
3258    CaptureAt {
3259        payload_buffer_id: u32,
3260        payload_offset: u32,
3261        frames: u32,
3262        responder: AudioCapturerCaptureAtResponder,
3263    },
3264    /// Places the AudioCapturer into 'async' capture mode and begin to produce
3265    /// packets of exactly 'frames_per_packet' number of frames each. The
3266    /// OnPacketProduced event (of StreamSink) will be used to inform the client
3267    /// of produced packets.
3268    StartAsyncCapture {
3269        frames_per_packet: u32,
3270        control_handle: AudioCapturerControlHandle,
3271    },
3272    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
3273    /// that may be used by the client if explicit synchronization is needed.
3274    StopAsyncCapture {
3275        responder: AudioCapturerStopAsyncCaptureResponder,
3276    },
3277    StopAsyncCaptureNoReply {
3278        control_handle: AudioCapturerControlHandle,
3279    },
3280    /// Binds to the gain control for this AudioCapturer.
3281    BindGainControl {
3282        gain_control_request:
3283            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
3284        control_handle: AudioCapturerControlHandle,
3285    },
3286    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
3287    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
3288    GetReferenceClock {
3289        responder: AudioCapturerGetReferenceClockResponder,
3290    },
3291    /// Sets the reference clock that controls this capturer's playback rate. If the input
3292    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
3293    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
3294    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
3295    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
3296    ///
3297    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
3298    /// added. It also cannot be called a second time (even before capture).
3299    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
3300    /// diverge at some later time, they should create a clone of the monotonic clock, set
3301    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
3302    SetReferenceClock {
3303        reference_clock: Option<fidl::Clock>,
3304        control_handle: AudioCapturerControlHandle,
3305    },
3306    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
3307    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
3308    SetUsage {
3309        usage: AudioCaptureUsage,
3310        control_handle: AudioCapturerControlHandle,
3311    },
3312    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
3313    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
3314    SetUsage2 {
3315        usage: AudioCaptureUsage2,
3316        control_handle: AudioCapturerControlHandle,
3317    },
3318    /// Gets the currently configured stream type. Note: for an AudioCapturer
3319    /// which was just created and has not yet had its stream type explicitly
3320    /// set, this will retrieve the stream type -- at the time the AudioCapturer
3321    /// was created -- of the source (input or looped-back output) to which the
3322    /// AudioCapturer is bound. Even if this matches the client's desired format,
3323    /// `SetPcmStreamType` must still be called.
3324    GetStreamType {
3325        responder: AudioCapturerGetStreamTypeResponder,
3326    },
3327    /// An interaction was received which does not match any known method.
3328    #[non_exhaustive]
3329    _UnknownMethod {
3330        /// Ordinal of the method that was called.
3331        ordinal: u64,
3332        control_handle: AudioCapturerControlHandle,
3333        method_type: fidl::MethodType,
3334    },
3335}
3336
3337impl AudioCapturerRequest {
3338    #[allow(irrefutable_let_patterns)]
3339    pub fn into_add_payload_buffer(self) -> Option<(u32, fidl::Vmo, AudioCapturerControlHandle)> {
3340        if let AudioCapturerRequest::AddPayloadBuffer { id, payload_buffer, control_handle } = self
3341        {
3342            Some((id, payload_buffer, control_handle))
3343        } else {
3344            None
3345        }
3346    }
3347
3348    #[allow(irrefutable_let_patterns)]
3349    pub fn into_remove_payload_buffer(self) -> Option<(u32, AudioCapturerControlHandle)> {
3350        if let AudioCapturerRequest::RemovePayloadBuffer { id, control_handle } = self {
3351            Some((id, control_handle))
3352        } else {
3353            None
3354        }
3355    }
3356
3357    #[allow(irrefutable_let_patterns)]
3358    pub fn into_release_packet(self) -> Option<(StreamPacket, AudioCapturerControlHandle)> {
3359        if let AudioCapturerRequest::ReleasePacket { packet, control_handle } = self {
3360            Some((packet, control_handle))
3361        } else {
3362            None
3363        }
3364    }
3365
3366    #[allow(irrefutable_let_patterns)]
3367    pub fn into_discard_all_packets(self) -> Option<(AudioCapturerDiscardAllPacketsResponder)> {
3368        if let AudioCapturerRequest::DiscardAllPackets { responder } = self {
3369            Some((responder))
3370        } else {
3371            None
3372        }
3373    }
3374
3375    #[allow(irrefutable_let_patterns)]
3376    pub fn into_discard_all_packets_no_reply(self) -> Option<(AudioCapturerControlHandle)> {
3377        if let AudioCapturerRequest::DiscardAllPacketsNoReply { control_handle } = self {
3378            Some((control_handle))
3379        } else {
3380            None
3381        }
3382    }
3383
3384    #[allow(irrefutable_let_patterns)]
3385    pub fn into_set_pcm_stream_type(self) -> Option<(AudioStreamType, AudioCapturerControlHandle)> {
3386        if let AudioCapturerRequest::SetPcmStreamType { stream_type, control_handle } = self {
3387            Some((stream_type, control_handle))
3388        } else {
3389            None
3390        }
3391    }
3392
3393    #[allow(irrefutable_let_patterns)]
3394    pub fn into_capture_at(self) -> Option<(u32, u32, u32, AudioCapturerCaptureAtResponder)> {
3395        if let AudioCapturerRequest::CaptureAt {
3396            payload_buffer_id,
3397            payload_offset,
3398            frames,
3399            responder,
3400        } = self
3401        {
3402            Some((payload_buffer_id, payload_offset, frames, responder))
3403        } else {
3404            None
3405        }
3406    }
3407
3408    #[allow(irrefutable_let_patterns)]
3409    pub fn into_start_async_capture(self) -> Option<(u32, AudioCapturerControlHandle)> {
3410        if let AudioCapturerRequest::StartAsyncCapture { frames_per_packet, control_handle } = self
3411        {
3412            Some((frames_per_packet, control_handle))
3413        } else {
3414            None
3415        }
3416    }
3417
3418    #[allow(irrefutable_let_patterns)]
3419    pub fn into_stop_async_capture(self) -> Option<(AudioCapturerStopAsyncCaptureResponder)> {
3420        if let AudioCapturerRequest::StopAsyncCapture { responder } = self {
3421            Some((responder))
3422        } else {
3423            None
3424        }
3425    }
3426
3427    #[allow(irrefutable_let_patterns)]
3428    pub fn into_stop_async_capture_no_reply(self) -> Option<(AudioCapturerControlHandle)> {
3429        if let AudioCapturerRequest::StopAsyncCaptureNoReply { control_handle } = self {
3430            Some((control_handle))
3431        } else {
3432            None
3433        }
3434    }
3435
3436    #[allow(irrefutable_let_patterns)]
3437    pub fn into_bind_gain_control(
3438        self,
3439    ) -> Option<(
3440        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
3441        AudioCapturerControlHandle,
3442    )> {
3443        if let AudioCapturerRequest::BindGainControl { gain_control_request, control_handle } = self
3444        {
3445            Some((gain_control_request, control_handle))
3446        } else {
3447            None
3448        }
3449    }
3450
3451    #[allow(irrefutable_let_patterns)]
3452    pub fn into_get_reference_clock(self) -> Option<(AudioCapturerGetReferenceClockResponder)> {
3453        if let AudioCapturerRequest::GetReferenceClock { responder } = self {
3454            Some((responder))
3455        } else {
3456            None
3457        }
3458    }
3459
3460    #[allow(irrefutable_let_patterns)]
3461    pub fn into_set_reference_clock(
3462        self,
3463    ) -> Option<(Option<fidl::Clock>, AudioCapturerControlHandle)> {
3464        if let AudioCapturerRequest::SetReferenceClock { reference_clock, control_handle } = self {
3465            Some((reference_clock, control_handle))
3466        } else {
3467            None
3468        }
3469    }
3470
3471    #[allow(irrefutable_let_patterns)]
3472    pub fn into_set_usage(self) -> Option<(AudioCaptureUsage, AudioCapturerControlHandle)> {
3473        if let AudioCapturerRequest::SetUsage { usage, control_handle } = self {
3474            Some((usage, control_handle))
3475        } else {
3476            None
3477        }
3478    }
3479
3480    #[allow(irrefutable_let_patterns)]
3481    pub fn into_set_usage2(self) -> Option<(AudioCaptureUsage2, AudioCapturerControlHandle)> {
3482        if let AudioCapturerRequest::SetUsage2 { usage, control_handle } = self {
3483            Some((usage, control_handle))
3484        } else {
3485            None
3486        }
3487    }
3488
3489    #[allow(irrefutable_let_patterns)]
3490    pub fn into_get_stream_type(self) -> Option<(AudioCapturerGetStreamTypeResponder)> {
3491        if let AudioCapturerRequest::GetStreamType { responder } = self {
3492            Some((responder))
3493        } else {
3494            None
3495        }
3496    }
3497
3498    /// Name of the method defined in FIDL
3499    pub fn method_name(&self) -> &'static str {
3500        match *self {
3501            AudioCapturerRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
3502            AudioCapturerRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
3503            AudioCapturerRequest::ReleasePacket { .. } => "release_packet",
3504            AudioCapturerRequest::DiscardAllPackets { .. } => "discard_all_packets",
3505            AudioCapturerRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
3506            AudioCapturerRequest::SetPcmStreamType { .. } => "set_pcm_stream_type",
3507            AudioCapturerRequest::CaptureAt { .. } => "capture_at",
3508            AudioCapturerRequest::StartAsyncCapture { .. } => "start_async_capture",
3509            AudioCapturerRequest::StopAsyncCapture { .. } => "stop_async_capture",
3510            AudioCapturerRequest::StopAsyncCaptureNoReply { .. } => "stop_async_capture_no_reply",
3511            AudioCapturerRequest::BindGainControl { .. } => "bind_gain_control",
3512            AudioCapturerRequest::GetReferenceClock { .. } => "get_reference_clock",
3513            AudioCapturerRequest::SetReferenceClock { .. } => "set_reference_clock",
3514            AudioCapturerRequest::SetUsage { .. } => "set_usage",
3515            AudioCapturerRequest::SetUsage2 { .. } => "set_usage2",
3516            AudioCapturerRequest::GetStreamType { .. } => "get_stream_type",
3517            AudioCapturerRequest::_UnknownMethod {
3518                method_type: fidl::MethodType::OneWay, ..
3519            } => "unknown one-way method",
3520            AudioCapturerRequest::_UnknownMethod {
3521                method_type: fidl::MethodType::TwoWay, ..
3522            } => "unknown two-way method",
3523        }
3524    }
3525}
3526
3527#[derive(Debug, Clone)]
3528pub struct AudioCapturerControlHandle {
3529    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3530}
3531
3532impl fidl::endpoints::ControlHandle for AudioCapturerControlHandle {
3533    fn shutdown(&self) {
3534        self.inner.shutdown()
3535    }
3536    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3537        self.inner.shutdown_with_epitaph(status)
3538    }
3539
3540    fn is_closed(&self) -> bool {
3541        self.inner.channel().is_closed()
3542    }
3543    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3544        self.inner.channel().on_closed()
3545    }
3546
3547    #[cfg(target_os = "fuchsia")]
3548    fn signal_peer(
3549        &self,
3550        clear_mask: zx::Signals,
3551        set_mask: zx::Signals,
3552    ) -> Result<(), zx_status::Status> {
3553        use fidl::Peered;
3554        self.inner.channel().signal_peer(clear_mask, set_mask)
3555    }
3556}
3557
3558impl AudioCapturerControlHandle {
3559    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
3560        self.inner.send::<StreamSourceOnPacketProducedRequest>(
3561            (packet,),
3562            0,
3563            0x6bbe69746a3c8bd9,
3564            fidl::encoding::DynamicFlags::empty(),
3565        )
3566    }
3567
3568    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
3569        self.inner.send::<fidl::encoding::EmptyPayload>(
3570            (),
3571            0,
3572            0x550e69b41d03e2c2,
3573            fidl::encoding::DynamicFlags::empty(),
3574        )
3575    }
3576}
3577
3578#[must_use = "FIDL methods require a response to be sent"]
3579#[derive(Debug)]
3580pub struct AudioCapturerDiscardAllPacketsResponder {
3581    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3582    tx_id: u32,
3583}
3584
3585/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3586/// if the responder is dropped without sending a response, so that the client
3587/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3588impl std::ops::Drop for AudioCapturerDiscardAllPacketsResponder {
3589    fn drop(&mut self) {
3590        self.control_handle.shutdown();
3591        // Safety: drops once, never accessed again
3592        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3593    }
3594}
3595
3596impl fidl::endpoints::Responder for AudioCapturerDiscardAllPacketsResponder {
3597    type ControlHandle = AudioCapturerControlHandle;
3598
3599    fn control_handle(&self) -> &AudioCapturerControlHandle {
3600        &self.control_handle
3601    }
3602
3603    fn drop_without_shutdown(mut self) {
3604        // Safety: drops once, never accessed again due to mem::forget
3605        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3606        // Prevent Drop from running (which would shut down the channel)
3607        std::mem::forget(self);
3608    }
3609}
3610
3611impl AudioCapturerDiscardAllPacketsResponder {
3612    /// Sends a response to the FIDL transaction.
3613    ///
3614    /// Sets the channel to shutdown if an error occurs.
3615    pub fn send(self) -> Result<(), fidl::Error> {
3616        let _result = self.send_raw();
3617        if _result.is_err() {
3618            self.control_handle.shutdown();
3619        }
3620        self.drop_without_shutdown();
3621        _result
3622    }
3623
3624    /// Similar to "send" but does not shutdown the channel if an error occurs.
3625    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3626        let _result = self.send_raw();
3627        self.drop_without_shutdown();
3628        _result
3629    }
3630
3631    fn send_raw(&self) -> Result<(), fidl::Error> {
3632        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3633            (),
3634            self.tx_id,
3635            0x27afd605e97b09d2,
3636            fidl::encoding::DynamicFlags::empty(),
3637        )
3638    }
3639}
3640
3641#[must_use = "FIDL methods require a response to be sent"]
3642#[derive(Debug)]
3643pub struct AudioCapturerCaptureAtResponder {
3644    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3645    tx_id: u32,
3646}
3647
3648/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3649/// if the responder is dropped without sending a response, so that the client
3650/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3651impl std::ops::Drop for AudioCapturerCaptureAtResponder {
3652    fn drop(&mut self) {
3653        self.control_handle.shutdown();
3654        // Safety: drops once, never accessed again
3655        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3656    }
3657}
3658
3659impl fidl::endpoints::Responder for AudioCapturerCaptureAtResponder {
3660    type ControlHandle = AudioCapturerControlHandle;
3661
3662    fn control_handle(&self) -> &AudioCapturerControlHandle {
3663        &self.control_handle
3664    }
3665
3666    fn drop_without_shutdown(mut self) {
3667        // Safety: drops once, never accessed again due to mem::forget
3668        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3669        // Prevent Drop from running (which would shut down the channel)
3670        std::mem::forget(self);
3671    }
3672}
3673
3674impl AudioCapturerCaptureAtResponder {
3675    /// Sends a response to the FIDL transaction.
3676    ///
3677    /// Sets the channel to shutdown if an error occurs.
3678    pub fn send(self, mut captured_packet: &StreamPacket) -> Result<(), fidl::Error> {
3679        let _result = self.send_raw(captured_packet);
3680        if _result.is_err() {
3681            self.control_handle.shutdown();
3682        }
3683        self.drop_without_shutdown();
3684        _result
3685    }
3686
3687    /// Similar to "send" but does not shutdown the channel if an error occurs.
3688    pub fn send_no_shutdown_on_err(
3689        self,
3690        mut captured_packet: &StreamPacket,
3691    ) -> Result<(), fidl::Error> {
3692        let _result = self.send_raw(captured_packet);
3693        self.drop_without_shutdown();
3694        _result
3695    }
3696
3697    fn send_raw(&self, mut captured_packet: &StreamPacket) -> Result<(), fidl::Error> {
3698        self.control_handle.inner.send::<AudioCapturerCaptureAtResponse>(
3699            (captured_packet,),
3700            self.tx_id,
3701            0x784e25df72cea780,
3702            fidl::encoding::DynamicFlags::empty(),
3703        )
3704    }
3705}
3706
3707#[must_use = "FIDL methods require a response to be sent"]
3708#[derive(Debug)]
3709pub struct AudioCapturerStopAsyncCaptureResponder {
3710    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3711    tx_id: u32,
3712}
3713
3714/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3715/// if the responder is dropped without sending a response, so that the client
3716/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3717impl std::ops::Drop for AudioCapturerStopAsyncCaptureResponder {
3718    fn drop(&mut self) {
3719        self.control_handle.shutdown();
3720        // Safety: drops once, never accessed again
3721        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3722    }
3723}
3724
3725impl fidl::endpoints::Responder for AudioCapturerStopAsyncCaptureResponder {
3726    type ControlHandle = AudioCapturerControlHandle;
3727
3728    fn control_handle(&self) -> &AudioCapturerControlHandle {
3729        &self.control_handle
3730    }
3731
3732    fn drop_without_shutdown(mut self) {
3733        // Safety: drops once, never accessed again due to mem::forget
3734        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3735        // Prevent Drop from running (which would shut down the channel)
3736        std::mem::forget(self);
3737    }
3738}
3739
3740impl AudioCapturerStopAsyncCaptureResponder {
3741    /// Sends a response to the FIDL transaction.
3742    ///
3743    /// Sets the channel to shutdown if an error occurs.
3744    pub fn send(self) -> Result<(), fidl::Error> {
3745        let _result = self.send_raw();
3746        if _result.is_err() {
3747            self.control_handle.shutdown();
3748        }
3749        self.drop_without_shutdown();
3750        _result
3751    }
3752
3753    /// Similar to "send" but does not shutdown the channel if an error occurs.
3754    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3755        let _result = self.send_raw();
3756        self.drop_without_shutdown();
3757        _result
3758    }
3759
3760    fn send_raw(&self) -> Result<(), fidl::Error> {
3761        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3762            (),
3763            self.tx_id,
3764            0x5bfc8790a8cef8cb,
3765            fidl::encoding::DynamicFlags::empty(),
3766        )
3767    }
3768}
3769
3770#[must_use = "FIDL methods require a response to be sent"]
3771#[derive(Debug)]
3772pub struct AudioCapturerGetReferenceClockResponder {
3773    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3774    tx_id: u32,
3775}
3776
3777/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3778/// if the responder is dropped without sending a response, so that the client
3779/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3780impl std::ops::Drop for AudioCapturerGetReferenceClockResponder {
3781    fn drop(&mut self) {
3782        self.control_handle.shutdown();
3783        // Safety: drops once, never accessed again
3784        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3785    }
3786}
3787
3788impl fidl::endpoints::Responder for AudioCapturerGetReferenceClockResponder {
3789    type ControlHandle = AudioCapturerControlHandle;
3790
3791    fn control_handle(&self) -> &AudioCapturerControlHandle {
3792        &self.control_handle
3793    }
3794
3795    fn drop_without_shutdown(mut self) {
3796        // Safety: drops once, never accessed again due to mem::forget
3797        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3798        // Prevent Drop from running (which would shut down the channel)
3799        std::mem::forget(self);
3800    }
3801}
3802
3803impl AudioCapturerGetReferenceClockResponder {
3804    /// Sends a response to the FIDL transaction.
3805    ///
3806    /// Sets the channel to shutdown if an error occurs.
3807    pub fn send(self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
3808        let _result = self.send_raw(reference_clock);
3809        if _result.is_err() {
3810            self.control_handle.shutdown();
3811        }
3812        self.drop_without_shutdown();
3813        _result
3814    }
3815
3816    /// Similar to "send" but does not shutdown the channel if an error occurs.
3817    pub fn send_no_shutdown_on_err(
3818        self,
3819        mut reference_clock: fidl::Clock,
3820    ) -> Result<(), fidl::Error> {
3821        let _result = self.send_raw(reference_clock);
3822        self.drop_without_shutdown();
3823        _result
3824    }
3825
3826    fn send_raw(&self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
3827        self.control_handle.inner.send::<AudioCapturerGetReferenceClockResponse>(
3828            (reference_clock,),
3829            self.tx_id,
3830            0x50d037aa5a4b4d71,
3831            fidl::encoding::DynamicFlags::empty(),
3832        )
3833    }
3834}
3835
3836#[must_use = "FIDL methods require a response to be sent"]
3837#[derive(Debug)]
3838pub struct AudioCapturerGetStreamTypeResponder {
3839    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3840    tx_id: u32,
3841}
3842
3843/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3844/// if the responder is dropped without sending a response, so that the client
3845/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3846impl std::ops::Drop for AudioCapturerGetStreamTypeResponder {
3847    fn drop(&mut self) {
3848        self.control_handle.shutdown();
3849        // Safety: drops once, never accessed again
3850        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3851    }
3852}
3853
3854impl fidl::endpoints::Responder for AudioCapturerGetStreamTypeResponder {
3855    type ControlHandle = AudioCapturerControlHandle;
3856
3857    fn control_handle(&self) -> &AudioCapturerControlHandle {
3858        &self.control_handle
3859    }
3860
3861    fn drop_without_shutdown(mut self) {
3862        // Safety: drops once, never accessed again due to mem::forget
3863        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3864        // Prevent Drop from running (which would shut down the channel)
3865        std::mem::forget(self);
3866    }
3867}
3868
3869impl AudioCapturerGetStreamTypeResponder {
3870    /// Sends a response to the FIDL transaction.
3871    ///
3872    /// Sets the channel to shutdown if an error occurs.
3873    pub fn send(self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3874        let _result = self.send_raw(stream_type);
3875        if _result.is_err() {
3876            self.control_handle.shutdown();
3877        }
3878        self.drop_without_shutdown();
3879        _result
3880    }
3881
3882    /// Similar to "send" but does not shutdown the channel if an error occurs.
3883    pub fn send_no_shutdown_on_err(self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3884        let _result = self.send_raw(stream_type);
3885        self.drop_without_shutdown();
3886        _result
3887    }
3888
3889    fn send_raw(&self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3890        self.control_handle.inner.send::<AudioCapturerGetStreamTypeResponse>(
3891            (stream_type,),
3892            self.tx_id,
3893            0x5dcaaa670b433088,
3894            fidl::encoding::DynamicFlags::empty(),
3895        )
3896    }
3897}
3898
3899#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3900pub struct AudioConsumerMarker;
3901
3902impl fidl::endpoints::ProtocolMarker for AudioConsumerMarker {
3903    type Proxy = AudioConsumerProxy;
3904    type RequestStream = AudioConsumerRequestStream;
3905    #[cfg(target_os = "fuchsia")]
3906    type SynchronousProxy = AudioConsumerSynchronousProxy;
3907
3908    const DEBUG_NAME: &'static str = "(anonymous) AudioConsumer";
3909}
3910
3911pub trait AudioConsumerProxyInterface: Send + Sync {
3912    fn r#create_stream_sink(
3913        &self,
3914        buffers: Vec<fidl::Vmo>,
3915        stream_type: &AudioStreamType,
3916        compression: Option<&Compression>,
3917        stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
3918    ) -> Result<(), fidl::Error>;
3919    fn r#start(
3920        &self,
3921        flags: AudioConsumerStartFlags,
3922        reference_time: i64,
3923        media_time: i64,
3924    ) -> Result<(), fidl::Error>;
3925    fn r#stop(&self) -> Result<(), fidl::Error>;
3926    fn r#set_rate(&self, rate: f32) -> Result<(), fidl::Error>;
3927    fn r#bind_volume_control(
3928        &self,
3929        volume_control_request: fidl::endpoints::ServerEnd<
3930            fidl_fuchsia_media_audio::VolumeControlMarker,
3931        >,
3932    ) -> Result<(), fidl::Error>;
3933    type WatchStatusResponseFut: std::future::Future<Output = Result<AudioConsumerStatus, fidl::Error>>
3934        + Send;
3935    fn r#watch_status(&self) -> Self::WatchStatusResponseFut;
3936}
3937#[derive(Debug)]
3938#[cfg(target_os = "fuchsia")]
3939pub struct AudioConsumerSynchronousProxy {
3940    client: fidl::client::sync::Client,
3941}
3942
3943#[cfg(target_os = "fuchsia")]
3944impl fidl::endpoints::SynchronousProxy for AudioConsumerSynchronousProxy {
3945    type Proxy = AudioConsumerProxy;
3946    type Protocol = AudioConsumerMarker;
3947
3948    fn from_channel(inner: fidl::Channel) -> Self {
3949        Self::new(inner)
3950    }
3951
3952    fn into_channel(self) -> fidl::Channel {
3953        self.client.into_channel()
3954    }
3955
3956    fn as_channel(&self) -> &fidl::Channel {
3957        self.client.as_channel()
3958    }
3959}
3960
3961#[cfg(target_os = "fuchsia")]
3962impl AudioConsumerSynchronousProxy {
3963    pub fn new(channel: fidl::Channel) -> Self {
3964        let protocol_name = <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3965        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3966    }
3967
3968    pub fn into_channel(self) -> fidl::Channel {
3969        self.client.into_channel()
3970    }
3971
3972    /// Waits until an event arrives and returns it. It is safe for other
3973    /// threads to make concurrent requests while waiting for an event.
3974    pub fn wait_for_event(
3975        &self,
3976        deadline: zx::MonotonicInstant,
3977    ) -> Result<AudioConsumerEvent, fidl::Error> {
3978        AudioConsumerEvent::decode(self.client.wait_for_event(deadline)?)
3979    }
3980
3981    /// Creates a `StreamSink` for the consumer with the indicated properties.
3982    ///
3983    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
3984    /// sequentially rather than concurrently. The first stream sink that's created using this
3985    /// method is used as the sole source of packets incoming to the logical consumer until that
3986    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
3987    /// the second stream sink is used, and so on.
3988    ///
3989    /// If an unsupported compression type is supplied, the
3990    /// `stream_sink_request` request will be closed with an epitaph value of
3991    /// `ZX_ERR_INVALID_ARGS`.
3992    pub fn r#create_stream_sink(
3993        &self,
3994        mut buffers: Vec<fidl::Vmo>,
3995        mut stream_type: &AudioStreamType,
3996        mut compression: Option<&Compression>,
3997        mut stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
3998    ) -> Result<(), fidl::Error> {
3999        self.client.send::<AudioConsumerCreateStreamSinkRequest>(
4000            (buffers.as_mut(), stream_type, compression, stream_sink_request),
4001            0x525b3b97fdf7d884,
4002            fidl::encoding::DynamicFlags::empty(),
4003        )
4004    }
4005
4006    /// Starts rendering as indicated by `flags`.
4007    ///
4008    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4009    /// Typically, this is the timestamp of the first packet that will be
4010    /// rendered. If packets will be supplied with no timestamps, this value
4011    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4012    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4013    ///     1. When starting for the first time, the default media time is the
4014    ///        timestamp on the first packet sent to the stream sink.
4015    ///     2. When resuming after stop, the default media time is the media
4016    ///        time at which the stream stopped.
4017    ///
4018    /// `reference_time` is the monotonic system time at which rendering should
4019    /// be started. For supply-driven sources, this must be the time at which
4020    /// the first packet was (or will be) sent plus a lead time, which must be
4021    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4022    /// sources, the client must ensure that the lead time requirement is met at
4023    /// the start time.  Passing the default value of 0 for `reference_time`
4024    /// causes the consumer to choose a start time based on the availability of
4025    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4026    /// specified.
4027    ///
4028    /// The actual start time will be reflected in the updated status.
4029    pub fn r#start(
4030        &self,
4031        mut flags: AudioConsumerStartFlags,
4032        mut reference_time: i64,
4033        mut media_time: i64,
4034    ) -> Result<(), fidl::Error> {
4035        self.client.send::<AudioConsumerStartRequest>(
4036            (flags, reference_time, media_time),
4037            0x4fdbd44b3f2a3a3c,
4038            fidl::encoding::DynamicFlags::empty(),
4039        )
4040    }
4041
4042    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4043    /// be reflected in the updated status.
4044    pub fn r#stop(&self) -> Result<(), fidl::Error> {
4045        self.client.send::<fidl::encoding::EmptyPayload>(
4046            (),
4047            0x3d46c3741686c40d,
4048            fidl::encoding::DynamicFlags::empty(),
4049        )
4050    }
4051
4052    /// Requests to change the playback rate of the renderer. 1.0 means normal
4053    /// playback. Negative rates are not supported. The new rate will be
4054    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4055    pub fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
4056        self.client.send::<AudioConsumerSetRateRequest>(
4057            (rate,),
4058            0x45342b73968bfafe,
4059            fidl::encoding::DynamicFlags::empty(),
4060        )
4061    }
4062
4063    /// Binds to this `AudioConsumer` volume control for control and notifications.
4064    pub fn r#bind_volume_control(
4065        &self,
4066        mut volume_control_request: fidl::endpoints::ServerEnd<
4067            fidl_fuchsia_media_audio::VolumeControlMarker,
4068        >,
4069    ) -> Result<(), fidl::Error> {
4070        self.client.send::<AudioConsumerBindVolumeControlRequest>(
4071            (volume_control_request,),
4072            0x6f1b01fd887f5748,
4073            fidl::encoding::DynamicFlags::empty(),
4074        )
4075    }
4076
4077    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4078    /// to this method when the status changes - initially with respect to the initial status value
4079    /// and thereafter with respect to the previously-reported status value.
4080    pub fn r#watch_status(
4081        &self,
4082        ___deadline: zx::MonotonicInstant,
4083    ) -> Result<AudioConsumerStatus, fidl::Error> {
4084        let _response = self
4085            .client
4086            .send_query::<fidl::encoding::EmptyPayload, AudioConsumerWatchStatusResponse>(
4087                (),
4088                0x35cf702c721e2cc6,
4089                fidl::encoding::DynamicFlags::empty(),
4090                ___deadline,
4091            )?;
4092        Ok(_response.status)
4093    }
4094}
4095
4096#[cfg(target_os = "fuchsia")]
4097impl From<AudioConsumerSynchronousProxy> for zx::Handle {
4098    fn from(value: AudioConsumerSynchronousProxy) -> Self {
4099        value.into_channel().into()
4100    }
4101}
4102
4103#[cfg(target_os = "fuchsia")]
4104impl From<fidl::Channel> for AudioConsumerSynchronousProxy {
4105    fn from(value: fidl::Channel) -> Self {
4106        Self::new(value)
4107    }
4108}
4109
4110#[cfg(target_os = "fuchsia")]
4111impl fidl::endpoints::FromClient for AudioConsumerSynchronousProxy {
4112    type Protocol = AudioConsumerMarker;
4113
4114    fn from_client(value: fidl::endpoints::ClientEnd<AudioConsumerMarker>) -> Self {
4115        Self::new(value.into_channel())
4116    }
4117}
4118
4119#[derive(Debug, Clone)]
4120pub struct AudioConsumerProxy {
4121    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4122}
4123
4124impl fidl::endpoints::Proxy for AudioConsumerProxy {
4125    type Protocol = AudioConsumerMarker;
4126
4127    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4128        Self::new(inner)
4129    }
4130
4131    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4132        self.client.into_channel().map_err(|client| Self { client })
4133    }
4134
4135    fn as_channel(&self) -> &::fidl::AsyncChannel {
4136        self.client.as_channel()
4137    }
4138}
4139
4140impl AudioConsumerProxy {
4141    /// Create a new Proxy for fuchsia.media/AudioConsumer.
4142    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4143        let protocol_name = <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4144        Self { client: fidl::client::Client::new(channel, protocol_name) }
4145    }
4146
4147    /// Get a Stream of events from the remote end of the protocol.
4148    ///
4149    /// # Panics
4150    ///
4151    /// Panics if the event stream was already taken.
4152    pub fn take_event_stream(&self) -> AudioConsumerEventStream {
4153        AudioConsumerEventStream { event_receiver: self.client.take_event_receiver() }
4154    }
4155
4156    /// Creates a `StreamSink` for the consumer with the indicated properties.
4157    ///
4158    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
4159    /// sequentially rather than concurrently. The first stream sink that's created using this
4160    /// method is used as the sole source of packets incoming to the logical consumer until that
4161    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
4162    /// the second stream sink is used, and so on.
4163    ///
4164    /// If an unsupported compression type is supplied, the
4165    /// `stream_sink_request` request will be closed with an epitaph value of
4166    /// `ZX_ERR_INVALID_ARGS`.
4167    pub fn r#create_stream_sink(
4168        &self,
4169        mut buffers: Vec<fidl::Vmo>,
4170        mut stream_type: &AudioStreamType,
4171        mut compression: Option<&Compression>,
4172        mut stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4173    ) -> Result<(), fidl::Error> {
4174        AudioConsumerProxyInterface::r#create_stream_sink(
4175            self,
4176            buffers,
4177            stream_type,
4178            compression,
4179            stream_sink_request,
4180        )
4181    }
4182
4183    /// Starts rendering as indicated by `flags`.
4184    ///
4185    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4186    /// Typically, this is the timestamp of the first packet that will be
4187    /// rendered. If packets will be supplied with no timestamps, this value
4188    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4189    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4190    ///     1. When starting for the first time, the default media time is the
4191    ///        timestamp on the first packet sent to the stream sink.
4192    ///     2. When resuming after stop, the default media time is the media
4193    ///        time at which the stream stopped.
4194    ///
4195    /// `reference_time` is the monotonic system time at which rendering should
4196    /// be started. For supply-driven sources, this must be the time at which
4197    /// the first packet was (or will be) sent plus a lead time, which must be
4198    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4199    /// sources, the client must ensure that the lead time requirement is met at
4200    /// the start time.  Passing the default value of 0 for `reference_time`
4201    /// causes the consumer to choose a start time based on the availability of
4202    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4203    /// specified.
4204    ///
4205    /// The actual start time will be reflected in the updated status.
4206    pub fn r#start(
4207        &self,
4208        mut flags: AudioConsumerStartFlags,
4209        mut reference_time: i64,
4210        mut media_time: i64,
4211    ) -> Result<(), fidl::Error> {
4212        AudioConsumerProxyInterface::r#start(self, flags, reference_time, media_time)
4213    }
4214
4215    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4216    /// be reflected in the updated status.
4217    pub fn r#stop(&self) -> Result<(), fidl::Error> {
4218        AudioConsumerProxyInterface::r#stop(self)
4219    }
4220
4221    /// Requests to change the playback rate of the renderer. 1.0 means normal
4222    /// playback. Negative rates are not supported. The new rate will be
4223    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4224    pub fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
4225        AudioConsumerProxyInterface::r#set_rate(self, rate)
4226    }
4227
4228    /// Binds to this `AudioConsumer` volume control for control and notifications.
4229    pub fn r#bind_volume_control(
4230        &self,
4231        mut volume_control_request: fidl::endpoints::ServerEnd<
4232            fidl_fuchsia_media_audio::VolumeControlMarker,
4233        >,
4234    ) -> Result<(), fidl::Error> {
4235        AudioConsumerProxyInterface::r#bind_volume_control(self, volume_control_request)
4236    }
4237
4238    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4239    /// to this method when the status changes - initially with respect to the initial status value
4240    /// and thereafter with respect to the previously-reported status value.
4241    pub fn r#watch_status(
4242        &self,
4243    ) -> fidl::client::QueryResponseFut<
4244        AudioConsumerStatus,
4245        fidl::encoding::DefaultFuchsiaResourceDialect,
4246    > {
4247        AudioConsumerProxyInterface::r#watch_status(self)
4248    }
4249}
4250
4251impl AudioConsumerProxyInterface for AudioConsumerProxy {
4252    fn r#create_stream_sink(
4253        &self,
4254        mut buffers: Vec<fidl::Vmo>,
4255        mut stream_type: &AudioStreamType,
4256        mut compression: Option<&Compression>,
4257        mut stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4258    ) -> Result<(), fidl::Error> {
4259        self.client.send::<AudioConsumerCreateStreamSinkRequest>(
4260            (buffers.as_mut(), stream_type, compression, stream_sink_request),
4261            0x525b3b97fdf7d884,
4262            fidl::encoding::DynamicFlags::empty(),
4263        )
4264    }
4265
4266    fn r#start(
4267        &self,
4268        mut flags: AudioConsumerStartFlags,
4269        mut reference_time: i64,
4270        mut media_time: i64,
4271    ) -> Result<(), fidl::Error> {
4272        self.client.send::<AudioConsumerStartRequest>(
4273            (flags, reference_time, media_time),
4274            0x4fdbd44b3f2a3a3c,
4275            fidl::encoding::DynamicFlags::empty(),
4276        )
4277    }
4278
4279    fn r#stop(&self) -> Result<(), fidl::Error> {
4280        self.client.send::<fidl::encoding::EmptyPayload>(
4281            (),
4282            0x3d46c3741686c40d,
4283            fidl::encoding::DynamicFlags::empty(),
4284        )
4285    }
4286
4287    fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
4288        self.client.send::<AudioConsumerSetRateRequest>(
4289            (rate,),
4290            0x45342b73968bfafe,
4291            fidl::encoding::DynamicFlags::empty(),
4292        )
4293    }
4294
4295    fn r#bind_volume_control(
4296        &self,
4297        mut volume_control_request: fidl::endpoints::ServerEnd<
4298            fidl_fuchsia_media_audio::VolumeControlMarker,
4299        >,
4300    ) -> Result<(), fidl::Error> {
4301        self.client.send::<AudioConsumerBindVolumeControlRequest>(
4302            (volume_control_request,),
4303            0x6f1b01fd887f5748,
4304            fidl::encoding::DynamicFlags::empty(),
4305        )
4306    }
4307
4308    type WatchStatusResponseFut = fidl::client::QueryResponseFut<
4309        AudioConsumerStatus,
4310        fidl::encoding::DefaultFuchsiaResourceDialect,
4311    >;
4312    fn r#watch_status(&self) -> Self::WatchStatusResponseFut {
4313        fn _decode(
4314            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4315        ) -> Result<AudioConsumerStatus, fidl::Error> {
4316            let _response = fidl::client::decode_transaction_body::<
4317                AudioConsumerWatchStatusResponse,
4318                fidl::encoding::DefaultFuchsiaResourceDialect,
4319                0x35cf702c721e2cc6,
4320            >(_buf?)?;
4321            Ok(_response.status)
4322        }
4323        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, AudioConsumerStatus>(
4324            (),
4325            0x35cf702c721e2cc6,
4326            fidl::encoding::DynamicFlags::empty(),
4327            _decode,
4328        )
4329    }
4330}
4331
4332pub struct AudioConsumerEventStream {
4333    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4334}
4335
4336impl std::marker::Unpin for AudioConsumerEventStream {}
4337
4338impl futures::stream::FusedStream for AudioConsumerEventStream {
4339    fn is_terminated(&self) -> bool {
4340        self.event_receiver.is_terminated()
4341    }
4342}
4343
4344impl futures::Stream for AudioConsumerEventStream {
4345    type Item = Result<AudioConsumerEvent, fidl::Error>;
4346
4347    fn poll_next(
4348        mut self: std::pin::Pin<&mut Self>,
4349        cx: &mut std::task::Context<'_>,
4350    ) -> std::task::Poll<Option<Self::Item>> {
4351        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4352            &mut self.event_receiver,
4353            cx
4354        )?) {
4355            Some(buf) => std::task::Poll::Ready(Some(AudioConsumerEvent::decode(buf))),
4356            None => std::task::Poll::Ready(None),
4357        }
4358    }
4359}
4360
4361#[derive(Debug)]
4362pub enum AudioConsumerEvent {
4363    OnEndOfStream {},
4364}
4365
4366impl AudioConsumerEvent {
4367    #[allow(irrefutable_let_patterns)]
4368    pub fn into_on_end_of_stream(self) -> Option<()> {
4369        if let AudioConsumerEvent::OnEndOfStream {} = self {
4370            Some(())
4371        } else {
4372            None
4373        }
4374    }
4375
4376    /// Decodes a message buffer as a [`AudioConsumerEvent`].
4377    fn decode(
4378        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4379    ) -> Result<AudioConsumerEvent, fidl::Error> {
4380        let (bytes, _handles) = buf.split_mut();
4381        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4382        debug_assert_eq!(tx_header.tx_id, 0);
4383        match tx_header.ordinal {
4384            0x53a64e6d0e8f8a20 => {
4385                let mut out = fidl::new_empty!(
4386                    fidl::encoding::EmptyPayload,
4387                    fidl::encoding::DefaultFuchsiaResourceDialect
4388                );
4389                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
4390                Ok((AudioConsumerEvent::OnEndOfStream {}))
4391            }
4392            _ => Err(fidl::Error::UnknownOrdinal {
4393                ordinal: tx_header.ordinal,
4394                protocol_name: <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4395            }),
4396        }
4397    }
4398}
4399
4400/// A Stream of incoming requests for fuchsia.media/AudioConsumer.
4401pub struct AudioConsumerRequestStream {
4402    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4403    is_terminated: bool,
4404}
4405
4406impl std::marker::Unpin for AudioConsumerRequestStream {}
4407
4408impl futures::stream::FusedStream for AudioConsumerRequestStream {
4409    fn is_terminated(&self) -> bool {
4410        self.is_terminated
4411    }
4412}
4413
4414impl fidl::endpoints::RequestStream for AudioConsumerRequestStream {
4415    type Protocol = AudioConsumerMarker;
4416    type ControlHandle = AudioConsumerControlHandle;
4417
4418    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4419        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4420    }
4421
4422    fn control_handle(&self) -> Self::ControlHandle {
4423        AudioConsumerControlHandle { inner: self.inner.clone() }
4424    }
4425
4426    fn into_inner(
4427        self,
4428    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4429    {
4430        (self.inner, self.is_terminated)
4431    }
4432
4433    fn from_inner(
4434        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4435        is_terminated: bool,
4436    ) -> Self {
4437        Self { inner, is_terminated }
4438    }
4439}
4440
4441impl futures::Stream for AudioConsumerRequestStream {
4442    type Item = Result<AudioConsumerRequest, fidl::Error>;
4443
4444    fn poll_next(
4445        mut self: std::pin::Pin<&mut Self>,
4446        cx: &mut std::task::Context<'_>,
4447    ) -> std::task::Poll<Option<Self::Item>> {
4448        let this = &mut *self;
4449        if this.inner.check_shutdown(cx) {
4450            this.is_terminated = true;
4451            return std::task::Poll::Ready(None);
4452        }
4453        if this.is_terminated {
4454            panic!("polled AudioConsumerRequestStream after completion");
4455        }
4456        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4457            |bytes, handles| {
4458                match this.inner.channel().read_etc(cx, bytes, handles) {
4459                    std::task::Poll::Ready(Ok(())) => {}
4460                    std::task::Poll::Pending => return std::task::Poll::Pending,
4461                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4462                        this.is_terminated = true;
4463                        return std::task::Poll::Ready(None);
4464                    }
4465                    std::task::Poll::Ready(Err(e)) => {
4466                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4467                            e.into(),
4468                        ))))
4469                    }
4470                }
4471
4472                // A message has been received from the channel
4473                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4474
4475                std::task::Poll::Ready(Some(match header.ordinal {
4476                    0x525b3b97fdf7d884 => {
4477                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4478                        let mut req = fidl::new_empty!(
4479                            AudioConsumerCreateStreamSinkRequest,
4480                            fidl::encoding::DefaultFuchsiaResourceDialect
4481                        );
4482                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerCreateStreamSinkRequest>(&header, _body_bytes, handles, &mut req)?;
4483                        let control_handle =
4484                            AudioConsumerControlHandle { inner: this.inner.clone() };
4485                        Ok(AudioConsumerRequest::CreateStreamSink {
4486                            buffers: req.buffers,
4487                            stream_type: req.stream_type,
4488                            compression: req.compression,
4489                            stream_sink_request: req.stream_sink_request,
4490
4491                            control_handle,
4492                        })
4493                    }
4494                    0x4fdbd44b3f2a3a3c => {
4495                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4496                        let mut req = fidl::new_empty!(
4497                            AudioConsumerStartRequest,
4498                            fidl::encoding::DefaultFuchsiaResourceDialect
4499                        );
4500                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerStartRequest>(&header, _body_bytes, handles, &mut req)?;
4501                        let control_handle =
4502                            AudioConsumerControlHandle { inner: this.inner.clone() };
4503                        Ok(AudioConsumerRequest::Start {
4504                            flags: req.flags,
4505                            reference_time: req.reference_time,
4506                            media_time: req.media_time,
4507
4508                            control_handle,
4509                        })
4510                    }
4511                    0x3d46c3741686c40d => {
4512                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4513                        let mut req = fidl::new_empty!(
4514                            fidl::encoding::EmptyPayload,
4515                            fidl::encoding::DefaultFuchsiaResourceDialect
4516                        );
4517                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4518                        let control_handle =
4519                            AudioConsumerControlHandle { inner: this.inner.clone() };
4520                        Ok(AudioConsumerRequest::Stop { control_handle })
4521                    }
4522                    0x45342b73968bfafe => {
4523                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4524                        let mut req = fidl::new_empty!(
4525                            AudioConsumerSetRateRequest,
4526                            fidl::encoding::DefaultFuchsiaResourceDialect
4527                        );
4528                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerSetRateRequest>(&header, _body_bytes, handles, &mut req)?;
4529                        let control_handle =
4530                            AudioConsumerControlHandle { inner: this.inner.clone() };
4531                        Ok(AudioConsumerRequest::SetRate { rate: req.rate, control_handle })
4532                    }
4533                    0x6f1b01fd887f5748 => {
4534                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4535                        let mut req = fidl::new_empty!(
4536                            AudioConsumerBindVolumeControlRequest,
4537                            fidl::encoding::DefaultFuchsiaResourceDialect
4538                        );
4539                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerBindVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
4540                        let control_handle =
4541                            AudioConsumerControlHandle { inner: this.inner.clone() };
4542                        Ok(AudioConsumerRequest::BindVolumeControl {
4543                            volume_control_request: req.volume_control_request,
4544
4545                            control_handle,
4546                        })
4547                    }
4548                    0x35cf702c721e2cc6 => {
4549                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4550                        let mut req = fidl::new_empty!(
4551                            fidl::encoding::EmptyPayload,
4552                            fidl::encoding::DefaultFuchsiaResourceDialect
4553                        );
4554                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4555                        let control_handle =
4556                            AudioConsumerControlHandle { inner: this.inner.clone() };
4557                        Ok(AudioConsumerRequest::WatchStatus {
4558                            responder: AudioConsumerWatchStatusResponder {
4559                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4560                                tx_id: header.tx_id,
4561                            },
4562                        })
4563                    }
4564                    _ => Err(fidl::Error::UnknownOrdinal {
4565                        ordinal: header.ordinal,
4566                        protocol_name:
4567                            <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4568                    }),
4569                }))
4570            },
4571        )
4572    }
4573}
4574
4575/// Interface for playing and controlling audio.
4576#[derive(Debug)]
4577pub enum AudioConsumerRequest {
4578    /// Creates a `StreamSink` for the consumer with the indicated properties.
4579    ///
4580    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
4581    /// sequentially rather than concurrently. The first stream sink that's created using this
4582    /// method is used as the sole source of packets incoming to the logical consumer until that
4583    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
4584    /// the second stream sink is used, and so on.
4585    ///
4586    /// If an unsupported compression type is supplied, the
4587    /// `stream_sink_request` request will be closed with an epitaph value of
4588    /// `ZX_ERR_INVALID_ARGS`.
4589    CreateStreamSink {
4590        buffers: Vec<fidl::Vmo>,
4591        stream_type: AudioStreamType,
4592        compression: Option<Box<Compression>>,
4593        stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4594        control_handle: AudioConsumerControlHandle,
4595    },
4596    /// Starts rendering as indicated by `flags`.
4597    ///
4598    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4599    /// Typically, this is the timestamp of the first packet that will be
4600    /// rendered. If packets will be supplied with no timestamps, this value
4601    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4602    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4603    ///     1. When starting for the first time, the default media time is the
4604    ///        timestamp on the first packet sent to the stream sink.
4605    ///     2. When resuming after stop, the default media time is the media
4606    ///        time at which the stream stopped.
4607    ///
4608    /// `reference_time` is the monotonic system time at which rendering should
4609    /// be started. For supply-driven sources, this must be the time at which
4610    /// the first packet was (or will be) sent plus a lead time, which must be
4611    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4612    /// sources, the client must ensure that the lead time requirement is met at
4613    /// the start time.  Passing the default value of 0 for `reference_time`
4614    /// causes the consumer to choose a start time based on the availability of
4615    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4616    /// specified.
4617    ///
4618    /// The actual start time will be reflected in the updated status.
4619    Start {
4620        flags: AudioConsumerStartFlags,
4621        reference_time: i64,
4622        media_time: i64,
4623        control_handle: AudioConsumerControlHandle,
4624    },
4625    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4626    /// be reflected in the updated status.
4627    Stop { control_handle: AudioConsumerControlHandle },
4628    /// Requests to change the playback rate of the renderer. 1.0 means normal
4629    /// playback. Negative rates are not supported. The new rate will be
4630    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4631    SetRate { rate: f32, control_handle: AudioConsumerControlHandle },
4632    /// Binds to this `AudioConsumer` volume control for control and notifications.
4633    BindVolumeControl {
4634        volume_control_request:
4635            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4636        control_handle: AudioConsumerControlHandle,
4637    },
4638    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4639    /// to this method when the status changes - initially with respect to the initial status value
4640    /// and thereafter with respect to the previously-reported status value.
4641    WatchStatus { responder: AudioConsumerWatchStatusResponder },
4642}
4643
4644impl AudioConsumerRequest {
4645    #[allow(irrefutable_let_patterns)]
4646    pub fn into_create_stream_sink(
4647        self,
4648    ) -> Option<(
4649        Vec<fidl::Vmo>,
4650        AudioStreamType,
4651        Option<Box<Compression>>,
4652        fidl::endpoints::ServerEnd<StreamSinkMarker>,
4653        AudioConsumerControlHandle,
4654    )> {
4655        if let AudioConsumerRequest::CreateStreamSink {
4656            buffers,
4657            stream_type,
4658            compression,
4659            stream_sink_request,
4660            control_handle,
4661        } = self
4662        {
4663            Some((buffers, stream_type, compression, stream_sink_request, control_handle))
4664        } else {
4665            None
4666        }
4667    }
4668
4669    #[allow(irrefutable_let_patterns)]
4670    pub fn into_start(
4671        self,
4672    ) -> Option<(AudioConsumerStartFlags, i64, i64, AudioConsumerControlHandle)> {
4673        if let AudioConsumerRequest::Start { flags, reference_time, media_time, control_handle } =
4674            self
4675        {
4676            Some((flags, reference_time, media_time, control_handle))
4677        } else {
4678            None
4679        }
4680    }
4681
4682    #[allow(irrefutable_let_patterns)]
4683    pub fn into_stop(self) -> Option<(AudioConsumerControlHandle)> {
4684        if let AudioConsumerRequest::Stop { control_handle } = self {
4685            Some((control_handle))
4686        } else {
4687            None
4688        }
4689    }
4690
4691    #[allow(irrefutable_let_patterns)]
4692    pub fn into_set_rate(self) -> Option<(f32, AudioConsumerControlHandle)> {
4693        if let AudioConsumerRequest::SetRate { rate, control_handle } = self {
4694            Some((rate, control_handle))
4695        } else {
4696            None
4697        }
4698    }
4699
4700    #[allow(irrefutable_let_patterns)]
4701    pub fn into_bind_volume_control(
4702        self,
4703    ) -> Option<(
4704        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4705        AudioConsumerControlHandle,
4706    )> {
4707        if let AudioConsumerRequest::BindVolumeControl { volume_control_request, control_handle } =
4708            self
4709        {
4710            Some((volume_control_request, control_handle))
4711        } else {
4712            None
4713        }
4714    }
4715
4716    #[allow(irrefutable_let_patterns)]
4717    pub fn into_watch_status(self) -> Option<(AudioConsumerWatchStatusResponder)> {
4718        if let AudioConsumerRequest::WatchStatus { responder } = self {
4719            Some((responder))
4720        } else {
4721            None
4722        }
4723    }
4724
4725    /// Name of the method defined in FIDL
4726    pub fn method_name(&self) -> &'static str {
4727        match *self {
4728            AudioConsumerRequest::CreateStreamSink { .. } => "create_stream_sink",
4729            AudioConsumerRequest::Start { .. } => "start",
4730            AudioConsumerRequest::Stop { .. } => "stop",
4731            AudioConsumerRequest::SetRate { .. } => "set_rate",
4732            AudioConsumerRequest::BindVolumeControl { .. } => "bind_volume_control",
4733            AudioConsumerRequest::WatchStatus { .. } => "watch_status",
4734        }
4735    }
4736}
4737
4738#[derive(Debug, Clone)]
4739pub struct AudioConsumerControlHandle {
4740    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4741}
4742
4743impl fidl::endpoints::ControlHandle for AudioConsumerControlHandle {
4744    fn shutdown(&self) {
4745        self.inner.shutdown()
4746    }
4747    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4748        self.inner.shutdown_with_epitaph(status)
4749    }
4750
4751    fn is_closed(&self) -> bool {
4752        self.inner.channel().is_closed()
4753    }
4754    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4755        self.inner.channel().on_closed()
4756    }
4757
4758    #[cfg(target_os = "fuchsia")]
4759    fn signal_peer(
4760        &self,
4761        clear_mask: zx::Signals,
4762        set_mask: zx::Signals,
4763    ) -> Result<(), zx_status::Status> {
4764        use fidl::Peered;
4765        self.inner.channel().signal_peer(clear_mask, set_mask)
4766    }
4767}
4768
4769impl AudioConsumerControlHandle {
4770    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
4771        self.inner.send::<fidl::encoding::EmptyPayload>(
4772            (),
4773            0,
4774            0x53a64e6d0e8f8a20,
4775            fidl::encoding::DynamicFlags::empty(),
4776        )
4777    }
4778}
4779
4780#[must_use = "FIDL methods require a response to be sent"]
4781#[derive(Debug)]
4782pub struct AudioConsumerWatchStatusResponder {
4783    control_handle: std::mem::ManuallyDrop<AudioConsumerControlHandle>,
4784    tx_id: u32,
4785}
4786
4787/// Set the the channel to be shutdown (see [`AudioConsumerControlHandle::shutdown`])
4788/// if the responder is dropped without sending a response, so that the client
4789/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4790impl std::ops::Drop for AudioConsumerWatchStatusResponder {
4791    fn drop(&mut self) {
4792        self.control_handle.shutdown();
4793        // Safety: drops once, never accessed again
4794        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4795    }
4796}
4797
4798impl fidl::endpoints::Responder for AudioConsumerWatchStatusResponder {
4799    type ControlHandle = AudioConsumerControlHandle;
4800
4801    fn control_handle(&self) -> &AudioConsumerControlHandle {
4802        &self.control_handle
4803    }
4804
4805    fn drop_without_shutdown(mut self) {
4806        // Safety: drops once, never accessed again due to mem::forget
4807        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4808        // Prevent Drop from running (which would shut down the channel)
4809        std::mem::forget(self);
4810    }
4811}
4812
4813impl AudioConsumerWatchStatusResponder {
4814    /// Sends a response to the FIDL transaction.
4815    ///
4816    /// Sets the channel to shutdown if an error occurs.
4817    pub fn send(self, mut status: &AudioConsumerStatus) -> Result<(), fidl::Error> {
4818        let _result = self.send_raw(status);
4819        if _result.is_err() {
4820            self.control_handle.shutdown();
4821        }
4822        self.drop_without_shutdown();
4823        _result
4824    }
4825
4826    /// Similar to "send" but does not shutdown the channel if an error occurs.
4827    pub fn send_no_shutdown_on_err(
4828        self,
4829        mut status: &AudioConsumerStatus,
4830    ) -> Result<(), fidl::Error> {
4831        let _result = self.send_raw(status);
4832        self.drop_without_shutdown();
4833        _result
4834    }
4835
4836    fn send_raw(&self, mut status: &AudioConsumerStatus) -> Result<(), fidl::Error> {
4837        self.control_handle.inner.send::<AudioConsumerWatchStatusResponse>(
4838            (status,),
4839            self.tx_id,
4840            0x35cf702c721e2cc6,
4841            fidl::encoding::DynamicFlags::empty(),
4842        )
4843    }
4844}
4845
4846#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4847pub struct AudioCoreMarker;
4848
4849impl fidl::endpoints::ProtocolMarker for AudioCoreMarker {
4850    type Proxy = AudioCoreProxy;
4851    type RequestStream = AudioCoreRequestStream;
4852    #[cfg(target_os = "fuchsia")]
4853    type SynchronousProxy = AudioCoreSynchronousProxy;
4854
4855    const DEBUG_NAME: &'static str = "fuchsia.media.AudioCore";
4856}
4857impl fidl::endpoints::DiscoverableProtocolMarker for AudioCoreMarker {}
4858
4859pub trait AudioCoreProxyInterface: Send + Sync {
4860    fn r#create_audio_renderer(
4861        &self,
4862        audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
4863    ) -> Result<(), fidl::Error>;
4864    fn r#create_audio_capturer_with_configuration(
4865        &self,
4866        stream_type: &AudioStreamType,
4867        configuration: &AudioCapturerConfiguration,
4868        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
4869    ) -> Result<(), fidl::Error>;
4870    fn r#create_audio_capturer(
4871        &self,
4872        loopback: bool,
4873        audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
4874    ) -> Result<(), fidl::Error>;
4875    fn r#enable_device_settings(&self, enabled: bool) -> Result<(), fidl::Error>;
4876    fn r#set_render_usage_gain(
4877        &self,
4878        usage: AudioRenderUsage,
4879        gain_db: f32,
4880    ) -> Result<(), fidl::Error>;
4881    fn r#set_render_usage_gain2(
4882        &self,
4883        usage: AudioRenderUsage2,
4884        gain_db: f32,
4885    ) -> Result<(), fidl::Error>;
4886    fn r#set_capture_usage_gain(
4887        &self,
4888        usage: AudioCaptureUsage,
4889        gain_db: f32,
4890    ) -> Result<(), fidl::Error>;
4891    fn r#set_capture_usage_gain2(
4892        &self,
4893        usage: AudioCaptureUsage2,
4894        gain_db: f32,
4895    ) -> Result<(), fidl::Error>;
4896    fn r#bind_usage_volume_control(
4897        &self,
4898        usage: &Usage,
4899        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4900    ) -> Result<(), fidl::Error>;
4901    fn r#bind_usage_volume_control2(
4902        &self,
4903        usage: &Usage2,
4904        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4905    ) -> Result<(), fidl::Error>;
4906    type GetVolumeFromDbResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4907    fn r#get_volume_from_db(&self, usage: &Usage, gain_db: f32)
4908        -> Self::GetVolumeFromDbResponseFut;
4909    type GetVolumeFromDb2ResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4910    fn r#get_volume_from_db2(
4911        &self,
4912        usage: &Usage2,
4913        gain_db: f32,
4914    ) -> Self::GetVolumeFromDb2ResponseFut;
4915    type GetDbFromVolumeResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4916    fn r#get_db_from_volume(&self, usage: &Usage, volume: f32) -> Self::GetDbFromVolumeResponseFut;
4917    type GetDbFromVolume2ResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4918    fn r#get_db_from_volume2(
4919        &self,
4920        usage: &Usage2,
4921        volume: f32,
4922    ) -> Self::GetDbFromVolume2ResponseFut;
4923    fn r#set_interaction(
4924        &self,
4925        active: &Usage,
4926        affected: &Usage,
4927        behavior: Behavior,
4928    ) -> Result<(), fidl::Error>;
4929    fn r#set_interaction2(
4930        &self,
4931        active: &Usage2,
4932        affected: &Usage2,
4933        behavior: Behavior,
4934    ) -> Result<(), fidl::Error>;
4935    fn r#reset_interactions(&self) -> Result<(), fidl::Error>;
4936    fn r#load_defaults(&self) -> Result<(), fidl::Error>;
4937}
4938#[derive(Debug)]
4939#[cfg(target_os = "fuchsia")]
4940pub struct AudioCoreSynchronousProxy {
4941    client: fidl::client::sync::Client,
4942}
4943
4944#[cfg(target_os = "fuchsia")]
4945impl fidl::endpoints::SynchronousProxy for AudioCoreSynchronousProxy {
4946    type Proxy = AudioCoreProxy;
4947    type Protocol = AudioCoreMarker;
4948
4949    fn from_channel(inner: fidl::Channel) -> Self {
4950        Self::new(inner)
4951    }
4952
4953    fn into_channel(self) -> fidl::Channel {
4954        self.client.into_channel()
4955    }
4956
4957    fn as_channel(&self) -> &fidl::Channel {
4958        self.client.as_channel()
4959    }
4960}
4961
4962#[cfg(target_os = "fuchsia")]
4963impl AudioCoreSynchronousProxy {
4964    pub fn new(channel: fidl::Channel) -> Self {
4965        let protocol_name = <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4966        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4967    }
4968
4969    pub fn into_channel(self) -> fidl::Channel {
4970        self.client.into_channel()
4971    }
4972
4973    /// Waits until an event arrives and returns it. It is safe for other
4974    /// threads to make concurrent requests while waiting for an event.
4975    pub fn wait_for_event(
4976        &self,
4977        deadline: zx::MonotonicInstant,
4978    ) -> Result<AudioCoreEvent, fidl::Error> {
4979        AudioCoreEvent::decode(self.client.wait_for_event(deadline)?)
4980    }
4981
4982    /// Creates an AudioRenderer which outputs audio to the default device.
4983    pub fn r#create_audio_renderer(
4984        &self,
4985        mut audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
4986    ) -> Result<(), fidl::Error> {
4987        self.client.send::<AudioCoreCreateAudioRendererRequest>(
4988            (audio_out_request,),
4989            0x2ac9beba47f83435,
4990            fidl::encoding::DynamicFlags::empty(),
4991        )
4992    }
4993
4994    /// Creates an AudioCapturer according to the given requirements.
4995    ///
4996    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
4997    /// It causes the source material to be reformatted/resampled if needed
4998    /// in order to produce the requested stream type.
4999    ///
5000    /// `usage` is used by Fuchsia to make decisions about user experience.
5001    /// See `AudioCaptureUsage` for more details.
5002    ///
5003    /// `configuration` must be initialized to a variant, or no capturer
5004    /// can be created.
5005    pub fn r#create_audio_capturer_with_configuration(
5006        &self,
5007        mut stream_type: &AudioStreamType,
5008        mut configuration: &AudioCapturerConfiguration,
5009        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5010    ) -> Result<(), fidl::Error> {
5011        self.client.send::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(
5012            (stream_type, configuration, audio_capturer_request),
5013            0x459de383b0d76d97,
5014            fidl::encoding::DynamicFlags::empty(),
5015        )
5016    }
5017
5018    /// Creates an AudioCapturer which either captures from the current default
5019    /// audio input device, or loops-back from the current default audio output
5020    /// device based on value passed for the loopback flag.
5021    pub fn r#create_audio_capturer(
5022        &self,
5023        mut loopback: bool,
5024        mut audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5025    ) -> Result<(), fidl::Error> {
5026        self.client.send::<AudioCoreCreateAudioCapturerRequest>(
5027            (loopback, audio_in_request),
5028            0x787db169df99aed0,
5029            fidl::encoding::DynamicFlags::empty(),
5030        )
5031    }
5032
5033    pub fn r#enable_device_settings(&self, mut enabled: bool) -> Result<(), fidl::Error> {
5034        self.client.send::<AudioCoreEnableDeviceSettingsRequest>(
5035            (enabled,),
5036            0x41107a1917269b3e,
5037            fidl::encoding::DynamicFlags::empty(),
5038        )
5039    }
5040
5041    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5042    pub fn r#set_render_usage_gain(
5043        &self,
5044        mut usage: AudioRenderUsage,
5045        mut gain_db: f32,
5046    ) -> Result<(), fidl::Error> {
5047        self.client.send::<AudioCoreSetRenderUsageGainRequest>(
5048            (usage, gain_db),
5049            0x48097f45f6e2b8e7,
5050            fidl::encoding::DynamicFlags::empty(),
5051        )
5052    }
5053
5054    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5055    pub fn r#set_render_usage_gain2(
5056        &self,
5057        mut usage: AudioRenderUsage2,
5058        mut gain_db: f32,
5059    ) -> Result<(), fidl::Error> {
5060        self.client.send::<AudioCoreSetRenderUsageGain2Request>(
5061            (usage, gain_db),
5062            0x779b1531dc9e64f4,
5063            fidl::encoding::DynamicFlags::FLEXIBLE,
5064        )
5065    }
5066
5067    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5068    pub fn r#set_capture_usage_gain(
5069        &self,
5070        mut usage: AudioCaptureUsage,
5071        mut gain_db: f32,
5072    ) -> Result<(), fidl::Error> {
5073        self.client.send::<AudioCoreSetCaptureUsageGainRequest>(
5074            (usage, gain_db),
5075            0x457d29217d4ea248,
5076            fidl::encoding::DynamicFlags::empty(),
5077        )
5078    }
5079
5080    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5081    pub fn r#set_capture_usage_gain2(
5082        &self,
5083        mut usage: AudioCaptureUsage2,
5084        mut gain_db: f32,
5085    ) -> Result<(), fidl::Error> {
5086        self.client.send::<AudioCoreSetCaptureUsageGain2Request>(
5087            (usage, gain_db),
5088            0x15065ee308f44af0,
5089            fidl::encoding::DynamicFlags::FLEXIBLE,
5090        )
5091    }
5092
5093    /// Binds to a volume control protocol for the given usage.
5094    pub fn r#bind_usage_volume_control(
5095        &self,
5096        mut usage: &Usage,
5097        mut volume_control: fidl::endpoints::ServerEnd<
5098            fidl_fuchsia_media_audio::VolumeControlMarker,
5099        >,
5100    ) -> Result<(), fidl::Error> {
5101        self.client.send::<AudioCoreBindUsageVolumeControlRequest>(
5102            (usage, volume_control),
5103            0x7225be116aadc137,
5104            fidl::encoding::DynamicFlags::empty(),
5105        )
5106    }
5107
5108    /// Binds to a volume control protocol for the given usage.
5109    pub fn r#bind_usage_volume_control2(
5110        &self,
5111        mut usage: &Usage2,
5112        mut volume_control: fidl::endpoints::ServerEnd<
5113            fidl_fuchsia_media_audio::VolumeControlMarker,
5114        >,
5115    ) -> Result<(), fidl::Error> {
5116        self.client.send::<AudioCoreBindUsageVolumeControl2Request>(
5117            (usage, volume_control),
5118            0x729dff93019d055,
5119            fidl::encoding::DynamicFlags::FLEXIBLE,
5120        )
5121    }
5122
5123    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5124    /// `usage`. This is the same mapping as used by the VolumeControl from
5125    /// `BindUsageVolumeControl`.
5126    pub fn r#get_volume_from_db(
5127        &self,
5128        mut usage: &Usage,
5129        mut gain_db: f32,
5130        ___deadline: zx::MonotonicInstant,
5131    ) -> Result<f32, fidl::Error> {
5132        let _response = self
5133            .client
5134            .send_query::<AudioCoreGetVolumeFromDbRequest, AudioCoreGetVolumeFromDbResponse>(
5135                (usage, gain_db),
5136                0x50e3ca45509770bf,
5137                fidl::encoding::DynamicFlags::empty(),
5138                ___deadline,
5139            )?;
5140        Ok(_response.volume)
5141    }
5142
5143    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5144    /// `usage`. This is the same mapping as used by the VolumeControl from
5145    /// `BindUsageVolumeControl`.
5146    pub fn r#get_volume_from_db2(
5147        &self,
5148        mut usage: &Usage2,
5149        mut gain_db: f32,
5150        ___deadline: zx::MonotonicInstant,
5151    ) -> Result<f32, fidl::Error> {
5152        let _response = self.client.send_query::<
5153            AudioCoreGetVolumeFromDb2Request,
5154            fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>,
5155        >(
5156            (usage, gain_db,),
5157            0x165c811091ef99da,
5158            fidl::encoding::DynamicFlags::FLEXIBLE,
5159            ___deadline,
5160        )?
5161        .into_result::<AudioCoreMarker>("get_volume_from_db2")?;
5162        Ok(_response.volume)
5163    }
5164
5165    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5166    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5167    pub fn r#get_db_from_volume(
5168        &self,
5169        mut usage: &Usage,
5170        mut volume: f32,
5171        ___deadline: zx::MonotonicInstant,
5172    ) -> Result<f32, fidl::Error> {
5173        let _response = self
5174            .client
5175            .send_query::<AudioCoreGetDbFromVolumeRequest, AudioCoreGetDbFromVolumeResponse>(
5176                (usage, volume),
5177                0x3e8eec27dd5a8bda,
5178                fidl::encoding::DynamicFlags::empty(),
5179                ___deadline,
5180            )?;
5181        Ok(_response.gain_db)
5182    }
5183
5184    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5185    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5186    pub fn r#get_db_from_volume2(
5187        &self,
5188        mut usage: &Usage2,
5189        mut volume: f32,
5190        ___deadline: zx::MonotonicInstant,
5191    ) -> Result<f32, fidl::Error> {
5192        let _response = self.client.send_query::<
5193            AudioCoreGetDbFromVolume2Request,
5194            fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>,
5195        >(
5196            (usage, volume,),
5197            0x5f421a8ebf265bf3,
5198            fidl::encoding::DynamicFlags::FLEXIBLE,
5199            ___deadline,
5200        )?
5201        .into_result::<AudioCoreMarker>("get_db_from_volume2")?;
5202        Ok(_response.gain_db)
5203    }
5204
5205    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5206    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5207    /// the Behavior specified will be applied to the streams of Usage `affected`.
5208    pub fn r#set_interaction(
5209        &self,
5210        mut active: &Usage,
5211        mut affected: &Usage,
5212        mut behavior: Behavior,
5213    ) -> Result<(), fidl::Error> {
5214        self.client.send::<AudioCoreSetInteractionRequest>(
5215            (active, affected, behavior),
5216            0x7bfed14345ece7b7,
5217            fidl::encoding::DynamicFlags::empty(),
5218        )
5219    }
5220
5221    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5222    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5223    /// the Behavior specified will be applied to the streams of Usage `affected`.
5224    pub fn r#set_interaction2(
5225        &self,
5226        mut active: &Usage2,
5227        mut affected: &Usage2,
5228        mut behavior: Behavior,
5229    ) -> Result<(), fidl::Error> {
5230        self.client.send::<AudioCoreSetInteraction2Request>(
5231            (active, affected, behavior),
5232            0x7226c7c6e6edc62f,
5233            fidl::encoding::DynamicFlags::FLEXIBLE,
5234        )
5235    }
5236
5237    /// Re-initializes the set of rules that are currently governing the interaction of streams in
5238    /// audio_core. The default behavior is 'NONE'.
5239    pub fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
5240        self.client.send::<fidl::encoding::EmptyPayload>(
5241            (),
5242            0x65bd94d9d0a28b5e,
5243            fidl::encoding::DynamicFlags::empty(),
5244        )
5245    }
5246
5247    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
5248    /// does not provide a config.
5249    pub fn r#load_defaults(&self) -> Result<(), fidl::Error> {
5250        self.client.send::<fidl::encoding::EmptyPayload>(
5251            (),
5252            0x54a0bebca85f6b31,
5253            fidl::encoding::DynamicFlags::empty(),
5254        )
5255    }
5256}
5257
5258#[cfg(target_os = "fuchsia")]
5259impl From<AudioCoreSynchronousProxy> for zx::Handle {
5260    fn from(value: AudioCoreSynchronousProxy) -> Self {
5261        value.into_channel().into()
5262    }
5263}
5264
5265#[cfg(target_os = "fuchsia")]
5266impl From<fidl::Channel> for AudioCoreSynchronousProxy {
5267    fn from(value: fidl::Channel) -> Self {
5268        Self::new(value)
5269    }
5270}
5271
5272#[cfg(target_os = "fuchsia")]
5273impl fidl::endpoints::FromClient for AudioCoreSynchronousProxy {
5274    type Protocol = AudioCoreMarker;
5275
5276    fn from_client(value: fidl::endpoints::ClientEnd<AudioCoreMarker>) -> Self {
5277        Self::new(value.into_channel())
5278    }
5279}
5280
5281#[derive(Debug, Clone)]
5282pub struct AudioCoreProxy {
5283    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5284}
5285
5286impl fidl::endpoints::Proxy for AudioCoreProxy {
5287    type Protocol = AudioCoreMarker;
5288
5289    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5290        Self::new(inner)
5291    }
5292
5293    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5294        self.client.into_channel().map_err(|client| Self { client })
5295    }
5296
5297    fn as_channel(&self) -> &::fidl::AsyncChannel {
5298        self.client.as_channel()
5299    }
5300}
5301
5302impl AudioCoreProxy {
5303    /// Create a new Proxy for fuchsia.media/AudioCore.
5304    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5305        let protocol_name = <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5306        Self { client: fidl::client::Client::new(channel, protocol_name) }
5307    }
5308
5309    /// Get a Stream of events from the remote end of the protocol.
5310    ///
5311    /// # Panics
5312    ///
5313    /// Panics if the event stream was already taken.
5314    pub fn take_event_stream(&self) -> AudioCoreEventStream {
5315        AudioCoreEventStream { event_receiver: self.client.take_event_receiver() }
5316    }
5317
5318    /// Creates an AudioRenderer which outputs audio to the default device.
5319    pub fn r#create_audio_renderer(
5320        &self,
5321        mut audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
5322    ) -> Result<(), fidl::Error> {
5323        AudioCoreProxyInterface::r#create_audio_renderer(self, audio_out_request)
5324    }
5325
5326    /// Creates an AudioCapturer according to the given requirements.
5327    ///
5328    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
5329    /// It causes the source material to be reformatted/resampled if needed
5330    /// in order to produce the requested stream type.
5331    ///
5332    /// `usage` is used by Fuchsia to make decisions about user experience.
5333    /// See `AudioCaptureUsage` for more details.
5334    ///
5335    /// `configuration` must be initialized to a variant, or no capturer
5336    /// can be created.
5337    pub fn r#create_audio_capturer_with_configuration(
5338        &self,
5339        mut stream_type: &AudioStreamType,
5340        mut configuration: &AudioCapturerConfiguration,
5341        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5342    ) -> Result<(), fidl::Error> {
5343        AudioCoreProxyInterface::r#create_audio_capturer_with_configuration(
5344            self,
5345            stream_type,
5346            configuration,
5347            audio_capturer_request,
5348        )
5349    }
5350
5351    /// Creates an AudioCapturer which either captures from the current default
5352    /// audio input device, or loops-back from the current default audio output
5353    /// device based on value passed for the loopback flag.
5354    pub fn r#create_audio_capturer(
5355        &self,
5356        mut loopback: bool,
5357        mut audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5358    ) -> Result<(), fidl::Error> {
5359        AudioCoreProxyInterface::r#create_audio_capturer(self, loopback, audio_in_request)
5360    }
5361
5362    pub fn r#enable_device_settings(&self, mut enabled: bool) -> Result<(), fidl::Error> {
5363        AudioCoreProxyInterface::r#enable_device_settings(self, enabled)
5364    }
5365
5366    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5367    pub fn r#set_render_usage_gain(
5368        &self,
5369        mut usage: AudioRenderUsage,
5370        mut gain_db: f32,
5371    ) -> Result<(), fidl::Error> {
5372        AudioCoreProxyInterface::r#set_render_usage_gain(self, usage, gain_db)
5373    }
5374
5375    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5376    pub fn r#set_render_usage_gain2(
5377        &self,
5378        mut usage: AudioRenderUsage2,
5379        mut gain_db: f32,
5380    ) -> Result<(), fidl::Error> {
5381        AudioCoreProxyInterface::r#set_render_usage_gain2(self, usage, gain_db)
5382    }
5383
5384    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5385    pub fn r#set_capture_usage_gain(
5386        &self,
5387        mut usage: AudioCaptureUsage,
5388        mut gain_db: f32,
5389    ) -> Result<(), fidl::Error> {
5390        AudioCoreProxyInterface::r#set_capture_usage_gain(self, usage, gain_db)
5391    }
5392
5393    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5394    pub fn r#set_capture_usage_gain2(
5395        &self,
5396        mut usage: AudioCaptureUsage2,
5397        mut gain_db: f32,
5398    ) -> Result<(), fidl::Error> {
5399        AudioCoreProxyInterface::r#set_capture_usage_gain2(self, usage, gain_db)
5400    }
5401
5402    /// Binds to a volume control protocol for the given usage.
5403    pub fn r#bind_usage_volume_control(
5404        &self,
5405        mut usage: &Usage,
5406        mut volume_control: fidl::endpoints::ServerEnd<
5407            fidl_fuchsia_media_audio::VolumeControlMarker,
5408        >,
5409    ) -> Result<(), fidl::Error> {
5410        AudioCoreProxyInterface::r#bind_usage_volume_control(self, usage, volume_control)
5411    }
5412
5413    /// Binds to a volume control protocol for the given usage.
5414    pub fn r#bind_usage_volume_control2(
5415        &self,
5416        mut usage: &Usage2,
5417        mut volume_control: fidl::endpoints::ServerEnd<
5418            fidl_fuchsia_media_audio::VolumeControlMarker,
5419        >,
5420    ) -> Result<(), fidl::Error> {
5421        AudioCoreProxyInterface::r#bind_usage_volume_control2(self, usage, volume_control)
5422    }
5423
5424    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5425    /// `usage`. This is the same mapping as used by the VolumeControl from
5426    /// `BindUsageVolumeControl`.
5427    pub fn r#get_volume_from_db(
5428        &self,
5429        mut usage: &Usage,
5430        mut gain_db: f32,
5431    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5432        AudioCoreProxyInterface::r#get_volume_from_db(self, usage, gain_db)
5433    }
5434
5435    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5436    /// `usage`. This is the same mapping as used by the VolumeControl from
5437    /// `BindUsageVolumeControl`.
5438    pub fn r#get_volume_from_db2(
5439        &self,
5440        mut usage: &Usage2,
5441        mut gain_db: f32,
5442    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5443        AudioCoreProxyInterface::r#get_volume_from_db2(self, usage, gain_db)
5444    }
5445
5446    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5447    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5448    pub fn r#get_db_from_volume(
5449        &self,
5450        mut usage: &Usage,
5451        mut volume: f32,
5452    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5453        AudioCoreProxyInterface::r#get_db_from_volume(self, usage, volume)
5454    }
5455
5456    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5457    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5458    pub fn r#get_db_from_volume2(
5459        &self,
5460        mut usage: &Usage2,
5461        mut volume: f32,
5462    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5463        AudioCoreProxyInterface::r#get_db_from_volume2(self, usage, volume)
5464    }
5465
5466    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5467    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5468    /// the Behavior specified will be applied to the streams of Usage `affected`.
5469    pub fn r#set_interaction(
5470        &self,
5471        mut active: &Usage,
5472        mut affected: &Usage,
5473        mut behavior: Behavior,
5474    ) -> Result<(), fidl::Error> {
5475        AudioCoreProxyInterface::r#set_interaction(self, active, affected, behavior)
5476    }
5477
5478    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5479    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5480    /// the Behavior specified will be applied to the streams of Usage `affected`.
5481    pub fn r#set_interaction2(
5482        &self,
5483        mut active: &Usage2,
5484        mut affected: &Usage2,
5485        mut behavior: Behavior,
5486    ) -> Result<(), fidl::Error> {
5487        AudioCoreProxyInterface::r#set_interaction2(self, active, affected, behavior)
5488    }
5489
5490    /// Re-initializes the set of rules that are currently governing the interaction of streams in
5491    /// audio_core. The default behavior is 'NONE'.
5492    pub fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
5493        AudioCoreProxyInterface::r#reset_interactions(self)
5494    }
5495
5496    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
5497    /// does not provide a config.
5498    pub fn r#load_defaults(&self) -> Result<(), fidl::Error> {
5499        AudioCoreProxyInterface::r#load_defaults(self)
5500    }
5501}
5502
5503impl AudioCoreProxyInterface for AudioCoreProxy {
5504    fn r#create_audio_renderer(
5505        &self,
5506        mut audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
5507    ) -> Result<(), fidl::Error> {
5508        self.client.send::<AudioCoreCreateAudioRendererRequest>(
5509            (audio_out_request,),
5510            0x2ac9beba47f83435,
5511            fidl::encoding::DynamicFlags::empty(),
5512        )
5513    }
5514
5515    fn r#create_audio_capturer_with_configuration(
5516        &self,
5517        mut stream_type: &AudioStreamType,
5518        mut configuration: &AudioCapturerConfiguration,
5519        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5520    ) -> Result<(), fidl::Error> {
5521        self.client.send::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(
5522            (stream_type, configuration, audio_capturer_request),
5523            0x459de383b0d76d97,
5524            fidl::encoding::DynamicFlags::empty(),
5525        )
5526    }
5527
5528    fn r#create_audio_capturer(
5529        &self,
5530        mut loopback: bool,
5531        mut audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5532    ) -> Result<(), fidl::Error> {
5533        self.client.send::<AudioCoreCreateAudioCapturerRequest>(
5534            (loopback, audio_in_request),
5535            0x787db169df99aed0,
5536            fidl::encoding::DynamicFlags::empty(),
5537        )
5538    }
5539
5540    fn r#enable_device_settings(&self, mut enabled: bool) -> Result<(), fidl::Error> {
5541        self.client.send::<AudioCoreEnableDeviceSettingsRequest>(
5542            (enabled,),
5543            0x41107a1917269b3e,
5544            fidl::encoding::DynamicFlags::empty(),
5545        )
5546    }
5547
5548    fn r#set_render_usage_gain(
5549        &self,
5550        mut usage: AudioRenderUsage,
5551        mut gain_db: f32,
5552    ) -> Result<(), fidl::Error> {
5553        self.client.send::<AudioCoreSetRenderUsageGainRequest>(
5554            (usage, gain_db),
5555            0x48097f45f6e2b8e7,
5556            fidl::encoding::DynamicFlags::empty(),
5557        )
5558    }
5559
5560    fn r#set_render_usage_gain2(
5561        &self,
5562        mut usage: AudioRenderUsage2,
5563        mut gain_db: f32,
5564    ) -> Result<(), fidl::Error> {
5565        self.client.send::<AudioCoreSetRenderUsageGain2Request>(
5566            (usage, gain_db),
5567            0x779b1531dc9e64f4,
5568            fidl::encoding::DynamicFlags::FLEXIBLE,
5569        )
5570    }
5571
5572    fn r#set_capture_usage_gain(
5573        &self,
5574        mut usage: AudioCaptureUsage,
5575        mut gain_db: f32,
5576    ) -> Result<(), fidl::Error> {
5577        self.client.send::<AudioCoreSetCaptureUsageGainRequest>(
5578            (usage, gain_db),
5579            0x457d29217d4ea248,
5580            fidl::encoding::DynamicFlags::empty(),
5581        )
5582    }
5583
5584    fn r#set_capture_usage_gain2(
5585        &self,
5586        mut usage: AudioCaptureUsage2,
5587        mut gain_db: f32,
5588    ) -> Result<(), fidl::Error> {
5589        self.client.send::<AudioCoreSetCaptureUsageGain2Request>(
5590            (usage, gain_db),
5591            0x15065ee308f44af0,
5592            fidl::encoding::DynamicFlags::FLEXIBLE,
5593        )
5594    }
5595
5596    fn r#bind_usage_volume_control(
5597        &self,
5598        mut usage: &Usage,
5599        mut volume_control: fidl::endpoints::ServerEnd<
5600            fidl_fuchsia_media_audio::VolumeControlMarker,
5601        >,
5602    ) -> Result<(), fidl::Error> {
5603        self.client.send::<AudioCoreBindUsageVolumeControlRequest>(
5604            (usage, volume_control),
5605            0x7225be116aadc137,
5606            fidl::encoding::DynamicFlags::empty(),
5607        )
5608    }
5609
5610    fn r#bind_usage_volume_control2(
5611        &self,
5612        mut usage: &Usage2,
5613        mut volume_control: fidl::endpoints::ServerEnd<
5614            fidl_fuchsia_media_audio::VolumeControlMarker,
5615        >,
5616    ) -> Result<(), fidl::Error> {
5617        self.client.send::<AudioCoreBindUsageVolumeControl2Request>(
5618            (usage, volume_control),
5619            0x729dff93019d055,
5620            fidl::encoding::DynamicFlags::FLEXIBLE,
5621        )
5622    }
5623
5624    type GetVolumeFromDbResponseFut =
5625        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5626    fn r#get_volume_from_db(
5627        &self,
5628        mut usage: &Usage,
5629        mut gain_db: f32,
5630    ) -> Self::GetVolumeFromDbResponseFut {
5631        fn _decode(
5632            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5633        ) -> Result<f32, fidl::Error> {
5634            let _response = fidl::client::decode_transaction_body::<
5635                AudioCoreGetVolumeFromDbResponse,
5636                fidl::encoding::DefaultFuchsiaResourceDialect,
5637                0x50e3ca45509770bf,
5638            >(_buf?)?;
5639            Ok(_response.volume)
5640        }
5641        self.client.send_query_and_decode::<AudioCoreGetVolumeFromDbRequest, f32>(
5642            (usage, gain_db),
5643            0x50e3ca45509770bf,
5644            fidl::encoding::DynamicFlags::empty(),
5645            _decode,
5646        )
5647    }
5648
5649    type GetVolumeFromDb2ResponseFut =
5650        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5651    fn r#get_volume_from_db2(
5652        &self,
5653        mut usage: &Usage2,
5654        mut gain_db: f32,
5655    ) -> Self::GetVolumeFromDb2ResponseFut {
5656        fn _decode(
5657            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5658        ) -> Result<f32, fidl::Error> {
5659            let _response = fidl::client::decode_transaction_body::<
5660                fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>,
5661                fidl::encoding::DefaultFuchsiaResourceDialect,
5662                0x165c811091ef99da,
5663            >(_buf?)?
5664            .into_result::<AudioCoreMarker>("get_volume_from_db2")?;
5665            Ok(_response.volume)
5666        }
5667        self.client.send_query_and_decode::<AudioCoreGetVolumeFromDb2Request, f32>(
5668            (usage, gain_db),
5669            0x165c811091ef99da,
5670            fidl::encoding::DynamicFlags::FLEXIBLE,
5671            _decode,
5672        )
5673    }
5674
5675    type GetDbFromVolumeResponseFut =
5676        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5677    fn r#get_db_from_volume(
5678        &self,
5679        mut usage: &Usage,
5680        mut volume: f32,
5681    ) -> Self::GetDbFromVolumeResponseFut {
5682        fn _decode(
5683            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5684        ) -> Result<f32, fidl::Error> {
5685            let _response = fidl::client::decode_transaction_body::<
5686                AudioCoreGetDbFromVolumeResponse,
5687                fidl::encoding::DefaultFuchsiaResourceDialect,
5688                0x3e8eec27dd5a8bda,
5689            >(_buf?)?;
5690            Ok(_response.gain_db)
5691        }
5692        self.client.send_query_and_decode::<AudioCoreGetDbFromVolumeRequest, f32>(
5693            (usage, volume),
5694            0x3e8eec27dd5a8bda,
5695            fidl::encoding::DynamicFlags::empty(),
5696            _decode,
5697        )
5698    }
5699
5700    type GetDbFromVolume2ResponseFut =
5701        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5702    fn r#get_db_from_volume2(
5703        &self,
5704        mut usage: &Usage2,
5705        mut volume: f32,
5706    ) -> Self::GetDbFromVolume2ResponseFut {
5707        fn _decode(
5708            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5709        ) -> Result<f32, fidl::Error> {
5710            let _response = fidl::client::decode_transaction_body::<
5711                fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>,
5712                fidl::encoding::DefaultFuchsiaResourceDialect,
5713                0x5f421a8ebf265bf3,
5714            >(_buf?)?
5715            .into_result::<AudioCoreMarker>("get_db_from_volume2")?;
5716            Ok(_response.gain_db)
5717        }
5718        self.client.send_query_and_decode::<AudioCoreGetDbFromVolume2Request, f32>(
5719            (usage, volume),
5720            0x5f421a8ebf265bf3,
5721            fidl::encoding::DynamicFlags::FLEXIBLE,
5722            _decode,
5723        )
5724    }
5725
5726    fn r#set_interaction(
5727        &self,
5728        mut active: &Usage,
5729        mut affected: &Usage,
5730        mut behavior: Behavior,
5731    ) -> Result<(), fidl::Error> {
5732        self.client.send::<AudioCoreSetInteractionRequest>(
5733            (active, affected, behavior),
5734            0x7bfed14345ece7b7,
5735            fidl::encoding::DynamicFlags::empty(),
5736        )
5737    }
5738
5739    fn r#set_interaction2(
5740        &self,
5741        mut active: &Usage2,
5742        mut affected: &Usage2,
5743        mut behavior: Behavior,
5744    ) -> Result<(), fidl::Error> {
5745        self.client.send::<AudioCoreSetInteraction2Request>(
5746            (active, affected, behavior),
5747            0x7226c7c6e6edc62f,
5748            fidl::encoding::DynamicFlags::FLEXIBLE,
5749        )
5750    }
5751
5752    fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
5753        self.client.send::<fidl::encoding::EmptyPayload>(
5754            (),
5755            0x65bd94d9d0a28b5e,
5756            fidl::encoding::DynamicFlags::empty(),
5757        )
5758    }
5759
5760    fn r#load_defaults(&self) -> Result<(), fidl::Error> {
5761        self.client.send::<fidl::encoding::EmptyPayload>(
5762            (),
5763            0x54a0bebca85f6b31,
5764            fidl::encoding::DynamicFlags::empty(),
5765        )
5766    }
5767}
5768
5769pub struct AudioCoreEventStream {
5770    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5771}
5772
5773impl std::marker::Unpin for AudioCoreEventStream {}
5774
5775impl futures::stream::FusedStream for AudioCoreEventStream {
5776    fn is_terminated(&self) -> bool {
5777        self.event_receiver.is_terminated()
5778    }
5779}
5780
5781impl futures::Stream for AudioCoreEventStream {
5782    type Item = Result<AudioCoreEvent, fidl::Error>;
5783
5784    fn poll_next(
5785        mut self: std::pin::Pin<&mut Self>,
5786        cx: &mut std::task::Context<'_>,
5787    ) -> std::task::Poll<Option<Self::Item>> {
5788        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5789            &mut self.event_receiver,
5790            cx
5791        )?) {
5792            Some(buf) => std::task::Poll::Ready(Some(AudioCoreEvent::decode(buf))),
5793            None => std::task::Poll::Ready(None),
5794        }
5795    }
5796}
5797
5798#[derive(Debug)]
5799pub enum AudioCoreEvent {
5800    #[non_exhaustive]
5801    _UnknownEvent {
5802        /// Ordinal of the event that was sent.
5803        ordinal: u64,
5804    },
5805}
5806
5807impl AudioCoreEvent {
5808    /// Decodes a message buffer as a [`AudioCoreEvent`].
5809    fn decode(
5810        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5811    ) -> Result<AudioCoreEvent, fidl::Error> {
5812        let (bytes, _handles) = buf.split_mut();
5813        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5814        debug_assert_eq!(tx_header.tx_id, 0);
5815        match tx_header.ordinal {
5816            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5817                Ok(AudioCoreEvent::_UnknownEvent { ordinal: tx_header.ordinal })
5818            }
5819            _ => Err(fidl::Error::UnknownOrdinal {
5820                ordinal: tx_header.ordinal,
5821                protocol_name: <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5822            }),
5823        }
5824    }
5825}
5826
5827/// A Stream of incoming requests for fuchsia.media/AudioCore.
5828pub struct AudioCoreRequestStream {
5829    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5830    is_terminated: bool,
5831}
5832
5833impl std::marker::Unpin for AudioCoreRequestStream {}
5834
5835impl futures::stream::FusedStream for AudioCoreRequestStream {
5836    fn is_terminated(&self) -> bool {
5837        self.is_terminated
5838    }
5839}
5840
5841impl fidl::endpoints::RequestStream for AudioCoreRequestStream {
5842    type Protocol = AudioCoreMarker;
5843    type ControlHandle = AudioCoreControlHandle;
5844
5845    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5846        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5847    }
5848
5849    fn control_handle(&self) -> Self::ControlHandle {
5850        AudioCoreControlHandle { inner: self.inner.clone() }
5851    }
5852
5853    fn into_inner(
5854        self,
5855    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5856    {
5857        (self.inner, self.is_terminated)
5858    }
5859
5860    fn from_inner(
5861        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5862        is_terminated: bool,
5863    ) -> Self {
5864        Self { inner, is_terminated }
5865    }
5866}
5867
5868impl futures::Stream for AudioCoreRequestStream {
5869    type Item = Result<AudioCoreRequest, fidl::Error>;
5870
5871    fn poll_next(
5872        mut self: std::pin::Pin<&mut Self>,
5873        cx: &mut std::task::Context<'_>,
5874    ) -> std::task::Poll<Option<Self::Item>> {
5875        let this = &mut *self;
5876        if this.inner.check_shutdown(cx) {
5877            this.is_terminated = true;
5878            return std::task::Poll::Ready(None);
5879        }
5880        if this.is_terminated {
5881            panic!("polled AudioCoreRequestStream after completion");
5882        }
5883        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5884            |bytes, handles| {
5885                match this.inner.channel().read_etc(cx, bytes, handles) {
5886                    std::task::Poll::Ready(Ok(())) => {}
5887                    std::task::Poll::Pending => return std::task::Poll::Pending,
5888                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5889                        this.is_terminated = true;
5890                        return std::task::Poll::Ready(None);
5891                    }
5892                    std::task::Poll::Ready(Err(e)) => {
5893                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5894                            e.into(),
5895                        ))))
5896                    }
5897                }
5898
5899                // A message has been received from the channel
5900                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5901
5902                std::task::Poll::Ready(Some(match header.ordinal {
5903                    0x2ac9beba47f83435 => {
5904                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5905                        let mut req = fidl::new_empty!(
5906                            AudioCoreCreateAudioRendererRequest,
5907                            fidl::encoding::DefaultFuchsiaResourceDialect
5908                        );
5909                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreCreateAudioRendererRequest>(&header, _body_bytes, handles, &mut req)?;
5910                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5911                        Ok(AudioCoreRequest::CreateAudioRenderer {
5912                            audio_out_request: req.audio_out_request,
5913
5914                            control_handle,
5915                        })
5916                    }
5917                    0x459de383b0d76d97 => {
5918                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5919                        let mut req = fidl::new_empty!(
5920                            AudioCoreCreateAudioCapturerWithConfigurationRequest,
5921                            fidl::encoding::DefaultFuchsiaResourceDialect
5922                        );
5923                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(&header, _body_bytes, handles, &mut req)?;
5924                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5925                        Ok(AudioCoreRequest::CreateAudioCapturerWithConfiguration {
5926                            stream_type: req.stream_type,
5927                            configuration: req.configuration,
5928                            audio_capturer_request: req.audio_capturer_request,
5929
5930                            control_handle,
5931                        })
5932                    }
5933                    0x787db169df99aed0 => {
5934                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5935                        let mut req = fidl::new_empty!(
5936                            AudioCoreCreateAudioCapturerRequest,
5937                            fidl::encoding::DefaultFuchsiaResourceDialect
5938                        );
5939                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreCreateAudioCapturerRequest>(&header, _body_bytes, handles, &mut req)?;
5940                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5941                        Ok(AudioCoreRequest::CreateAudioCapturer {
5942                            loopback: req.loopback,
5943                            audio_in_request: req.audio_in_request,
5944
5945                            control_handle,
5946                        })
5947                    }
5948                    0x41107a1917269b3e => {
5949                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5950                        let mut req = fidl::new_empty!(
5951                            AudioCoreEnableDeviceSettingsRequest,
5952                            fidl::encoding::DefaultFuchsiaResourceDialect
5953                        );
5954                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreEnableDeviceSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
5955                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5956                        Ok(AudioCoreRequest::EnableDeviceSettings {
5957                            enabled: req.enabled,
5958
5959                            control_handle,
5960                        })
5961                    }
5962                    0x48097f45f6e2b8e7 => {
5963                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5964                        let mut req = fidl::new_empty!(
5965                            AudioCoreSetRenderUsageGainRequest,
5966                            fidl::encoding::DefaultFuchsiaResourceDialect
5967                        );
5968                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetRenderUsageGainRequest>(&header, _body_bytes, handles, &mut req)?;
5969                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5970                        Ok(AudioCoreRequest::SetRenderUsageGain {
5971                            usage: req.usage,
5972                            gain_db: req.gain_db,
5973
5974                            control_handle,
5975                        })
5976                    }
5977                    0x779b1531dc9e64f4 => {
5978                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5979                        let mut req = fidl::new_empty!(
5980                            AudioCoreSetRenderUsageGain2Request,
5981                            fidl::encoding::DefaultFuchsiaResourceDialect
5982                        );
5983                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetRenderUsageGain2Request>(&header, _body_bytes, handles, &mut req)?;
5984                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5985                        Ok(AudioCoreRequest::SetRenderUsageGain2 {
5986                            usage: req.usage,
5987                            gain_db: req.gain_db,
5988
5989                            control_handle,
5990                        })
5991                    }
5992                    0x457d29217d4ea248 => {
5993                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5994                        let mut req = fidl::new_empty!(
5995                            AudioCoreSetCaptureUsageGainRequest,
5996                            fidl::encoding::DefaultFuchsiaResourceDialect
5997                        );
5998                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetCaptureUsageGainRequest>(&header, _body_bytes, handles, &mut req)?;
5999                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6000                        Ok(AudioCoreRequest::SetCaptureUsageGain {
6001                            usage: req.usage,
6002                            gain_db: req.gain_db,
6003
6004                            control_handle,
6005                        })
6006                    }
6007                    0x15065ee308f44af0 => {
6008                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6009                        let mut req = fidl::new_empty!(
6010                            AudioCoreSetCaptureUsageGain2Request,
6011                            fidl::encoding::DefaultFuchsiaResourceDialect
6012                        );
6013                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetCaptureUsageGain2Request>(&header, _body_bytes, handles, &mut req)?;
6014                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6015                        Ok(AudioCoreRequest::SetCaptureUsageGain2 {
6016                            usage: req.usage,
6017                            gain_db: req.gain_db,
6018
6019                            control_handle,
6020                        })
6021                    }
6022                    0x7225be116aadc137 => {
6023                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6024                        let mut req = fidl::new_empty!(
6025                            AudioCoreBindUsageVolumeControlRequest,
6026                            fidl::encoding::DefaultFuchsiaResourceDialect
6027                        );
6028                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreBindUsageVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
6029                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6030                        Ok(AudioCoreRequest::BindUsageVolumeControl {
6031                            usage: req.usage,
6032                            volume_control: req.volume_control,
6033
6034                            control_handle,
6035                        })
6036                    }
6037                    0x729dff93019d055 => {
6038                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6039                        let mut req = fidl::new_empty!(
6040                            AudioCoreBindUsageVolumeControl2Request,
6041                            fidl::encoding::DefaultFuchsiaResourceDialect
6042                        );
6043                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreBindUsageVolumeControl2Request>(&header, _body_bytes, handles, &mut req)?;
6044                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6045                        Ok(AudioCoreRequest::BindUsageVolumeControl2 {
6046                            usage: req.usage,
6047                            volume_control: req.volume_control,
6048
6049                            control_handle,
6050                        })
6051                    }
6052                    0x50e3ca45509770bf => {
6053                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6054                        let mut req = fidl::new_empty!(
6055                            AudioCoreGetVolumeFromDbRequest,
6056                            fidl::encoding::DefaultFuchsiaResourceDialect
6057                        );
6058                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetVolumeFromDbRequest>(&header, _body_bytes, handles, &mut req)?;
6059                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6060                        Ok(AudioCoreRequest::GetVolumeFromDb {
6061                            usage: req.usage,
6062                            gain_db: req.gain_db,
6063
6064                            responder: AudioCoreGetVolumeFromDbResponder {
6065                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6066                                tx_id: header.tx_id,
6067                            },
6068                        })
6069                    }
6070                    0x165c811091ef99da => {
6071                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6072                        let mut req = fidl::new_empty!(
6073                            AudioCoreGetVolumeFromDb2Request,
6074                            fidl::encoding::DefaultFuchsiaResourceDialect
6075                        );
6076                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetVolumeFromDb2Request>(&header, _body_bytes, handles, &mut req)?;
6077                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6078                        Ok(AudioCoreRequest::GetVolumeFromDb2 {
6079                            usage: req.usage,
6080                            gain_db: req.gain_db,
6081
6082                            responder: AudioCoreGetVolumeFromDb2Responder {
6083                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6084                                tx_id: header.tx_id,
6085                            },
6086                        })
6087                    }
6088                    0x3e8eec27dd5a8bda => {
6089                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6090                        let mut req = fidl::new_empty!(
6091                            AudioCoreGetDbFromVolumeRequest,
6092                            fidl::encoding::DefaultFuchsiaResourceDialect
6093                        );
6094                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetDbFromVolumeRequest>(&header, _body_bytes, handles, &mut req)?;
6095                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6096                        Ok(AudioCoreRequest::GetDbFromVolume {
6097                            usage: req.usage,
6098                            volume: req.volume,
6099
6100                            responder: AudioCoreGetDbFromVolumeResponder {
6101                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6102                                tx_id: header.tx_id,
6103                            },
6104                        })
6105                    }
6106                    0x5f421a8ebf265bf3 => {
6107                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6108                        let mut req = fidl::new_empty!(
6109                            AudioCoreGetDbFromVolume2Request,
6110                            fidl::encoding::DefaultFuchsiaResourceDialect
6111                        );
6112                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetDbFromVolume2Request>(&header, _body_bytes, handles, &mut req)?;
6113                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6114                        Ok(AudioCoreRequest::GetDbFromVolume2 {
6115                            usage: req.usage,
6116                            volume: req.volume,
6117
6118                            responder: AudioCoreGetDbFromVolume2Responder {
6119                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6120                                tx_id: header.tx_id,
6121                            },
6122                        })
6123                    }
6124                    0x7bfed14345ece7b7 => {
6125                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6126                        let mut req = fidl::new_empty!(
6127                            AudioCoreSetInteractionRequest,
6128                            fidl::encoding::DefaultFuchsiaResourceDialect
6129                        );
6130                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetInteractionRequest>(&header, _body_bytes, handles, &mut req)?;
6131                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6132                        Ok(AudioCoreRequest::SetInteraction {
6133                            active: req.active,
6134                            affected: req.affected,
6135                            behavior: req.behavior,
6136
6137                            control_handle,
6138                        })
6139                    }
6140                    0x7226c7c6e6edc62f => {
6141                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6142                        let mut req = fidl::new_empty!(
6143                            AudioCoreSetInteraction2Request,
6144                            fidl::encoding::DefaultFuchsiaResourceDialect
6145                        );
6146                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetInteraction2Request>(&header, _body_bytes, handles, &mut req)?;
6147                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6148                        Ok(AudioCoreRequest::SetInteraction2 {
6149                            active: req.active,
6150                            affected: req.affected,
6151                            behavior: req.behavior,
6152
6153                            control_handle,
6154                        })
6155                    }
6156                    0x65bd94d9d0a28b5e => {
6157                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6158                        let mut req = fidl::new_empty!(
6159                            fidl::encoding::EmptyPayload,
6160                            fidl::encoding::DefaultFuchsiaResourceDialect
6161                        );
6162                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6163                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6164                        Ok(AudioCoreRequest::ResetInteractions { control_handle })
6165                    }
6166                    0x54a0bebca85f6b31 => {
6167                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6168                        let mut req = fidl::new_empty!(
6169                            fidl::encoding::EmptyPayload,
6170                            fidl::encoding::DefaultFuchsiaResourceDialect
6171                        );
6172                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6173                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6174                        Ok(AudioCoreRequest::LoadDefaults { control_handle })
6175                    }
6176                    _ if header.tx_id == 0
6177                        && header
6178                            .dynamic_flags()
6179                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6180                    {
6181                        Ok(AudioCoreRequest::_UnknownMethod {
6182                            ordinal: header.ordinal,
6183                            control_handle: AudioCoreControlHandle { inner: this.inner.clone() },
6184                            method_type: fidl::MethodType::OneWay,
6185                        })
6186                    }
6187                    _ if header
6188                        .dynamic_flags()
6189                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6190                    {
6191                        this.inner.send_framework_err(
6192                            fidl::encoding::FrameworkErr::UnknownMethod,
6193                            header.tx_id,
6194                            header.ordinal,
6195                            header.dynamic_flags(),
6196                            (bytes, handles),
6197                        )?;
6198                        Ok(AudioCoreRequest::_UnknownMethod {
6199                            ordinal: header.ordinal,
6200                            control_handle: AudioCoreControlHandle { inner: this.inner.clone() },
6201                            method_type: fidl::MethodType::TwoWay,
6202                        })
6203                    }
6204                    _ => Err(fidl::Error::UnknownOrdinal {
6205                        ordinal: header.ordinal,
6206                        protocol_name:
6207                            <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6208                    }),
6209                }))
6210            },
6211        )
6212    }
6213}
6214
6215#[derive(Debug)]
6216pub enum AudioCoreRequest {
6217    /// Creates an AudioRenderer which outputs audio to the default device.
6218    CreateAudioRenderer {
6219        audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
6220        control_handle: AudioCoreControlHandle,
6221    },
6222    /// Creates an AudioCapturer according to the given requirements.
6223    ///
6224    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
6225    /// It causes the source material to be reformatted/resampled if needed
6226    /// in order to produce the requested stream type.
6227    ///
6228    /// `usage` is used by Fuchsia to make decisions about user experience.
6229    /// See `AudioCaptureUsage` for more details.
6230    ///
6231    /// `configuration` must be initialized to a variant, or no capturer
6232    /// can be created.
6233    CreateAudioCapturerWithConfiguration {
6234        stream_type: AudioStreamType,
6235        configuration: AudioCapturerConfiguration,
6236        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
6237        control_handle: AudioCoreControlHandle,
6238    },
6239    /// Creates an AudioCapturer which either captures from the current default
6240    /// audio input device, or loops-back from the current default audio output
6241    /// device based on value passed for the loopback flag.
6242    CreateAudioCapturer {
6243        loopback: bool,
6244        audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
6245        control_handle: AudioCoreControlHandle,
6246    },
6247    EnableDeviceSettings {
6248        enabled: bool,
6249        control_handle: AudioCoreControlHandle,
6250    },
6251    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
6252    SetRenderUsageGain {
6253        usage: AudioRenderUsage,
6254        gain_db: f32,
6255        control_handle: AudioCoreControlHandle,
6256    },
6257    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
6258    SetRenderUsageGain2 {
6259        usage: AudioRenderUsage2,
6260        gain_db: f32,
6261        control_handle: AudioCoreControlHandle,
6262    },
6263    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
6264    SetCaptureUsageGain {
6265        usage: AudioCaptureUsage,
6266        gain_db: f32,
6267        control_handle: AudioCoreControlHandle,
6268    },
6269    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
6270    SetCaptureUsageGain2 {
6271        usage: AudioCaptureUsage2,
6272        gain_db: f32,
6273        control_handle: AudioCoreControlHandle,
6274    },
6275    /// Binds to a volume control protocol for the given usage.
6276    BindUsageVolumeControl {
6277        usage: Usage,
6278        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6279        control_handle: AudioCoreControlHandle,
6280    },
6281    /// Binds to a volume control protocol for the given usage.
6282    BindUsageVolumeControl2 {
6283        usage: Usage2,
6284        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6285        control_handle: AudioCoreControlHandle,
6286    },
6287    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
6288    /// `usage`. This is the same mapping as used by the VolumeControl from
6289    /// `BindUsageVolumeControl`.
6290    GetVolumeFromDb {
6291        usage: Usage,
6292        gain_db: f32,
6293        responder: AudioCoreGetVolumeFromDbResponder,
6294    },
6295    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
6296    /// `usage`. This is the same mapping as used by the VolumeControl from
6297    /// `BindUsageVolumeControl`.
6298    GetVolumeFromDb2 {
6299        usage: Usage2,
6300        gain_db: f32,
6301        responder: AudioCoreGetVolumeFromDb2Responder,
6302    },
6303    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
6304    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
6305    GetDbFromVolume {
6306        usage: Usage,
6307        volume: f32,
6308        responder: AudioCoreGetDbFromVolumeResponder,
6309    },
6310    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
6311    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
6312    GetDbFromVolume2 {
6313        usage: Usage2,
6314        volume: f32,
6315        responder: AudioCoreGetDbFromVolume2Responder,
6316    },
6317    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
6318    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
6319    /// the Behavior specified will be applied to the streams of Usage `affected`.
6320    SetInteraction {
6321        active: Usage,
6322        affected: Usage,
6323        behavior: Behavior,
6324        control_handle: AudioCoreControlHandle,
6325    },
6326    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
6327    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
6328    /// the Behavior specified will be applied to the streams of Usage `affected`.
6329    SetInteraction2 {
6330        active: Usage2,
6331        affected: Usage2,
6332        behavior: Behavior,
6333        control_handle: AudioCoreControlHandle,
6334    },
6335    /// Re-initializes the set of rules that are currently governing the interaction of streams in
6336    /// audio_core. The default behavior is 'NONE'.
6337    ResetInteractions {
6338        control_handle: AudioCoreControlHandle,
6339    },
6340    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
6341    /// does not provide a config.
6342    LoadDefaults {
6343        control_handle: AudioCoreControlHandle,
6344    },
6345    /// An interaction was received which does not match any known method.
6346    #[non_exhaustive]
6347    _UnknownMethod {
6348        /// Ordinal of the method that was called.
6349        ordinal: u64,
6350        control_handle: AudioCoreControlHandle,
6351        method_type: fidl::MethodType,
6352    },
6353}
6354
6355impl AudioCoreRequest {
6356    #[allow(irrefutable_let_patterns)]
6357    pub fn into_create_audio_renderer(
6358        self,
6359    ) -> Option<(fidl::endpoints::ServerEnd<AudioRendererMarker>, AudioCoreControlHandle)> {
6360        if let AudioCoreRequest::CreateAudioRenderer { audio_out_request, control_handle } = self {
6361            Some((audio_out_request, control_handle))
6362        } else {
6363            None
6364        }
6365    }
6366
6367    #[allow(irrefutable_let_patterns)]
6368    pub fn into_create_audio_capturer_with_configuration(
6369        self,
6370    ) -> Option<(
6371        AudioStreamType,
6372        AudioCapturerConfiguration,
6373        fidl::endpoints::ServerEnd<AudioCapturerMarker>,
6374        AudioCoreControlHandle,
6375    )> {
6376        if let AudioCoreRequest::CreateAudioCapturerWithConfiguration {
6377            stream_type,
6378            configuration,
6379            audio_capturer_request,
6380            control_handle,
6381        } = self
6382        {
6383            Some((stream_type, configuration, audio_capturer_request, control_handle))
6384        } else {
6385            None
6386        }
6387    }
6388
6389    #[allow(irrefutable_let_patterns)]
6390    pub fn into_create_audio_capturer(
6391        self,
6392    ) -> Option<(bool, fidl::endpoints::ServerEnd<AudioCapturerMarker>, AudioCoreControlHandle)>
6393    {
6394        if let AudioCoreRequest::CreateAudioCapturer {
6395            loopback,
6396            audio_in_request,
6397            control_handle,
6398        } = self
6399        {
6400            Some((loopback, audio_in_request, control_handle))
6401        } else {
6402            None
6403        }
6404    }
6405
6406    #[allow(irrefutable_let_patterns)]
6407    pub fn into_enable_device_settings(self) -> Option<(bool, AudioCoreControlHandle)> {
6408        if let AudioCoreRequest::EnableDeviceSettings { enabled, control_handle } = self {
6409            Some((enabled, control_handle))
6410        } else {
6411            None
6412        }
6413    }
6414
6415    #[allow(irrefutable_let_patterns)]
6416    pub fn into_set_render_usage_gain(
6417        self,
6418    ) -> Option<(AudioRenderUsage, f32, AudioCoreControlHandle)> {
6419        if let AudioCoreRequest::SetRenderUsageGain { usage, gain_db, control_handle } = self {
6420            Some((usage, gain_db, control_handle))
6421        } else {
6422            None
6423        }
6424    }
6425
6426    #[allow(irrefutable_let_patterns)]
6427    pub fn into_set_render_usage_gain2(
6428        self,
6429    ) -> Option<(AudioRenderUsage2, f32, AudioCoreControlHandle)> {
6430        if let AudioCoreRequest::SetRenderUsageGain2 { usage, gain_db, control_handle } = self {
6431            Some((usage, gain_db, control_handle))
6432        } else {
6433            None
6434        }
6435    }
6436
6437    #[allow(irrefutable_let_patterns)]
6438    pub fn into_set_capture_usage_gain(
6439        self,
6440    ) -> Option<(AudioCaptureUsage, f32, AudioCoreControlHandle)> {
6441        if let AudioCoreRequest::SetCaptureUsageGain { usage, gain_db, control_handle } = self {
6442            Some((usage, gain_db, control_handle))
6443        } else {
6444            None
6445        }
6446    }
6447
6448    #[allow(irrefutable_let_patterns)]
6449    pub fn into_set_capture_usage_gain2(
6450        self,
6451    ) -> Option<(AudioCaptureUsage2, f32, AudioCoreControlHandle)> {
6452        if let AudioCoreRequest::SetCaptureUsageGain2 { usage, gain_db, control_handle } = self {
6453            Some((usage, gain_db, control_handle))
6454        } else {
6455            None
6456        }
6457    }
6458
6459    #[allow(irrefutable_let_patterns)]
6460    pub fn into_bind_usage_volume_control(
6461        self,
6462    ) -> Option<(
6463        Usage,
6464        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6465        AudioCoreControlHandle,
6466    )> {
6467        if let AudioCoreRequest::BindUsageVolumeControl { usage, volume_control, control_handle } =
6468            self
6469        {
6470            Some((usage, volume_control, control_handle))
6471        } else {
6472            None
6473        }
6474    }
6475
6476    #[allow(irrefutable_let_patterns)]
6477    pub fn into_bind_usage_volume_control2(
6478        self,
6479    ) -> Option<(
6480        Usage2,
6481        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6482        AudioCoreControlHandle,
6483    )> {
6484        if let AudioCoreRequest::BindUsageVolumeControl2 { usage, volume_control, control_handle } =
6485            self
6486        {
6487            Some((usage, volume_control, control_handle))
6488        } else {
6489            None
6490        }
6491    }
6492
6493    #[allow(irrefutable_let_patterns)]
6494    pub fn into_get_volume_from_db(
6495        self,
6496    ) -> Option<(Usage, f32, AudioCoreGetVolumeFromDbResponder)> {
6497        if let AudioCoreRequest::GetVolumeFromDb { usage, gain_db, responder } = self {
6498            Some((usage, gain_db, responder))
6499        } else {
6500            None
6501        }
6502    }
6503
6504    #[allow(irrefutable_let_patterns)]
6505    pub fn into_get_volume_from_db2(
6506        self,
6507    ) -> Option<(Usage2, f32, AudioCoreGetVolumeFromDb2Responder)> {
6508        if let AudioCoreRequest::GetVolumeFromDb2 { usage, gain_db, responder } = self {
6509            Some((usage, gain_db, responder))
6510        } else {
6511            None
6512        }
6513    }
6514
6515    #[allow(irrefutable_let_patterns)]
6516    pub fn into_get_db_from_volume(
6517        self,
6518    ) -> Option<(Usage, f32, AudioCoreGetDbFromVolumeResponder)> {
6519        if let AudioCoreRequest::GetDbFromVolume { usage, volume, responder } = self {
6520            Some((usage, volume, responder))
6521        } else {
6522            None
6523        }
6524    }
6525
6526    #[allow(irrefutable_let_patterns)]
6527    pub fn into_get_db_from_volume2(
6528        self,
6529    ) -> Option<(Usage2, f32, AudioCoreGetDbFromVolume2Responder)> {
6530        if let AudioCoreRequest::GetDbFromVolume2 { usage, volume, responder } = self {
6531            Some((usage, volume, responder))
6532        } else {
6533            None
6534        }
6535    }
6536
6537    #[allow(irrefutable_let_patterns)]
6538    pub fn into_set_interaction(self) -> Option<(Usage, Usage, Behavior, AudioCoreControlHandle)> {
6539        if let AudioCoreRequest::SetInteraction { active, affected, behavior, control_handle } =
6540            self
6541        {
6542            Some((active, affected, behavior, control_handle))
6543        } else {
6544            None
6545        }
6546    }
6547
6548    #[allow(irrefutable_let_patterns)]
6549    pub fn into_set_interaction2(
6550        self,
6551    ) -> Option<(Usage2, Usage2, Behavior, AudioCoreControlHandle)> {
6552        if let AudioCoreRequest::SetInteraction2 { active, affected, behavior, control_handle } =
6553            self
6554        {
6555            Some((active, affected, behavior, control_handle))
6556        } else {
6557            None
6558        }
6559    }
6560
6561    #[allow(irrefutable_let_patterns)]
6562    pub fn into_reset_interactions(self) -> Option<(AudioCoreControlHandle)> {
6563        if let AudioCoreRequest::ResetInteractions { control_handle } = self {
6564            Some((control_handle))
6565        } else {
6566            None
6567        }
6568    }
6569
6570    #[allow(irrefutable_let_patterns)]
6571    pub fn into_load_defaults(self) -> Option<(AudioCoreControlHandle)> {
6572        if let AudioCoreRequest::LoadDefaults { control_handle } = self {
6573            Some((control_handle))
6574        } else {
6575            None
6576        }
6577    }
6578
6579    /// Name of the method defined in FIDL
6580    pub fn method_name(&self) -> &'static str {
6581        match *self {
6582            AudioCoreRequest::CreateAudioRenderer { .. } => "create_audio_renderer",
6583            AudioCoreRequest::CreateAudioCapturerWithConfiguration { .. } => {
6584                "create_audio_capturer_with_configuration"
6585            }
6586            AudioCoreRequest::CreateAudioCapturer { .. } => "create_audio_capturer",
6587            AudioCoreRequest::EnableDeviceSettings { .. } => "enable_device_settings",
6588            AudioCoreRequest::SetRenderUsageGain { .. } => "set_render_usage_gain",
6589            AudioCoreRequest::SetRenderUsageGain2 { .. } => "set_render_usage_gain2",
6590            AudioCoreRequest::SetCaptureUsageGain { .. } => "set_capture_usage_gain",
6591            AudioCoreRequest::SetCaptureUsageGain2 { .. } => "set_capture_usage_gain2",
6592            AudioCoreRequest::BindUsageVolumeControl { .. } => "bind_usage_volume_control",
6593            AudioCoreRequest::BindUsageVolumeControl2 { .. } => "bind_usage_volume_control2",
6594            AudioCoreRequest::GetVolumeFromDb { .. } => "get_volume_from_db",
6595            AudioCoreRequest::GetVolumeFromDb2 { .. } => "get_volume_from_db2",
6596            AudioCoreRequest::GetDbFromVolume { .. } => "get_db_from_volume",
6597            AudioCoreRequest::GetDbFromVolume2 { .. } => "get_db_from_volume2",
6598            AudioCoreRequest::SetInteraction { .. } => "set_interaction",
6599            AudioCoreRequest::SetInteraction2 { .. } => "set_interaction2",
6600            AudioCoreRequest::ResetInteractions { .. } => "reset_interactions",
6601            AudioCoreRequest::LoadDefaults { .. } => "load_defaults",
6602            AudioCoreRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
6603                "unknown one-way method"
6604            }
6605            AudioCoreRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
6606                "unknown two-way method"
6607            }
6608        }
6609    }
6610}
6611
6612#[derive(Debug, Clone)]
6613pub struct AudioCoreControlHandle {
6614    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6615}
6616
6617impl fidl::endpoints::ControlHandle for AudioCoreControlHandle {
6618    fn shutdown(&self) {
6619        self.inner.shutdown()
6620    }
6621    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6622        self.inner.shutdown_with_epitaph(status)
6623    }
6624
6625    fn is_closed(&self) -> bool {
6626        self.inner.channel().is_closed()
6627    }
6628    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6629        self.inner.channel().on_closed()
6630    }
6631
6632    #[cfg(target_os = "fuchsia")]
6633    fn signal_peer(
6634        &self,
6635        clear_mask: zx::Signals,
6636        set_mask: zx::Signals,
6637    ) -> Result<(), zx_status::Status> {
6638        use fidl::Peered;
6639        self.inner.channel().signal_peer(clear_mask, set_mask)
6640    }
6641}
6642
6643impl AudioCoreControlHandle {}
6644
6645#[must_use = "FIDL methods require a response to be sent"]
6646#[derive(Debug)]
6647pub struct AudioCoreGetVolumeFromDbResponder {
6648    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6649    tx_id: u32,
6650}
6651
6652/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6653/// if the responder is dropped without sending a response, so that the client
6654/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6655impl std::ops::Drop for AudioCoreGetVolumeFromDbResponder {
6656    fn drop(&mut self) {
6657        self.control_handle.shutdown();
6658        // Safety: drops once, never accessed again
6659        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6660    }
6661}
6662
6663impl fidl::endpoints::Responder for AudioCoreGetVolumeFromDbResponder {
6664    type ControlHandle = AudioCoreControlHandle;
6665
6666    fn control_handle(&self) -> &AudioCoreControlHandle {
6667        &self.control_handle
6668    }
6669
6670    fn drop_without_shutdown(mut self) {
6671        // Safety: drops once, never accessed again due to mem::forget
6672        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6673        // Prevent Drop from running (which would shut down the channel)
6674        std::mem::forget(self);
6675    }
6676}
6677
6678impl AudioCoreGetVolumeFromDbResponder {
6679    /// Sends a response to the FIDL transaction.
6680    ///
6681    /// Sets the channel to shutdown if an error occurs.
6682    pub fn send(self, mut volume: f32) -> Result<(), fidl::Error> {
6683        let _result = self.send_raw(volume);
6684        if _result.is_err() {
6685            self.control_handle.shutdown();
6686        }
6687        self.drop_without_shutdown();
6688        _result
6689    }
6690
6691    /// Similar to "send" but does not shutdown the channel if an error occurs.
6692    pub fn send_no_shutdown_on_err(self, mut volume: f32) -> Result<(), fidl::Error> {
6693        let _result = self.send_raw(volume);
6694        self.drop_without_shutdown();
6695        _result
6696    }
6697
6698    fn send_raw(&self, mut volume: f32) -> Result<(), fidl::Error> {
6699        self.control_handle.inner.send::<AudioCoreGetVolumeFromDbResponse>(
6700            (volume,),
6701            self.tx_id,
6702            0x50e3ca45509770bf,
6703            fidl::encoding::DynamicFlags::empty(),
6704        )
6705    }
6706}
6707
6708#[must_use = "FIDL methods require a response to be sent"]
6709#[derive(Debug)]
6710pub struct AudioCoreGetVolumeFromDb2Responder {
6711    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6712    tx_id: u32,
6713}
6714
6715/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6716/// if the responder is dropped without sending a response, so that the client
6717/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6718impl std::ops::Drop for AudioCoreGetVolumeFromDb2Responder {
6719    fn drop(&mut self) {
6720        self.control_handle.shutdown();
6721        // Safety: drops once, never accessed again
6722        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6723    }
6724}
6725
6726impl fidl::endpoints::Responder for AudioCoreGetVolumeFromDb2Responder {
6727    type ControlHandle = AudioCoreControlHandle;
6728
6729    fn control_handle(&self) -> &AudioCoreControlHandle {
6730        &self.control_handle
6731    }
6732
6733    fn drop_without_shutdown(mut self) {
6734        // Safety: drops once, never accessed again due to mem::forget
6735        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6736        // Prevent Drop from running (which would shut down the channel)
6737        std::mem::forget(self);
6738    }
6739}
6740
6741impl AudioCoreGetVolumeFromDb2Responder {
6742    /// Sends a response to the FIDL transaction.
6743    ///
6744    /// Sets the channel to shutdown if an error occurs.
6745    pub fn send(self, mut volume: f32) -> Result<(), fidl::Error> {
6746        let _result = self.send_raw(volume);
6747        if _result.is_err() {
6748            self.control_handle.shutdown();
6749        }
6750        self.drop_without_shutdown();
6751        _result
6752    }
6753
6754    /// Similar to "send" but does not shutdown the channel if an error occurs.
6755    pub fn send_no_shutdown_on_err(self, mut volume: f32) -> Result<(), fidl::Error> {
6756        let _result = self.send_raw(volume);
6757        self.drop_without_shutdown();
6758        _result
6759    }
6760
6761    fn send_raw(&self, mut volume: f32) -> Result<(), fidl::Error> {
6762        self.control_handle
6763            .inner
6764            .send::<fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>>(
6765                fidl::encoding::Flexible::new((volume,)),
6766                self.tx_id,
6767                0x165c811091ef99da,
6768                fidl::encoding::DynamicFlags::FLEXIBLE,
6769            )
6770    }
6771}
6772
6773#[must_use = "FIDL methods require a response to be sent"]
6774#[derive(Debug)]
6775pub struct AudioCoreGetDbFromVolumeResponder {
6776    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6777    tx_id: u32,
6778}
6779
6780/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6781/// if the responder is dropped without sending a response, so that the client
6782/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6783impl std::ops::Drop for AudioCoreGetDbFromVolumeResponder {
6784    fn drop(&mut self) {
6785        self.control_handle.shutdown();
6786        // Safety: drops once, never accessed again
6787        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6788    }
6789}
6790
6791impl fidl::endpoints::Responder for AudioCoreGetDbFromVolumeResponder {
6792    type ControlHandle = AudioCoreControlHandle;
6793
6794    fn control_handle(&self) -> &AudioCoreControlHandle {
6795        &self.control_handle
6796    }
6797
6798    fn drop_without_shutdown(mut self) {
6799        // Safety: drops once, never accessed again due to mem::forget
6800        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6801        // Prevent Drop from running (which would shut down the channel)
6802        std::mem::forget(self);
6803    }
6804}
6805
6806impl AudioCoreGetDbFromVolumeResponder {
6807    /// Sends a response to the FIDL transaction.
6808    ///
6809    /// Sets the channel to shutdown if an error occurs.
6810    pub fn send(self, mut gain_db: f32) -> Result<(), fidl::Error> {
6811        let _result = self.send_raw(gain_db);
6812        if _result.is_err() {
6813            self.control_handle.shutdown();
6814        }
6815        self.drop_without_shutdown();
6816        _result
6817    }
6818
6819    /// Similar to "send" but does not shutdown the channel if an error occurs.
6820    pub fn send_no_shutdown_on_err(self, mut gain_db: f32) -> Result<(), fidl::Error> {
6821        let _result = self.send_raw(gain_db);
6822        self.drop_without_shutdown();
6823        _result
6824    }
6825
6826    fn send_raw(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
6827        self.control_handle.inner.send::<AudioCoreGetDbFromVolumeResponse>(
6828            (gain_db,),
6829            self.tx_id,
6830            0x3e8eec27dd5a8bda,
6831            fidl::encoding::DynamicFlags::empty(),
6832        )
6833    }
6834}
6835
6836#[must_use = "FIDL methods require a response to be sent"]
6837#[derive(Debug)]
6838pub struct AudioCoreGetDbFromVolume2Responder {
6839    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6840    tx_id: u32,
6841}
6842
6843/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6844/// if the responder is dropped without sending a response, so that the client
6845/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6846impl std::ops::Drop for AudioCoreGetDbFromVolume2Responder {
6847    fn drop(&mut self) {
6848        self.control_handle.shutdown();
6849        // Safety: drops once, never accessed again
6850        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6851    }
6852}
6853
6854impl fidl::endpoints::Responder for AudioCoreGetDbFromVolume2Responder {
6855    type ControlHandle = AudioCoreControlHandle;
6856
6857    fn control_handle(&self) -> &AudioCoreControlHandle {
6858        &self.control_handle
6859    }
6860
6861    fn drop_without_shutdown(mut self) {
6862        // Safety: drops once, never accessed again due to mem::forget
6863        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6864        // Prevent Drop from running (which would shut down the channel)
6865        std::mem::forget(self);
6866    }
6867}
6868
6869impl AudioCoreGetDbFromVolume2Responder {
6870    /// Sends a response to the FIDL transaction.
6871    ///
6872    /// Sets the channel to shutdown if an error occurs.
6873    pub fn send(self, mut gain_db: f32) -> Result<(), fidl::Error> {
6874        let _result = self.send_raw(gain_db);
6875        if _result.is_err() {
6876            self.control_handle.shutdown();
6877        }
6878        self.drop_without_shutdown();
6879        _result
6880    }
6881
6882    /// Similar to "send" but does not shutdown the channel if an error occurs.
6883    pub fn send_no_shutdown_on_err(self, mut gain_db: f32) -> Result<(), fidl::Error> {
6884        let _result = self.send_raw(gain_db);
6885        self.drop_without_shutdown();
6886        _result
6887    }
6888
6889    fn send_raw(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
6890        self.control_handle
6891            .inner
6892            .send::<fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>>(
6893                fidl::encoding::Flexible::new((gain_db,)),
6894                self.tx_id,
6895                0x5f421a8ebf265bf3,
6896                fidl::encoding::DynamicFlags::FLEXIBLE,
6897            )
6898    }
6899}
6900
6901#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6902pub struct AudioDeviceEnumeratorMarker;
6903
6904impl fidl::endpoints::ProtocolMarker for AudioDeviceEnumeratorMarker {
6905    type Proxy = AudioDeviceEnumeratorProxy;
6906    type RequestStream = AudioDeviceEnumeratorRequestStream;
6907    #[cfg(target_os = "fuchsia")]
6908    type SynchronousProxy = AudioDeviceEnumeratorSynchronousProxy;
6909
6910    const DEBUG_NAME: &'static str = "fuchsia.media.AudioDeviceEnumerator";
6911}
6912impl fidl::endpoints::DiscoverableProtocolMarker for AudioDeviceEnumeratorMarker {}
6913
6914pub trait AudioDeviceEnumeratorProxyInterface: Send + Sync {
6915    type GetDevicesResponseFut: std::future::Future<Output = Result<Vec<AudioDeviceInfo>, fidl::Error>>
6916        + Send;
6917    fn r#get_devices(&self) -> Self::GetDevicesResponseFut;
6918    type GetDeviceGainResponseFut: std::future::Future<Output = Result<(u64, AudioGainInfo), fidl::Error>>
6919        + Send;
6920    fn r#get_device_gain(&self, device_token: u64) -> Self::GetDeviceGainResponseFut;
6921    fn r#set_device_gain(
6922        &self,
6923        device_token: u64,
6924        gain_info: &AudioGainInfo,
6925        valid_flags: AudioGainValidFlags,
6926    ) -> Result<(), fidl::Error>;
6927    fn r#add_device_by_channel(
6928        &self,
6929        device_name: &str,
6930        is_input: bool,
6931        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
6932    ) -> Result<(), fidl::Error>;
6933}
6934#[derive(Debug)]
6935#[cfg(target_os = "fuchsia")]
6936pub struct AudioDeviceEnumeratorSynchronousProxy {
6937    client: fidl::client::sync::Client,
6938}
6939
6940#[cfg(target_os = "fuchsia")]
6941impl fidl::endpoints::SynchronousProxy for AudioDeviceEnumeratorSynchronousProxy {
6942    type Proxy = AudioDeviceEnumeratorProxy;
6943    type Protocol = AudioDeviceEnumeratorMarker;
6944
6945    fn from_channel(inner: fidl::Channel) -> Self {
6946        Self::new(inner)
6947    }
6948
6949    fn into_channel(self) -> fidl::Channel {
6950        self.client.into_channel()
6951    }
6952
6953    fn as_channel(&self) -> &fidl::Channel {
6954        self.client.as_channel()
6955    }
6956}
6957
6958#[cfg(target_os = "fuchsia")]
6959impl AudioDeviceEnumeratorSynchronousProxy {
6960    pub fn new(channel: fidl::Channel) -> Self {
6961        let protocol_name =
6962            <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6963        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6964    }
6965
6966    pub fn into_channel(self) -> fidl::Channel {
6967        self.client.into_channel()
6968    }
6969
6970    /// Waits until an event arrives and returns it. It is safe for other
6971    /// threads to make concurrent requests while waiting for an event.
6972    pub fn wait_for_event(
6973        &self,
6974        deadline: zx::MonotonicInstant,
6975    ) -> Result<AudioDeviceEnumeratorEvent, fidl::Error> {
6976        AudioDeviceEnumeratorEvent::decode(self.client.wait_for_event(deadline)?)
6977    }
6978
6979    /// Obtain the list of currently active audio devices.
6980    pub fn r#get_devices(
6981        &self,
6982        ___deadline: zx::MonotonicInstant,
6983    ) -> Result<Vec<AudioDeviceInfo>, fidl::Error> {
6984        let _response = self
6985            .client
6986            .send_query::<fidl::encoding::EmptyPayload, AudioDeviceEnumeratorGetDevicesResponse>(
6987                (),
6988                0x4ce1aa218aeb12a6,
6989                fidl::encoding::DynamicFlags::empty(),
6990                ___deadline,
6991            )?;
6992        Ok(_response.devices)
6993    }
6994
6995    /// Gain/Mute/AGC control
6996    ///
6997    /// Note that each of these operations requires a device_token in order to
6998    /// target the proper input/output.
6999    ///
7000    /// The Get command returns the device_token of the device whose gain is
7001    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
7002    /// device_token was invalid or the device had been removed from the system
7003    /// before the Get command could be processed.
7004    ///
7005    /// Set commands which are given an invalid device token are ignored and
7006    /// have no effect on the system. In addition, users do not need to control
7007    /// all of the gain settings for an audio device with each call. Only the
7008    /// settings with a corresponding flag set in the set_flags parameter will
7009    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
7010    /// a SetDeviceGain call to care only about the mute setting in the
7011    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
7012    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
7013    /// status to be changed simultaneously.
7014    pub fn r#get_device_gain(
7015        &self,
7016        mut device_token: u64,
7017        ___deadline: zx::MonotonicInstant,
7018    ) -> Result<(u64, AudioGainInfo), fidl::Error> {
7019        let _response = self.client.send_query::<
7020            AudioDeviceEnumeratorGetDeviceGainRequest,
7021            AudioDeviceEnumeratorGetDeviceGainResponse,
7022        >(
7023            (device_token,),
7024            0x25dd4723403c414b,
7025            fidl::encoding::DynamicFlags::empty(),
7026            ___deadline,
7027        )?;
7028        Ok((_response.device_token, _response.gain_info))
7029    }
7030
7031    pub fn r#set_device_gain(
7032        &self,
7033        mut device_token: u64,
7034        mut gain_info: &AudioGainInfo,
7035        mut valid_flags: AudioGainValidFlags,
7036    ) -> Result<(), fidl::Error> {
7037        self.client.send::<AudioDeviceEnumeratorSetDeviceGainRequest>(
7038            (device_token, gain_info, valid_flags),
7039            0x5bdabc8ebe83591,
7040            fidl::encoding::DynamicFlags::empty(),
7041        )
7042    }
7043
7044    /// # Deprecation
7045    ///
7046    /// StreamConfig is not supported anymore, instead use an
7047    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
7048    /// , see
7049    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
7050    pub fn r#add_device_by_channel(
7051        &self,
7052        mut device_name: &str,
7053        mut is_input: bool,
7054        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7055    ) -> Result<(), fidl::Error> {
7056        self.client.send::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(
7057            (device_name, is_input, channel),
7058            0x72cdbada4d70ed67,
7059            fidl::encoding::DynamicFlags::empty(),
7060        )
7061    }
7062}
7063
7064#[cfg(target_os = "fuchsia")]
7065impl From<AudioDeviceEnumeratorSynchronousProxy> for zx::Handle {
7066    fn from(value: AudioDeviceEnumeratorSynchronousProxy) -> Self {
7067        value.into_channel().into()
7068    }
7069}
7070
7071#[cfg(target_os = "fuchsia")]
7072impl From<fidl::Channel> for AudioDeviceEnumeratorSynchronousProxy {
7073    fn from(value: fidl::Channel) -> Self {
7074        Self::new(value)
7075    }
7076}
7077
7078#[cfg(target_os = "fuchsia")]
7079impl fidl::endpoints::FromClient for AudioDeviceEnumeratorSynchronousProxy {
7080    type Protocol = AudioDeviceEnumeratorMarker;
7081
7082    fn from_client(value: fidl::endpoints::ClientEnd<AudioDeviceEnumeratorMarker>) -> Self {
7083        Self::new(value.into_channel())
7084    }
7085}
7086
7087#[derive(Debug, Clone)]
7088pub struct AudioDeviceEnumeratorProxy {
7089    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7090}
7091
7092impl fidl::endpoints::Proxy for AudioDeviceEnumeratorProxy {
7093    type Protocol = AudioDeviceEnumeratorMarker;
7094
7095    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7096        Self::new(inner)
7097    }
7098
7099    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7100        self.client.into_channel().map_err(|client| Self { client })
7101    }
7102
7103    fn as_channel(&self) -> &::fidl::AsyncChannel {
7104        self.client.as_channel()
7105    }
7106}
7107
7108impl AudioDeviceEnumeratorProxy {
7109    /// Create a new Proxy for fuchsia.media/AudioDeviceEnumerator.
7110    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7111        let protocol_name =
7112            <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7113        Self { client: fidl::client::Client::new(channel, protocol_name) }
7114    }
7115
7116    /// Get a Stream of events from the remote end of the protocol.
7117    ///
7118    /// # Panics
7119    ///
7120    /// Panics if the event stream was already taken.
7121    pub fn take_event_stream(&self) -> AudioDeviceEnumeratorEventStream {
7122        AudioDeviceEnumeratorEventStream { event_receiver: self.client.take_event_receiver() }
7123    }
7124
7125    /// Obtain the list of currently active audio devices.
7126    pub fn r#get_devices(
7127        &self,
7128    ) -> fidl::client::QueryResponseFut<
7129        Vec<AudioDeviceInfo>,
7130        fidl::encoding::DefaultFuchsiaResourceDialect,
7131    > {
7132        AudioDeviceEnumeratorProxyInterface::r#get_devices(self)
7133    }
7134
7135    /// Gain/Mute/AGC control
7136    ///
7137    /// Note that each of these operations requires a device_token in order to
7138    /// target the proper input/output.
7139    ///
7140    /// The Get command returns the device_token of the device whose gain is
7141    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
7142    /// device_token was invalid or the device had been removed from the system
7143    /// before the Get command could be processed.
7144    ///
7145    /// Set commands which are given an invalid device token are ignored and
7146    /// have no effect on the system. In addition, users do not need to control
7147    /// all of the gain settings for an audio device with each call. Only the
7148    /// settings with a corresponding flag set in the set_flags parameter will
7149    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
7150    /// a SetDeviceGain call to care only about the mute setting in the
7151    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
7152    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
7153    /// status to be changed simultaneously.
7154    pub fn r#get_device_gain(
7155        &self,
7156        mut device_token: u64,
7157    ) -> fidl::client::QueryResponseFut<
7158        (u64, AudioGainInfo),
7159        fidl::encoding::DefaultFuchsiaResourceDialect,
7160    > {
7161        AudioDeviceEnumeratorProxyInterface::r#get_device_gain(self, device_token)
7162    }
7163
7164    pub fn r#set_device_gain(
7165        &self,
7166        mut device_token: u64,
7167        mut gain_info: &AudioGainInfo,
7168        mut valid_flags: AudioGainValidFlags,
7169    ) -> Result<(), fidl::Error> {
7170        AudioDeviceEnumeratorProxyInterface::r#set_device_gain(
7171            self,
7172            device_token,
7173            gain_info,
7174            valid_flags,
7175        )
7176    }
7177
7178    /// # Deprecation
7179    ///
7180    /// StreamConfig is not supported anymore, instead use an
7181    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
7182    /// , see
7183    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
7184    pub fn r#add_device_by_channel(
7185        &self,
7186        mut device_name: &str,
7187        mut is_input: bool,
7188        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7189    ) -> Result<(), fidl::Error> {
7190        AudioDeviceEnumeratorProxyInterface::r#add_device_by_channel(
7191            self,
7192            device_name,
7193            is_input,
7194            channel,
7195        )
7196    }
7197}
7198
7199impl AudioDeviceEnumeratorProxyInterface for AudioDeviceEnumeratorProxy {
7200    type GetDevicesResponseFut = fidl::client::QueryResponseFut<
7201        Vec<AudioDeviceInfo>,
7202        fidl::encoding::DefaultFuchsiaResourceDialect,
7203    >;
7204    fn r#get_devices(&self) -> Self::GetDevicesResponseFut {
7205        fn _decode(
7206            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7207        ) -> Result<Vec<AudioDeviceInfo>, fidl::Error> {
7208            let _response = fidl::client::decode_transaction_body::<
7209                AudioDeviceEnumeratorGetDevicesResponse,
7210                fidl::encoding::DefaultFuchsiaResourceDialect,
7211                0x4ce1aa218aeb12a6,
7212            >(_buf?)?;
7213            Ok(_response.devices)
7214        }
7215        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioDeviceInfo>>(
7216            (),
7217            0x4ce1aa218aeb12a6,
7218            fidl::encoding::DynamicFlags::empty(),
7219            _decode,
7220        )
7221    }
7222
7223    type GetDeviceGainResponseFut = fidl::client::QueryResponseFut<
7224        (u64, AudioGainInfo),
7225        fidl::encoding::DefaultFuchsiaResourceDialect,
7226    >;
7227    fn r#get_device_gain(&self, mut device_token: u64) -> Self::GetDeviceGainResponseFut {
7228        fn _decode(
7229            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7230        ) -> Result<(u64, AudioGainInfo), fidl::Error> {
7231            let _response = fidl::client::decode_transaction_body::<
7232                AudioDeviceEnumeratorGetDeviceGainResponse,
7233                fidl::encoding::DefaultFuchsiaResourceDialect,
7234                0x25dd4723403c414b,
7235            >(_buf?)?;
7236            Ok((_response.device_token, _response.gain_info))
7237        }
7238        self.client.send_query_and_decode::<
7239            AudioDeviceEnumeratorGetDeviceGainRequest,
7240            (u64, AudioGainInfo),
7241        >(
7242            (device_token,),
7243            0x25dd4723403c414b,
7244            fidl::encoding::DynamicFlags::empty(),
7245            _decode,
7246        )
7247    }
7248
7249    fn r#set_device_gain(
7250        &self,
7251        mut device_token: u64,
7252        mut gain_info: &AudioGainInfo,
7253        mut valid_flags: AudioGainValidFlags,
7254    ) -> Result<(), fidl::Error> {
7255        self.client.send::<AudioDeviceEnumeratorSetDeviceGainRequest>(
7256            (device_token, gain_info, valid_flags),
7257            0x5bdabc8ebe83591,
7258            fidl::encoding::DynamicFlags::empty(),
7259        )
7260    }
7261
7262    fn r#add_device_by_channel(
7263        &self,
7264        mut device_name: &str,
7265        mut is_input: bool,
7266        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7267    ) -> Result<(), fidl::Error> {
7268        self.client.send::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(
7269            (device_name, is_input, channel),
7270            0x72cdbada4d70ed67,
7271            fidl::encoding::DynamicFlags::empty(),
7272        )
7273    }
7274}
7275
7276pub struct AudioDeviceEnumeratorEventStream {
7277    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7278}
7279
7280impl std::marker::Unpin for AudioDeviceEnumeratorEventStream {}
7281
7282impl futures::stream::FusedStream for AudioDeviceEnumeratorEventStream {
7283    fn is_terminated(&self) -> bool {
7284        self.event_receiver.is_terminated()
7285    }
7286}
7287
7288impl futures::Stream for AudioDeviceEnumeratorEventStream {
7289    type Item = Result<AudioDeviceEnumeratorEvent, fidl::Error>;
7290
7291    fn poll_next(
7292        mut self: std::pin::Pin<&mut Self>,
7293        cx: &mut std::task::Context<'_>,
7294    ) -> std::task::Poll<Option<Self::Item>> {
7295        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7296            &mut self.event_receiver,
7297            cx
7298        )?) {
7299            Some(buf) => std::task::Poll::Ready(Some(AudioDeviceEnumeratorEvent::decode(buf))),
7300            None => std::task::Poll::Ready(None),
7301        }
7302    }
7303}
7304
7305#[derive(Debug)]
7306pub enum AudioDeviceEnumeratorEvent {
7307    OnDeviceAdded { device: AudioDeviceInfo },
7308    OnDeviceRemoved { device_token: u64 },
7309    OnDeviceGainChanged { device_token: u64, gain_info: AudioGainInfo },
7310    OnDefaultDeviceChanged { old_default_token: u64, new_default_token: u64 },
7311}
7312
7313impl AudioDeviceEnumeratorEvent {
7314    #[allow(irrefutable_let_patterns)]
7315    pub fn into_on_device_added(self) -> Option<AudioDeviceInfo> {
7316        if let AudioDeviceEnumeratorEvent::OnDeviceAdded { device } = self {
7317            Some((device))
7318        } else {
7319            None
7320        }
7321    }
7322    #[allow(irrefutable_let_patterns)]
7323    pub fn into_on_device_removed(self) -> Option<u64> {
7324        if let AudioDeviceEnumeratorEvent::OnDeviceRemoved { device_token } = self {
7325            Some((device_token))
7326        } else {
7327            None
7328        }
7329    }
7330    #[allow(irrefutable_let_patterns)]
7331    pub fn into_on_device_gain_changed(self) -> Option<(u64, AudioGainInfo)> {
7332        if let AudioDeviceEnumeratorEvent::OnDeviceGainChanged { device_token, gain_info } = self {
7333            Some((device_token, gain_info))
7334        } else {
7335            None
7336        }
7337    }
7338    #[allow(irrefutable_let_patterns)]
7339    pub fn into_on_default_device_changed(self) -> Option<(u64, u64)> {
7340        if let AudioDeviceEnumeratorEvent::OnDefaultDeviceChanged {
7341            old_default_token,
7342            new_default_token,
7343        } = self
7344        {
7345            Some((old_default_token, new_default_token))
7346        } else {
7347            None
7348        }
7349    }
7350
7351    /// Decodes a message buffer as a [`AudioDeviceEnumeratorEvent`].
7352    fn decode(
7353        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7354    ) -> Result<AudioDeviceEnumeratorEvent, fidl::Error> {
7355        let (bytes, _handles) = buf.split_mut();
7356        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7357        debug_assert_eq!(tx_header.tx_id, 0);
7358        match tx_header.ordinal {
7359            0xe0fbe40057c4b44 => {
7360                let mut out = fidl::new_empty!(
7361                    AudioDeviceEnumeratorOnDeviceAddedRequest,
7362                    fidl::encoding::DefaultFuchsiaResourceDialect
7363                );
7364                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceAddedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7365                Ok((AudioDeviceEnumeratorEvent::OnDeviceAdded { device: out.device }))
7366            }
7367            0x6f3b7574463d9ff8 => {
7368                let mut out = fidl::new_empty!(
7369                    AudioDeviceEnumeratorOnDeviceRemovedRequest,
7370                    fidl::encoding::DefaultFuchsiaResourceDialect
7371                );
7372                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceRemovedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7373                Ok((AudioDeviceEnumeratorEvent::OnDeviceRemoved { device_token: out.device_token }))
7374            }
7375            0x14aefcbbb076b0e9 => {
7376                let mut out = fidl::new_empty!(
7377                    AudioDeviceEnumeratorOnDeviceGainChangedRequest,
7378                    fidl::encoding::DefaultFuchsiaResourceDialect
7379                );
7380                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceGainChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7381                Ok((AudioDeviceEnumeratorEvent::OnDeviceGainChanged {
7382                    device_token: out.device_token,
7383                    gain_info: out.gain_info,
7384                }))
7385            }
7386            0x16357b42d4c16e11 => {
7387                let mut out = fidl::new_empty!(
7388                    AudioDeviceEnumeratorOnDefaultDeviceChangedRequest,
7389                    fidl::encoding::DefaultFuchsiaResourceDialect
7390                );
7391                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDefaultDeviceChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7392                Ok((AudioDeviceEnumeratorEvent::OnDefaultDeviceChanged {
7393                    old_default_token: out.old_default_token,
7394                    new_default_token: out.new_default_token,
7395                }))
7396            }
7397            _ => Err(fidl::Error::UnknownOrdinal {
7398                ordinal: tx_header.ordinal,
7399                protocol_name:
7400                    <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7401            }),
7402        }
7403    }
7404}
7405
7406/// A Stream of incoming requests for fuchsia.media/AudioDeviceEnumerator.
7407pub struct AudioDeviceEnumeratorRequestStream {
7408    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7409    is_terminated: bool,
7410}
7411
7412impl std::marker::Unpin for AudioDeviceEnumeratorRequestStream {}
7413
7414impl futures::stream::FusedStream for AudioDeviceEnumeratorRequestStream {
7415    fn is_terminated(&self) -> bool {
7416        self.is_terminated
7417    }
7418}
7419
7420impl fidl::endpoints::RequestStream for AudioDeviceEnumeratorRequestStream {
7421    type Protocol = AudioDeviceEnumeratorMarker;
7422    type ControlHandle = AudioDeviceEnumeratorControlHandle;
7423
7424    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7425        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7426    }
7427
7428    fn control_handle(&self) -> Self::ControlHandle {
7429        AudioDeviceEnumeratorControlHandle { inner: self.inner.clone() }
7430    }
7431
7432    fn into_inner(
7433        self,
7434    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7435    {
7436        (self.inner, self.is_terminated)
7437    }
7438
7439    fn from_inner(
7440        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7441        is_terminated: bool,
7442    ) -> Self {
7443        Self { inner, is_terminated }
7444    }
7445}
7446
7447impl futures::Stream for AudioDeviceEnumeratorRequestStream {
7448    type Item = Result<AudioDeviceEnumeratorRequest, fidl::Error>;
7449
7450    fn poll_next(
7451        mut self: std::pin::Pin<&mut Self>,
7452        cx: &mut std::task::Context<'_>,
7453    ) -> std::task::Poll<Option<Self::Item>> {
7454        let this = &mut *self;
7455        if this.inner.check_shutdown(cx) {
7456            this.is_terminated = true;
7457            return std::task::Poll::Ready(None);
7458        }
7459        if this.is_terminated {
7460            panic!("polled AudioDeviceEnumeratorRequestStream after completion");
7461        }
7462        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7463            |bytes, handles| {
7464                match this.inner.channel().read_etc(cx, bytes, handles) {
7465                    std::task::Poll::Ready(Ok(())) => {}
7466                    std::task::Poll::Pending => return std::task::Poll::Pending,
7467                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7468                        this.is_terminated = true;
7469                        return std::task::Poll::Ready(None);
7470                    }
7471                    std::task::Poll::Ready(Err(e)) => {
7472                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7473                            e.into(),
7474                        ))))
7475                    }
7476                }
7477
7478                // A message has been received from the channel
7479                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7480
7481                std::task::Poll::Ready(Some(match header.ordinal {
7482                0x4ce1aa218aeb12a6 => {
7483                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7484                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7485                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7486                    let control_handle = AudioDeviceEnumeratorControlHandle {
7487                        inner: this.inner.clone(),
7488                    };
7489                    Ok(AudioDeviceEnumeratorRequest::GetDevices {
7490                        responder: AudioDeviceEnumeratorGetDevicesResponder {
7491                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7492                            tx_id: header.tx_id,
7493                        },
7494                    })
7495                }
7496                0x25dd4723403c414b => {
7497                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7498                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorGetDeviceGainRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7499                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorGetDeviceGainRequest>(&header, _body_bytes, handles, &mut req)?;
7500                    let control_handle = AudioDeviceEnumeratorControlHandle {
7501                        inner: this.inner.clone(),
7502                    };
7503                    Ok(AudioDeviceEnumeratorRequest::GetDeviceGain {device_token: req.device_token,
7504
7505                        responder: AudioDeviceEnumeratorGetDeviceGainResponder {
7506                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7507                            tx_id: header.tx_id,
7508                        },
7509                    })
7510                }
7511                0x5bdabc8ebe83591 => {
7512                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7513                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorSetDeviceGainRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7514                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorSetDeviceGainRequest>(&header, _body_bytes, handles, &mut req)?;
7515                    let control_handle = AudioDeviceEnumeratorControlHandle {
7516                        inner: this.inner.clone(),
7517                    };
7518                    Ok(AudioDeviceEnumeratorRequest::SetDeviceGain {device_token: req.device_token,
7519gain_info: req.gain_info,
7520valid_flags: req.valid_flags,
7521
7522                        control_handle,
7523                    })
7524                }
7525                0x72cdbada4d70ed67 => {
7526                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7527                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorAddDeviceByChannelRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7528                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(&header, _body_bytes, handles, &mut req)?;
7529                    let control_handle = AudioDeviceEnumeratorControlHandle {
7530                        inner: this.inner.clone(),
7531                    };
7532                    Ok(AudioDeviceEnumeratorRequest::AddDeviceByChannel {device_name: req.device_name,
7533is_input: req.is_input,
7534channel: req.channel,
7535
7536                        control_handle,
7537                    })
7538                }
7539                _ => Err(fidl::Error::UnknownOrdinal {
7540                    ordinal: header.ordinal,
7541                    protocol_name: <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7542                }),
7543            }))
7544            },
7545        )
7546    }
7547}
7548
7549#[derive(Debug)]
7550pub enum AudioDeviceEnumeratorRequest {
7551    /// Obtain the list of currently active audio devices.
7552    GetDevices { responder: AudioDeviceEnumeratorGetDevicesResponder },
7553    /// Gain/Mute/AGC control
7554    ///
7555    /// Note that each of these operations requires a device_token in order to
7556    /// target the proper input/output.
7557    ///
7558    /// The Get command returns the device_token of the device whose gain is
7559    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
7560    /// device_token was invalid or the device had been removed from the system
7561    /// before the Get command could be processed.
7562    ///
7563    /// Set commands which are given an invalid device token are ignored and
7564    /// have no effect on the system. In addition, users do not need to control
7565    /// all of the gain settings for an audio device with each call. Only the
7566    /// settings with a corresponding flag set in the set_flags parameter will
7567    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
7568    /// a SetDeviceGain call to care only about the mute setting in the
7569    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
7570    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
7571    /// status to be changed simultaneously.
7572    GetDeviceGain { device_token: u64, responder: AudioDeviceEnumeratorGetDeviceGainResponder },
7573    SetDeviceGain {
7574        device_token: u64,
7575        gain_info: AudioGainInfo,
7576        valid_flags: AudioGainValidFlags,
7577        control_handle: AudioDeviceEnumeratorControlHandle,
7578    },
7579    /// # Deprecation
7580    ///
7581    /// StreamConfig is not supported anymore, instead use an
7582    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
7583    /// , see
7584    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
7585    AddDeviceByChannel {
7586        device_name: String,
7587        is_input: bool,
7588        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7589        control_handle: AudioDeviceEnumeratorControlHandle,
7590    },
7591}
7592
7593impl AudioDeviceEnumeratorRequest {
7594    #[allow(irrefutable_let_patterns)]
7595    pub fn into_get_devices(self) -> Option<(AudioDeviceEnumeratorGetDevicesResponder)> {
7596        if let AudioDeviceEnumeratorRequest::GetDevices { responder } = self {
7597            Some((responder))
7598        } else {
7599            None
7600        }
7601    }
7602
7603    #[allow(irrefutable_let_patterns)]
7604    pub fn into_get_device_gain(
7605        self,
7606    ) -> Option<(u64, AudioDeviceEnumeratorGetDeviceGainResponder)> {
7607        if let AudioDeviceEnumeratorRequest::GetDeviceGain { device_token, responder } = self {
7608            Some((device_token, responder))
7609        } else {
7610            None
7611        }
7612    }
7613
7614    #[allow(irrefutable_let_patterns)]
7615    pub fn into_set_device_gain(
7616        self,
7617    ) -> Option<(u64, AudioGainInfo, AudioGainValidFlags, AudioDeviceEnumeratorControlHandle)> {
7618        if let AudioDeviceEnumeratorRequest::SetDeviceGain {
7619            device_token,
7620            gain_info,
7621            valid_flags,
7622            control_handle,
7623        } = self
7624        {
7625            Some((device_token, gain_info, valid_flags, control_handle))
7626        } else {
7627            None
7628        }
7629    }
7630
7631    #[allow(irrefutable_let_patterns)]
7632    pub fn into_add_device_by_channel(
7633        self,
7634    ) -> Option<(
7635        String,
7636        bool,
7637        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7638        AudioDeviceEnumeratorControlHandle,
7639    )> {
7640        if let AudioDeviceEnumeratorRequest::AddDeviceByChannel {
7641            device_name,
7642            is_input,
7643            channel,
7644            control_handle,
7645        } = self
7646        {
7647            Some((device_name, is_input, channel, control_handle))
7648        } else {
7649            None
7650        }
7651    }
7652
7653    /// Name of the method defined in FIDL
7654    pub fn method_name(&self) -> &'static str {
7655        match *self {
7656            AudioDeviceEnumeratorRequest::GetDevices { .. } => "get_devices",
7657            AudioDeviceEnumeratorRequest::GetDeviceGain { .. } => "get_device_gain",
7658            AudioDeviceEnumeratorRequest::SetDeviceGain { .. } => "set_device_gain",
7659            AudioDeviceEnumeratorRequest::AddDeviceByChannel { .. } => "add_device_by_channel",
7660        }
7661    }
7662}
7663
7664#[derive(Debug, Clone)]
7665pub struct AudioDeviceEnumeratorControlHandle {
7666    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7667}
7668
7669impl fidl::endpoints::ControlHandle for AudioDeviceEnumeratorControlHandle {
7670    fn shutdown(&self) {
7671        self.inner.shutdown()
7672    }
7673    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7674        self.inner.shutdown_with_epitaph(status)
7675    }
7676
7677    fn is_closed(&self) -> bool {
7678        self.inner.channel().is_closed()
7679    }
7680    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7681        self.inner.channel().on_closed()
7682    }
7683
7684    #[cfg(target_os = "fuchsia")]
7685    fn signal_peer(
7686        &self,
7687        clear_mask: zx::Signals,
7688        set_mask: zx::Signals,
7689    ) -> Result<(), zx_status::Status> {
7690        use fidl::Peered;
7691        self.inner.channel().signal_peer(clear_mask, set_mask)
7692    }
7693}
7694
7695impl AudioDeviceEnumeratorControlHandle {
7696    pub fn send_on_device_added(&self, mut device: &AudioDeviceInfo) -> Result<(), fidl::Error> {
7697        self.inner.send::<AudioDeviceEnumeratorOnDeviceAddedRequest>(
7698            (device,),
7699            0,
7700            0xe0fbe40057c4b44,
7701            fidl::encoding::DynamicFlags::empty(),
7702        )
7703    }
7704
7705    pub fn send_on_device_removed(&self, mut device_token: u64) -> Result<(), fidl::Error> {
7706        self.inner.send::<AudioDeviceEnumeratorOnDeviceRemovedRequest>(
7707            (device_token,),
7708            0,
7709            0x6f3b7574463d9ff8,
7710            fidl::encoding::DynamicFlags::empty(),
7711        )
7712    }
7713
7714    pub fn send_on_device_gain_changed(
7715        &self,
7716        mut device_token: u64,
7717        mut gain_info: &AudioGainInfo,
7718    ) -> Result<(), fidl::Error> {
7719        self.inner.send::<AudioDeviceEnumeratorOnDeviceGainChangedRequest>(
7720            (device_token, gain_info),
7721            0,
7722            0x14aefcbbb076b0e9,
7723            fidl::encoding::DynamicFlags::empty(),
7724        )
7725    }
7726
7727    pub fn send_on_default_device_changed(
7728        &self,
7729        mut old_default_token: u64,
7730        mut new_default_token: u64,
7731    ) -> Result<(), fidl::Error> {
7732        self.inner.send::<AudioDeviceEnumeratorOnDefaultDeviceChangedRequest>(
7733            (old_default_token, new_default_token),
7734            0,
7735            0x16357b42d4c16e11,
7736            fidl::encoding::DynamicFlags::empty(),
7737        )
7738    }
7739}
7740
7741#[must_use = "FIDL methods require a response to be sent"]
7742#[derive(Debug)]
7743pub struct AudioDeviceEnumeratorGetDevicesResponder {
7744    control_handle: std::mem::ManuallyDrop<AudioDeviceEnumeratorControlHandle>,
7745    tx_id: u32,
7746}
7747
7748/// Set the the channel to be shutdown (see [`AudioDeviceEnumeratorControlHandle::shutdown`])
7749/// if the responder is dropped without sending a response, so that the client
7750/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7751impl std::ops::Drop for AudioDeviceEnumeratorGetDevicesResponder {
7752    fn drop(&mut self) {
7753        self.control_handle.shutdown();
7754        // Safety: drops once, never accessed again
7755        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7756    }
7757}
7758
7759impl fidl::endpoints::Responder for AudioDeviceEnumeratorGetDevicesResponder {
7760    type ControlHandle = AudioDeviceEnumeratorControlHandle;
7761
7762    fn control_handle(&self) -> &AudioDeviceEnumeratorControlHandle {
7763        &self.control_handle
7764    }
7765
7766    fn drop_without_shutdown(mut self) {
7767        // Safety: drops once, never accessed again due to mem::forget
7768        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7769        // Prevent Drop from running (which would shut down the channel)
7770        std::mem::forget(self);
7771    }
7772}
7773
7774impl AudioDeviceEnumeratorGetDevicesResponder {
7775    /// Sends a response to the FIDL transaction.
7776    ///
7777    /// Sets the channel to shutdown if an error occurs.
7778    pub fn send(self, mut devices: &[AudioDeviceInfo]) -> Result<(), fidl::Error> {
7779        let _result = self.send_raw(devices);
7780        if _result.is_err() {
7781            self.control_handle.shutdown();
7782        }
7783        self.drop_without_shutdown();
7784        _result
7785    }
7786
7787    /// Similar to "send" but does not shutdown the channel if an error occurs.
7788    pub fn send_no_shutdown_on_err(
7789        self,
7790        mut devices: &[AudioDeviceInfo],
7791    ) -> Result<(), fidl::Error> {
7792        let _result = self.send_raw(devices);
7793        self.drop_without_shutdown();
7794        _result
7795    }
7796
7797    fn send_raw(&self, mut devices: &[AudioDeviceInfo]) -> Result<(), fidl::Error> {
7798        self.control_handle.inner.send::<AudioDeviceEnumeratorGetDevicesResponse>(
7799            (devices,),
7800            self.tx_id,
7801            0x4ce1aa218aeb12a6,
7802            fidl::encoding::DynamicFlags::empty(),
7803        )
7804    }
7805}
7806
7807#[must_use = "FIDL methods require a response to be sent"]
7808#[derive(Debug)]
7809pub struct AudioDeviceEnumeratorGetDeviceGainResponder {
7810    control_handle: std::mem::ManuallyDrop<AudioDeviceEnumeratorControlHandle>,
7811    tx_id: u32,
7812}
7813
7814/// Set the the channel to be shutdown (see [`AudioDeviceEnumeratorControlHandle::shutdown`])
7815/// if the responder is dropped without sending a response, so that the client
7816/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7817impl std::ops::Drop for AudioDeviceEnumeratorGetDeviceGainResponder {
7818    fn drop(&mut self) {
7819        self.control_handle.shutdown();
7820        // Safety: drops once, never accessed again
7821        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7822    }
7823}
7824
7825impl fidl::endpoints::Responder for AudioDeviceEnumeratorGetDeviceGainResponder {
7826    type ControlHandle = AudioDeviceEnumeratorControlHandle;
7827
7828    fn control_handle(&self) -> &AudioDeviceEnumeratorControlHandle {
7829        &self.control_handle
7830    }
7831
7832    fn drop_without_shutdown(mut self) {
7833        // Safety: drops once, never accessed again due to mem::forget
7834        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7835        // Prevent Drop from running (which would shut down the channel)
7836        std::mem::forget(self);
7837    }
7838}
7839
7840impl AudioDeviceEnumeratorGetDeviceGainResponder {
7841    /// Sends a response to the FIDL transaction.
7842    ///
7843    /// Sets the channel to shutdown if an error occurs.
7844    pub fn send(
7845        self,
7846        mut device_token: u64,
7847        mut gain_info: &AudioGainInfo,
7848    ) -> Result<(), fidl::Error> {
7849        let _result = self.send_raw(device_token, gain_info);
7850        if _result.is_err() {
7851            self.control_handle.shutdown();
7852        }
7853        self.drop_without_shutdown();
7854        _result
7855    }
7856
7857    /// Similar to "send" but does not shutdown the channel if an error occurs.
7858    pub fn send_no_shutdown_on_err(
7859        self,
7860        mut device_token: u64,
7861        mut gain_info: &AudioGainInfo,
7862    ) -> Result<(), fidl::Error> {
7863        let _result = self.send_raw(device_token, gain_info);
7864        self.drop_without_shutdown();
7865        _result
7866    }
7867
7868    fn send_raw(
7869        &self,
7870        mut device_token: u64,
7871        mut gain_info: &AudioGainInfo,
7872    ) -> Result<(), fidl::Error> {
7873        self.control_handle.inner.send::<AudioDeviceEnumeratorGetDeviceGainResponse>(
7874            (device_token, gain_info),
7875            self.tx_id,
7876            0x25dd4723403c414b,
7877            fidl::encoding::DynamicFlags::empty(),
7878        )
7879    }
7880}
7881
7882#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7883pub struct AudioRendererMarker;
7884
7885impl fidl::endpoints::ProtocolMarker for AudioRendererMarker {
7886    type Proxy = AudioRendererProxy;
7887    type RequestStream = AudioRendererRequestStream;
7888    #[cfg(target_os = "fuchsia")]
7889    type SynchronousProxy = AudioRendererSynchronousProxy;
7890
7891    const DEBUG_NAME: &'static str = "fuchsia.media.AudioRenderer";
7892}
7893impl fidl::endpoints::DiscoverableProtocolMarker for AudioRendererMarker {}
7894
7895pub trait AudioRendererProxyInterface: Send + Sync {
7896    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
7897    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
7898    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7899    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
7900    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
7901    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
7902    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7903    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
7904    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
7905    fn r#bind_gain_control(
7906        &self,
7907        gain_control_request: fidl::endpoints::ServerEnd<
7908            fidl_fuchsia_media_audio::GainControlMarker,
7909        >,
7910    ) -> Result<(), fidl::Error>;
7911    fn r#set_pts_units(
7912        &self,
7913        tick_per_second_numerator: u32,
7914        tick_per_second_denominator: u32,
7915    ) -> Result<(), fidl::Error>;
7916    fn r#set_pts_continuity_threshold(&self, threshold_seconds: f32) -> Result<(), fidl::Error>;
7917    type GetReferenceClockResponseFut: std::future::Future<Output = Result<fidl::Clock, fidl::Error>>
7918        + Send;
7919    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
7920    fn r#set_reference_clock(
7921        &self,
7922        reference_clock: Option<fidl::Clock>,
7923    ) -> Result<(), fidl::Error>;
7924    fn r#set_usage(&self, usage: AudioRenderUsage) -> Result<(), fidl::Error>;
7925    fn r#set_usage2(&self, usage2: AudioRenderUsage2) -> Result<(), fidl::Error>;
7926    fn r#set_pcm_stream_type(&self, type_: &AudioStreamType) -> Result<(), fidl::Error>;
7927    fn r#enable_min_lead_time_events(&self, enabled: bool) -> Result<(), fidl::Error>;
7928    type GetMinLeadTimeResponseFut: std::future::Future<Output = Result<i64, fidl::Error>> + Send;
7929    fn r#get_min_lead_time(&self) -> Self::GetMinLeadTimeResponseFut;
7930    type PlayResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>> + Send;
7931    fn r#play(&self, reference_time: i64, media_time: i64) -> Self::PlayResponseFut;
7932    fn r#play_no_reply(&self, reference_time: i64, media_time: i64) -> Result<(), fidl::Error>;
7933    type PauseResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>> + Send;
7934    fn r#pause(&self) -> Self::PauseResponseFut;
7935    fn r#pause_no_reply(&self) -> Result<(), fidl::Error>;
7936}
7937#[derive(Debug)]
7938#[cfg(target_os = "fuchsia")]
7939pub struct AudioRendererSynchronousProxy {
7940    client: fidl::client::sync::Client,
7941}
7942
7943#[cfg(target_os = "fuchsia")]
7944impl fidl::endpoints::SynchronousProxy for AudioRendererSynchronousProxy {
7945    type Proxy = AudioRendererProxy;
7946    type Protocol = AudioRendererMarker;
7947
7948    fn from_channel(inner: fidl::Channel) -> Self {
7949        Self::new(inner)
7950    }
7951
7952    fn into_channel(self) -> fidl::Channel {
7953        self.client.into_channel()
7954    }
7955
7956    fn as_channel(&self) -> &fidl::Channel {
7957        self.client.as_channel()
7958    }
7959}
7960
7961#[cfg(target_os = "fuchsia")]
7962impl AudioRendererSynchronousProxy {
7963    pub fn new(channel: fidl::Channel) -> Self {
7964        let protocol_name = <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7965        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7966    }
7967
7968    pub fn into_channel(self) -> fidl::Channel {
7969        self.client.into_channel()
7970    }
7971
7972    /// Waits until an event arrives and returns it. It is safe for other
7973    /// threads to make concurrent requests while waiting for an event.
7974    pub fn wait_for_event(
7975        &self,
7976        deadline: zx::MonotonicInstant,
7977    ) -> Result<AudioRendererEvent, fidl::Error> {
7978        AudioRendererEvent::decode(self.client.wait_for_event(deadline)?)
7979    }
7980
7981    /// Adds a payload buffer to the current buffer set associated with the
7982    /// connection. A `StreamPacket` struct reference a payload buffer in the
7983    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
7984    ///
7985    /// A buffer with ID `id` must not be in the current set when this method is
7986    /// invoked, otherwise the service will close the connection.
7987    pub fn r#add_payload_buffer(
7988        &self,
7989        mut id: u32,
7990        mut payload_buffer: fidl::Vmo,
7991    ) -> Result<(), fidl::Error> {
7992        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
7993            (id, payload_buffer),
7994            0x3b3a37fc34fe5b56,
7995            fidl::encoding::DynamicFlags::empty(),
7996        )
7997    }
7998
7999    /// Removes a payload buffer from the current buffer set associated with the
8000    /// connection.
8001    ///
8002    /// A buffer with ID `id` must exist in the current set when this method is
8003    /// invoked, otherwise the service will will close the connection.
8004    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
8005        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
8006            (id,),
8007            0x5d1e4f74c3658262,
8008            fidl::encoding::DynamicFlags::empty(),
8009        )
8010    }
8011
8012    /// Sends a packet to the service. The response is sent when the service is
8013    /// done with the associated payload memory.
8014    ///
8015    /// `packet` must be valid for the current buffer set, otherwise the service
8016    /// will close the connection.
8017    pub fn r#send_packet(
8018        &self,
8019        mut packet: &StreamPacket,
8020        ___deadline: zx::MonotonicInstant,
8021    ) -> Result<(), fidl::Error> {
8022        let _response =
8023            self.client.send_query::<StreamSinkSendPacketRequest, fidl::encoding::EmptyPayload>(
8024                (packet,),
8025                0x67cddd607442775f,
8026                fidl::encoding::DynamicFlags::empty(),
8027                ___deadline,
8028            )?;
8029        Ok(_response)
8030    }
8031
8032    /// Sends a packet to the service. This interface doesn't define how the
8033    /// client knows when the sink is done with the associated payload memory.
8034    /// The inheriting interface must define that.
8035    ///
8036    /// `packet` must be valid for the current buffer set, otherwise the service
8037    /// will close the connection.
8038    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
8039        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
8040            (packet,),
8041            0x8d9b8b413ceba9d,
8042            fidl::encoding::DynamicFlags::empty(),
8043        )
8044    }
8045
8046    /// Indicates the stream has ended. The precise semantics of this method are
8047    /// determined by the inheriting interface.
8048    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
8049        self.client.send::<fidl::encoding::EmptyPayload>(
8050            (),
8051            0x6180fd6f7e793b71,
8052            fidl::encoding::DynamicFlags::empty(),
8053        )
8054    }
8055
8056    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8057    /// and not yet released. The response is sent after all packets have been
8058    /// released.
8059    pub fn r#discard_all_packets(
8060        &self,
8061        ___deadline: zx::MonotonicInstant,
8062    ) -> Result<(), fidl::Error> {
8063        let _response =
8064            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
8065                (),
8066                0x6f4dad7af2917665,
8067                fidl::encoding::DynamicFlags::empty(),
8068                ___deadline,
8069            )?;
8070        Ok(_response)
8071    }
8072
8073    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8074    /// and not yet released.
8075    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
8076        self.client.send::<fidl::encoding::EmptyPayload>(
8077            (),
8078            0x50d36d0d23081bc4,
8079            fidl::encoding::DynamicFlags::empty(),
8080        )
8081    }
8082
8083    /// Binds to the gain control for this AudioRenderer.
8084    pub fn r#bind_gain_control(
8085        &self,
8086        mut gain_control_request: fidl::endpoints::ServerEnd<
8087            fidl_fuchsia_media_audio::GainControlMarker,
8088        >,
8089    ) -> Result<(), fidl::Error> {
8090        self.client.send::<AudioRendererBindGainControlRequest>(
8091            (gain_control_request,),
8092            0x293f5c7f8fba2bdc,
8093            fidl::encoding::DynamicFlags::empty(),
8094        )
8095    }
8096
8097    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
8098    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
8099    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
8100    pub fn r#set_pts_units(
8101        &self,
8102        mut tick_per_second_numerator: u32,
8103        mut tick_per_second_denominator: u32,
8104    ) -> Result<(), fidl::Error> {
8105        self.client.send::<AudioRendererSetPtsUnitsRequest>(
8106            (tick_per_second_numerator, tick_per_second_denominator),
8107            0xf68cd108785a27c,
8108            fidl::encoding::DynamicFlags::empty(),
8109        )
8110    }
8111
8112    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
8113    /// and expected PTS (determined using interpolation). Beyond this threshold,
8114    /// a stream is no longer considered 'continuous' by the renderer.
8115    ///
8116    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
8117    /// Most users should not need to change this value from its default.
8118    ///
8119    /// Example:
8120    /// A user is playing back 48KHz audio from a container, which also contains
8121    /// video and needs to be synchronized with the audio. The timestamps are
8122    /// provided explicitly per packet by the container, and expressed in mSec
8123    /// units. This means that a single tick of the media timeline (1 mSec)
8124    /// represents exactly 48 frames of audio. The application in this scenario
8125    /// delivers packets of audio to the AudioRenderer, each with exactly 470
8126    /// frames of audio, and each with an explicit timestamp set to the best
8127    /// possible representation of the presentation time (given this media
8128    /// clock's resolution). So, starting from zero, the timestamps would be..
8129    ///
8130    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
8131    ///
8132    /// In this example, attempting to use the presentation time to compute the
8133    /// starting frame number of the audio in the packet would be wrong the
8134    /// majority of the time. The first timestamp is correct (by definition), but
8135    /// it will be 24 packets before the timestamps and frame numbers come back
8136    /// into alignment (the 24th packet would start with the 11280th audio frame
8137    /// and have a PTS of exactly 235).
8138    ///
8139    /// One way to fix this situation is to set the PTS continuity threshold
8140    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
8141    /// the number of frames contained within a single tick of the media clock,
8142    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
8143    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
8144    /// explicitly provided PTS would be considered to be a continuation of the
8145    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
8146    /// would work well.
8147    ///
8148    /// Other possible uses:
8149    /// Users who are scheduling audio explicitly, relative to a clock which has
8150    /// not been configured as the reference clock, can use this value to control
8151    /// the maximum acceptable synchronization error before a discontinuity is
8152    /// introduced. E.g., if a user is scheduling audio based on a recovered
8153    /// common media clock, and has not published that clock as the reference
8154    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
8155    /// can accumulate before the AudioRenderer deliberately inserts a
8156    /// presentation discontinuity to account for the error.
8157    ///
8158    /// Users whose need to deal with a container where their timestamps may be
8159    /// even less correct than +/- 1/2 of a PTS tick may set this value to
8160    /// something larger. This should be the maximum level of inaccuracy present
8161    /// in the container timestamps, if known. Failing that, it could be set to
8162    /// the maximum tolerable level of drift error before absolute timestamps are
8163    /// explicitly obeyed. Finally, a user could set this number to a very large
8164    /// value (86400.0 seconds, for example) to effectively cause *all*
8165    /// timestamps to be ignored after the first, thus treating all audio as
8166    /// continuous with previously delivered packets. Conversely, users who wish
8167    /// to *always* explicitly schedule their audio packets exactly may specify
8168    /// a CT of 0.
8169    ///
8170    /// Note: explicitly specifying high-frequency PTS units reduces the default
8171    /// continuity threshold accordingly. Internally, this threshold is stored as an
8172    /// integer of 1/8192 subframes. The default threshold is computed as follows:
8173    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
8174    /// For this reason, specifying PTS units with a frequency greater than 8192x
8175    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
8176    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
8177    pub fn r#set_pts_continuity_threshold(
8178        &self,
8179        mut threshold_seconds: f32,
8180    ) -> Result<(), fidl::Error> {
8181        self.client.send::<AudioRendererSetPtsContinuityThresholdRequest>(
8182            (threshold_seconds,),
8183            0x2849ba571d1971ba,
8184            fidl::encoding::DynamicFlags::empty(),
8185        )
8186    }
8187
8188    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
8189    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
8190    pub fn r#get_reference_clock(
8191        &self,
8192        ___deadline: zx::MonotonicInstant,
8193    ) -> Result<fidl::Clock, fidl::Error> {
8194        let _response = self
8195            .client
8196            .send_query::<fidl::encoding::EmptyPayload, AudioRendererGetReferenceClockResponse>(
8197                (),
8198                0x2f7a7f011a172f7e,
8199                fidl::encoding::DynamicFlags::empty(),
8200                ___deadline,
8201            )?;
8202        Ok(_response.reference_clock)
8203    }
8204
8205    /// Sets the reference clock that controls this renderer's playback rate. If the input
8206    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
8207    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
8208    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
8209    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
8210    ///
8211    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
8212    /// cannot be called a second time (even if the renderer format has not yet been set).
8213    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
8214    /// diverge at some later time, they should create a clone of the monotonic clock, set
8215    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
8216    pub fn r#set_reference_clock(
8217        &self,
8218        mut reference_clock: Option<fidl::Clock>,
8219    ) -> Result<(), fidl::Error> {
8220        self.client.send::<AudioRendererSetReferenceClockRequest>(
8221            (reference_clock,),
8222            0x39acd05d832b5fed,
8223            fidl::encoding::DynamicFlags::empty(),
8224        )
8225    }
8226
8227    /// Sets the usage of the render stream. This method may not be called after
8228    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8229    pub fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
8230        self.client.send::<AudioRendererSetUsageRequest>(
8231            (usage,),
8232            0x3994bd23b55a733e,
8233            fidl::encoding::DynamicFlags::empty(),
8234        )
8235    }
8236
8237    /// Sets the usage of the render stream. This method may not be called after
8238    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8239    pub fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
8240        self.client.send::<AudioRendererSetUsage2Request>(
8241            (usage2,),
8242            0x2904035c7132b103,
8243            fidl::encoding::DynamicFlags::FLEXIBLE,
8244        )
8245    }
8246
8247    /// Sets the type of the stream to be delivered by the client. Using this method implies
8248    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
8249    ///
8250    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
8251    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
8252    /// methods such as `SendPacket`/`SendPacketNoReply`.
8253    pub fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
8254        self.client.send::<AudioRendererSetPcmStreamTypeRequest>(
8255            (type_,),
8256            0x27aa715d8901fa19,
8257            fidl::encoding::DynamicFlags::empty(),
8258        )
8259    }
8260
8261    /// Enables or disables notifications about changes to the minimum clock lead
8262    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
8263    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
8264    /// event with the current minimum lead time for the AudioRenderer. If the
8265    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
8266    /// new value. This behavior will continue until the user calls
8267    /// `EnableMinLeadTimeEvents(false)`.
8268    ///
8269    /// The minimum clock lead time is the amount of time ahead of the reference
8270    /// clock's understanding of "now" that packets needs to arrive (relative to
8271    /// the playback clock transformation) in order for the mixer to be able to
8272    /// mix packet. For example...
8273    ///
8274    /// + Let the PTS of packet X be P(X)
8275    /// + Let the function which transforms PTS -> RefClock be R(p) (this
8276    ///   function is determined by the call to Play(...)
8277    /// + Let the minimum lead time be MLT
8278    ///
8279    /// If R(P(X)) < RefClock.Now() + MLT
8280    /// Then the packet is late, and some (or all) of the packet's payload will
8281    /// need to be skipped in order to present the packet at the scheduled time.
8282    ///
8283    /// The value `min_lead_time_nsec = 0` is a special value which indicates
8284    /// that the AudioRenderer is not yet routed to an output device. If `Play`
8285    /// is called before the AudioRenderer is routed, any played packets will be
8286    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
8287    /// calling `Play`.
8288    pub fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
8289        self.client.send::<AudioRendererEnableMinLeadTimeEventsRequest>(
8290            (enabled,),
8291            0x62808dfad72bf890,
8292            fidl::encoding::DynamicFlags::empty(),
8293        )
8294    }
8295
8296    ///
8297    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
8298    /// there's little reason to do so. This is because lead time is a function
8299    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
8300    /// If min lead time events are enabled before `SetPcmStreamType` (with
8301    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
8302    /// response to `SetPcmStreamType`.
8303    pub fn r#get_min_lead_time(
8304        &self,
8305        ___deadline: zx::MonotonicInstant,
8306    ) -> Result<i64, fidl::Error> {
8307        let _response = self
8308            .client
8309            .send_query::<fidl::encoding::EmptyPayload, AudioRendererGetMinLeadTimeResponse>(
8310                (),
8311                0x1cf3c3ecd8fec26b,
8312                fidl::encoding::DynamicFlags::empty(),
8313                ___deadline,
8314            )?;
8315        Ok(_response.min_lead_time_nsec)
8316    }
8317
8318    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
8319    /// of the media timeline, using specific values provided by the caller (or
8320    /// default values if not specified). In an optional callback, returns the
8321    /// timestamp values ultimately used -- these set the ongoing relationship
8322    /// between the media and reference timelines (i.e., how to translate between
8323    /// the domain of presentation timestamps, and the realm of local system
8324    /// time).
8325    ///
8326    /// Local system time is specified in units of nanoseconds; media_time is
8327    /// specified in the units defined by the user in the `SetPtsUnits` function,
8328    /// or nanoseconds if `SetPtsUnits` is not called.
8329    ///
8330    /// The act of placing an AudioRenderer into the playback state establishes a
8331    /// relationship between 1) the user-defined media (or presentation) timeline
8332    /// for this particular AudioRenderer, and 2) the real-world system reference
8333    /// timeline. To communicate how to translate between timelines, the Play()
8334    /// callback provides an equivalent timestamp in each time domain. The first
8335    /// value ('reference_time') is given in terms of this renderer's reference
8336    /// clock; the second value ('media_time') is what media instant exactly
8337    /// corresponds to that local time. Restated, the frame at 'media_time' in
8338    /// the audio stream should be presented at 'reference_time' according to
8339    /// the reference clock.
8340    ///
8341    /// Note: on calling this API, media_time immediately starts advancing. It is
8342    /// possible (if uncommon) for a caller to specify a system time that is
8343    /// far in the past, or far into the future. This, along with the specified
8344    /// media time, is simply used to determine what media time corresponds to
8345    /// 'now', and THAT media time is then intersected with presentation
8346    /// timestamps of packets already submitted, to determine which media frames
8347    /// should be presented next.
8348    ///
8349    /// With the corresponding reference_time and media_time values, a user can
8350    /// translate arbitrary time values from one timeline into the other. After
8351    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
8352    /// given the 'ref_start' and 'media_start' values from `Play`, then for
8353    /// any 'ref_time':
8354    ///
8355    /// media_time = ( (ref_time - ref_start) / 1e9
8356    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
8357    ///              + media_start
8358    ///
8359    /// Conversely, for any presentation timestamp 'media_time':
8360    ///
8361    /// ref_time = ( (media_time - media_start)
8362    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
8363    ///              * 1e9 )
8364    ///            + ref_start
8365    ///
8366    /// Users, depending on their use case, may optionally choose not to specify
8367    /// one or both of these timestamps. A timestamp may be omitted by supplying
8368    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
8369    /// any omitted timestamp value using the following rules:
8370    ///
8371    /// Reference Time
8372    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
8373    /// reference time to begin presentation, based on the minimum lead times for
8374    /// the output devices that are currently bound to this AudioRenderer. For
8375    /// example, if an AudioRenderer is bound to an internal audio output
8376    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
8377    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
8378    /// is omitted) select a reference time 80 mSec from now.
8379    ///
8380    /// Media Time
8381    /// If media_time is omitted, the AudioRenderer will select one of two
8382    /// values.
8383    /// - If the AudioRenderer is resuming from the paused state, and packets
8384    /// have not been discarded since being paused, then the AudioRenderer will
8385    /// use a media_time corresponding to the instant at which the presentation
8386    /// became paused.
8387    /// - If the AudioRenderer is being placed into a playing state for the first
8388    /// time following startup or a 'discard packets' operation, the initial
8389    /// media_time will be set to the PTS of the first payload in the pending
8390    /// packet queue. If the pending queue is empty, initial media_time will be
8391    /// set to zero.
8392    ///
8393    /// Return Value
8394    /// When requested, the AudioRenderer will return the 'reference_time' and
8395    /// 'media_time' which were selected and used (whether they were explicitly
8396    /// specified or not) in the return value of the play call.
8397    ///
8398    /// Examples
8399    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
8400    /// to start playing as soon as possible. The user may call Play without
8401    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
8402    ///
8403    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
8404    /// playback at a specified 'reference_time', in sync with some other media
8405    /// stream, either initially or after discarding packets. The user would call
8406    /// `Play(reference_time, NO_TIMESTAMP)`.
8407    ///
8408    /// 3. A user has queued some audio using `SendPacket`. The first of these
8409    /// packets has a PTS of zero, and the user wishes playback to begin as soon
8410    /// as possible, but wishes to skip all of the audio content between PTS 0
8411    /// and PTS 'media_time'. The user would call
8412    /// `Play(NO_TIMESTAMP, media_time)`.
8413    ///
8414    /// 4. A user has queued some audio using `SendPacket` and want to present
8415    /// this media in synch with another player in a different device. The
8416    /// coordinator of the group of distributed players sends an explicit
8417    /// message to each player telling them to begin presentation of audio at
8418    /// PTS 'media_time', at the time (based on the group's shared reference
8419    /// clock) 'reference_time'. Here the user would call
8420    /// `Play(reference_time, media_time)`.
8421    pub fn r#play(
8422        &self,
8423        mut reference_time: i64,
8424        mut media_time: i64,
8425        ___deadline: zx::MonotonicInstant,
8426    ) -> Result<(i64, i64), fidl::Error> {
8427        let _response =
8428            self.client.send_query::<AudioRendererPlayRequest, AudioRendererPlayResponse>(
8429                (reference_time, media_time),
8430                0x3c0162db084f74a3,
8431                fidl::encoding::DynamicFlags::empty(),
8432                ___deadline,
8433            )?;
8434        Ok((_response.reference_time, _response.media_time))
8435    }
8436
8437    pub fn r#play_no_reply(
8438        &self,
8439        mut reference_time: i64,
8440        mut media_time: i64,
8441    ) -> Result<(), fidl::Error> {
8442        self.client.send::<AudioRendererPlayNoReplyRequest>(
8443            (reference_time, media_time),
8444            0x1b7fe832b68c22ef,
8445            fidl::encoding::DynamicFlags::empty(),
8446        )
8447    }
8448
8449    /// Immediately puts the AudioRenderer into the paused state and then report
8450    /// the relationship between the media and reference timelines which was
8451    /// established (if requested).
8452    ///
8453    /// If the AudioRenderer is already in the paused state when this called,
8454    /// the previously-established timeline values are returned (if requested).
8455    pub fn r#pause(&self, ___deadline: zx::MonotonicInstant) -> Result<(i64, i64), fidl::Error> {
8456        let _response =
8457            self.client.send_query::<fidl::encoding::EmptyPayload, AudioRendererPauseResponse>(
8458                (),
8459                0x41d557588d93d153,
8460                fidl::encoding::DynamicFlags::empty(),
8461                ___deadline,
8462            )?;
8463        Ok((_response.reference_time, _response.media_time))
8464    }
8465
8466    pub fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
8467        self.client.send::<fidl::encoding::EmptyPayload>(
8468            (),
8469            0x24cc45d4f3855ab,
8470            fidl::encoding::DynamicFlags::empty(),
8471        )
8472    }
8473}
8474
8475#[cfg(target_os = "fuchsia")]
8476impl From<AudioRendererSynchronousProxy> for zx::Handle {
8477    fn from(value: AudioRendererSynchronousProxy) -> Self {
8478        value.into_channel().into()
8479    }
8480}
8481
8482#[cfg(target_os = "fuchsia")]
8483impl From<fidl::Channel> for AudioRendererSynchronousProxy {
8484    fn from(value: fidl::Channel) -> Self {
8485        Self::new(value)
8486    }
8487}
8488
8489#[cfg(target_os = "fuchsia")]
8490impl fidl::endpoints::FromClient for AudioRendererSynchronousProxy {
8491    type Protocol = AudioRendererMarker;
8492
8493    fn from_client(value: fidl::endpoints::ClientEnd<AudioRendererMarker>) -> Self {
8494        Self::new(value.into_channel())
8495    }
8496}
8497
8498#[derive(Debug, Clone)]
8499pub struct AudioRendererProxy {
8500    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8501}
8502
8503impl fidl::endpoints::Proxy for AudioRendererProxy {
8504    type Protocol = AudioRendererMarker;
8505
8506    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8507        Self::new(inner)
8508    }
8509
8510    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8511        self.client.into_channel().map_err(|client| Self { client })
8512    }
8513
8514    fn as_channel(&self) -> &::fidl::AsyncChannel {
8515        self.client.as_channel()
8516    }
8517}
8518
8519impl AudioRendererProxy {
8520    /// Create a new Proxy for fuchsia.media/AudioRenderer.
8521    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8522        let protocol_name = <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8523        Self { client: fidl::client::Client::new(channel, protocol_name) }
8524    }
8525
8526    /// Get a Stream of events from the remote end of the protocol.
8527    ///
8528    /// # Panics
8529    ///
8530    /// Panics if the event stream was already taken.
8531    pub fn take_event_stream(&self) -> AudioRendererEventStream {
8532        AudioRendererEventStream { event_receiver: self.client.take_event_receiver() }
8533    }
8534
8535    /// Adds a payload buffer to the current buffer set associated with the
8536    /// connection. A `StreamPacket` struct reference a payload buffer in the
8537    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
8538    ///
8539    /// A buffer with ID `id` must not be in the current set when this method is
8540    /// invoked, otherwise the service will close the connection.
8541    pub fn r#add_payload_buffer(
8542        &self,
8543        mut id: u32,
8544        mut payload_buffer: fidl::Vmo,
8545    ) -> Result<(), fidl::Error> {
8546        AudioRendererProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
8547    }
8548
8549    /// Removes a payload buffer from the current buffer set associated with the
8550    /// connection.
8551    ///
8552    /// A buffer with ID `id` must exist in the current set when this method is
8553    /// invoked, otherwise the service will will close the connection.
8554    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
8555        AudioRendererProxyInterface::r#remove_payload_buffer(self, id)
8556    }
8557
8558    /// Sends a packet to the service. The response is sent when the service is
8559    /// done with the associated payload memory.
8560    ///
8561    /// `packet` must be valid for the current buffer set, otherwise the service
8562    /// will close the connection.
8563    pub fn r#send_packet(
8564        &self,
8565        mut packet: &StreamPacket,
8566    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8567        AudioRendererProxyInterface::r#send_packet(self, packet)
8568    }
8569
8570    /// Sends a packet to the service. This interface doesn't define how the
8571    /// client knows when the sink is done with the associated payload memory.
8572    /// The inheriting interface must define that.
8573    ///
8574    /// `packet` must be valid for the current buffer set, otherwise the service
8575    /// will close the connection.
8576    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
8577        AudioRendererProxyInterface::r#send_packet_no_reply(self, packet)
8578    }
8579
8580    /// Indicates the stream has ended. The precise semantics of this method are
8581    /// determined by the inheriting interface.
8582    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
8583        AudioRendererProxyInterface::r#end_of_stream(self)
8584    }
8585
8586    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8587    /// and not yet released. The response is sent after all packets have been
8588    /// released.
8589    pub fn r#discard_all_packets(
8590        &self,
8591    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8592        AudioRendererProxyInterface::r#discard_all_packets(self)
8593    }
8594
8595    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8596    /// and not yet released.
8597    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
8598        AudioRendererProxyInterface::r#discard_all_packets_no_reply(self)
8599    }
8600
8601    /// Binds to the gain control for this AudioRenderer.
8602    pub fn r#bind_gain_control(
8603        &self,
8604        mut gain_control_request: fidl::endpoints::ServerEnd<
8605            fidl_fuchsia_media_audio::GainControlMarker,
8606        >,
8607    ) -> Result<(), fidl::Error> {
8608        AudioRendererProxyInterface::r#bind_gain_control(self, gain_control_request)
8609    }
8610
8611    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
8612    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
8613    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
8614    pub fn r#set_pts_units(
8615        &self,
8616        mut tick_per_second_numerator: u32,
8617        mut tick_per_second_denominator: u32,
8618    ) -> Result<(), fidl::Error> {
8619        AudioRendererProxyInterface::r#set_pts_units(
8620            self,
8621            tick_per_second_numerator,
8622            tick_per_second_denominator,
8623        )
8624    }
8625
8626    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
8627    /// and expected PTS (determined using interpolation). Beyond this threshold,
8628    /// a stream is no longer considered 'continuous' by the renderer.
8629    ///
8630    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
8631    /// Most users should not need to change this value from its default.
8632    ///
8633    /// Example:
8634    /// A user is playing back 48KHz audio from a container, which also contains
8635    /// video and needs to be synchronized with the audio. The timestamps are
8636    /// provided explicitly per packet by the container, and expressed in mSec
8637    /// units. This means that a single tick of the media timeline (1 mSec)
8638    /// represents exactly 48 frames of audio. The application in this scenario
8639    /// delivers packets of audio to the AudioRenderer, each with exactly 470
8640    /// frames of audio, and each with an explicit timestamp set to the best
8641    /// possible representation of the presentation time (given this media
8642    /// clock's resolution). So, starting from zero, the timestamps would be..
8643    ///
8644    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
8645    ///
8646    /// In this example, attempting to use the presentation time to compute the
8647    /// starting frame number of the audio in the packet would be wrong the
8648    /// majority of the time. The first timestamp is correct (by definition), but
8649    /// it will be 24 packets before the timestamps and frame numbers come back
8650    /// into alignment (the 24th packet would start with the 11280th audio frame
8651    /// and have a PTS of exactly 235).
8652    ///
8653    /// One way to fix this situation is to set the PTS continuity threshold
8654    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
8655    /// the number of frames contained within a single tick of the media clock,
8656    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
8657    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
8658    /// explicitly provided PTS would be considered to be a continuation of the
8659    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
8660    /// would work well.
8661    ///
8662    /// Other possible uses:
8663    /// Users who are scheduling audio explicitly, relative to a clock which has
8664    /// not been configured as the reference clock, can use this value to control
8665    /// the maximum acceptable synchronization error before a discontinuity is
8666    /// introduced. E.g., if a user is scheduling audio based on a recovered
8667    /// common media clock, and has not published that clock as the reference
8668    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
8669    /// can accumulate before the AudioRenderer deliberately inserts a
8670    /// presentation discontinuity to account for the error.
8671    ///
8672    /// Users whose need to deal with a container where their timestamps may be
8673    /// even less correct than +/- 1/2 of a PTS tick may set this value to
8674    /// something larger. This should be the maximum level of inaccuracy present
8675    /// in the container timestamps, if known. Failing that, it could be set to
8676    /// the maximum tolerable level of drift error before absolute timestamps are
8677    /// explicitly obeyed. Finally, a user could set this number to a very large
8678    /// value (86400.0 seconds, for example) to effectively cause *all*
8679    /// timestamps to be ignored after the first, thus treating all audio as
8680    /// continuous with previously delivered packets. Conversely, users who wish
8681    /// to *always* explicitly schedule their audio packets exactly may specify
8682    /// a CT of 0.
8683    ///
8684    /// Note: explicitly specifying high-frequency PTS units reduces the default
8685    /// continuity threshold accordingly. Internally, this threshold is stored as an
8686    /// integer of 1/8192 subframes. The default threshold is computed as follows:
8687    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
8688    /// For this reason, specifying PTS units with a frequency greater than 8192x
8689    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
8690    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
8691    pub fn r#set_pts_continuity_threshold(
8692        &self,
8693        mut threshold_seconds: f32,
8694    ) -> Result<(), fidl::Error> {
8695        AudioRendererProxyInterface::r#set_pts_continuity_threshold(self, threshold_seconds)
8696    }
8697
8698    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
8699    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
8700    pub fn r#get_reference_clock(
8701        &self,
8702    ) -> fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>
8703    {
8704        AudioRendererProxyInterface::r#get_reference_clock(self)
8705    }
8706
8707    /// Sets the reference clock that controls this renderer's playback rate. If the input
8708    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
8709    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
8710    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
8711    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
8712    ///
8713    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
8714    /// cannot be called a second time (even if the renderer format has not yet been set).
8715    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
8716    /// diverge at some later time, they should create a clone of the monotonic clock, set
8717    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
8718    pub fn r#set_reference_clock(
8719        &self,
8720        mut reference_clock: Option<fidl::Clock>,
8721    ) -> Result<(), fidl::Error> {
8722        AudioRendererProxyInterface::r#set_reference_clock(self, reference_clock)
8723    }
8724
8725    /// Sets the usage of the render stream. This method may not be called after
8726    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8727    pub fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
8728        AudioRendererProxyInterface::r#set_usage(self, usage)
8729    }
8730
8731    /// Sets the usage of the render stream. This method may not be called after
8732    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8733    pub fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
8734        AudioRendererProxyInterface::r#set_usage2(self, usage2)
8735    }
8736
8737    /// Sets the type of the stream to be delivered by the client. Using this method implies
8738    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
8739    ///
8740    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
8741    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
8742    /// methods such as `SendPacket`/`SendPacketNoReply`.
8743    pub fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
8744        AudioRendererProxyInterface::r#set_pcm_stream_type(self, type_)
8745    }
8746
8747    /// Enables or disables notifications about changes to the minimum clock lead
8748    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
8749    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
8750    /// event with the current minimum lead time for the AudioRenderer. If the
8751    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
8752    /// new value. This behavior will continue until the user calls
8753    /// `EnableMinLeadTimeEvents(false)`.
8754    ///
8755    /// The minimum clock lead time is the amount of time ahead of the reference
8756    /// clock's understanding of "now" that packets needs to arrive (relative to
8757    /// the playback clock transformation) in order for the mixer to be able to
8758    /// mix packet. For example...
8759    ///
8760    /// + Let the PTS of packet X be P(X)
8761    /// + Let the function which transforms PTS -> RefClock be R(p) (this
8762    ///   function is determined by the call to Play(...)
8763    /// + Let the minimum lead time be MLT
8764    ///
8765    /// If R(P(X)) < RefClock.Now() + MLT
8766    /// Then the packet is late, and some (or all) of the packet's payload will
8767    /// need to be skipped in order to present the packet at the scheduled time.
8768    ///
8769    /// The value `min_lead_time_nsec = 0` is a special value which indicates
8770    /// that the AudioRenderer is not yet routed to an output device. If `Play`
8771    /// is called before the AudioRenderer is routed, any played packets will be
8772    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
8773    /// calling `Play`.
8774    pub fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
8775        AudioRendererProxyInterface::r#enable_min_lead_time_events(self, enabled)
8776    }
8777
8778    ///
8779    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
8780    /// there's little reason to do so. This is because lead time is a function
8781    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
8782    /// If min lead time events are enabled before `SetPcmStreamType` (with
8783    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
8784    /// response to `SetPcmStreamType`.
8785    pub fn r#get_min_lead_time(
8786        &self,
8787    ) -> fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect> {
8788        AudioRendererProxyInterface::r#get_min_lead_time(self)
8789    }
8790
8791    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
8792    /// of the media timeline, using specific values provided by the caller (or
8793    /// default values if not specified). In an optional callback, returns the
8794    /// timestamp values ultimately used -- these set the ongoing relationship
8795    /// between the media and reference timelines (i.e., how to translate between
8796    /// the domain of presentation timestamps, and the realm of local system
8797    /// time).
8798    ///
8799    /// Local system time is specified in units of nanoseconds; media_time is
8800    /// specified in the units defined by the user in the `SetPtsUnits` function,
8801    /// or nanoseconds if `SetPtsUnits` is not called.
8802    ///
8803    /// The act of placing an AudioRenderer into the playback state establishes a
8804    /// relationship between 1) the user-defined media (or presentation) timeline
8805    /// for this particular AudioRenderer, and 2) the real-world system reference
8806    /// timeline. To communicate how to translate between timelines, the Play()
8807    /// callback provides an equivalent timestamp in each time domain. The first
8808    /// value ('reference_time') is given in terms of this renderer's reference
8809    /// clock; the second value ('media_time') is what media instant exactly
8810    /// corresponds to that local time. Restated, the frame at 'media_time' in
8811    /// the audio stream should be presented at 'reference_time' according to
8812    /// the reference clock.
8813    ///
8814    /// Note: on calling this API, media_time immediately starts advancing. It is
8815    /// possible (if uncommon) for a caller to specify a system time that is
8816    /// far in the past, or far into the future. This, along with the specified
8817    /// media time, is simply used to determine what media time corresponds to
8818    /// 'now', and THAT media time is then intersected with presentation
8819    /// timestamps of packets already submitted, to determine which media frames
8820    /// should be presented next.
8821    ///
8822    /// With the corresponding reference_time and media_time values, a user can
8823    /// translate arbitrary time values from one timeline into the other. After
8824    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
8825    /// given the 'ref_start' and 'media_start' values from `Play`, then for
8826    /// any 'ref_time':
8827    ///
8828    /// media_time = ( (ref_time - ref_start) / 1e9
8829    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
8830    ///              + media_start
8831    ///
8832    /// Conversely, for any presentation timestamp 'media_time':
8833    ///
8834    /// ref_time = ( (media_time - media_start)
8835    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
8836    ///              * 1e9 )
8837    ///            + ref_start
8838    ///
8839    /// Users, depending on their use case, may optionally choose not to specify
8840    /// one or both of these timestamps. A timestamp may be omitted by supplying
8841    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
8842    /// any omitted timestamp value using the following rules:
8843    ///
8844    /// Reference Time
8845    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
8846    /// reference time to begin presentation, based on the minimum lead times for
8847    /// the output devices that are currently bound to this AudioRenderer. For
8848    /// example, if an AudioRenderer is bound to an internal audio output
8849    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
8850    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
8851    /// is omitted) select a reference time 80 mSec from now.
8852    ///
8853    /// Media Time
8854    /// If media_time is omitted, the AudioRenderer will select one of two
8855    /// values.
8856    /// - If the AudioRenderer is resuming from the paused state, and packets
8857    /// have not been discarded since being paused, then the AudioRenderer will
8858    /// use a media_time corresponding to the instant at which the presentation
8859    /// became paused.
8860    /// - If the AudioRenderer is being placed into a playing state for the first
8861    /// time following startup or a 'discard packets' operation, the initial
8862    /// media_time will be set to the PTS of the first payload in the pending
8863    /// packet queue. If the pending queue is empty, initial media_time will be
8864    /// set to zero.
8865    ///
8866    /// Return Value
8867    /// When requested, the AudioRenderer will return the 'reference_time' and
8868    /// 'media_time' which were selected and used (whether they were explicitly
8869    /// specified or not) in the return value of the play call.
8870    ///
8871    /// Examples
8872    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
8873    /// to start playing as soon as possible. The user may call Play without
8874    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
8875    ///
8876    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
8877    /// playback at a specified 'reference_time', in sync with some other media
8878    /// stream, either initially or after discarding packets. The user would call
8879    /// `Play(reference_time, NO_TIMESTAMP)`.
8880    ///
8881    /// 3. A user has queued some audio using `SendPacket`. The first of these
8882    /// packets has a PTS of zero, and the user wishes playback to begin as soon
8883    /// as possible, but wishes to skip all of the audio content between PTS 0
8884    /// and PTS 'media_time'. The user would call
8885    /// `Play(NO_TIMESTAMP, media_time)`.
8886    ///
8887    /// 4. A user has queued some audio using `SendPacket` and want to present
8888    /// this media in synch with another player in a different device. The
8889    /// coordinator of the group of distributed players sends an explicit
8890    /// message to each player telling them to begin presentation of audio at
8891    /// PTS 'media_time', at the time (based on the group's shared reference
8892    /// clock) 'reference_time'. Here the user would call
8893    /// `Play(reference_time, media_time)`.
8894    pub fn r#play(
8895        &self,
8896        mut reference_time: i64,
8897        mut media_time: i64,
8898    ) -> fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>
8899    {
8900        AudioRendererProxyInterface::r#play(self, reference_time, media_time)
8901    }
8902
8903    pub fn r#play_no_reply(
8904        &self,
8905        mut reference_time: i64,
8906        mut media_time: i64,
8907    ) -> Result<(), fidl::Error> {
8908        AudioRendererProxyInterface::r#play_no_reply(self, reference_time, media_time)
8909    }
8910
8911    /// Immediately puts the AudioRenderer into the paused state and then report
8912    /// the relationship between the media and reference timelines which was
8913    /// established (if requested).
8914    ///
8915    /// If the AudioRenderer is already in the paused state when this called,
8916    /// the previously-established timeline values are returned (if requested).
8917    pub fn r#pause(
8918        &self,
8919    ) -> fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>
8920    {
8921        AudioRendererProxyInterface::r#pause(self)
8922    }
8923
8924    pub fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
8925        AudioRendererProxyInterface::r#pause_no_reply(self)
8926    }
8927}
8928
8929impl AudioRendererProxyInterface for AudioRendererProxy {
8930    fn r#add_payload_buffer(
8931        &self,
8932        mut id: u32,
8933        mut payload_buffer: fidl::Vmo,
8934    ) -> Result<(), fidl::Error> {
8935        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
8936            (id, payload_buffer),
8937            0x3b3a37fc34fe5b56,
8938            fidl::encoding::DynamicFlags::empty(),
8939        )
8940    }
8941
8942    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
8943        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
8944            (id,),
8945            0x5d1e4f74c3658262,
8946            fidl::encoding::DynamicFlags::empty(),
8947        )
8948    }
8949
8950    type SendPacketResponseFut =
8951        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8952    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
8953        fn _decode(
8954            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8955        ) -> Result<(), fidl::Error> {
8956            let _response = fidl::client::decode_transaction_body::<
8957                fidl::encoding::EmptyPayload,
8958                fidl::encoding::DefaultFuchsiaResourceDialect,
8959                0x67cddd607442775f,
8960            >(_buf?)?;
8961            Ok(_response)
8962        }
8963        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
8964            (packet,),
8965            0x67cddd607442775f,
8966            fidl::encoding::DynamicFlags::empty(),
8967            _decode,
8968        )
8969    }
8970
8971    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
8972        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
8973            (packet,),
8974            0x8d9b8b413ceba9d,
8975            fidl::encoding::DynamicFlags::empty(),
8976        )
8977    }
8978
8979    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
8980        self.client.send::<fidl::encoding::EmptyPayload>(
8981            (),
8982            0x6180fd6f7e793b71,
8983            fidl::encoding::DynamicFlags::empty(),
8984        )
8985    }
8986
8987    type DiscardAllPacketsResponseFut =
8988        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8989    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
8990        fn _decode(
8991            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8992        ) -> Result<(), fidl::Error> {
8993            let _response = fidl::client::decode_transaction_body::<
8994                fidl::encoding::EmptyPayload,
8995                fidl::encoding::DefaultFuchsiaResourceDialect,
8996                0x6f4dad7af2917665,
8997            >(_buf?)?;
8998            Ok(_response)
8999        }
9000        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
9001            (),
9002            0x6f4dad7af2917665,
9003            fidl::encoding::DynamicFlags::empty(),
9004            _decode,
9005        )
9006    }
9007
9008    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
9009        self.client.send::<fidl::encoding::EmptyPayload>(
9010            (),
9011            0x50d36d0d23081bc4,
9012            fidl::encoding::DynamicFlags::empty(),
9013        )
9014    }
9015
9016    fn r#bind_gain_control(
9017        &self,
9018        mut gain_control_request: fidl::endpoints::ServerEnd<
9019            fidl_fuchsia_media_audio::GainControlMarker,
9020        >,
9021    ) -> Result<(), fidl::Error> {
9022        self.client.send::<AudioRendererBindGainControlRequest>(
9023            (gain_control_request,),
9024            0x293f5c7f8fba2bdc,
9025            fidl::encoding::DynamicFlags::empty(),
9026        )
9027    }
9028
9029    fn r#set_pts_units(
9030        &self,
9031        mut tick_per_second_numerator: u32,
9032        mut tick_per_second_denominator: u32,
9033    ) -> Result<(), fidl::Error> {
9034        self.client.send::<AudioRendererSetPtsUnitsRequest>(
9035            (tick_per_second_numerator, tick_per_second_denominator),
9036            0xf68cd108785a27c,
9037            fidl::encoding::DynamicFlags::empty(),
9038        )
9039    }
9040
9041    fn r#set_pts_continuity_threshold(
9042        &self,
9043        mut threshold_seconds: f32,
9044    ) -> Result<(), fidl::Error> {
9045        self.client.send::<AudioRendererSetPtsContinuityThresholdRequest>(
9046            (threshold_seconds,),
9047            0x2849ba571d1971ba,
9048            fidl::encoding::DynamicFlags::empty(),
9049        )
9050    }
9051
9052    type GetReferenceClockResponseFut =
9053        fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>;
9054    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
9055        fn _decode(
9056            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9057        ) -> Result<fidl::Clock, fidl::Error> {
9058            let _response = fidl::client::decode_transaction_body::<
9059                AudioRendererGetReferenceClockResponse,
9060                fidl::encoding::DefaultFuchsiaResourceDialect,
9061                0x2f7a7f011a172f7e,
9062            >(_buf?)?;
9063            Ok(_response.reference_clock)
9064        }
9065        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Clock>(
9066            (),
9067            0x2f7a7f011a172f7e,
9068            fidl::encoding::DynamicFlags::empty(),
9069            _decode,
9070        )
9071    }
9072
9073    fn r#set_reference_clock(
9074        &self,
9075        mut reference_clock: Option<fidl::Clock>,
9076    ) -> Result<(), fidl::Error> {
9077        self.client.send::<AudioRendererSetReferenceClockRequest>(
9078            (reference_clock,),
9079            0x39acd05d832b5fed,
9080            fidl::encoding::DynamicFlags::empty(),
9081        )
9082    }
9083
9084    fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
9085        self.client.send::<AudioRendererSetUsageRequest>(
9086            (usage,),
9087            0x3994bd23b55a733e,
9088            fidl::encoding::DynamicFlags::empty(),
9089        )
9090    }
9091
9092    fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
9093        self.client.send::<AudioRendererSetUsage2Request>(
9094            (usage2,),
9095            0x2904035c7132b103,
9096            fidl::encoding::DynamicFlags::FLEXIBLE,
9097        )
9098    }
9099
9100    fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
9101        self.client.send::<AudioRendererSetPcmStreamTypeRequest>(
9102            (type_,),
9103            0x27aa715d8901fa19,
9104            fidl::encoding::DynamicFlags::empty(),
9105        )
9106    }
9107
9108    fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
9109        self.client.send::<AudioRendererEnableMinLeadTimeEventsRequest>(
9110            (enabled,),
9111            0x62808dfad72bf890,
9112            fidl::encoding::DynamicFlags::empty(),
9113        )
9114    }
9115
9116    type GetMinLeadTimeResponseFut =
9117        fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect>;
9118    fn r#get_min_lead_time(&self) -> Self::GetMinLeadTimeResponseFut {
9119        fn _decode(
9120            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9121        ) -> Result<i64, fidl::Error> {
9122            let _response = fidl::client::decode_transaction_body::<
9123                AudioRendererGetMinLeadTimeResponse,
9124                fidl::encoding::DefaultFuchsiaResourceDialect,
9125                0x1cf3c3ecd8fec26b,
9126            >(_buf?)?;
9127            Ok(_response.min_lead_time_nsec)
9128        }
9129        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i64>(
9130            (),
9131            0x1cf3c3ecd8fec26b,
9132            fidl::encoding::DynamicFlags::empty(),
9133            _decode,
9134        )
9135    }
9136
9137    type PlayResponseFut =
9138        fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>;
9139    fn r#play(&self, mut reference_time: i64, mut media_time: i64) -> Self::PlayResponseFut {
9140        fn _decode(
9141            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9142        ) -> Result<(i64, i64), fidl::Error> {
9143            let _response = fidl::client::decode_transaction_body::<
9144                AudioRendererPlayResponse,
9145                fidl::encoding::DefaultFuchsiaResourceDialect,
9146                0x3c0162db084f74a3,
9147            >(_buf?)?;
9148            Ok((_response.reference_time, _response.media_time))
9149        }
9150        self.client.send_query_and_decode::<AudioRendererPlayRequest, (i64, i64)>(
9151            (reference_time, media_time),
9152            0x3c0162db084f74a3,
9153            fidl::encoding::DynamicFlags::empty(),
9154            _decode,
9155        )
9156    }
9157
9158    fn r#play_no_reply(
9159        &self,
9160        mut reference_time: i64,
9161        mut media_time: i64,
9162    ) -> Result<(), fidl::Error> {
9163        self.client.send::<AudioRendererPlayNoReplyRequest>(
9164            (reference_time, media_time),
9165            0x1b7fe832b68c22ef,
9166            fidl::encoding::DynamicFlags::empty(),
9167        )
9168    }
9169
9170    type PauseResponseFut =
9171        fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>;
9172    fn r#pause(&self) -> Self::PauseResponseFut {
9173        fn _decode(
9174            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9175        ) -> Result<(i64, i64), fidl::Error> {
9176            let _response = fidl::client::decode_transaction_body::<
9177                AudioRendererPauseResponse,
9178                fidl::encoding::DefaultFuchsiaResourceDialect,
9179                0x41d557588d93d153,
9180            >(_buf?)?;
9181            Ok((_response.reference_time, _response.media_time))
9182        }
9183        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i64, i64)>(
9184            (),
9185            0x41d557588d93d153,
9186            fidl::encoding::DynamicFlags::empty(),
9187            _decode,
9188        )
9189    }
9190
9191    fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
9192        self.client.send::<fidl::encoding::EmptyPayload>(
9193            (),
9194            0x24cc45d4f3855ab,
9195            fidl::encoding::DynamicFlags::empty(),
9196        )
9197    }
9198}
9199
9200pub struct AudioRendererEventStream {
9201    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
9202}
9203
9204impl std::marker::Unpin for AudioRendererEventStream {}
9205
9206impl futures::stream::FusedStream for AudioRendererEventStream {
9207    fn is_terminated(&self) -> bool {
9208        self.event_receiver.is_terminated()
9209    }
9210}
9211
9212impl futures::Stream for AudioRendererEventStream {
9213    type Item = Result<AudioRendererEvent, fidl::Error>;
9214
9215    fn poll_next(
9216        mut self: std::pin::Pin<&mut Self>,
9217        cx: &mut std::task::Context<'_>,
9218    ) -> std::task::Poll<Option<Self::Item>> {
9219        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9220            &mut self.event_receiver,
9221            cx
9222        )?) {
9223            Some(buf) => std::task::Poll::Ready(Some(AudioRendererEvent::decode(buf))),
9224            None => std::task::Poll::Ready(None),
9225        }
9226    }
9227}
9228
9229#[derive(Debug)]
9230pub enum AudioRendererEvent {
9231    OnMinLeadTimeChanged {
9232        min_lead_time_nsec: i64,
9233    },
9234    #[non_exhaustive]
9235    _UnknownEvent {
9236        /// Ordinal of the event that was sent.
9237        ordinal: u64,
9238    },
9239}
9240
9241impl AudioRendererEvent {
9242    #[allow(irrefutable_let_patterns)]
9243    pub fn into_on_min_lead_time_changed(self) -> Option<i64> {
9244        if let AudioRendererEvent::OnMinLeadTimeChanged { min_lead_time_nsec } = self {
9245            Some((min_lead_time_nsec))
9246        } else {
9247            None
9248        }
9249    }
9250
9251    /// Decodes a message buffer as a [`AudioRendererEvent`].
9252    fn decode(
9253        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9254    ) -> Result<AudioRendererEvent, fidl::Error> {
9255        let (bytes, _handles) = buf.split_mut();
9256        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9257        debug_assert_eq!(tx_header.tx_id, 0);
9258        match tx_header.ordinal {
9259            0x4feff7d278978c4e => {
9260                let mut out = fidl::new_empty!(
9261                    AudioRendererOnMinLeadTimeChangedRequest,
9262                    fidl::encoding::DefaultFuchsiaResourceDialect
9263                );
9264                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererOnMinLeadTimeChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
9265                Ok((AudioRendererEvent::OnMinLeadTimeChanged {
9266                    min_lead_time_nsec: out.min_lead_time_nsec,
9267                }))
9268            }
9269            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
9270                Ok(AudioRendererEvent::_UnknownEvent { ordinal: tx_header.ordinal })
9271            }
9272            _ => Err(fidl::Error::UnknownOrdinal {
9273                ordinal: tx_header.ordinal,
9274                protocol_name: <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9275            }),
9276        }
9277    }
9278}
9279
9280/// A Stream of incoming requests for fuchsia.media/AudioRenderer.
9281pub struct AudioRendererRequestStream {
9282    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9283    is_terminated: bool,
9284}
9285
9286impl std::marker::Unpin for AudioRendererRequestStream {}
9287
9288impl futures::stream::FusedStream for AudioRendererRequestStream {
9289    fn is_terminated(&self) -> bool {
9290        self.is_terminated
9291    }
9292}
9293
9294impl fidl::endpoints::RequestStream for AudioRendererRequestStream {
9295    type Protocol = AudioRendererMarker;
9296    type ControlHandle = AudioRendererControlHandle;
9297
9298    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
9299        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9300    }
9301
9302    fn control_handle(&self) -> Self::ControlHandle {
9303        AudioRendererControlHandle { inner: self.inner.clone() }
9304    }
9305
9306    fn into_inner(
9307        self,
9308    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
9309    {
9310        (self.inner, self.is_terminated)
9311    }
9312
9313    fn from_inner(
9314        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9315        is_terminated: bool,
9316    ) -> Self {
9317        Self { inner, is_terminated }
9318    }
9319}
9320
9321impl futures::Stream for AudioRendererRequestStream {
9322    type Item = Result<AudioRendererRequest, fidl::Error>;
9323
9324    fn poll_next(
9325        mut self: std::pin::Pin<&mut Self>,
9326        cx: &mut std::task::Context<'_>,
9327    ) -> std::task::Poll<Option<Self::Item>> {
9328        let this = &mut *self;
9329        if this.inner.check_shutdown(cx) {
9330            this.is_terminated = true;
9331            return std::task::Poll::Ready(None);
9332        }
9333        if this.is_terminated {
9334            panic!("polled AudioRendererRequestStream after completion");
9335        }
9336        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
9337            |bytes, handles| {
9338                match this.inner.channel().read_etc(cx, bytes, handles) {
9339                    std::task::Poll::Ready(Ok(())) => {}
9340                    std::task::Poll::Pending => return std::task::Poll::Pending,
9341                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
9342                        this.is_terminated = true;
9343                        return std::task::Poll::Ready(None);
9344                    }
9345                    std::task::Poll::Ready(Err(e)) => {
9346                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9347                            e.into(),
9348                        ))))
9349                    }
9350                }
9351
9352                // A message has been received from the channel
9353                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9354
9355                std::task::Poll::Ready(Some(match header.ordinal {
9356                    0x3b3a37fc34fe5b56 => {
9357                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9358                        let mut req = fidl::new_empty!(
9359                            StreamBufferSetAddPayloadBufferRequest,
9360                            fidl::encoding::DefaultFuchsiaResourceDialect
9361                        );
9362                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
9363                        let control_handle =
9364                            AudioRendererControlHandle { inner: this.inner.clone() };
9365                        Ok(AudioRendererRequest::AddPayloadBuffer {
9366                            id: req.id,
9367                            payload_buffer: req.payload_buffer,
9368
9369                            control_handle,
9370                        })
9371                    }
9372                    0x5d1e4f74c3658262 => {
9373                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9374                        let mut req = fidl::new_empty!(
9375                            StreamBufferSetRemovePayloadBufferRequest,
9376                            fidl::encoding::DefaultFuchsiaResourceDialect
9377                        );
9378                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
9379                        let control_handle =
9380                            AudioRendererControlHandle { inner: this.inner.clone() };
9381                        Ok(AudioRendererRequest::RemovePayloadBuffer { id: req.id, control_handle })
9382                    }
9383                    0x67cddd607442775f => {
9384                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9385                        let mut req = fidl::new_empty!(
9386                            StreamSinkSendPacketRequest,
9387                            fidl::encoding::DefaultFuchsiaResourceDialect
9388                        );
9389                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
9390                        let control_handle =
9391                            AudioRendererControlHandle { inner: this.inner.clone() };
9392                        Ok(AudioRendererRequest::SendPacket {
9393                            packet: req.packet,
9394
9395                            responder: AudioRendererSendPacketResponder {
9396                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9397                                tx_id: header.tx_id,
9398                            },
9399                        })
9400                    }
9401                    0x8d9b8b413ceba9d => {
9402                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9403                        let mut req = fidl::new_empty!(
9404                            StreamSinkSendPacketNoReplyRequest,
9405                            fidl::encoding::DefaultFuchsiaResourceDialect
9406                        );
9407                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
9408                        let control_handle =
9409                            AudioRendererControlHandle { inner: this.inner.clone() };
9410                        Ok(AudioRendererRequest::SendPacketNoReply {
9411                            packet: req.packet,
9412
9413                            control_handle,
9414                        })
9415                    }
9416                    0x6180fd6f7e793b71 => {
9417                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9418                        let mut req = fidl::new_empty!(
9419                            fidl::encoding::EmptyPayload,
9420                            fidl::encoding::DefaultFuchsiaResourceDialect
9421                        );
9422                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9423                        let control_handle =
9424                            AudioRendererControlHandle { inner: this.inner.clone() };
9425                        Ok(AudioRendererRequest::EndOfStream { control_handle })
9426                    }
9427                    0x6f4dad7af2917665 => {
9428                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9429                        let mut req = fidl::new_empty!(
9430                            fidl::encoding::EmptyPayload,
9431                            fidl::encoding::DefaultFuchsiaResourceDialect
9432                        );
9433                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9434                        let control_handle =
9435                            AudioRendererControlHandle { inner: this.inner.clone() };
9436                        Ok(AudioRendererRequest::DiscardAllPackets {
9437                            responder: AudioRendererDiscardAllPacketsResponder {
9438                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9439                                tx_id: header.tx_id,
9440                            },
9441                        })
9442                    }
9443                    0x50d36d0d23081bc4 => {
9444                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9445                        let mut req = fidl::new_empty!(
9446                            fidl::encoding::EmptyPayload,
9447                            fidl::encoding::DefaultFuchsiaResourceDialect
9448                        );
9449                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9450                        let control_handle =
9451                            AudioRendererControlHandle { inner: this.inner.clone() };
9452                        Ok(AudioRendererRequest::DiscardAllPacketsNoReply { control_handle })
9453                    }
9454                    0x293f5c7f8fba2bdc => {
9455                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9456                        let mut req = fidl::new_empty!(
9457                            AudioRendererBindGainControlRequest,
9458                            fidl::encoding::DefaultFuchsiaResourceDialect
9459                        );
9460                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererBindGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
9461                        let control_handle =
9462                            AudioRendererControlHandle { inner: this.inner.clone() };
9463                        Ok(AudioRendererRequest::BindGainControl {
9464                            gain_control_request: req.gain_control_request,
9465
9466                            control_handle,
9467                        })
9468                    }
9469                    0xf68cd108785a27c => {
9470                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9471                        let mut req = fidl::new_empty!(
9472                            AudioRendererSetPtsUnitsRequest,
9473                            fidl::encoding::DefaultFuchsiaResourceDialect
9474                        );
9475                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetPtsUnitsRequest>(&header, _body_bytes, handles, &mut req)?;
9476                        let control_handle =
9477                            AudioRendererControlHandle { inner: this.inner.clone() };
9478                        Ok(AudioRendererRequest::SetPtsUnits {
9479                            tick_per_second_numerator: req.tick_per_second_numerator,
9480                            tick_per_second_denominator: req.tick_per_second_denominator,
9481
9482                            control_handle,
9483                        })
9484                    }
9485                    0x2849ba571d1971ba => {
9486                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9487                        let mut req = fidl::new_empty!(
9488                            AudioRendererSetPtsContinuityThresholdRequest,
9489                            fidl::encoding::DefaultFuchsiaResourceDialect
9490                        );
9491                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetPtsContinuityThresholdRequest>(&header, _body_bytes, handles, &mut req)?;
9492                        let control_handle =
9493                            AudioRendererControlHandle { inner: this.inner.clone() };
9494                        Ok(AudioRendererRequest::SetPtsContinuityThreshold {
9495                            threshold_seconds: req.threshold_seconds,
9496
9497                            control_handle,
9498                        })
9499                    }
9500                    0x2f7a7f011a172f7e => {
9501                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9502                        let mut req = fidl::new_empty!(
9503                            fidl::encoding::EmptyPayload,
9504                            fidl::encoding::DefaultFuchsiaResourceDialect
9505                        );
9506                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9507                        let control_handle =
9508                            AudioRendererControlHandle { inner: this.inner.clone() };
9509                        Ok(AudioRendererRequest::GetReferenceClock {
9510                            responder: AudioRendererGetReferenceClockResponder {
9511                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9512                                tx_id: header.tx_id,
9513                            },
9514                        })
9515                    }
9516                    0x39acd05d832b5fed => {
9517                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9518                        let mut req = fidl::new_empty!(
9519                            AudioRendererSetReferenceClockRequest,
9520                            fidl::encoding::DefaultFuchsiaResourceDialect
9521                        );
9522                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetReferenceClockRequest>(&header, _body_bytes, handles, &mut req)?;
9523                        let control_handle =
9524                            AudioRendererControlHandle { inner: this.inner.clone() };
9525                        Ok(AudioRendererRequest::SetReferenceClock {
9526                            reference_clock: req.reference_clock,
9527
9528                            control_handle,
9529                        })
9530                    }
9531                    0x3994bd23b55a733e => {
9532                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9533                        let mut req = fidl::new_empty!(
9534                            AudioRendererSetUsageRequest,
9535                            fidl::encoding::DefaultFuchsiaResourceDialect
9536                        );
9537                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetUsageRequest>(&header, _body_bytes, handles, &mut req)?;
9538                        let control_handle =
9539                            AudioRendererControlHandle { inner: this.inner.clone() };
9540                        Ok(AudioRendererRequest::SetUsage { usage: req.usage, control_handle })
9541                    }
9542                    0x2904035c7132b103 => {
9543                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9544                        let mut req = fidl::new_empty!(
9545                            AudioRendererSetUsage2Request,
9546                            fidl::encoding::DefaultFuchsiaResourceDialect
9547                        );
9548                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetUsage2Request>(&header, _body_bytes, handles, &mut req)?;
9549                        let control_handle =
9550                            AudioRendererControlHandle { inner: this.inner.clone() };
9551                        Ok(AudioRendererRequest::SetUsage2 { usage2: req.usage2, control_handle })
9552                    }
9553                    0x27aa715d8901fa19 => {
9554                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9555                        let mut req = fidl::new_empty!(
9556                            AudioRendererSetPcmStreamTypeRequest,
9557                            fidl::encoding::DefaultFuchsiaResourceDialect
9558                        );
9559                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetPcmStreamTypeRequest>(&header, _body_bytes, handles, &mut req)?;
9560                        let control_handle =
9561                            AudioRendererControlHandle { inner: this.inner.clone() };
9562                        Ok(AudioRendererRequest::SetPcmStreamType {
9563                            type_: req.type_,
9564
9565                            control_handle,
9566                        })
9567                    }
9568                    0x62808dfad72bf890 => {
9569                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9570                        let mut req = fidl::new_empty!(
9571                            AudioRendererEnableMinLeadTimeEventsRequest,
9572                            fidl::encoding::DefaultFuchsiaResourceDialect
9573                        );
9574                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererEnableMinLeadTimeEventsRequest>(&header, _body_bytes, handles, &mut req)?;
9575                        let control_handle =
9576                            AudioRendererControlHandle { inner: this.inner.clone() };
9577                        Ok(AudioRendererRequest::EnableMinLeadTimeEvents {
9578                            enabled: req.enabled,
9579
9580                            control_handle,
9581                        })
9582                    }
9583                    0x1cf3c3ecd8fec26b => {
9584                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9585                        let mut req = fidl::new_empty!(
9586                            fidl::encoding::EmptyPayload,
9587                            fidl::encoding::DefaultFuchsiaResourceDialect
9588                        );
9589                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9590                        let control_handle =
9591                            AudioRendererControlHandle { inner: this.inner.clone() };
9592                        Ok(AudioRendererRequest::GetMinLeadTime {
9593                            responder: AudioRendererGetMinLeadTimeResponder {
9594                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9595                                tx_id: header.tx_id,
9596                            },
9597                        })
9598                    }
9599                    0x3c0162db084f74a3 => {
9600                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9601                        let mut req = fidl::new_empty!(
9602                            AudioRendererPlayRequest,
9603                            fidl::encoding::DefaultFuchsiaResourceDialect
9604                        );
9605                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererPlayRequest>(&header, _body_bytes, handles, &mut req)?;
9606                        let control_handle =
9607                            AudioRendererControlHandle { inner: this.inner.clone() };
9608                        Ok(AudioRendererRequest::Play {
9609                            reference_time: req.reference_time,
9610                            media_time: req.media_time,
9611
9612                            responder: AudioRendererPlayResponder {
9613                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9614                                tx_id: header.tx_id,
9615                            },
9616                        })
9617                    }
9618                    0x1b7fe832b68c22ef => {
9619                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9620                        let mut req = fidl::new_empty!(
9621                            AudioRendererPlayNoReplyRequest,
9622                            fidl::encoding::DefaultFuchsiaResourceDialect
9623                        );
9624                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererPlayNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
9625                        let control_handle =
9626                            AudioRendererControlHandle { inner: this.inner.clone() };
9627                        Ok(AudioRendererRequest::PlayNoReply {
9628                            reference_time: req.reference_time,
9629                            media_time: req.media_time,
9630
9631                            control_handle,
9632                        })
9633                    }
9634                    0x41d557588d93d153 => {
9635                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9636                        let mut req = fidl::new_empty!(
9637                            fidl::encoding::EmptyPayload,
9638                            fidl::encoding::DefaultFuchsiaResourceDialect
9639                        );
9640                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9641                        let control_handle =
9642                            AudioRendererControlHandle { inner: this.inner.clone() };
9643                        Ok(AudioRendererRequest::Pause {
9644                            responder: AudioRendererPauseResponder {
9645                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9646                                tx_id: header.tx_id,
9647                            },
9648                        })
9649                    }
9650                    0x24cc45d4f3855ab => {
9651                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9652                        let mut req = fidl::new_empty!(
9653                            fidl::encoding::EmptyPayload,
9654                            fidl::encoding::DefaultFuchsiaResourceDialect
9655                        );
9656                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9657                        let control_handle =
9658                            AudioRendererControlHandle { inner: this.inner.clone() };
9659                        Ok(AudioRendererRequest::PauseNoReply { control_handle })
9660                    }
9661                    _ if header.tx_id == 0
9662                        && header
9663                            .dynamic_flags()
9664                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
9665                    {
9666                        Ok(AudioRendererRequest::_UnknownMethod {
9667                            ordinal: header.ordinal,
9668                            control_handle: AudioRendererControlHandle {
9669                                inner: this.inner.clone(),
9670                            },
9671                            method_type: fidl::MethodType::OneWay,
9672                        })
9673                    }
9674                    _ if header
9675                        .dynamic_flags()
9676                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
9677                    {
9678                        this.inner.send_framework_err(
9679                            fidl::encoding::FrameworkErr::UnknownMethod,
9680                            header.tx_id,
9681                            header.ordinal,
9682                            header.dynamic_flags(),
9683                            (bytes, handles),
9684                        )?;
9685                        Ok(AudioRendererRequest::_UnknownMethod {
9686                            ordinal: header.ordinal,
9687                            control_handle: AudioRendererControlHandle {
9688                                inner: this.inner.clone(),
9689                            },
9690                            method_type: fidl::MethodType::TwoWay,
9691                        })
9692                    }
9693                    _ => Err(fidl::Error::UnknownOrdinal {
9694                        ordinal: header.ordinal,
9695                        protocol_name:
9696                            <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9697                    }),
9698                }))
9699            },
9700        )
9701    }
9702}
9703
9704/// AudioRenderers can be in one of two states at any time: _configurable_ or _operational_. A
9705/// renderer is considered operational whenever it has packets queued to be rendered; otherwise it
9706/// is _configurable_. Once an AudioRenderer enters the operational state, calls to "configuring"
9707/// methods are disallowed and will cause the audio service to disconnect the client's connection.
9708/// The following are considered configuring methods: `AddPayloadBuffer`, `SetPcmStreamType`,
9709/// `SetStreamType`, `SetPtsUnits`, `SetPtsContinuityThreshold`.
9710///
9711/// If an AudioRenderer must be reconfigured, the client must ensure that no packets are still
9712/// enqueued when these "configuring" methods are called. Thus it is best practice to call
9713/// `DiscardAllPackets` on the AudioRenderer (and ideally `Stop` before `DiscardAllPackets`), prior
9714/// to reconfiguring the renderer.
9715#[derive(Debug)]
9716pub enum AudioRendererRequest {
9717    /// Adds a payload buffer to the current buffer set associated with the
9718    /// connection. A `StreamPacket` struct reference a payload buffer in the
9719    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
9720    ///
9721    /// A buffer with ID `id` must not be in the current set when this method is
9722    /// invoked, otherwise the service will close the connection.
9723    AddPayloadBuffer {
9724        id: u32,
9725        payload_buffer: fidl::Vmo,
9726        control_handle: AudioRendererControlHandle,
9727    },
9728    /// Removes a payload buffer from the current buffer set associated with the
9729    /// connection.
9730    ///
9731    /// A buffer with ID `id` must exist in the current set when this method is
9732    /// invoked, otherwise the service will will close the connection.
9733    RemovePayloadBuffer {
9734        id: u32,
9735        control_handle: AudioRendererControlHandle,
9736    },
9737    /// Sends a packet to the service. The response is sent when the service is
9738    /// done with the associated payload memory.
9739    ///
9740    /// `packet` must be valid for the current buffer set, otherwise the service
9741    /// will close the connection.
9742    SendPacket {
9743        packet: StreamPacket,
9744        responder: AudioRendererSendPacketResponder,
9745    },
9746    /// Sends a packet to the service. This interface doesn't define how the
9747    /// client knows when the sink is done with the associated payload memory.
9748    /// The inheriting interface must define that.
9749    ///
9750    /// `packet` must be valid for the current buffer set, otherwise the service
9751    /// will close the connection.
9752    SendPacketNoReply {
9753        packet: StreamPacket,
9754        control_handle: AudioRendererControlHandle,
9755    },
9756    /// Indicates the stream has ended. The precise semantics of this method are
9757    /// determined by the inheriting interface.
9758    EndOfStream {
9759        control_handle: AudioRendererControlHandle,
9760    },
9761    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
9762    /// and not yet released. The response is sent after all packets have been
9763    /// released.
9764    DiscardAllPackets {
9765        responder: AudioRendererDiscardAllPacketsResponder,
9766    },
9767    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
9768    /// and not yet released.
9769    DiscardAllPacketsNoReply {
9770        control_handle: AudioRendererControlHandle,
9771    },
9772    /// Binds to the gain control for this AudioRenderer.
9773    BindGainControl {
9774        gain_control_request:
9775            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
9776        control_handle: AudioRendererControlHandle,
9777    },
9778    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
9779    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
9780    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
9781    SetPtsUnits {
9782        tick_per_second_numerator: u32,
9783        tick_per_second_denominator: u32,
9784        control_handle: AudioRendererControlHandle,
9785    },
9786    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
9787    /// and expected PTS (determined using interpolation). Beyond this threshold,
9788    /// a stream is no longer considered 'continuous' by the renderer.
9789    ///
9790    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
9791    /// Most users should not need to change this value from its default.
9792    ///
9793    /// Example:
9794    /// A user is playing back 48KHz audio from a container, which also contains
9795    /// video and needs to be synchronized with the audio. The timestamps are
9796    /// provided explicitly per packet by the container, and expressed in mSec
9797    /// units. This means that a single tick of the media timeline (1 mSec)
9798    /// represents exactly 48 frames of audio. The application in this scenario
9799    /// delivers packets of audio to the AudioRenderer, each with exactly 470
9800    /// frames of audio, and each with an explicit timestamp set to the best
9801    /// possible representation of the presentation time (given this media
9802    /// clock's resolution). So, starting from zero, the timestamps would be..
9803    ///
9804    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
9805    ///
9806    /// In this example, attempting to use the presentation time to compute the
9807    /// starting frame number of the audio in the packet would be wrong the
9808    /// majority of the time. The first timestamp is correct (by definition), but
9809    /// it will be 24 packets before the timestamps and frame numbers come back
9810    /// into alignment (the 24th packet would start with the 11280th audio frame
9811    /// and have a PTS of exactly 235).
9812    ///
9813    /// One way to fix this situation is to set the PTS continuity threshold
9814    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
9815    /// the number of frames contained within a single tick of the media clock,
9816    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
9817    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
9818    /// explicitly provided PTS would be considered to be a continuation of the
9819    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
9820    /// would work well.
9821    ///
9822    /// Other possible uses:
9823    /// Users who are scheduling audio explicitly, relative to a clock which has
9824    /// not been configured as the reference clock, can use this value to control
9825    /// the maximum acceptable synchronization error before a discontinuity is
9826    /// introduced. E.g., if a user is scheduling audio based on a recovered
9827    /// common media clock, and has not published that clock as the reference
9828    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
9829    /// can accumulate before the AudioRenderer deliberately inserts a
9830    /// presentation discontinuity to account for the error.
9831    ///
9832    /// Users whose need to deal with a container where their timestamps may be
9833    /// even less correct than +/- 1/2 of a PTS tick may set this value to
9834    /// something larger. This should be the maximum level of inaccuracy present
9835    /// in the container timestamps, if known. Failing that, it could be set to
9836    /// the maximum tolerable level of drift error before absolute timestamps are
9837    /// explicitly obeyed. Finally, a user could set this number to a very large
9838    /// value (86400.0 seconds, for example) to effectively cause *all*
9839    /// timestamps to be ignored after the first, thus treating all audio as
9840    /// continuous with previously delivered packets. Conversely, users who wish
9841    /// to *always* explicitly schedule their audio packets exactly may specify
9842    /// a CT of 0.
9843    ///
9844    /// Note: explicitly specifying high-frequency PTS units reduces the default
9845    /// continuity threshold accordingly. Internally, this threshold is stored as an
9846    /// integer of 1/8192 subframes. The default threshold is computed as follows:
9847    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
9848    /// For this reason, specifying PTS units with a frequency greater than 8192x
9849    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
9850    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
9851    SetPtsContinuityThreshold {
9852        threshold_seconds: f32,
9853        control_handle: AudioRendererControlHandle,
9854    },
9855    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
9856    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
9857    GetReferenceClock {
9858        responder: AudioRendererGetReferenceClockResponder,
9859    },
9860    /// Sets the reference clock that controls this renderer's playback rate. If the input
9861    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
9862    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
9863    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
9864    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
9865    ///
9866    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
9867    /// cannot be called a second time (even if the renderer format has not yet been set).
9868    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
9869    /// diverge at some later time, they should create a clone of the monotonic clock, set
9870    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
9871    SetReferenceClock {
9872        reference_clock: Option<fidl::Clock>,
9873        control_handle: AudioRendererControlHandle,
9874    },
9875    /// Sets the usage of the render stream. This method may not be called after
9876    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
9877    SetUsage {
9878        usage: AudioRenderUsage,
9879        control_handle: AudioRendererControlHandle,
9880    },
9881    /// Sets the usage of the render stream. This method may not be called after
9882    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
9883    SetUsage2 {
9884        usage2: AudioRenderUsage2,
9885        control_handle: AudioRendererControlHandle,
9886    },
9887    /// Sets the type of the stream to be delivered by the client. Using this method implies
9888    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
9889    ///
9890    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
9891    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
9892    /// methods such as `SendPacket`/`SendPacketNoReply`.
9893    SetPcmStreamType {
9894        type_: AudioStreamType,
9895        control_handle: AudioRendererControlHandle,
9896    },
9897    /// Enables or disables notifications about changes to the minimum clock lead
9898    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
9899    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
9900    /// event with the current minimum lead time for the AudioRenderer. If the
9901    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
9902    /// new value. This behavior will continue until the user calls
9903    /// `EnableMinLeadTimeEvents(false)`.
9904    ///
9905    /// The minimum clock lead time is the amount of time ahead of the reference
9906    /// clock's understanding of "now" that packets needs to arrive (relative to
9907    /// the playback clock transformation) in order for the mixer to be able to
9908    /// mix packet. For example...
9909    ///
9910    /// + Let the PTS of packet X be P(X)
9911    /// + Let the function which transforms PTS -> RefClock be R(p) (this
9912    ///   function is determined by the call to Play(...)
9913    /// + Let the minimum lead time be MLT
9914    ///
9915    /// If R(P(X)) < RefClock.Now() + MLT
9916    /// Then the packet is late, and some (or all) of the packet's payload will
9917    /// need to be skipped in order to present the packet at the scheduled time.
9918    ///
9919    /// The value `min_lead_time_nsec = 0` is a special value which indicates
9920    /// that the AudioRenderer is not yet routed to an output device. If `Play`
9921    /// is called before the AudioRenderer is routed, any played packets will be
9922    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
9923    /// calling `Play`.
9924    EnableMinLeadTimeEvents {
9925        enabled: bool,
9926        control_handle: AudioRendererControlHandle,
9927    },
9928    ///
9929    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
9930    /// there's little reason to do so. This is because lead time is a function
9931    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
9932    /// If min lead time events are enabled before `SetPcmStreamType` (with
9933    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
9934    /// response to `SetPcmStreamType`.
9935    GetMinLeadTime {
9936        responder: AudioRendererGetMinLeadTimeResponder,
9937    },
9938    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
9939    /// of the media timeline, using specific values provided by the caller (or
9940    /// default values if not specified). In an optional callback, returns the
9941    /// timestamp values ultimately used -- these set the ongoing relationship
9942    /// between the media and reference timelines (i.e., how to translate between
9943    /// the domain of presentation timestamps, and the realm of local system
9944    /// time).
9945    ///
9946    /// Local system time is specified in units of nanoseconds; media_time is
9947    /// specified in the units defined by the user in the `SetPtsUnits` function,
9948    /// or nanoseconds if `SetPtsUnits` is not called.
9949    ///
9950    /// The act of placing an AudioRenderer into the playback state establishes a
9951    /// relationship between 1) the user-defined media (or presentation) timeline
9952    /// for this particular AudioRenderer, and 2) the real-world system reference
9953    /// timeline. To communicate how to translate between timelines, the Play()
9954    /// callback provides an equivalent timestamp in each time domain. The first
9955    /// value ('reference_time') is given in terms of this renderer's reference
9956    /// clock; the second value ('media_time') is what media instant exactly
9957    /// corresponds to that local time. Restated, the frame at 'media_time' in
9958    /// the audio stream should be presented at 'reference_time' according to
9959    /// the reference clock.
9960    ///
9961    /// Note: on calling this API, media_time immediately starts advancing. It is
9962    /// possible (if uncommon) for a caller to specify a system time that is
9963    /// far in the past, or far into the future. This, along with the specified
9964    /// media time, is simply used to determine what media time corresponds to
9965    /// 'now', and THAT media time is then intersected with presentation
9966    /// timestamps of packets already submitted, to determine which media frames
9967    /// should be presented next.
9968    ///
9969    /// With the corresponding reference_time and media_time values, a user can
9970    /// translate arbitrary time values from one timeline into the other. After
9971    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
9972    /// given the 'ref_start' and 'media_start' values from `Play`, then for
9973    /// any 'ref_time':
9974    ///
9975    /// media_time = ( (ref_time - ref_start) / 1e9
9976    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
9977    ///              + media_start
9978    ///
9979    /// Conversely, for any presentation timestamp 'media_time':
9980    ///
9981    /// ref_time = ( (media_time - media_start)
9982    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
9983    ///              * 1e9 )
9984    ///            + ref_start
9985    ///
9986    /// Users, depending on their use case, may optionally choose not to specify
9987    /// one or both of these timestamps. A timestamp may be omitted by supplying
9988    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
9989    /// any omitted timestamp value using the following rules:
9990    ///
9991    /// Reference Time
9992    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
9993    /// reference time to begin presentation, based on the minimum lead times for
9994    /// the output devices that are currently bound to this AudioRenderer. For
9995    /// example, if an AudioRenderer is bound to an internal audio output
9996    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
9997    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
9998    /// is omitted) select a reference time 80 mSec from now.
9999    ///
10000    /// Media Time
10001    /// If media_time is omitted, the AudioRenderer will select one of two
10002    /// values.
10003    /// - If the AudioRenderer is resuming from the paused state, and packets
10004    /// have not been discarded since being paused, then the AudioRenderer will
10005    /// use a media_time corresponding to the instant at which the presentation
10006    /// became paused.
10007    /// - If the AudioRenderer is being placed into a playing state for the first
10008    /// time following startup or a 'discard packets' operation, the initial
10009    /// media_time will be set to the PTS of the first payload in the pending
10010    /// packet queue. If the pending queue is empty, initial media_time will be
10011    /// set to zero.
10012    ///
10013    /// Return Value
10014    /// When requested, the AudioRenderer will return the 'reference_time' and
10015    /// 'media_time' which were selected and used (whether they were explicitly
10016    /// specified or not) in the return value of the play call.
10017    ///
10018    /// Examples
10019    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
10020    /// to start playing as soon as possible. The user may call Play without
10021    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
10022    ///
10023    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
10024    /// playback at a specified 'reference_time', in sync with some other media
10025    /// stream, either initially or after discarding packets. The user would call
10026    /// `Play(reference_time, NO_TIMESTAMP)`.
10027    ///
10028    /// 3. A user has queued some audio using `SendPacket`. The first of these
10029    /// packets has a PTS of zero, and the user wishes playback to begin as soon
10030    /// as possible, but wishes to skip all of the audio content between PTS 0
10031    /// and PTS 'media_time'. The user would call
10032    /// `Play(NO_TIMESTAMP, media_time)`.
10033    ///
10034    /// 4. A user has queued some audio using `SendPacket` and want to present
10035    /// this media in synch with another player in a different device. The
10036    /// coordinator of the group of distributed players sends an explicit
10037    /// message to each player telling them to begin presentation of audio at
10038    /// PTS 'media_time', at the time (based on the group's shared reference
10039    /// clock) 'reference_time'. Here the user would call
10040    /// `Play(reference_time, media_time)`.
10041    Play {
10042        reference_time: i64,
10043        media_time: i64,
10044        responder: AudioRendererPlayResponder,
10045    },
10046    PlayNoReply {
10047        reference_time: i64,
10048        media_time: i64,
10049        control_handle: AudioRendererControlHandle,
10050    },
10051    /// Immediately puts the AudioRenderer into the paused state and then report
10052    /// the relationship between the media and reference timelines which was
10053    /// established (if requested).
10054    ///
10055    /// If the AudioRenderer is already in the paused state when this called,
10056    /// the previously-established timeline values are returned (if requested).
10057    Pause {
10058        responder: AudioRendererPauseResponder,
10059    },
10060    PauseNoReply {
10061        control_handle: AudioRendererControlHandle,
10062    },
10063    /// An interaction was received which does not match any known method.
10064    #[non_exhaustive]
10065    _UnknownMethod {
10066        /// Ordinal of the method that was called.
10067        ordinal: u64,
10068        control_handle: AudioRendererControlHandle,
10069        method_type: fidl::MethodType,
10070    },
10071}
10072
10073impl AudioRendererRequest {
10074    #[allow(irrefutable_let_patterns)]
10075    pub fn into_add_payload_buffer(self) -> Option<(u32, fidl::Vmo, AudioRendererControlHandle)> {
10076        if let AudioRendererRequest::AddPayloadBuffer { id, payload_buffer, control_handle } = self
10077        {
10078            Some((id, payload_buffer, control_handle))
10079        } else {
10080            None
10081        }
10082    }
10083
10084    #[allow(irrefutable_let_patterns)]
10085    pub fn into_remove_payload_buffer(self) -> Option<(u32, AudioRendererControlHandle)> {
10086        if let AudioRendererRequest::RemovePayloadBuffer { id, control_handle } = self {
10087            Some((id, control_handle))
10088        } else {
10089            None
10090        }
10091    }
10092
10093    #[allow(irrefutable_let_patterns)]
10094    pub fn into_send_packet(self) -> Option<(StreamPacket, AudioRendererSendPacketResponder)> {
10095        if let AudioRendererRequest::SendPacket { packet, responder } = self {
10096            Some((packet, responder))
10097        } else {
10098            None
10099        }
10100    }
10101
10102    #[allow(irrefutable_let_patterns)]
10103    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, AudioRendererControlHandle)> {
10104        if let AudioRendererRequest::SendPacketNoReply { packet, control_handle } = self {
10105            Some((packet, control_handle))
10106        } else {
10107            None
10108        }
10109    }
10110
10111    #[allow(irrefutable_let_patterns)]
10112    pub fn into_end_of_stream(self) -> Option<(AudioRendererControlHandle)> {
10113        if let AudioRendererRequest::EndOfStream { control_handle } = self {
10114            Some((control_handle))
10115        } else {
10116            None
10117        }
10118    }
10119
10120    #[allow(irrefutable_let_patterns)]
10121    pub fn into_discard_all_packets(self) -> Option<(AudioRendererDiscardAllPacketsResponder)> {
10122        if let AudioRendererRequest::DiscardAllPackets { responder } = self {
10123            Some((responder))
10124        } else {
10125            None
10126        }
10127    }
10128
10129    #[allow(irrefutable_let_patterns)]
10130    pub fn into_discard_all_packets_no_reply(self) -> Option<(AudioRendererControlHandle)> {
10131        if let AudioRendererRequest::DiscardAllPacketsNoReply { control_handle } = self {
10132            Some((control_handle))
10133        } else {
10134            None
10135        }
10136    }
10137
10138    #[allow(irrefutable_let_patterns)]
10139    pub fn into_bind_gain_control(
10140        self,
10141    ) -> Option<(
10142        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
10143        AudioRendererControlHandle,
10144    )> {
10145        if let AudioRendererRequest::BindGainControl { gain_control_request, control_handle } = self
10146        {
10147            Some((gain_control_request, control_handle))
10148        } else {
10149            None
10150        }
10151    }
10152
10153    #[allow(irrefutable_let_patterns)]
10154    pub fn into_set_pts_units(self) -> Option<(u32, u32, AudioRendererControlHandle)> {
10155        if let AudioRendererRequest::SetPtsUnits {
10156            tick_per_second_numerator,
10157            tick_per_second_denominator,
10158            control_handle,
10159        } = self
10160        {
10161            Some((tick_per_second_numerator, tick_per_second_denominator, control_handle))
10162        } else {
10163            None
10164        }
10165    }
10166
10167    #[allow(irrefutable_let_patterns)]
10168    pub fn into_set_pts_continuity_threshold(self) -> Option<(f32, AudioRendererControlHandle)> {
10169        if let AudioRendererRequest::SetPtsContinuityThreshold {
10170            threshold_seconds,
10171            control_handle,
10172        } = self
10173        {
10174            Some((threshold_seconds, control_handle))
10175        } else {
10176            None
10177        }
10178    }
10179
10180    #[allow(irrefutable_let_patterns)]
10181    pub fn into_get_reference_clock(self) -> Option<(AudioRendererGetReferenceClockResponder)> {
10182        if let AudioRendererRequest::GetReferenceClock { responder } = self {
10183            Some((responder))
10184        } else {
10185            None
10186        }
10187    }
10188
10189    #[allow(irrefutable_let_patterns)]
10190    pub fn into_set_reference_clock(
10191        self,
10192    ) -> Option<(Option<fidl::Clock>, AudioRendererControlHandle)> {
10193        if let AudioRendererRequest::SetReferenceClock { reference_clock, control_handle } = self {
10194            Some((reference_clock, control_handle))
10195        } else {
10196            None
10197        }
10198    }
10199
10200    #[allow(irrefutable_let_patterns)]
10201    pub fn into_set_usage(self) -> Option<(AudioRenderUsage, AudioRendererControlHandle)> {
10202        if let AudioRendererRequest::SetUsage { usage, control_handle } = self {
10203            Some((usage, control_handle))
10204        } else {
10205            None
10206        }
10207    }
10208
10209    #[allow(irrefutable_let_patterns)]
10210    pub fn into_set_usage2(self) -> Option<(AudioRenderUsage2, AudioRendererControlHandle)> {
10211        if let AudioRendererRequest::SetUsage2 { usage2, control_handle } = self {
10212            Some((usage2, control_handle))
10213        } else {
10214            None
10215        }
10216    }
10217
10218    #[allow(irrefutable_let_patterns)]
10219    pub fn into_set_pcm_stream_type(self) -> Option<(AudioStreamType, AudioRendererControlHandle)> {
10220        if let AudioRendererRequest::SetPcmStreamType { type_, control_handle } = self {
10221            Some((type_, control_handle))
10222        } else {
10223            None
10224        }
10225    }
10226
10227    #[allow(irrefutable_let_patterns)]
10228    pub fn into_enable_min_lead_time_events(self) -> Option<(bool, AudioRendererControlHandle)> {
10229        if let AudioRendererRequest::EnableMinLeadTimeEvents { enabled, control_handle } = self {
10230            Some((enabled, control_handle))
10231        } else {
10232            None
10233        }
10234    }
10235
10236    #[allow(irrefutable_let_patterns)]
10237    pub fn into_get_min_lead_time(self) -> Option<(AudioRendererGetMinLeadTimeResponder)> {
10238        if let AudioRendererRequest::GetMinLeadTime { responder } = self {
10239            Some((responder))
10240        } else {
10241            None
10242        }
10243    }
10244
10245    #[allow(irrefutable_let_patterns)]
10246    pub fn into_play(self) -> Option<(i64, i64, AudioRendererPlayResponder)> {
10247        if let AudioRendererRequest::Play { reference_time, media_time, responder } = self {
10248            Some((reference_time, media_time, responder))
10249        } else {
10250            None
10251        }
10252    }
10253
10254    #[allow(irrefutable_let_patterns)]
10255    pub fn into_play_no_reply(self) -> Option<(i64, i64, AudioRendererControlHandle)> {
10256        if let AudioRendererRequest::PlayNoReply { reference_time, media_time, control_handle } =
10257            self
10258        {
10259            Some((reference_time, media_time, control_handle))
10260        } else {
10261            None
10262        }
10263    }
10264
10265    #[allow(irrefutable_let_patterns)]
10266    pub fn into_pause(self) -> Option<(AudioRendererPauseResponder)> {
10267        if let AudioRendererRequest::Pause { responder } = self {
10268            Some((responder))
10269        } else {
10270            None
10271        }
10272    }
10273
10274    #[allow(irrefutable_let_patterns)]
10275    pub fn into_pause_no_reply(self) -> Option<(AudioRendererControlHandle)> {
10276        if let AudioRendererRequest::PauseNoReply { control_handle } = self {
10277            Some((control_handle))
10278        } else {
10279            None
10280        }
10281    }
10282
10283    /// Name of the method defined in FIDL
10284    pub fn method_name(&self) -> &'static str {
10285        match *self {
10286            AudioRendererRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
10287            AudioRendererRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
10288            AudioRendererRequest::SendPacket { .. } => "send_packet",
10289            AudioRendererRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
10290            AudioRendererRequest::EndOfStream { .. } => "end_of_stream",
10291            AudioRendererRequest::DiscardAllPackets { .. } => "discard_all_packets",
10292            AudioRendererRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
10293            AudioRendererRequest::BindGainControl { .. } => "bind_gain_control",
10294            AudioRendererRequest::SetPtsUnits { .. } => "set_pts_units",
10295            AudioRendererRequest::SetPtsContinuityThreshold { .. } => {
10296                "set_pts_continuity_threshold"
10297            }
10298            AudioRendererRequest::GetReferenceClock { .. } => "get_reference_clock",
10299            AudioRendererRequest::SetReferenceClock { .. } => "set_reference_clock",
10300            AudioRendererRequest::SetUsage { .. } => "set_usage",
10301            AudioRendererRequest::SetUsage2 { .. } => "set_usage2",
10302            AudioRendererRequest::SetPcmStreamType { .. } => "set_pcm_stream_type",
10303            AudioRendererRequest::EnableMinLeadTimeEvents { .. } => "enable_min_lead_time_events",
10304            AudioRendererRequest::GetMinLeadTime { .. } => "get_min_lead_time",
10305            AudioRendererRequest::Play { .. } => "play",
10306            AudioRendererRequest::PlayNoReply { .. } => "play_no_reply",
10307            AudioRendererRequest::Pause { .. } => "pause",
10308            AudioRendererRequest::PauseNoReply { .. } => "pause_no_reply",
10309            AudioRendererRequest::_UnknownMethod {
10310                method_type: fidl::MethodType::OneWay, ..
10311            } => "unknown one-way method",
10312            AudioRendererRequest::_UnknownMethod {
10313                method_type: fidl::MethodType::TwoWay, ..
10314            } => "unknown two-way method",
10315        }
10316    }
10317}
10318
10319#[derive(Debug, Clone)]
10320pub struct AudioRendererControlHandle {
10321    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10322}
10323
10324impl fidl::endpoints::ControlHandle for AudioRendererControlHandle {
10325    fn shutdown(&self) {
10326        self.inner.shutdown()
10327    }
10328    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
10329        self.inner.shutdown_with_epitaph(status)
10330    }
10331
10332    fn is_closed(&self) -> bool {
10333        self.inner.channel().is_closed()
10334    }
10335    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
10336        self.inner.channel().on_closed()
10337    }
10338
10339    #[cfg(target_os = "fuchsia")]
10340    fn signal_peer(
10341        &self,
10342        clear_mask: zx::Signals,
10343        set_mask: zx::Signals,
10344    ) -> Result<(), zx_status::Status> {
10345        use fidl::Peered;
10346        self.inner.channel().signal_peer(clear_mask, set_mask)
10347    }
10348}
10349
10350impl AudioRendererControlHandle {
10351    pub fn send_on_min_lead_time_changed(
10352        &self,
10353        mut min_lead_time_nsec: i64,
10354    ) -> Result<(), fidl::Error> {
10355        self.inner.send::<AudioRendererOnMinLeadTimeChangedRequest>(
10356            (min_lead_time_nsec,),
10357            0,
10358            0x4feff7d278978c4e,
10359            fidl::encoding::DynamicFlags::empty(),
10360        )
10361    }
10362}
10363
10364#[must_use = "FIDL methods require a response to be sent"]
10365#[derive(Debug)]
10366pub struct AudioRendererSendPacketResponder {
10367    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10368    tx_id: u32,
10369}
10370
10371/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10372/// if the responder is dropped without sending a response, so that the client
10373/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10374impl std::ops::Drop for AudioRendererSendPacketResponder {
10375    fn drop(&mut self) {
10376        self.control_handle.shutdown();
10377        // Safety: drops once, never accessed again
10378        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10379    }
10380}
10381
10382impl fidl::endpoints::Responder for AudioRendererSendPacketResponder {
10383    type ControlHandle = AudioRendererControlHandle;
10384
10385    fn control_handle(&self) -> &AudioRendererControlHandle {
10386        &self.control_handle
10387    }
10388
10389    fn drop_without_shutdown(mut self) {
10390        // Safety: drops once, never accessed again due to mem::forget
10391        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10392        // Prevent Drop from running (which would shut down the channel)
10393        std::mem::forget(self);
10394    }
10395}
10396
10397impl AudioRendererSendPacketResponder {
10398    /// Sends a response to the FIDL transaction.
10399    ///
10400    /// Sets the channel to shutdown if an error occurs.
10401    pub fn send(self) -> Result<(), fidl::Error> {
10402        let _result = self.send_raw();
10403        if _result.is_err() {
10404            self.control_handle.shutdown();
10405        }
10406        self.drop_without_shutdown();
10407        _result
10408    }
10409
10410    /// Similar to "send" but does not shutdown the channel if an error occurs.
10411    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10412        let _result = self.send_raw();
10413        self.drop_without_shutdown();
10414        _result
10415    }
10416
10417    fn send_raw(&self) -> Result<(), fidl::Error> {
10418        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10419            (),
10420            self.tx_id,
10421            0x67cddd607442775f,
10422            fidl::encoding::DynamicFlags::empty(),
10423        )
10424    }
10425}
10426
10427#[must_use = "FIDL methods require a response to be sent"]
10428#[derive(Debug)]
10429pub struct AudioRendererDiscardAllPacketsResponder {
10430    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10431    tx_id: u32,
10432}
10433
10434/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10435/// if the responder is dropped without sending a response, so that the client
10436/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10437impl std::ops::Drop for AudioRendererDiscardAllPacketsResponder {
10438    fn drop(&mut self) {
10439        self.control_handle.shutdown();
10440        // Safety: drops once, never accessed again
10441        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10442    }
10443}
10444
10445impl fidl::endpoints::Responder for AudioRendererDiscardAllPacketsResponder {
10446    type ControlHandle = AudioRendererControlHandle;
10447
10448    fn control_handle(&self) -> &AudioRendererControlHandle {
10449        &self.control_handle
10450    }
10451
10452    fn drop_without_shutdown(mut self) {
10453        // Safety: drops once, never accessed again due to mem::forget
10454        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10455        // Prevent Drop from running (which would shut down the channel)
10456        std::mem::forget(self);
10457    }
10458}
10459
10460impl AudioRendererDiscardAllPacketsResponder {
10461    /// Sends a response to the FIDL transaction.
10462    ///
10463    /// Sets the channel to shutdown if an error occurs.
10464    pub fn send(self) -> Result<(), fidl::Error> {
10465        let _result = self.send_raw();
10466        if _result.is_err() {
10467            self.control_handle.shutdown();
10468        }
10469        self.drop_without_shutdown();
10470        _result
10471    }
10472
10473    /// Similar to "send" but does not shutdown the channel if an error occurs.
10474    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10475        let _result = self.send_raw();
10476        self.drop_without_shutdown();
10477        _result
10478    }
10479
10480    fn send_raw(&self) -> Result<(), fidl::Error> {
10481        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10482            (),
10483            self.tx_id,
10484            0x6f4dad7af2917665,
10485            fidl::encoding::DynamicFlags::empty(),
10486        )
10487    }
10488}
10489
10490#[must_use = "FIDL methods require a response to be sent"]
10491#[derive(Debug)]
10492pub struct AudioRendererGetReferenceClockResponder {
10493    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10494    tx_id: u32,
10495}
10496
10497/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10498/// if the responder is dropped without sending a response, so that the client
10499/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10500impl std::ops::Drop for AudioRendererGetReferenceClockResponder {
10501    fn drop(&mut self) {
10502        self.control_handle.shutdown();
10503        // Safety: drops once, never accessed again
10504        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10505    }
10506}
10507
10508impl fidl::endpoints::Responder for AudioRendererGetReferenceClockResponder {
10509    type ControlHandle = AudioRendererControlHandle;
10510
10511    fn control_handle(&self) -> &AudioRendererControlHandle {
10512        &self.control_handle
10513    }
10514
10515    fn drop_without_shutdown(mut self) {
10516        // Safety: drops once, never accessed again due to mem::forget
10517        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10518        // Prevent Drop from running (which would shut down the channel)
10519        std::mem::forget(self);
10520    }
10521}
10522
10523impl AudioRendererGetReferenceClockResponder {
10524    /// Sends a response to the FIDL transaction.
10525    ///
10526    /// Sets the channel to shutdown if an error occurs.
10527    pub fn send(self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
10528        let _result = self.send_raw(reference_clock);
10529        if _result.is_err() {
10530            self.control_handle.shutdown();
10531        }
10532        self.drop_without_shutdown();
10533        _result
10534    }
10535
10536    /// Similar to "send" but does not shutdown the channel if an error occurs.
10537    pub fn send_no_shutdown_on_err(
10538        self,
10539        mut reference_clock: fidl::Clock,
10540    ) -> Result<(), fidl::Error> {
10541        let _result = self.send_raw(reference_clock);
10542        self.drop_without_shutdown();
10543        _result
10544    }
10545
10546    fn send_raw(&self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
10547        self.control_handle.inner.send::<AudioRendererGetReferenceClockResponse>(
10548            (reference_clock,),
10549            self.tx_id,
10550            0x2f7a7f011a172f7e,
10551            fidl::encoding::DynamicFlags::empty(),
10552        )
10553    }
10554}
10555
10556#[must_use = "FIDL methods require a response to be sent"]
10557#[derive(Debug)]
10558pub struct AudioRendererGetMinLeadTimeResponder {
10559    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10560    tx_id: u32,
10561}
10562
10563/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10564/// if the responder is dropped without sending a response, so that the client
10565/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10566impl std::ops::Drop for AudioRendererGetMinLeadTimeResponder {
10567    fn drop(&mut self) {
10568        self.control_handle.shutdown();
10569        // Safety: drops once, never accessed again
10570        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10571    }
10572}
10573
10574impl fidl::endpoints::Responder for AudioRendererGetMinLeadTimeResponder {
10575    type ControlHandle = AudioRendererControlHandle;
10576
10577    fn control_handle(&self) -> &AudioRendererControlHandle {
10578        &self.control_handle
10579    }
10580
10581    fn drop_without_shutdown(mut self) {
10582        // Safety: drops once, never accessed again due to mem::forget
10583        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10584        // Prevent Drop from running (which would shut down the channel)
10585        std::mem::forget(self);
10586    }
10587}
10588
10589impl AudioRendererGetMinLeadTimeResponder {
10590    /// Sends a response to the FIDL transaction.
10591    ///
10592    /// Sets the channel to shutdown if an error occurs.
10593    pub fn send(self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
10594        let _result = self.send_raw(min_lead_time_nsec);
10595        if _result.is_err() {
10596            self.control_handle.shutdown();
10597        }
10598        self.drop_without_shutdown();
10599        _result
10600    }
10601
10602    /// Similar to "send" but does not shutdown the channel if an error occurs.
10603    pub fn send_no_shutdown_on_err(self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
10604        let _result = self.send_raw(min_lead_time_nsec);
10605        self.drop_without_shutdown();
10606        _result
10607    }
10608
10609    fn send_raw(&self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
10610        self.control_handle.inner.send::<AudioRendererGetMinLeadTimeResponse>(
10611            (min_lead_time_nsec,),
10612            self.tx_id,
10613            0x1cf3c3ecd8fec26b,
10614            fidl::encoding::DynamicFlags::empty(),
10615        )
10616    }
10617}
10618
10619#[must_use = "FIDL methods require a response to be sent"]
10620#[derive(Debug)]
10621pub struct AudioRendererPlayResponder {
10622    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10623    tx_id: u32,
10624}
10625
10626/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10627/// if the responder is dropped without sending a response, so that the client
10628/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10629impl std::ops::Drop for AudioRendererPlayResponder {
10630    fn drop(&mut self) {
10631        self.control_handle.shutdown();
10632        // Safety: drops once, never accessed again
10633        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10634    }
10635}
10636
10637impl fidl::endpoints::Responder for AudioRendererPlayResponder {
10638    type ControlHandle = AudioRendererControlHandle;
10639
10640    fn control_handle(&self) -> &AudioRendererControlHandle {
10641        &self.control_handle
10642    }
10643
10644    fn drop_without_shutdown(mut self) {
10645        // Safety: drops once, never accessed again due to mem::forget
10646        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10647        // Prevent Drop from running (which would shut down the channel)
10648        std::mem::forget(self);
10649    }
10650}
10651
10652impl AudioRendererPlayResponder {
10653    /// Sends a response to the FIDL transaction.
10654    ///
10655    /// Sets the channel to shutdown if an error occurs.
10656    pub fn send(self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10657        let _result = self.send_raw(reference_time, media_time);
10658        if _result.is_err() {
10659            self.control_handle.shutdown();
10660        }
10661        self.drop_without_shutdown();
10662        _result
10663    }
10664
10665    /// Similar to "send" but does not shutdown the channel if an error occurs.
10666    pub fn send_no_shutdown_on_err(
10667        self,
10668        mut reference_time: i64,
10669        mut media_time: i64,
10670    ) -> Result<(), fidl::Error> {
10671        let _result = self.send_raw(reference_time, media_time);
10672        self.drop_without_shutdown();
10673        _result
10674    }
10675
10676    fn send_raw(&self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10677        self.control_handle.inner.send::<AudioRendererPlayResponse>(
10678            (reference_time, media_time),
10679            self.tx_id,
10680            0x3c0162db084f74a3,
10681            fidl::encoding::DynamicFlags::empty(),
10682        )
10683    }
10684}
10685
10686#[must_use = "FIDL methods require a response to be sent"]
10687#[derive(Debug)]
10688pub struct AudioRendererPauseResponder {
10689    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10690    tx_id: u32,
10691}
10692
10693/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10694/// if the responder is dropped without sending a response, so that the client
10695/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10696impl std::ops::Drop for AudioRendererPauseResponder {
10697    fn drop(&mut self) {
10698        self.control_handle.shutdown();
10699        // Safety: drops once, never accessed again
10700        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10701    }
10702}
10703
10704impl fidl::endpoints::Responder for AudioRendererPauseResponder {
10705    type ControlHandle = AudioRendererControlHandle;
10706
10707    fn control_handle(&self) -> &AudioRendererControlHandle {
10708        &self.control_handle
10709    }
10710
10711    fn drop_without_shutdown(mut self) {
10712        // Safety: drops once, never accessed again due to mem::forget
10713        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10714        // Prevent Drop from running (which would shut down the channel)
10715        std::mem::forget(self);
10716    }
10717}
10718
10719impl AudioRendererPauseResponder {
10720    /// Sends a response to the FIDL transaction.
10721    ///
10722    /// Sets the channel to shutdown if an error occurs.
10723    pub fn send(self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10724        let _result = self.send_raw(reference_time, media_time);
10725        if _result.is_err() {
10726            self.control_handle.shutdown();
10727        }
10728        self.drop_without_shutdown();
10729        _result
10730    }
10731
10732    /// Similar to "send" but does not shutdown the channel if an error occurs.
10733    pub fn send_no_shutdown_on_err(
10734        self,
10735        mut reference_time: i64,
10736        mut media_time: i64,
10737    ) -> Result<(), fidl::Error> {
10738        let _result = self.send_raw(reference_time, media_time);
10739        self.drop_without_shutdown();
10740        _result
10741    }
10742
10743    fn send_raw(&self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10744        self.control_handle.inner.send::<AudioRendererPauseResponse>(
10745            (reference_time, media_time),
10746            self.tx_id,
10747            0x41d557588d93d153,
10748            fidl::encoding::DynamicFlags::empty(),
10749        )
10750    }
10751}
10752
10753#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
10754pub struct ProfileProviderMarker;
10755
10756impl fidl::endpoints::ProtocolMarker for ProfileProviderMarker {
10757    type Proxy = ProfileProviderProxy;
10758    type RequestStream = ProfileProviderRequestStream;
10759    #[cfg(target_os = "fuchsia")]
10760    type SynchronousProxy = ProfileProviderSynchronousProxy;
10761
10762    const DEBUG_NAME: &'static str = "fuchsia.media.ProfileProvider";
10763}
10764impl fidl::endpoints::DiscoverableProtocolMarker for ProfileProviderMarker {}
10765
10766pub trait ProfileProviderProxyInterface: Send + Sync {
10767    type RegisterHandlerWithCapacityResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>>
10768        + Send;
10769    fn r#register_handler_with_capacity(
10770        &self,
10771        thread_handle: fidl::Thread,
10772        name: &str,
10773        period: i64,
10774        capacity: f32,
10775    ) -> Self::RegisterHandlerWithCapacityResponseFut;
10776    type UnregisterHandlerResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
10777    fn r#unregister_handler(
10778        &self,
10779        thread_handle: fidl::Thread,
10780        name: &str,
10781    ) -> Self::UnregisterHandlerResponseFut;
10782    type RegisterMemoryRangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
10783        + Send;
10784    fn r#register_memory_range(
10785        &self,
10786        vmar_handle: fidl::Vmar,
10787        name: &str,
10788    ) -> Self::RegisterMemoryRangeResponseFut;
10789    type UnregisterMemoryRangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
10790        + Send;
10791    fn r#unregister_memory_range(
10792        &self,
10793        vmar_handle: fidl::Vmar,
10794    ) -> Self::UnregisterMemoryRangeResponseFut;
10795}
10796#[derive(Debug)]
10797#[cfg(target_os = "fuchsia")]
10798pub struct ProfileProviderSynchronousProxy {
10799    client: fidl::client::sync::Client,
10800}
10801
10802#[cfg(target_os = "fuchsia")]
10803impl fidl::endpoints::SynchronousProxy for ProfileProviderSynchronousProxy {
10804    type Proxy = ProfileProviderProxy;
10805    type Protocol = ProfileProviderMarker;
10806
10807    fn from_channel(inner: fidl::Channel) -> Self {
10808        Self::new(inner)
10809    }
10810
10811    fn into_channel(self) -> fidl::Channel {
10812        self.client.into_channel()
10813    }
10814
10815    fn as_channel(&self) -> &fidl::Channel {
10816        self.client.as_channel()
10817    }
10818}
10819
10820#[cfg(target_os = "fuchsia")]
10821impl ProfileProviderSynchronousProxy {
10822    pub fn new(channel: fidl::Channel) -> Self {
10823        let protocol_name = <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10824        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
10825    }
10826
10827    pub fn into_channel(self) -> fidl::Channel {
10828        self.client.into_channel()
10829    }
10830
10831    /// Waits until an event arrives and returns it. It is safe for other
10832    /// threads to make concurrent requests while waiting for an event.
10833    pub fn wait_for_event(
10834        &self,
10835        deadline: zx::MonotonicInstant,
10836    ) -> Result<ProfileProviderEvent, fidl::Error> {
10837        ProfileProviderEvent::decode(self.client.wait_for_event(deadline)?)
10838    }
10839
10840    /// Register a thread as a media thread. This notifies the media subsystem that this thread
10841    /// should have an elevated scheduling profile applied to it in order to meet audio or video
10842    /// deadlines.
10843    ///
10844    /// `name` is the name of a system scheduling role to apply to the thread given by
10845    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
10846    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
10847    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
10848    /// the scheduling interval the thread needs to be running to achieve good performance or to
10849    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
10850    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
10851    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
10852    /// be rejected or result in scaling back the performance of other threads to fit resource
10853    /// limits.
10854    ///
10855    /// Capacity, max runtime, and period have the following relationship:
10856    ///
10857    ///   capacity = max runtime / period
10858    ///
10859    /// Where:
10860    ///
10861    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
10862    ///
10863    /// For heterogeneous systems, the capacity should be planned / measured against the highest
10864    /// performance processor(s) in the system. The system will automatically adjust the effective
10865    /// capacity to account for slower processors and operating points and will avoid processors and
10866    /// operating points that are too slow to meet the requested scheduling parameters (provided
10867    /// they are reasonable).
10868    ///
10869    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
10870    /// may be zero to indicate not applicable.
10871    pub fn r#register_handler_with_capacity(
10872        &self,
10873        mut thread_handle: fidl::Thread,
10874        mut name: &str,
10875        mut period: i64,
10876        mut capacity: f32,
10877        ___deadline: zx::MonotonicInstant,
10878    ) -> Result<(i64, i64), fidl::Error> {
10879        let _response = self.client.send_query::<
10880            ProfileProviderRegisterHandlerWithCapacityRequest,
10881            ProfileProviderRegisterHandlerWithCapacityResponse,
10882        >(
10883            (thread_handle, name, period, capacity,),
10884            0x60459ecef7458176,
10885            fidl::encoding::DynamicFlags::empty(),
10886            ___deadline,
10887        )?;
10888        Ok((_response.period, _response.capacity))
10889    }
10890
10891    /// Reset a thread's scheduling profile to the default.
10892    pub fn r#unregister_handler(
10893        &self,
10894        mut thread_handle: fidl::Thread,
10895        mut name: &str,
10896        ___deadline: zx::MonotonicInstant,
10897    ) -> Result<(), fidl::Error> {
10898        let _response = self
10899            .client
10900            .send_query::<ProfileProviderUnregisterHandlerRequest, fidl::encoding::EmptyPayload>(
10901                (thread_handle, name),
10902                0x724d9d5fd8ef544c,
10903                fidl::encoding::DynamicFlags::empty(),
10904                ___deadline,
10905            )?;
10906        Ok(_response)
10907    }
10908
10909    /// Register a memory range as being used for media processing. This notifies the media
10910    /// subsystem that this memory should have an elevated memory profile applied to it in order to
10911    /// meet audio or video deadlines.
10912    ///
10913    /// `name` is the name of a system memory role to apply to the memory given by
10914    /// `vmar_handle` -- different products may customize the underlying memory strategy based
10915    /// on the requested role.
10916    pub fn r#register_memory_range(
10917        &self,
10918        mut vmar_handle: fidl::Vmar,
10919        mut name: &str,
10920        ___deadline: zx::MonotonicInstant,
10921    ) -> Result<(), fidl::Error> {
10922        let _response = self
10923            .client
10924            .send_query::<ProfileProviderRegisterMemoryRangeRequest, fidl::encoding::EmptyPayload>(
10925                (vmar_handle, name),
10926                0x2f509d3523e9562d,
10927                fidl::encoding::DynamicFlags::empty(),
10928                ___deadline,
10929            )?;
10930        Ok(_response)
10931    }
10932
10933    /// Reset a memory range's memory profile.
10934    pub fn r#unregister_memory_range(
10935        &self,
10936        mut vmar_handle: fidl::Vmar,
10937        ___deadline: zx::MonotonicInstant,
10938    ) -> Result<(), fidl::Error> {
10939        let _response = self.client.send_query::<
10940            ProfileProviderUnregisterMemoryRangeRequest,
10941            fidl::encoding::EmptyPayload,
10942        >(
10943            (vmar_handle,),
10944            0x2dc313d6aa81ad27,
10945            fidl::encoding::DynamicFlags::empty(),
10946            ___deadline,
10947        )?;
10948        Ok(_response)
10949    }
10950}
10951
10952#[cfg(target_os = "fuchsia")]
10953impl From<ProfileProviderSynchronousProxy> for zx::Handle {
10954    fn from(value: ProfileProviderSynchronousProxy) -> Self {
10955        value.into_channel().into()
10956    }
10957}
10958
10959#[cfg(target_os = "fuchsia")]
10960impl From<fidl::Channel> for ProfileProviderSynchronousProxy {
10961    fn from(value: fidl::Channel) -> Self {
10962        Self::new(value)
10963    }
10964}
10965
10966#[cfg(target_os = "fuchsia")]
10967impl fidl::endpoints::FromClient for ProfileProviderSynchronousProxy {
10968    type Protocol = ProfileProviderMarker;
10969
10970    fn from_client(value: fidl::endpoints::ClientEnd<ProfileProviderMarker>) -> Self {
10971        Self::new(value.into_channel())
10972    }
10973}
10974
10975#[derive(Debug, Clone)]
10976pub struct ProfileProviderProxy {
10977    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
10978}
10979
10980impl fidl::endpoints::Proxy for ProfileProviderProxy {
10981    type Protocol = ProfileProviderMarker;
10982
10983    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
10984        Self::new(inner)
10985    }
10986
10987    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
10988        self.client.into_channel().map_err(|client| Self { client })
10989    }
10990
10991    fn as_channel(&self) -> &::fidl::AsyncChannel {
10992        self.client.as_channel()
10993    }
10994}
10995
10996impl ProfileProviderProxy {
10997    /// Create a new Proxy for fuchsia.media/ProfileProvider.
10998    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
10999        let protocol_name = <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
11000        Self { client: fidl::client::Client::new(channel, protocol_name) }
11001    }
11002
11003    /// Get a Stream of events from the remote end of the protocol.
11004    ///
11005    /// # Panics
11006    ///
11007    /// Panics if the event stream was already taken.
11008    pub fn take_event_stream(&self) -> ProfileProviderEventStream {
11009        ProfileProviderEventStream { event_receiver: self.client.take_event_receiver() }
11010    }
11011
11012    /// Register a thread as a media thread. This notifies the media subsystem that this thread
11013    /// should have an elevated scheduling profile applied to it in order to meet audio or video
11014    /// deadlines.
11015    ///
11016    /// `name` is the name of a system scheduling role to apply to the thread given by
11017    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
11018    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
11019    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
11020    /// the scheduling interval the thread needs to be running to achieve good performance or to
11021    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
11022    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
11023    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
11024    /// be rejected or result in scaling back the performance of other threads to fit resource
11025    /// limits.
11026    ///
11027    /// Capacity, max runtime, and period have the following relationship:
11028    ///
11029    ///   capacity = max runtime / period
11030    ///
11031    /// Where:
11032    ///
11033    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
11034    ///
11035    /// For heterogeneous systems, the capacity should be planned / measured against the highest
11036    /// performance processor(s) in the system. The system will automatically adjust the effective
11037    /// capacity to account for slower processors and operating points and will avoid processors and
11038    /// operating points that are too slow to meet the requested scheduling parameters (provided
11039    /// they are reasonable).
11040    ///
11041    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
11042    /// may be zero to indicate not applicable.
11043    pub fn r#register_handler_with_capacity(
11044        &self,
11045        mut thread_handle: fidl::Thread,
11046        mut name: &str,
11047        mut period: i64,
11048        mut capacity: f32,
11049    ) -> fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>
11050    {
11051        ProfileProviderProxyInterface::r#register_handler_with_capacity(
11052            self,
11053            thread_handle,
11054            name,
11055            period,
11056            capacity,
11057        )
11058    }
11059
11060    /// Reset a thread's scheduling profile to the default.
11061    pub fn r#unregister_handler(
11062        &self,
11063        mut thread_handle: fidl::Thread,
11064        mut name: &str,
11065    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
11066        ProfileProviderProxyInterface::r#unregister_handler(self, thread_handle, name)
11067    }
11068
11069    /// Register a memory range as being used for media processing. This notifies the media
11070    /// subsystem that this memory should have an elevated memory profile applied to it in order to
11071    /// meet audio or video deadlines.
11072    ///
11073    /// `name` is the name of a system memory role to apply to the memory given by
11074    /// `vmar_handle` -- different products may customize the underlying memory strategy based
11075    /// on the requested role.
11076    pub fn r#register_memory_range(
11077        &self,
11078        mut vmar_handle: fidl::Vmar,
11079        mut name: &str,
11080    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
11081        ProfileProviderProxyInterface::r#register_memory_range(self, vmar_handle, name)
11082    }
11083
11084    /// Reset a memory range's memory profile.
11085    pub fn r#unregister_memory_range(
11086        &self,
11087        mut vmar_handle: fidl::Vmar,
11088    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
11089        ProfileProviderProxyInterface::r#unregister_memory_range(self, vmar_handle)
11090    }
11091}
11092
11093impl ProfileProviderProxyInterface for ProfileProviderProxy {
11094    type RegisterHandlerWithCapacityResponseFut =
11095        fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>;
11096    fn r#register_handler_with_capacity(
11097        &self,
11098        mut thread_handle: fidl::Thread,
11099        mut name: &str,
11100        mut period: i64,
11101        mut capacity: f32,
11102    ) -> Self::RegisterHandlerWithCapacityResponseFut {
11103        fn _decode(
11104            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11105        ) -> Result<(i64, i64), fidl::Error> {
11106            let _response = fidl::client::decode_transaction_body::<
11107                ProfileProviderRegisterHandlerWithCapacityResponse,
11108                fidl::encoding::DefaultFuchsiaResourceDialect,
11109                0x60459ecef7458176,
11110            >(_buf?)?;
11111            Ok((_response.period, _response.capacity))
11112        }
11113        self.client
11114            .send_query_and_decode::<ProfileProviderRegisterHandlerWithCapacityRequest, (i64, i64)>(
11115                (thread_handle, name, period, capacity),
11116                0x60459ecef7458176,
11117                fidl::encoding::DynamicFlags::empty(),
11118                _decode,
11119            )
11120    }
11121
11122    type UnregisterHandlerResponseFut =
11123        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
11124    fn r#unregister_handler(
11125        &self,
11126        mut thread_handle: fidl::Thread,
11127        mut name: &str,
11128    ) -> Self::UnregisterHandlerResponseFut {
11129        fn _decode(
11130            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11131        ) -> Result<(), fidl::Error> {
11132            let _response = fidl::client::decode_transaction_body::<
11133                fidl::encoding::EmptyPayload,
11134                fidl::encoding::DefaultFuchsiaResourceDialect,
11135                0x724d9d5fd8ef544c,
11136            >(_buf?)?;
11137            Ok(_response)
11138        }
11139        self.client.send_query_and_decode::<ProfileProviderUnregisterHandlerRequest, ()>(
11140            (thread_handle, name),
11141            0x724d9d5fd8ef544c,
11142            fidl::encoding::DynamicFlags::empty(),
11143            _decode,
11144        )
11145    }
11146
11147    type RegisterMemoryRangeResponseFut =
11148        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
11149    fn r#register_memory_range(
11150        &self,
11151        mut vmar_handle: fidl::Vmar,
11152        mut name: &str,
11153    ) -> Self::RegisterMemoryRangeResponseFut {
11154        fn _decode(
11155            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11156        ) -> Result<(), fidl::Error> {
11157            let _response = fidl::client::decode_transaction_body::<
11158                fidl::encoding::EmptyPayload,
11159                fidl::encoding::DefaultFuchsiaResourceDialect,
11160                0x2f509d3523e9562d,
11161            >(_buf?)?;
11162            Ok(_response)
11163        }
11164        self.client.send_query_and_decode::<ProfileProviderRegisterMemoryRangeRequest, ()>(
11165            (vmar_handle, name),
11166            0x2f509d3523e9562d,
11167            fidl::encoding::DynamicFlags::empty(),
11168            _decode,
11169        )
11170    }
11171
11172    type UnregisterMemoryRangeResponseFut =
11173        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
11174    fn r#unregister_memory_range(
11175        &self,
11176        mut vmar_handle: fidl::Vmar,
11177    ) -> Self::UnregisterMemoryRangeResponseFut {
11178        fn _decode(
11179            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11180        ) -> Result<(), fidl::Error> {
11181            let _response = fidl::client::decode_transaction_body::<
11182                fidl::encoding::EmptyPayload,
11183                fidl::encoding::DefaultFuchsiaResourceDialect,
11184                0x2dc313d6aa81ad27,
11185            >(_buf?)?;
11186            Ok(_response)
11187        }
11188        self.client.send_query_and_decode::<ProfileProviderUnregisterMemoryRangeRequest, ()>(
11189            (vmar_handle,),
11190            0x2dc313d6aa81ad27,
11191            fidl::encoding::DynamicFlags::empty(),
11192            _decode,
11193        )
11194    }
11195}
11196
11197pub struct ProfileProviderEventStream {
11198    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
11199}
11200
11201impl std::marker::Unpin for ProfileProviderEventStream {}
11202
11203impl futures::stream::FusedStream for ProfileProviderEventStream {
11204    fn is_terminated(&self) -> bool {
11205        self.event_receiver.is_terminated()
11206    }
11207}
11208
11209impl futures::Stream for ProfileProviderEventStream {
11210    type Item = Result<ProfileProviderEvent, fidl::Error>;
11211
11212    fn poll_next(
11213        mut self: std::pin::Pin<&mut Self>,
11214        cx: &mut std::task::Context<'_>,
11215    ) -> std::task::Poll<Option<Self::Item>> {
11216        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
11217            &mut self.event_receiver,
11218            cx
11219        )?) {
11220            Some(buf) => std::task::Poll::Ready(Some(ProfileProviderEvent::decode(buf))),
11221            None => std::task::Poll::Ready(None),
11222        }
11223    }
11224}
11225
11226#[derive(Debug)]
11227pub enum ProfileProviderEvent {}
11228
11229impl ProfileProviderEvent {
11230    /// Decodes a message buffer as a [`ProfileProviderEvent`].
11231    fn decode(
11232        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
11233    ) -> Result<ProfileProviderEvent, fidl::Error> {
11234        let (bytes, _handles) = buf.split_mut();
11235        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11236        debug_assert_eq!(tx_header.tx_id, 0);
11237        match tx_header.ordinal {
11238            _ => Err(fidl::Error::UnknownOrdinal {
11239                ordinal: tx_header.ordinal,
11240                protocol_name:
11241                    <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11242            }),
11243        }
11244    }
11245}
11246
11247/// A Stream of incoming requests for fuchsia.media/ProfileProvider.
11248pub struct ProfileProviderRequestStream {
11249    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11250    is_terminated: bool,
11251}
11252
11253impl std::marker::Unpin for ProfileProviderRequestStream {}
11254
11255impl futures::stream::FusedStream for ProfileProviderRequestStream {
11256    fn is_terminated(&self) -> bool {
11257        self.is_terminated
11258    }
11259}
11260
11261impl fidl::endpoints::RequestStream for ProfileProviderRequestStream {
11262    type Protocol = ProfileProviderMarker;
11263    type ControlHandle = ProfileProviderControlHandle;
11264
11265    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
11266        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
11267    }
11268
11269    fn control_handle(&self) -> Self::ControlHandle {
11270        ProfileProviderControlHandle { inner: self.inner.clone() }
11271    }
11272
11273    fn into_inner(
11274        self,
11275    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
11276    {
11277        (self.inner, self.is_terminated)
11278    }
11279
11280    fn from_inner(
11281        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11282        is_terminated: bool,
11283    ) -> Self {
11284        Self { inner, is_terminated }
11285    }
11286}
11287
11288impl futures::Stream for ProfileProviderRequestStream {
11289    type Item = Result<ProfileProviderRequest, fidl::Error>;
11290
11291    fn poll_next(
11292        mut self: std::pin::Pin<&mut Self>,
11293        cx: &mut std::task::Context<'_>,
11294    ) -> std::task::Poll<Option<Self::Item>> {
11295        let this = &mut *self;
11296        if this.inner.check_shutdown(cx) {
11297            this.is_terminated = true;
11298            return std::task::Poll::Ready(None);
11299        }
11300        if this.is_terminated {
11301            panic!("polled ProfileProviderRequestStream after completion");
11302        }
11303        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
11304            |bytes, handles| {
11305                match this.inner.channel().read_etc(cx, bytes, handles) {
11306                    std::task::Poll::Ready(Ok(())) => {}
11307                    std::task::Poll::Pending => return std::task::Poll::Pending,
11308                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
11309                        this.is_terminated = true;
11310                        return std::task::Poll::Ready(None);
11311                    }
11312                    std::task::Poll::Ready(Err(e)) => {
11313                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
11314                            e.into(),
11315                        ))))
11316                    }
11317                }
11318
11319                // A message has been received from the channel
11320                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11321
11322                std::task::Poll::Ready(Some(match header.ordinal {
11323                    0x60459ecef7458176 => {
11324                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11325                        let mut req = fidl::new_empty!(
11326                            ProfileProviderRegisterHandlerWithCapacityRequest,
11327                            fidl::encoding::DefaultFuchsiaResourceDialect
11328                        );
11329                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderRegisterHandlerWithCapacityRequest>(&header, _body_bytes, handles, &mut req)?;
11330                        let control_handle =
11331                            ProfileProviderControlHandle { inner: this.inner.clone() };
11332                        Ok(ProfileProviderRequest::RegisterHandlerWithCapacity {
11333                            thread_handle: req.thread_handle,
11334                            name: req.name,
11335                            period: req.period,
11336                            capacity: req.capacity,
11337
11338                            responder: ProfileProviderRegisterHandlerWithCapacityResponder {
11339                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11340                                tx_id: header.tx_id,
11341                            },
11342                        })
11343                    }
11344                    0x724d9d5fd8ef544c => {
11345                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11346                        let mut req = fidl::new_empty!(
11347                            ProfileProviderUnregisterHandlerRequest,
11348                            fidl::encoding::DefaultFuchsiaResourceDialect
11349                        );
11350                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderUnregisterHandlerRequest>(&header, _body_bytes, handles, &mut req)?;
11351                        let control_handle =
11352                            ProfileProviderControlHandle { inner: this.inner.clone() };
11353                        Ok(ProfileProviderRequest::UnregisterHandler {
11354                            thread_handle: req.thread_handle,
11355                            name: req.name,
11356
11357                            responder: ProfileProviderUnregisterHandlerResponder {
11358                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11359                                tx_id: header.tx_id,
11360                            },
11361                        })
11362                    }
11363                    0x2f509d3523e9562d => {
11364                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11365                        let mut req = fidl::new_empty!(
11366                            ProfileProviderRegisterMemoryRangeRequest,
11367                            fidl::encoding::DefaultFuchsiaResourceDialect
11368                        );
11369                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderRegisterMemoryRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11370                        let control_handle =
11371                            ProfileProviderControlHandle { inner: this.inner.clone() };
11372                        Ok(ProfileProviderRequest::RegisterMemoryRange {
11373                            vmar_handle: req.vmar_handle,
11374                            name: req.name,
11375
11376                            responder: ProfileProviderRegisterMemoryRangeResponder {
11377                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11378                                tx_id: header.tx_id,
11379                            },
11380                        })
11381                    }
11382                    0x2dc313d6aa81ad27 => {
11383                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11384                        let mut req = fidl::new_empty!(
11385                            ProfileProviderUnregisterMemoryRangeRequest,
11386                            fidl::encoding::DefaultFuchsiaResourceDialect
11387                        );
11388                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderUnregisterMemoryRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11389                        let control_handle =
11390                            ProfileProviderControlHandle { inner: this.inner.clone() };
11391                        Ok(ProfileProviderRequest::UnregisterMemoryRange {
11392                            vmar_handle: req.vmar_handle,
11393
11394                            responder: ProfileProviderUnregisterMemoryRangeResponder {
11395                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11396                                tx_id: header.tx_id,
11397                            },
11398                        })
11399                    }
11400                    _ => Err(fidl::Error::UnknownOrdinal {
11401                        ordinal: header.ordinal,
11402                        protocol_name:
11403                            <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11404                    }),
11405                }))
11406            },
11407        )
11408    }
11409}
11410
11411#[derive(Debug)]
11412pub enum ProfileProviderRequest {
11413    /// Register a thread as a media thread. This notifies the media subsystem that this thread
11414    /// should have an elevated scheduling profile applied to it in order to meet audio or video
11415    /// deadlines.
11416    ///
11417    /// `name` is the name of a system scheduling role to apply to the thread given by
11418    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
11419    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
11420    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
11421    /// the scheduling interval the thread needs to be running to achieve good performance or to
11422    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
11423    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
11424    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
11425    /// be rejected or result in scaling back the performance of other threads to fit resource
11426    /// limits.
11427    ///
11428    /// Capacity, max runtime, and period have the following relationship:
11429    ///
11430    ///   capacity = max runtime / period
11431    ///
11432    /// Where:
11433    ///
11434    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
11435    ///
11436    /// For heterogeneous systems, the capacity should be planned / measured against the highest
11437    /// performance processor(s) in the system. The system will automatically adjust the effective
11438    /// capacity to account for slower processors and operating points and will avoid processors and
11439    /// operating points that are too slow to meet the requested scheduling parameters (provided
11440    /// they are reasonable).
11441    ///
11442    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
11443    /// may be zero to indicate not applicable.
11444    RegisterHandlerWithCapacity {
11445        thread_handle: fidl::Thread,
11446        name: String,
11447        period: i64,
11448        capacity: f32,
11449        responder: ProfileProviderRegisterHandlerWithCapacityResponder,
11450    },
11451    /// Reset a thread's scheduling profile to the default.
11452    UnregisterHandler {
11453        thread_handle: fidl::Thread,
11454        name: String,
11455        responder: ProfileProviderUnregisterHandlerResponder,
11456    },
11457    /// Register a memory range as being used for media processing. This notifies the media
11458    /// subsystem that this memory should have an elevated memory profile applied to it in order to
11459    /// meet audio or video deadlines.
11460    ///
11461    /// `name` is the name of a system memory role to apply to the memory given by
11462    /// `vmar_handle` -- different products may customize the underlying memory strategy based
11463    /// on the requested role.
11464    RegisterMemoryRange {
11465        vmar_handle: fidl::Vmar,
11466        name: String,
11467        responder: ProfileProviderRegisterMemoryRangeResponder,
11468    },
11469    /// Reset a memory range's memory profile.
11470    UnregisterMemoryRange {
11471        vmar_handle: fidl::Vmar,
11472        responder: ProfileProviderUnregisterMemoryRangeResponder,
11473    },
11474}
11475
11476impl ProfileProviderRequest {
11477    #[allow(irrefutable_let_patterns)]
11478    pub fn into_register_handler_with_capacity(
11479        self,
11480    ) -> Option<(fidl::Thread, String, i64, f32, ProfileProviderRegisterHandlerWithCapacityResponder)>
11481    {
11482        if let ProfileProviderRequest::RegisterHandlerWithCapacity {
11483            thread_handle,
11484            name,
11485            period,
11486            capacity,
11487            responder,
11488        } = self
11489        {
11490            Some((thread_handle, name, period, capacity, responder))
11491        } else {
11492            None
11493        }
11494    }
11495
11496    #[allow(irrefutable_let_patterns)]
11497    pub fn into_unregister_handler(
11498        self,
11499    ) -> Option<(fidl::Thread, String, ProfileProviderUnregisterHandlerResponder)> {
11500        if let ProfileProviderRequest::UnregisterHandler { thread_handle, name, responder } = self {
11501            Some((thread_handle, name, responder))
11502        } else {
11503            None
11504        }
11505    }
11506
11507    #[allow(irrefutable_let_patterns)]
11508    pub fn into_register_memory_range(
11509        self,
11510    ) -> Option<(fidl::Vmar, String, ProfileProviderRegisterMemoryRangeResponder)> {
11511        if let ProfileProviderRequest::RegisterMemoryRange { vmar_handle, name, responder } = self {
11512            Some((vmar_handle, name, responder))
11513        } else {
11514            None
11515        }
11516    }
11517
11518    #[allow(irrefutable_let_patterns)]
11519    pub fn into_unregister_memory_range(
11520        self,
11521    ) -> Option<(fidl::Vmar, ProfileProviderUnregisterMemoryRangeResponder)> {
11522        if let ProfileProviderRequest::UnregisterMemoryRange { vmar_handle, responder } = self {
11523            Some((vmar_handle, responder))
11524        } else {
11525            None
11526        }
11527    }
11528
11529    /// Name of the method defined in FIDL
11530    pub fn method_name(&self) -> &'static str {
11531        match *self {
11532            ProfileProviderRequest::RegisterHandlerWithCapacity { .. } => {
11533                "register_handler_with_capacity"
11534            }
11535            ProfileProviderRequest::UnregisterHandler { .. } => "unregister_handler",
11536            ProfileProviderRequest::RegisterMemoryRange { .. } => "register_memory_range",
11537            ProfileProviderRequest::UnregisterMemoryRange { .. } => "unregister_memory_range",
11538        }
11539    }
11540}
11541
11542#[derive(Debug, Clone)]
11543pub struct ProfileProviderControlHandle {
11544    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11545}
11546
11547impl fidl::endpoints::ControlHandle for ProfileProviderControlHandle {
11548    fn shutdown(&self) {
11549        self.inner.shutdown()
11550    }
11551    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
11552        self.inner.shutdown_with_epitaph(status)
11553    }
11554
11555    fn is_closed(&self) -> bool {
11556        self.inner.channel().is_closed()
11557    }
11558    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
11559        self.inner.channel().on_closed()
11560    }
11561
11562    #[cfg(target_os = "fuchsia")]
11563    fn signal_peer(
11564        &self,
11565        clear_mask: zx::Signals,
11566        set_mask: zx::Signals,
11567    ) -> Result<(), zx_status::Status> {
11568        use fidl::Peered;
11569        self.inner.channel().signal_peer(clear_mask, set_mask)
11570    }
11571}
11572
11573impl ProfileProviderControlHandle {}
11574
11575#[must_use = "FIDL methods require a response to be sent"]
11576#[derive(Debug)]
11577pub struct ProfileProviderRegisterHandlerWithCapacityResponder {
11578    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11579    tx_id: u32,
11580}
11581
11582/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11583/// if the responder is dropped without sending a response, so that the client
11584/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11585impl std::ops::Drop for ProfileProviderRegisterHandlerWithCapacityResponder {
11586    fn drop(&mut self) {
11587        self.control_handle.shutdown();
11588        // Safety: drops once, never accessed again
11589        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11590    }
11591}
11592
11593impl fidl::endpoints::Responder for ProfileProviderRegisterHandlerWithCapacityResponder {
11594    type ControlHandle = ProfileProviderControlHandle;
11595
11596    fn control_handle(&self) -> &ProfileProviderControlHandle {
11597        &self.control_handle
11598    }
11599
11600    fn drop_without_shutdown(mut self) {
11601        // Safety: drops once, never accessed again due to mem::forget
11602        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11603        // Prevent Drop from running (which would shut down the channel)
11604        std::mem::forget(self);
11605    }
11606}
11607
11608impl ProfileProviderRegisterHandlerWithCapacityResponder {
11609    /// Sends a response to the FIDL transaction.
11610    ///
11611    /// Sets the channel to shutdown if an error occurs.
11612    pub fn send(self, mut period: i64, mut capacity: i64) -> Result<(), fidl::Error> {
11613        let _result = self.send_raw(period, capacity);
11614        if _result.is_err() {
11615            self.control_handle.shutdown();
11616        }
11617        self.drop_without_shutdown();
11618        _result
11619    }
11620
11621    /// Similar to "send" but does not shutdown the channel if an error occurs.
11622    pub fn send_no_shutdown_on_err(
11623        self,
11624        mut period: i64,
11625        mut capacity: i64,
11626    ) -> Result<(), fidl::Error> {
11627        let _result = self.send_raw(period, capacity);
11628        self.drop_without_shutdown();
11629        _result
11630    }
11631
11632    fn send_raw(&self, mut period: i64, mut capacity: i64) -> Result<(), fidl::Error> {
11633        self.control_handle.inner.send::<ProfileProviderRegisterHandlerWithCapacityResponse>(
11634            (period, capacity),
11635            self.tx_id,
11636            0x60459ecef7458176,
11637            fidl::encoding::DynamicFlags::empty(),
11638        )
11639    }
11640}
11641
11642#[must_use = "FIDL methods require a response to be sent"]
11643#[derive(Debug)]
11644pub struct ProfileProviderUnregisterHandlerResponder {
11645    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11646    tx_id: u32,
11647}
11648
11649/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11650/// if the responder is dropped without sending a response, so that the client
11651/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11652impl std::ops::Drop for ProfileProviderUnregisterHandlerResponder {
11653    fn drop(&mut self) {
11654        self.control_handle.shutdown();
11655        // Safety: drops once, never accessed again
11656        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11657    }
11658}
11659
11660impl fidl::endpoints::Responder for ProfileProviderUnregisterHandlerResponder {
11661    type ControlHandle = ProfileProviderControlHandle;
11662
11663    fn control_handle(&self) -> &ProfileProviderControlHandle {
11664        &self.control_handle
11665    }
11666
11667    fn drop_without_shutdown(mut self) {
11668        // Safety: drops once, never accessed again due to mem::forget
11669        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11670        // Prevent Drop from running (which would shut down the channel)
11671        std::mem::forget(self);
11672    }
11673}
11674
11675impl ProfileProviderUnregisterHandlerResponder {
11676    /// Sends a response to the FIDL transaction.
11677    ///
11678    /// Sets the channel to shutdown if an error occurs.
11679    pub fn send(self) -> Result<(), fidl::Error> {
11680        let _result = self.send_raw();
11681        if _result.is_err() {
11682            self.control_handle.shutdown();
11683        }
11684        self.drop_without_shutdown();
11685        _result
11686    }
11687
11688    /// Similar to "send" but does not shutdown the channel if an error occurs.
11689    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11690        let _result = self.send_raw();
11691        self.drop_without_shutdown();
11692        _result
11693    }
11694
11695    fn send_raw(&self) -> Result<(), fidl::Error> {
11696        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11697            (),
11698            self.tx_id,
11699            0x724d9d5fd8ef544c,
11700            fidl::encoding::DynamicFlags::empty(),
11701        )
11702    }
11703}
11704
11705#[must_use = "FIDL methods require a response to be sent"]
11706#[derive(Debug)]
11707pub struct ProfileProviderRegisterMemoryRangeResponder {
11708    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11709    tx_id: u32,
11710}
11711
11712/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11713/// if the responder is dropped without sending a response, so that the client
11714/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11715impl std::ops::Drop for ProfileProviderRegisterMemoryRangeResponder {
11716    fn drop(&mut self) {
11717        self.control_handle.shutdown();
11718        // Safety: drops once, never accessed again
11719        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11720    }
11721}
11722
11723impl fidl::endpoints::Responder for ProfileProviderRegisterMemoryRangeResponder {
11724    type ControlHandle = ProfileProviderControlHandle;
11725
11726    fn control_handle(&self) -> &ProfileProviderControlHandle {
11727        &self.control_handle
11728    }
11729
11730    fn drop_without_shutdown(mut self) {
11731        // Safety: drops once, never accessed again due to mem::forget
11732        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11733        // Prevent Drop from running (which would shut down the channel)
11734        std::mem::forget(self);
11735    }
11736}
11737
11738impl ProfileProviderRegisterMemoryRangeResponder {
11739    /// Sends a response to the FIDL transaction.
11740    ///
11741    /// Sets the channel to shutdown if an error occurs.
11742    pub fn send(self) -> Result<(), fidl::Error> {
11743        let _result = self.send_raw();
11744        if _result.is_err() {
11745            self.control_handle.shutdown();
11746        }
11747        self.drop_without_shutdown();
11748        _result
11749    }
11750
11751    /// Similar to "send" but does not shutdown the channel if an error occurs.
11752    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11753        let _result = self.send_raw();
11754        self.drop_without_shutdown();
11755        _result
11756    }
11757
11758    fn send_raw(&self) -> Result<(), fidl::Error> {
11759        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11760            (),
11761            self.tx_id,
11762            0x2f509d3523e9562d,
11763            fidl::encoding::DynamicFlags::empty(),
11764        )
11765    }
11766}
11767
11768#[must_use = "FIDL methods require a response to be sent"]
11769#[derive(Debug)]
11770pub struct ProfileProviderUnregisterMemoryRangeResponder {
11771    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11772    tx_id: u32,
11773}
11774
11775/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11776/// if the responder is dropped without sending a response, so that the client
11777/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11778impl std::ops::Drop for ProfileProviderUnregisterMemoryRangeResponder {
11779    fn drop(&mut self) {
11780        self.control_handle.shutdown();
11781        // Safety: drops once, never accessed again
11782        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11783    }
11784}
11785
11786impl fidl::endpoints::Responder for ProfileProviderUnregisterMemoryRangeResponder {
11787    type ControlHandle = ProfileProviderControlHandle;
11788
11789    fn control_handle(&self) -> &ProfileProviderControlHandle {
11790        &self.control_handle
11791    }
11792
11793    fn drop_without_shutdown(mut self) {
11794        // Safety: drops once, never accessed again due to mem::forget
11795        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11796        // Prevent Drop from running (which would shut down the channel)
11797        std::mem::forget(self);
11798    }
11799}
11800
11801impl ProfileProviderUnregisterMemoryRangeResponder {
11802    /// Sends a response to the FIDL transaction.
11803    ///
11804    /// Sets the channel to shutdown if an error occurs.
11805    pub fn send(self) -> Result<(), fidl::Error> {
11806        let _result = self.send_raw();
11807        if _result.is_err() {
11808            self.control_handle.shutdown();
11809        }
11810        self.drop_without_shutdown();
11811        _result
11812    }
11813
11814    /// Similar to "send" but does not shutdown the channel if an error occurs.
11815    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11816        let _result = self.send_raw();
11817        self.drop_without_shutdown();
11818        _result
11819    }
11820
11821    fn send_raw(&self) -> Result<(), fidl::Error> {
11822        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11823            (),
11824            self.tx_id,
11825            0x2dc313d6aa81ad27,
11826            fidl::encoding::DynamicFlags::empty(),
11827        )
11828    }
11829}
11830
11831#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
11832pub struct SessionAudioConsumerFactoryMarker;
11833
11834impl fidl::endpoints::ProtocolMarker for SessionAudioConsumerFactoryMarker {
11835    type Proxy = SessionAudioConsumerFactoryProxy;
11836    type RequestStream = SessionAudioConsumerFactoryRequestStream;
11837    #[cfg(target_os = "fuchsia")]
11838    type SynchronousProxy = SessionAudioConsumerFactorySynchronousProxy;
11839
11840    const DEBUG_NAME: &'static str = "fuchsia.media.SessionAudioConsumerFactory";
11841}
11842impl fidl::endpoints::DiscoverableProtocolMarker for SessionAudioConsumerFactoryMarker {}
11843
11844pub trait SessionAudioConsumerFactoryProxyInterface: Send + Sync {
11845    fn r#create_audio_consumer(
11846        &self,
11847        session_id: u64,
11848        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
11849    ) -> Result<(), fidl::Error>;
11850}
11851#[derive(Debug)]
11852#[cfg(target_os = "fuchsia")]
11853pub struct SessionAudioConsumerFactorySynchronousProxy {
11854    client: fidl::client::sync::Client,
11855}
11856
11857#[cfg(target_os = "fuchsia")]
11858impl fidl::endpoints::SynchronousProxy for SessionAudioConsumerFactorySynchronousProxy {
11859    type Proxy = SessionAudioConsumerFactoryProxy;
11860    type Protocol = SessionAudioConsumerFactoryMarker;
11861
11862    fn from_channel(inner: fidl::Channel) -> Self {
11863        Self::new(inner)
11864    }
11865
11866    fn into_channel(self) -> fidl::Channel {
11867        self.client.into_channel()
11868    }
11869
11870    fn as_channel(&self) -> &fidl::Channel {
11871        self.client.as_channel()
11872    }
11873}
11874
11875#[cfg(target_os = "fuchsia")]
11876impl SessionAudioConsumerFactorySynchronousProxy {
11877    pub fn new(channel: fidl::Channel) -> Self {
11878        let protocol_name =
11879            <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
11880        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
11881    }
11882
11883    pub fn into_channel(self) -> fidl::Channel {
11884        self.client.into_channel()
11885    }
11886
11887    /// Waits until an event arrives and returns it. It is safe for other
11888    /// threads to make concurrent requests while waiting for an event.
11889    pub fn wait_for_event(
11890        &self,
11891        deadline: zx::MonotonicInstant,
11892    ) -> Result<SessionAudioConsumerFactoryEvent, fidl::Error> {
11893        SessionAudioConsumerFactoryEvent::decode(self.client.wait_for_event(deadline)?)
11894    }
11895
11896    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
11897    /// to a particular session. `session_id` is the identifier of the media session
11898    /// for which audio is to be rendered.
11899    pub fn r#create_audio_consumer(
11900        &self,
11901        mut session_id: u64,
11902        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
11903    ) -> Result<(), fidl::Error> {
11904        self.client.send::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
11905            (session_id, audio_consumer_request),
11906            0x6fab96f988e7d7fb,
11907            fidl::encoding::DynamicFlags::empty(),
11908        )
11909    }
11910}
11911
11912#[cfg(target_os = "fuchsia")]
11913impl From<SessionAudioConsumerFactorySynchronousProxy> for zx::Handle {
11914    fn from(value: SessionAudioConsumerFactorySynchronousProxy) -> Self {
11915        value.into_channel().into()
11916    }
11917}
11918
11919#[cfg(target_os = "fuchsia")]
11920impl From<fidl::Channel> for SessionAudioConsumerFactorySynchronousProxy {
11921    fn from(value: fidl::Channel) -> Self {
11922        Self::new(value)
11923    }
11924}
11925
11926#[cfg(target_os = "fuchsia")]
11927impl fidl::endpoints::FromClient for SessionAudioConsumerFactorySynchronousProxy {
11928    type Protocol = SessionAudioConsumerFactoryMarker;
11929
11930    fn from_client(value: fidl::endpoints::ClientEnd<SessionAudioConsumerFactoryMarker>) -> Self {
11931        Self::new(value.into_channel())
11932    }
11933}
11934
11935#[derive(Debug, Clone)]
11936pub struct SessionAudioConsumerFactoryProxy {
11937    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
11938}
11939
11940impl fidl::endpoints::Proxy for SessionAudioConsumerFactoryProxy {
11941    type Protocol = SessionAudioConsumerFactoryMarker;
11942
11943    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
11944        Self::new(inner)
11945    }
11946
11947    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
11948        self.client.into_channel().map_err(|client| Self { client })
11949    }
11950
11951    fn as_channel(&self) -> &::fidl::AsyncChannel {
11952        self.client.as_channel()
11953    }
11954}
11955
11956impl SessionAudioConsumerFactoryProxy {
11957    /// Create a new Proxy for fuchsia.media/SessionAudioConsumerFactory.
11958    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
11959        let protocol_name =
11960            <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
11961        Self { client: fidl::client::Client::new(channel, protocol_name) }
11962    }
11963
11964    /// Get a Stream of events from the remote end of the protocol.
11965    ///
11966    /// # Panics
11967    ///
11968    /// Panics if the event stream was already taken.
11969    pub fn take_event_stream(&self) -> SessionAudioConsumerFactoryEventStream {
11970        SessionAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
11971    }
11972
11973    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
11974    /// to a particular session. `session_id` is the identifier of the media session
11975    /// for which audio is to be rendered.
11976    pub fn r#create_audio_consumer(
11977        &self,
11978        mut session_id: u64,
11979        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
11980    ) -> Result<(), fidl::Error> {
11981        SessionAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
11982            self,
11983            session_id,
11984            audio_consumer_request,
11985        )
11986    }
11987}
11988
11989impl SessionAudioConsumerFactoryProxyInterface for SessionAudioConsumerFactoryProxy {
11990    fn r#create_audio_consumer(
11991        &self,
11992        mut session_id: u64,
11993        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
11994    ) -> Result<(), fidl::Error> {
11995        self.client.send::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
11996            (session_id, audio_consumer_request),
11997            0x6fab96f988e7d7fb,
11998            fidl::encoding::DynamicFlags::empty(),
11999        )
12000    }
12001}
12002
12003pub struct SessionAudioConsumerFactoryEventStream {
12004    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
12005}
12006
12007impl std::marker::Unpin for SessionAudioConsumerFactoryEventStream {}
12008
12009impl futures::stream::FusedStream for SessionAudioConsumerFactoryEventStream {
12010    fn is_terminated(&self) -> bool {
12011        self.event_receiver.is_terminated()
12012    }
12013}
12014
12015impl futures::Stream for SessionAudioConsumerFactoryEventStream {
12016    type Item = Result<SessionAudioConsumerFactoryEvent, fidl::Error>;
12017
12018    fn poll_next(
12019        mut self: std::pin::Pin<&mut Self>,
12020        cx: &mut std::task::Context<'_>,
12021    ) -> std::task::Poll<Option<Self::Item>> {
12022        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
12023            &mut self.event_receiver,
12024            cx
12025        )?) {
12026            Some(buf) => {
12027                std::task::Poll::Ready(Some(SessionAudioConsumerFactoryEvent::decode(buf)))
12028            }
12029            None => std::task::Poll::Ready(None),
12030        }
12031    }
12032}
12033
12034#[derive(Debug)]
12035pub enum SessionAudioConsumerFactoryEvent {}
12036
12037impl SessionAudioConsumerFactoryEvent {
12038    /// Decodes a message buffer as a [`SessionAudioConsumerFactoryEvent`].
12039    fn decode(
12040        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
12041    ) -> Result<SessionAudioConsumerFactoryEvent, fidl::Error> {
12042        let (bytes, _handles) = buf.split_mut();
12043        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12044        debug_assert_eq!(tx_header.tx_id, 0);
12045        match tx_header.ordinal {
12046            _ => Err(fidl::Error::UnknownOrdinal {
12047                ordinal: tx_header.ordinal,
12048                protocol_name: <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12049            })
12050        }
12051    }
12052}
12053
12054/// A Stream of incoming requests for fuchsia.media/SessionAudioConsumerFactory.
12055pub struct SessionAudioConsumerFactoryRequestStream {
12056    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12057    is_terminated: bool,
12058}
12059
12060impl std::marker::Unpin for SessionAudioConsumerFactoryRequestStream {}
12061
12062impl futures::stream::FusedStream for SessionAudioConsumerFactoryRequestStream {
12063    fn is_terminated(&self) -> bool {
12064        self.is_terminated
12065    }
12066}
12067
12068impl fidl::endpoints::RequestStream for SessionAudioConsumerFactoryRequestStream {
12069    type Protocol = SessionAudioConsumerFactoryMarker;
12070    type ControlHandle = SessionAudioConsumerFactoryControlHandle;
12071
12072    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
12073        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
12074    }
12075
12076    fn control_handle(&self) -> Self::ControlHandle {
12077        SessionAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
12078    }
12079
12080    fn into_inner(
12081        self,
12082    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
12083    {
12084        (self.inner, self.is_terminated)
12085    }
12086
12087    fn from_inner(
12088        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12089        is_terminated: bool,
12090    ) -> Self {
12091        Self { inner, is_terminated }
12092    }
12093}
12094
12095impl futures::Stream for SessionAudioConsumerFactoryRequestStream {
12096    type Item = Result<SessionAudioConsumerFactoryRequest, fidl::Error>;
12097
12098    fn poll_next(
12099        mut self: std::pin::Pin<&mut Self>,
12100        cx: &mut std::task::Context<'_>,
12101    ) -> std::task::Poll<Option<Self::Item>> {
12102        let this = &mut *self;
12103        if this.inner.check_shutdown(cx) {
12104            this.is_terminated = true;
12105            return std::task::Poll::Ready(None);
12106        }
12107        if this.is_terminated {
12108            panic!("polled SessionAudioConsumerFactoryRequestStream after completion");
12109        }
12110        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
12111            |bytes, handles| {
12112                match this.inner.channel().read_etc(cx, bytes, handles) {
12113                    std::task::Poll::Ready(Ok(())) => {}
12114                    std::task::Poll::Pending => return std::task::Poll::Pending,
12115                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
12116                        this.is_terminated = true;
12117                        return std::task::Poll::Ready(None);
12118                    }
12119                    std::task::Poll::Ready(Err(e)) => {
12120                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
12121                            e.into(),
12122                        ))))
12123                    }
12124                }
12125
12126                // A message has been received from the channel
12127                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12128
12129                std::task::Poll::Ready(Some(match header.ordinal {
12130                0x6fab96f988e7d7fb => {
12131                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12132                    let mut req = fidl::new_empty!(SessionAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
12133                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
12134                    let control_handle = SessionAudioConsumerFactoryControlHandle {
12135                        inner: this.inner.clone(),
12136                    };
12137                    Ok(SessionAudioConsumerFactoryRequest::CreateAudioConsumer {session_id: req.session_id,
12138audio_consumer_request: req.audio_consumer_request,
12139
12140                        control_handle,
12141                    })
12142                }
12143                _ => Err(fidl::Error::UnknownOrdinal {
12144                    ordinal: header.ordinal,
12145                    protocol_name: <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12146                }),
12147            }))
12148            },
12149        )
12150    }
12151}
12152
12153/// Interface for creating audio consumers bound to a session.
12154#[derive(Debug)]
12155pub enum SessionAudioConsumerFactoryRequest {
12156    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
12157    /// to a particular session. `session_id` is the identifier of the media session
12158    /// for which audio is to be rendered.
12159    CreateAudioConsumer {
12160        session_id: u64,
12161        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12162        control_handle: SessionAudioConsumerFactoryControlHandle,
12163    },
12164}
12165
12166impl SessionAudioConsumerFactoryRequest {
12167    #[allow(irrefutable_let_patterns)]
12168    pub fn into_create_audio_consumer(
12169        self,
12170    ) -> Option<(
12171        u64,
12172        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12173        SessionAudioConsumerFactoryControlHandle,
12174    )> {
12175        if let SessionAudioConsumerFactoryRequest::CreateAudioConsumer {
12176            session_id,
12177            audio_consumer_request,
12178            control_handle,
12179        } = self
12180        {
12181            Some((session_id, audio_consumer_request, control_handle))
12182        } else {
12183            None
12184        }
12185    }
12186
12187    /// Name of the method defined in FIDL
12188    pub fn method_name(&self) -> &'static str {
12189        match *self {
12190            SessionAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
12191                "create_audio_consumer"
12192            }
12193        }
12194    }
12195}
12196
12197#[derive(Debug, Clone)]
12198pub struct SessionAudioConsumerFactoryControlHandle {
12199    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12200}
12201
12202impl fidl::endpoints::ControlHandle for SessionAudioConsumerFactoryControlHandle {
12203    fn shutdown(&self) {
12204        self.inner.shutdown()
12205    }
12206    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
12207        self.inner.shutdown_with_epitaph(status)
12208    }
12209
12210    fn is_closed(&self) -> bool {
12211        self.inner.channel().is_closed()
12212    }
12213    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
12214        self.inner.channel().on_closed()
12215    }
12216
12217    #[cfg(target_os = "fuchsia")]
12218    fn signal_peer(
12219        &self,
12220        clear_mask: zx::Signals,
12221        set_mask: zx::Signals,
12222    ) -> Result<(), zx_status::Status> {
12223        use fidl::Peered;
12224        self.inner.channel().signal_peer(clear_mask, set_mask)
12225    }
12226}
12227
12228impl SessionAudioConsumerFactoryControlHandle {}
12229
12230#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
12231pub struct SimpleStreamSinkMarker;
12232
12233impl fidl::endpoints::ProtocolMarker for SimpleStreamSinkMarker {
12234    type Proxy = SimpleStreamSinkProxy;
12235    type RequestStream = SimpleStreamSinkRequestStream;
12236    #[cfg(target_os = "fuchsia")]
12237    type SynchronousProxy = SimpleStreamSinkSynchronousProxy;
12238
12239    const DEBUG_NAME: &'static str = "(anonymous) SimpleStreamSink";
12240}
12241
12242pub trait SimpleStreamSinkProxyInterface: Send + Sync {
12243    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
12244    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
12245    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
12246    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
12247    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
12248    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
12249    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
12250    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
12251    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
12252}
12253#[derive(Debug)]
12254#[cfg(target_os = "fuchsia")]
12255pub struct SimpleStreamSinkSynchronousProxy {
12256    client: fidl::client::sync::Client,
12257}
12258
12259#[cfg(target_os = "fuchsia")]
12260impl fidl::endpoints::SynchronousProxy for SimpleStreamSinkSynchronousProxy {
12261    type Proxy = SimpleStreamSinkProxy;
12262    type Protocol = SimpleStreamSinkMarker;
12263
12264    fn from_channel(inner: fidl::Channel) -> Self {
12265        Self::new(inner)
12266    }
12267
12268    fn into_channel(self) -> fidl::Channel {
12269        self.client.into_channel()
12270    }
12271
12272    fn as_channel(&self) -> &fidl::Channel {
12273        self.client.as_channel()
12274    }
12275}
12276
12277#[cfg(target_os = "fuchsia")]
12278impl SimpleStreamSinkSynchronousProxy {
12279    pub fn new(channel: fidl::Channel) -> Self {
12280        let protocol_name = <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
12281        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
12282    }
12283
12284    pub fn into_channel(self) -> fidl::Channel {
12285        self.client.into_channel()
12286    }
12287
12288    /// Waits until an event arrives and returns it. It is safe for other
12289    /// threads to make concurrent requests while waiting for an event.
12290    pub fn wait_for_event(
12291        &self,
12292        deadline: zx::MonotonicInstant,
12293    ) -> Result<SimpleStreamSinkEvent, fidl::Error> {
12294        SimpleStreamSinkEvent::decode(self.client.wait_for_event(deadline)?)
12295    }
12296
12297    /// Adds a payload buffer to the current buffer set associated with the
12298    /// connection. A `StreamPacket` struct reference a payload buffer in the
12299    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
12300    ///
12301    /// A buffer with ID `id` must not be in the current set when this method is
12302    /// invoked, otherwise the service will close the connection.
12303    pub fn r#add_payload_buffer(
12304        &self,
12305        mut id: u32,
12306        mut payload_buffer: fidl::Vmo,
12307    ) -> Result<(), fidl::Error> {
12308        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
12309            (id, payload_buffer),
12310            0x3b3a37fc34fe5b56,
12311            fidl::encoding::DynamicFlags::empty(),
12312        )
12313    }
12314
12315    /// Removes a payload buffer from the current buffer set associated with the
12316    /// connection.
12317    ///
12318    /// A buffer with ID `id` must exist in the current set when this method is
12319    /// invoked, otherwise the service will will close the connection.
12320    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
12321        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
12322            (id,),
12323            0x5d1e4f74c3658262,
12324            fidl::encoding::DynamicFlags::empty(),
12325        )
12326    }
12327
12328    /// Sends a packet to the service. The response is sent when the service is
12329    /// done with the associated payload memory.
12330    ///
12331    /// `packet` must be valid for the current buffer set, otherwise the service
12332    /// will close the connection.
12333    pub fn r#send_packet(
12334        &self,
12335        mut packet: &StreamPacket,
12336        ___deadline: zx::MonotonicInstant,
12337    ) -> Result<(), fidl::Error> {
12338        let _response =
12339            self.client.send_query::<StreamSinkSendPacketRequest, fidl::encoding::EmptyPayload>(
12340                (packet,),
12341                0x67cddd607442775f,
12342                fidl::encoding::DynamicFlags::empty(),
12343                ___deadline,
12344            )?;
12345        Ok(_response)
12346    }
12347
12348    /// Sends a packet to the service. This interface doesn't define how the
12349    /// client knows when the sink is done with the associated payload memory.
12350    /// The inheriting interface must define that.
12351    ///
12352    /// `packet` must be valid for the current buffer set, otherwise the service
12353    /// will close the connection.
12354    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12355        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
12356            (packet,),
12357            0x8d9b8b413ceba9d,
12358            fidl::encoding::DynamicFlags::empty(),
12359        )
12360    }
12361
12362    /// Indicates the stream has ended. The precise semantics of this method are
12363    /// determined by the inheriting interface.
12364    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12365        self.client.send::<fidl::encoding::EmptyPayload>(
12366            (),
12367            0x6180fd6f7e793b71,
12368            fidl::encoding::DynamicFlags::empty(),
12369        )
12370    }
12371
12372    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12373    /// and not yet released. The response is sent after all packets have been
12374    /// released.
12375    pub fn r#discard_all_packets(
12376        &self,
12377        ___deadline: zx::MonotonicInstant,
12378    ) -> Result<(), fidl::Error> {
12379        let _response =
12380            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
12381                (),
12382                0x6f4dad7af2917665,
12383                fidl::encoding::DynamicFlags::empty(),
12384                ___deadline,
12385            )?;
12386        Ok(_response)
12387    }
12388
12389    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12390    /// and not yet released.
12391    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12392        self.client.send::<fidl::encoding::EmptyPayload>(
12393            (),
12394            0x50d36d0d23081bc4,
12395            fidl::encoding::DynamicFlags::empty(),
12396        )
12397    }
12398}
12399
12400#[cfg(target_os = "fuchsia")]
12401impl From<SimpleStreamSinkSynchronousProxy> for zx::Handle {
12402    fn from(value: SimpleStreamSinkSynchronousProxy) -> Self {
12403        value.into_channel().into()
12404    }
12405}
12406
12407#[cfg(target_os = "fuchsia")]
12408impl From<fidl::Channel> for SimpleStreamSinkSynchronousProxy {
12409    fn from(value: fidl::Channel) -> Self {
12410        Self::new(value)
12411    }
12412}
12413
12414#[cfg(target_os = "fuchsia")]
12415impl fidl::endpoints::FromClient for SimpleStreamSinkSynchronousProxy {
12416    type Protocol = SimpleStreamSinkMarker;
12417
12418    fn from_client(value: fidl::endpoints::ClientEnd<SimpleStreamSinkMarker>) -> Self {
12419        Self::new(value.into_channel())
12420    }
12421}
12422
12423#[derive(Debug, Clone)]
12424pub struct SimpleStreamSinkProxy {
12425    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
12426}
12427
12428impl fidl::endpoints::Proxy for SimpleStreamSinkProxy {
12429    type Protocol = SimpleStreamSinkMarker;
12430
12431    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
12432        Self::new(inner)
12433    }
12434
12435    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
12436        self.client.into_channel().map_err(|client| Self { client })
12437    }
12438
12439    fn as_channel(&self) -> &::fidl::AsyncChannel {
12440        self.client.as_channel()
12441    }
12442}
12443
12444impl SimpleStreamSinkProxy {
12445    /// Create a new Proxy for fuchsia.media/SimpleStreamSink.
12446    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
12447        let protocol_name = <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
12448        Self { client: fidl::client::Client::new(channel, protocol_name) }
12449    }
12450
12451    /// Get a Stream of events from the remote end of the protocol.
12452    ///
12453    /// # Panics
12454    ///
12455    /// Panics if the event stream was already taken.
12456    pub fn take_event_stream(&self) -> SimpleStreamSinkEventStream {
12457        SimpleStreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
12458    }
12459
12460    /// Adds a payload buffer to the current buffer set associated with the
12461    /// connection. A `StreamPacket` struct reference a payload buffer in the
12462    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
12463    ///
12464    /// A buffer with ID `id` must not be in the current set when this method is
12465    /// invoked, otherwise the service will close the connection.
12466    pub fn r#add_payload_buffer(
12467        &self,
12468        mut id: u32,
12469        mut payload_buffer: fidl::Vmo,
12470    ) -> Result<(), fidl::Error> {
12471        SimpleStreamSinkProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
12472    }
12473
12474    /// Removes a payload buffer from the current buffer set associated with the
12475    /// connection.
12476    ///
12477    /// A buffer with ID `id` must exist in the current set when this method is
12478    /// invoked, otherwise the service will will close the connection.
12479    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
12480        SimpleStreamSinkProxyInterface::r#remove_payload_buffer(self, id)
12481    }
12482
12483    /// Sends a packet to the service. The response is sent when the service is
12484    /// done with the associated payload memory.
12485    ///
12486    /// `packet` must be valid for the current buffer set, otherwise the service
12487    /// will close the connection.
12488    pub fn r#send_packet(
12489        &self,
12490        mut packet: &StreamPacket,
12491    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
12492        SimpleStreamSinkProxyInterface::r#send_packet(self, packet)
12493    }
12494
12495    /// Sends a packet to the service. This interface doesn't define how the
12496    /// client knows when the sink is done with the associated payload memory.
12497    /// The inheriting interface must define that.
12498    ///
12499    /// `packet` must be valid for the current buffer set, otherwise the service
12500    /// will close the connection.
12501    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12502        SimpleStreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
12503    }
12504
12505    /// Indicates the stream has ended. The precise semantics of this method are
12506    /// determined by the inheriting interface.
12507    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12508        SimpleStreamSinkProxyInterface::r#end_of_stream(self)
12509    }
12510
12511    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12512    /// and not yet released. The response is sent after all packets have been
12513    /// released.
12514    pub fn r#discard_all_packets(
12515        &self,
12516    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
12517        SimpleStreamSinkProxyInterface::r#discard_all_packets(self)
12518    }
12519
12520    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12521    /// and not yet released.
12522    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12523        SimpleStreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
12524    }
12525}
12526
12527impl SimpleStreamSinkProxyInterface for SimpleStreamSinkProxy {
12528    fn r#add_payload_buffer(
12529        &self,
12530        mut id: u32,
12531        mut payload_buffer: fidl::Vmo,
12532    ) -> Result<(), fidl::Error> {
12533        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
12534            (id, payload_buffer),
12535            0x3b3a37fc34fe5b56,
12536            fidl::encoding::DynamicFlags::empty(),
12537        )
12538    }
12539
12540    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
12541        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
12542            (id,),
12543            0x5d1e4f74c3658262,
12544            fidl::encoding::DynamicFlags::empty(),
12545        )
12546    }
12547
12548    type SendPacketResponseFut =
12549        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
12550    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
12551        fn _decode(
12552            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12553        ) -> Result<(), fidl::Error> {
12554            let _response = fidl::client::decode_transaction_body::<
12555                fidl::encoding::EmptyPayload,
12556                fidl::encoding::DefaultFuchsiaResourceDialect,
12557                0x67cddd607442775f,
12558            >(_buf?)?;
12559            Ok(_response)
12560        }
12561        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
12562            (packet,),
12563            0x67cddd607442775f,
12564            fidl::encoding::DynamicFlags::empty(),
12565            _decode,
12566        )
12567    }
12568
12569    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12570        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
12571            (packet,),
12572            0x8d9b8b413ceba9d,
12573            fidl::encoding::DynamicFlags::empty(),
12574        )
12575    }
12576
12577    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12578        self.client.send::<fidl::encoding::EmptyPayload>(
12579            (),
12580            0x6180fd6f7e793b71,
12581            fidl::encoding::DynamicFlags::empty(),
12582        )
12583    }
12584
12585    type DiscardAllPacketsResponseFut =
12586        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
12587    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
12588        fn _decode(
12589            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12590        ) -> Result<(), fidl::Error> {
12591            let _response = fidl::client::decode_transaction_body::<
12592                fidl::encoding::EmptyPayload,
12593                fidl::encoding::DefaultFuchsiaResourceDialect,
12594                0x6f4dad7af2917665,
12595            >(_buf?)?;
12596            Ok(_response)
12597        }
12598        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
12599            (),
12600            0x6f4dad7af2917665,
12601            fidl::encoding::DynamicFlags::empty(),
12602            _decode,
12603        )
12604    }
12605
12606    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12607        self.client.send::<fidl::encoding::EmptyPayload>(
12608            (),
12609            0x50d36d0d23081bc4,
12610            fidl::encoding::DynamicFlags::empty(),
12611        )
12612    }
12613}
12614
12615pub struct SimpleStreamSinkEventStream {
12616    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
12617}
12618
12619impl std::marker::Unpin for SimpleStreamSinkEventStream {}
12620
12621impl futures::stream::FusedStream for SimpleStreamSinkEventStream {
12622    fn is_terminated(&self) -> bool {
12623        self.event_receiver.is_terminated()
12624    }
12625}
12626
12627impl futures::Stream for SimpleStreamSinkEventStream {
12628    type Item = Result<SimpleStreamSinkEvent, fidl::Error>;
12629
12630    fn poll_next(
12631        mut self: std::pin::Pin<&mut Self>,
12632        cx: &mut std::task::Context<'_>,
12633    ) -> std::task::Poll<Option<Self::Item>> {
12634        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
12635            &mut self.event_receiver,
12636            cx
12637        )?) {
12638            Some(buf) => std::task::Poll::Ready(Some(SimpleStreamSinkEvent::decode(buf))),
12639            None => std::task::Poll::Ready(None),
12640        }
12641    }
12642}
12643
12644#[derive(Debug)]
12645pub enum SimpleStreamSinkEvent {}
12646
12647impl SimpleStreamSinkEvent {
12648    /// Decodes a message buffer as a [`SimpleStreamSinkEvent`].
12649    fn decode(
12650        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
12651    ) -> Result<SimpleStreamSinkEvent, fidl::Error> {
12652        let (bytes, _handles) = buf.split_mut();
12653        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12654        debug_assert_eq!(tx_header.tx_id, 0);
12655        match tx_header.ordinal {
12656            _ => Err(fidl::Error::UnknownOrdinal {
12657                ordinal: tx_header.ordinal,
12658                protocol_name:
12659                    <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12660            }),
12661        }
12662    }
12663}
12664
12665/// A Stream of incoming requests for fuchsia.media/SimpleStreamSink.
12666pub struct SimpleStreamSinkRequestStream {
12667    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12668    is_terminated: bool,
12669}
12670
12671impl std::marker::Unpin for SimpleStreamSinkRequestStream {}
12672
12673impl futures::stream::FusedStream for SimpleStreamSinkRequestStream {
12674    fn is_terminated(&self) -> bool {
12675        self.is_terminated
12676    }
12677}
12678
12679impl fidl::endpoints::RequestStream for SimpleStreamSinkRequestStream {
12680    type Protocol = SimpleStreamSinkMarker;
12681    type ControlHandle = SimpleStreamSinkControlHandle;
12682
12683    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
12684        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
12685    }
12686
12687    fn control_handle(&self) -> Self::ControlHandle {
12688        SimpleStreamSinkControlHandle { inner: self.inner.clone() }
12689    }
12690
12691    fn into_inner(
12692        self,
12693    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
12694    {
12695        (self.inner, self.is_terminated)
12696    }
12697
12698    fn from_inner(
12699        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12700        is_terminated: bool,
12701    ) -> Self {
12702        Self { inner, is_terminated }
12703    }
12704}
12705
12706impl futures::Stream for SimpleStreamSinkRequestStream {
12707    type Item = Result<SimpleStreamSinkRequest, fidl::Error>;
12708
12709    fn poll_next(
12710        mut self: std::pin::Pin<&mut Self>,
12711        cx: &mut std::task::Context<'_>,
12712    ) -> std::task::Poll<Option<Self::Item>> {
12713        let this = &mut *self;
12714        if this.inner.check_shutdown(cx) {
12715            this.is_terminated = true;
12716            return std::task::Poll::Ready(None);
12717        }
12718        if this.is_terminated {
12719            panic!("polled SimpleStreamSinkRequestStream after completion");
12720        }
12721        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
12722            |bytes, handles| {
12723                match this.inner.channel().read_etc(cx, bytes, handles) {
12724                    std::task::Poll::Ready(Ok(())) => {}
12725                    std::task::Poll::Pending => return std::task::Poll::Pending,
12726                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
12727                        this.is_terminated = true;
12728                        return std::task::Poll::Ready(None);
12729                    }
12730                    std::task::Poll::Ready(Err(e)) => {
12731                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
12732                            e.into(),
12733                        ))))
12734                    }
12735                }
12736
12737                // A message has been received from the channel
12738                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12739
12740                std::task::Poll::Ready(Some(match header.ordinal {
12741                    0x3b3a37fc34fe5b56 => {
12742                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12743                        let mut req = fidl::new_empty!(
12744                            StreamBufferSetAddPayloadBufferRequest,
12745                            fidl::encoding::DefaultFuchsiaResourceDialect
12746                        );
12747                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
12748                        let control_handle =
12749                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12750                        Ok(SimpleStreamSinkRequest::AddPayloadBuffer {
12751                            id: req.id,
12752                            payload_buffer: req.payload_buffer,
12753
12754                            control_handle,
12755                        })
12756                    }
12757                    0x5d1e4f74c3658262 => {
12758                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12759                        let mut req = fidl::new_empty!(
12760                            StreamBufferSetRemovePayloadBufferRequest,
12761                            fidl::encoding::DefaultFuchsiaResourceDialect
12762                        );
12763                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
12764                        let control_handle =
12765                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12766                        Ok(SimpleStreamSinkRequest::RemovePayloadBuffer {
12767                            id: req.id,
12768
12769                            control_handle,
12770                        })
12771                    }
12772                    0x67cddd607442775f => {
12773                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12774                        let mut req = fidl::new_empty!(
12775                            StreamSinkSendPacketRequest,
12776                            fidl::encoding::DefaultFuchsiaResourceDialect
12777                        );
12778                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
12779                        let control_handle =
12780                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12781                        Ok(SimpleStreamSinkRequest::SendPacket {
12782                            packet: req.packet,
12783
12784                            responder: SimpleStreamSinkSendPacketResponder {
12785                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12786                                tx_id: header.tx_id,
12787                            },
12788                        })
12789                    }
12790                    0x8d9b8b413ceba9d => {
12791                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12792                        let mut req = fidl::new_empty!(
12793                            StreamSinkSendPacketNoReplyRequest,
12794                            fidl::encoding::DefaultFuchsiaResourceDialect
12795                        );
12796                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
12797                        let control_handle =
12798                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12799                        Ok(SimpleStreamSinkRequest::SendPacketNoReply {
12800                            packet: req.packet,
12801
12802                            control_handle,
12803                        })
12804                    }
12805                    0x6180fd6f7e793b71 => {
12806                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12807                        let mut req = fidl::new_empty!(
12808                            fidl::encoding::EmptyPayload,
12809                            fidl::encoding::DefaultFuchsiaResourceDialect
12810                        );
12811                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12812                        let control_handle =
12813                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12814                        Ok(SimpleStreamSinkRequest::EndOfStream { control_handle })
12815                    }
12816                    0x6f4dad7af2917665 => {
12817                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12818                        let mut req = fidl::new_empty!(
12819                            fidl::encoding::EmptyPayload,
12820                            fidl::encoding::DefaultFuchsiaResourceDialect
12821                        );
12822                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12823                        let control_handle =
12824                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12825                        Ok(SimpleStreamSinkRequest::DiscardAllPackets {
12826                            responder: SimpleStreamSinkDiscardAllPacketsResponder {
12827                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12828                                tx_id: header.tx_id,
12829                            },
12830                        })
12831                    }
12832                    0x50d36d0d23081bc4 => {
12833                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12834                        let mut req = fidl::new_empty!(
12835                            fidl::encoding::EmptyPayload,
12836                            fidl::encoding::DefaultFuchsiaResourceDialect
12837                        );
12838                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12839                        let control_handle =
12840                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12841                        Ok(SimpleStreamSinkRequest::DiscardAllPacketsNoReply { control_handle })
12842                    }
12843                    _ => Err(fidl::Error::UnknownOrdinal {
12844                        ordinal: header.ordinal,
12845                        protocol_name:
12846                            <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12847                    }),
12848                }))
12849            },
12850        )
12851    }
12852}
12853
12854/// A StreamSink that uses StreamBufferSet for buffer management.
12855#[derive(Debug)]
12856pub enum SimpleStreamSinkRequest {
12857    /// Adds a payload buffer to the current buffer set associated with the
12858    /// connection. A `StreamPacket` struct reference a payload buffer in the
12859    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
12860    ///
12861    /// A buffer with ID `id` must not be in the current set when this method is
12862    /// invoked, otherwise the service will close the connection.
12863    AddPayloadBuffer {
12864        id: u32,
12865        payload_buffer: fidl::Vmo,
12866        control_handle: SimpleStreamSinkControlHandle,
12867    },
12868    /// Removes a payload buffer from the current buffer set associated with the
12869    /// connection.
12870    ///
12871    /// A buffer with ID `id` must exist in the current set when this method is
12872    /// invoked, otherwise the service will will close the connection.
12873    RemovePayloadBuffer { id: u32, control_handle: SimpleStreamSinkControlHandle },
12874    /// Sends a packet to the service. The response is sent when the service is
12875    /// done with the associated payload memory.
12876    ///
12877    /// `packet` must be valid for the current buffer set, otherwise the service
12878    /// will close the connection.
12879    SendPacket { packet: StreamPacket, responder: SimpleStreamSinkSendPacketResponder },
12880    /// Sends a packet to the service. This interface doesn't define how the
12881    /// client knows when the sink is done with the associated payload memory.
12882    /// The inheriting interface must define that.
12883    ///
12884    /// `packet` must be valid for the current buffer set, otherwise the service
12885    /// will close the connection.
12886    SendPacketNoReply { packet: StreamPacket, control_handle: SimpleStreamSinkControlHandle },
12887    /// Indicates the stream has ended. The precise semantics of this method are
12888    /// determined by the inheriting interface.
12889    EndOfStream { control_handle: SimpleStreamSinkControlHandle },
12890    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12891    /// and not yet released. The response is sent after all packets have been
12892    /// released.
12893    DiscardAllPackets { responder: SimpleStreamSinkDiscardAllPacketsResponder },
12894    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12895    /// and not yet released.
12896    DiscardAllPacketsNoReply { control_handle: SimpleStreamSinkControlHandle },
12897}
12898
12899impl SimpleStreamSinkRequest {
12900    #[allow(irrefutable_let_patterns)]
12901    pub fn into_add_payload_buffer(
12902        self,
12903    ) -> Option<(u32, fidl::Vmo, SimpleStreamSinkControlHandle)> {
12904        if let SimpleStreamSinkRequest::AddPayloadBuffer { id, payload_buffer, control_handle } =
12905            self
12906        {
12907            Some((id, payload_buffer, control_handle))
12908        } else {
12909            None
12910        }
12911    }
12912
12913    #[allow(irrefutable_let_patterns)]
12914    pub fn into_remove_payload_buffer(self) -> Option<(u32, SimpleStreamSinkControlHandle)> {
12915        if let SimpleStreamSinkRequest::RemovePayloadBuffer { id, control_handle } = self {
12916            Some((id, control_handle))
12917        } else {
12918            None
12919        }
12920    }
12921
12922    #[allow(irrefutable_let_patterns)]
12923    pub fn into_send_packet(self) -> Option<(StreamPacket, SimpleStreamSinkSendPacketResponder)> {
12924        if let SimpleStreamSinkRequest::SendPacket { packet, responder } = self {
12925            Some((packet, responder))
12926        } else {
12927            None
12928        }
12929    }
12930
12931    #[allow(irrefutable_let_patterns)]
12932    pub fn into_send_packet_no_reply(
12933        self,
12934    ) -> Option<(StreamPacket, SimpleStreamSinkControlHandle)> {
12935        if let SimpleStreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
12936            Some((packet, control_handle))
12937        } else {
12938            None
12939        }
12940    }
12941
12942    #[allow(irrefutable_let_patterns)]
12943    pub fn into_end_of_stream(self) -> Option<(SimpleStreamSinkControlHandle)> {
12944        if let SimpleStreamSinkRequest::EndOfStream { control_handle } = self {
12945            Some((control_handle))
12946        } else {
12947            None
12948        }
12949    }
12950
12951    #[allow(irrefutable_let_patterns)]
12952    pub fn into_discard_all_packets(self) -> Option<(SimpleStreamSinkDiscardAllPacketsResponder)> {
12953        if let SimpleStreamSinkRequest::DiscardAllPackets { responder } = self {
12954            Some((responder))
12955        } else {
12956            None
12957        }
12958    }
12959
12960    #[allow(irrefutable_let_patterns)]
12961    pub fn into_discard_all_packets_no_reply(self) -> Option<(SimpleStreamSinkControlHandle)> {
12962        if let SimpleStreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
12963            Some((control_handle))
12964        } else {
12965            None
12966        }
12967    }
12968
12969    /// Name of the method defined in FIDL
12970    pub fn method_name(&self) -> &'static str {
12971        match *self {
12972            SimpleStreamSinkRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
12973            SimpleStreamSinkRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
12974            SimpleStreamSinkRequest::SendPacket { .. } => "send_packet",
12975            SimpleStreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
12976            SimpleStreamSinkRequest::EndOfStream { .. } => "end_of_stream",
12977            SimpleStreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
12978            SimpleStreamSinkRequest::DiscardAllPacketsNoReply { .. } => {
12979                "discard_all_packets_no_reply"
12980            }
12981        }
12982    }
12983}
12984
12985#[derive(Debug, Clone)]
12986pub struct SimpleStreamSinkControlHandle {
12987    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12988}
12989
12990impl fidl::endpoints::ControlHandle for SimpleStreamSinkControlHandle {
12991    fn shutdown(&self) {
12992        self.inner.shutdown()
12993    }
12994    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
12995        self.inner.shutdown_with_epitaph(status)
12996    }
12997
12998    fn is_closed(&self) -> bool {
12999        self.inner.channel().is_closed()
13000    }
13001    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
13002        self.inner.channel().on_closed()
13003    }
13004
13005    #[cfg(target_os = "fuchsia")]
13006    fn signal_peer(
13007        &self,
13008        clear_mask: zx::Signals,
13009        set_mask: zx::Signals,
13010    ) -> Result<(), zx_status::Status> {
13011        use fidl::Peered;
13012        self.inner.channel().signal_peer(clear_mask, set_mask)
13013    }
13014}
13015
13016impl SimpleStreamSinkControlHandle {}
13017
13018#[must_use = "FIDL methods require a response to be sent"]
13019#[derive(Debug)]
13020pub struct SimpleStreamSinkSendPacketResponder {
13021    control_handle: std::mem::ManuallyDrop<SimpleStreamSinkControlHandle>,
13022    tx_id: u32,
13023}
13024
13025/// Set the the channel to be shutdown (see [`SimpleStreamSinkControlHandle::shutdown`])
13026/// if the responder is dropped without sending a response, so that the client
13027/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13028impl std::ops::Drop for SimpleStreamSinkSendPacketResponder {
13029    fn drop(&mut self) {
13030        self.control_handle.shutdown();
13031        // Safety: drops once, never accessed again
13032        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13033    }
13034}
13035
13036impl fidl::endpoints::Responder for SimpleStreamSinkSendPacketResponder {
13037    type ControlHandle = SimpleStreamSinkControlHandle;
13038
13039    fn control_handle(&self) -> &SimpleStreamSinkControlHandle {
13040        &self.control_handle
13041    }
13042
13043    fn drop_without_shutdown(mut self) {
13044        // Safety: drops once, never accessed again due to mem::forget
13045        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13046        // Prevent Drop from running (which would shut down the channel)
13047        std::mem::forget(self);
13048    }
13049}
13050
13051impl SimpleStreamSinkSendPacketResponder {
13052    /// Sends a response to the FIDL transaction.
13053    ///
13054    /// Sets the channel to shutdown if an error occurs.
13055    pub fn send(self) -> Result<(), fidl::Error> {
13056        let _result = self.send_raw();
13057        if _result.is_err() {
13058            self.control_handle.shutdown();
13059        }
13060        self.drop_without_shutdown();
13061        _result
13062    }
13063
13064    /// Similar to "send" but does not shutdown the channel if an error occurs.
13065    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
13066        let _result = self.send_raw();
13067        self.drop_without_shutdown();
13068        _result
13069    }
13070
13071    fn send_raw(&self) -> Result<(), fidl::Error> {
13072        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
13073            (),
13074            self.tx_id,
13075            0x67cddd607442775f,
13076            fidl::encoding::DynamicFlags::empty(),
13077        )
13078    }
13079}
13080
13081#[must_use = "FIDL methods require a response to be sent"]
13082#[derive(Debug)]
13083pub struct SimpleStreamSinkDiscardAllPacketsResponder {
13084    control_handle: std::mem::ManuallyDrop<SimpleStreamSinkControlHandle>,
13085    tx_id: u32,
13086}
13087
13088/// Set the the channel to be shutdown (see [`SimpleStreamSinkControlHandle::shutdown`])
13089/// if the responder is dropped without sending a response, so that the client
13090/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13091impl std::ops::Drop for SimpleStreamSinkDiscardAllPacketsResponder {
13092    fn drop(&mut self) {
13093        self.control_handle.shutdown();
13094        // Safety: drops once, never accessed again
13095        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13096    }
13097}
13098
13099impl fidl::endpoints::Responder for SimpleStreamSinkDiscardAllPacketsResponder {
13100    type ControlHandle = SimpleStreamSinkControlHandle;
13101
13102    fn control_handle(&self) -> &SimpleStreamSinkControlHandle {
13103        &self.control_handle
13104    }
13105
13106    fn drop_without_shutdown(mut self) {
13107        // Safety: drops once, never accessed again due to mem::forget
13108        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13109        // Prevent Drop from running (which would shut down the channel)
13110        std::mem::forget(self);
13111    }
13112}
13113
13114impl SimpleStreamSinkDiscardAllPacketsResponder {
13115    /// Sends a response to the FIDL transaction.
13116    ///
13117    /// Sets the channel to shutdown if an error occurs.
13118    pub fn send(self) -> Result<(), fidl::Error> {
13119        let _result = self.send_raw();
13120        if _result.is_err() {
13121            self.control_handle.shutdown();
13122        }
13123        self.drop_without_shutdown();
13124        _result
13125    }
13126
13127    /// Similar to "send" but does not shutdown the channel if an error occurs.
13128    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
13129        let _result = self.send_raw();
13130        self.drop_without_shutdown();
13131        _result
13132    }
13133
13134    fn send_raw(&self) -> Result<(), fidl::Error> {
13135        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
13136            (),
13137            self.tx_id,
13138            0x6f4dad7af2917665,
13139            fidl::encoding::DynamicFlags::empty(),
13140        )
13141    }
13142}
13143
13144#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
13145pub struct StreamBufferSetMarker;
13146
13147impl fidl::endpoints::ProtocolMarker for StreamBufferSetMarker {
13148    type Proxy = StreamBufferSetProxy;
13149    type RequestStream = StreamBufferSetRequestStream;
13150    #[cfg(target_os = "fuchsia")]
13151    type SynchronousProxy = StreamBufferSetSynchronousProxy;
13152
13153    const DEBUG_NAME: &'static str = "(anonymous) StreamBufferSet";
13154}
13155
13156pub trait StreamBufferSetProxyInterface: Send + Sync {
13157    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
13158    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
13159}
13160#[derive(Debug)]
13161#[cfg(target_os = "fuchsia")]
13162pub struct StreamBufferSetSynchronousProxy {
13163    client: fidl::client::sync::Client,
13164}
13165
13166#[cfg(target_os = "fuchsia")]
13167impl fidl::endpoints::SynchronousProxy for StreamBufferSetSynchronousProxy {
13168    type Proxy = StreamBufferSetProxy;
13169    type Protocol = StreamBufferSetMarker;
13170
13171    fn from_channel(inner: fidl::Channel) -> Self {
13172        Self::new(inner)
13173    }
13174
13175    fn into_channel(self) -> fidl::Channel {
13176        self.client.into_channel()
13177    }
13178
13179    fn as_channel(&self) -> &fidl::Channel {
13180        self.client.as_channel()
13181    }
13182}
13183
13184#[cfg(target_os = "fuchsia")]
13185impl StreamBufferSetSynchronousProxy {
13186    pub fn new(channel: fidl::Channel) -> Self {
13187        let protocol_name = <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
13188        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
13189    }
13190
13191    pub fn into_channel(self) -> fidl::Channel {
13192        self.client.into_channel()
13193    }
13194
13195    /// Waits until an event arrives and returns it. It is safe for other
13196    /// threads to make concurrent requests while waiting for an event.
13197    pub fn wait_for_event(
13198        &self,
13199        deadline: zx::MonotonicInstant,
13200    ) -> Result<StreamBufferSetEvent, fidl::Error> {
13201        StreamBufferSetEvent::decode(self.client.wait_for_event(deadline)?)
13202    }
13203
13204    /// Adds a payload buffer to the current buffer set associated with the
13205    /// connection. A `StreamPacket` struct reference a payload buffer in the
13206    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13207    ///
13208    /// A buffer with ID `id` must not be in the current set when this method is
13209    /// invoked, otherwise the service will close the connection.
13210    pub fn r#add_payload_buffer(
13211        &self,
13212        mut id: u32,
13213        mut payload_buffer: fidl::Vmo,
13214    ) -> Result<(), fidl::Error> {
13215        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
13216            (id, payload_buffer),
13217            0x3b3a37fc34fe5b56,
13218            fidl::encoding::DynamicFlags::empty(),
13219        )
13220    }
13221
13222    /// Removes a payload buffer from the current buffer set associated with the
13223    /// connection.
13224    ///
13225    /// A buffer with ID `id` must exist in the current set when this method is
13226    /// invoked, otherwise the service will will close the connection.
13227    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
13228        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
13229            (id,),
13230            0x5d1e4f74c3658262,
13231            fidl::encoding::DynamicFlags::empty(),
13232        )
13233    }
13234}
13235
13236#[cfg(target_os = "fuchsia")]
13237impl From<StreamBufferSetSynchronousProxy> for zx::Handle {
13238    fn from(value: StreamBufferSetSynchronousProxy) -> Self {
13239        value.into_channel().into()
13240    }
13241}
13242
13243#[cfg(target_os = "fuchsia")]
13244impl From<fidl::Channel> for StreamBufferSetSynchronousProxy {
13245    fn from(value: fidl::Channel) -> Self {
13246        Self::new(value)
13247    }
13248}
13249
13250#[cfg(target_os = "fuchsia")]
13251impl fidl::endpoints::FromClient for StreamBufferSetSynchronousProxy {
13252    type Protocol = StreamBufferSetMarker;
13253
13254    fn from_client(value: fidl::endpoints::ClientEnd<StreamBufferSetMarker>) -> Self {
13255        Self::new(value.into_channel())
13256    }
13257}
13258
13259#[derive(Debug, Clone)]
13260pub struct StreamBufferSetProxy {
13261    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
13262}
13263
13264impl fidl::endpoints::Proxy for StreamBufferSetProxy {
13265    type Protocol = StreamBufferSetMarker;
13266
13267    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
13268        Self::new(inner)
13269    }
13270
13271    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
13272        self.client.into_channel().map_err(|client| Self { client })
13273    }
13274
13275    fn as_channel(&self) -> &::fidl::AsyncChannel {
13276        self.client.as_channel()
13277    }
13278}
13279
13280impl StreamBufferSetProxy {
13281    /// Create a new Proxy for fuchsia.media/StreamBufferSet.
13282    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
13283        let protocol_name = <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
13284        Self { client: fidl::client::Client::new(channel, protocol_name) }
13285    }
13286
13287    /// Get a Stream of events from the remote end of the protocol.
13288    ///
13289    /// # Panics
13290    ///
13291    /// Panics if the event stream was already taken.
13292    pub fn take_event_stream(&self) -> StreamBufferSetEventStream {
13293        StreamBufferSetEventStream { event_receiver: self.client.take_event_receiver() }
13294    }
13295
13296    /// Adds a payload buffer to the current buffer set associated with the
13297    /// connection. A `StreamPacket` struct reference a payload buffer in the
13298    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13299    ///
13300    /// A buffer with ID `id` must not be in the current set when this method is
13301    /// invoked, otherwise the service will close the connection.
13302    pub fn r#add_payload_buffer(
13303        &self,
13304        mut id: u32,
13305        mut payload_buffer: fidl::Vmo,
13306    ) -> Result<(), fidl::Error> {
13307        StreamBufferSetProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
13308    }
13309
13310    /// Removes a payload buffer from the current buffer set associated with the
13311    /// connection.
13312    ///
13313    /// A buffer with ID `id` must exist in the current set when this method is
13314    /// invoked, otherwise the service will will close the connection.
13315    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
13316        StreamBufferSetProxyInterface::r#remove_payload_buffer(self, id)
13317    }
13318}
13319
13320impl StreamBufferSetProxyInterface for StreamBufferSetProxy {
13321    fn r#add_payload_buffer(
13322        &self,
13323        mut id: u32,
13324        mut payload_buffer: fidl::Vmo,
13325    ) -> Result<(), fidl::Error> {
13326        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
13327            (id, payload_buffer),
13328            0x3b3a37fc34fe5b56,
13329            fidl::encoding::DynamicFlags::empty(),
13330        )
13331    }
13332
13333    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
13334        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
13335            (id,),
13336            0x5d1e4f74c3658262,
13337            fidl::encoding::DynamicFlags::empty(),
13338        )
13339    }
13340}
13341
13342pub struct StreamBufferSetEventStream {
13343    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
13344}
13345
13346impl std::marker::Unpin for StreamBufferSetEventStream {}
13347
13348impl futures::stream::FusedStream for StreamBufferSetEventStream {
13349    fn is_terminated(&self) -> bool {
13350        self.event_receiver.is_terminated()
13351    }
13352}
13353
13354impl futures::Stream for StreamBufferSetEventStream {
13355    type Item = Result<StreamBufferSetEvent, fidl::Error>;
13356
13357    fn poll_next(
13358        mut self: std::pin::Pin<&mut Self>,
13359        cx: &mut std::task::Context<'_>,
13360    ) -> std::task::Poll<Option<Self::Item>> {
13361        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
13362            &mut self.event_receiver,
13363            cx
13364        )?) {
13365            Some(buf) => std::task::Poll::Ready(Some(StreamBufferSetEvent::decode(buf))),
13366            None => std::task::Poll::Ready(None),
13367        }
13368    }
13369}
13370
13371#[derive(Debug)]
13372pub enum StreamBufferSetEvent {}
13373
13374impl StreamBufferSetEvent {
13375    /// Decodes a message buffer as a [`StreamBufferSetEvent`].
13376    fn decode(
13377        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
13378    ) -> Result<StreamBufferSetEvent, fidl::Error> {
13379        let (bytes, _handles) = buf.split_mut();
13380        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13381        debug_assert_eq!(tx_header.tx_id, 0);
13382        match tx_header.ordinal {
13383            _ => Err(fidl::Error::UnknownOrdinal {
13384                ordinal: tx_header.ordinal,
13385                protocol_name:
13386                    <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
13387            }),
13388        }
13389    }
13390}
13391
13392/// A Stream of incoming requests for fuchsia.media/StreamBufferSet.
13393pub struct StreamBufferSetRequestStream {
13394    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13395    is_terminated: bool,
13396}
13397
13398impl std::marker::Unpin for StreamBufferSetRequestStream {}
13399
13400impl futures::stream::FusedStream for StreamBufferSetRequestStream {
13401    fn is_terminated(&self) -> bool {
13402        self.is_terminated
13403    }
13404}
13405
13406impl fidl::endpoints::RequestStream for StreamBufferSetRequestStream {
13407    type Protocol = StreamBufferSetMarker;
13408    type ControlHandle = StreamBufferSetControlHandle;
13409
13410    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
13411        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
13412    }
13413
13414    fn control_handle(&self) -> Self::ControlHandle {
13415        StreamBufferSetControlHandle { inner: self.inner.clone() }
13416    }
13417
13418    fn into_inner(
13419        self,
13420    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
13421    {
13422        (self.inner, self.is_terminated)
13423    }
13424
13425    fn from_inner(
13426        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13427        is_terminated: bool,
13428    ) -> Self {
13429        Self { inner, is_terminated }
13430    }
13431}
13432
13433impl futures::Stream for StreamBufferSetRequestStream {
13434    type Item = Result<StreamBufferSetRequest, fidl::Error>;
13435
13436    fn poll_next(
13437        mut self: std::pin::Pin<&mut Self>,
13438        cx: &mut std::task::Context<'_>,
13439    ) -> std::task::Poll<Option<Self::Item>> {
13440        let this = &mut *self;
13441        if this.inner.check_shutdown(cx) {
13442            this.is_terminated = true;
13443            return std::task::Poll::Ready(None);
13444        }
13445        if this.is_terminated {
13446            panic!("polled StreamBufferSetRequestStream after completion");
13447        }
13448        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
13449            |bytes, handles| {
13450                match this.inner.channel().read_etc(cx, bytes, handles) {
13451                    std::task::Poll::Ready(Ok(())) => {}
13452                    std::task::Poll::Pending => return std::task::Poll::Pending,
13453                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
13454                        this.is_terminated = true;
13455                        return std::task::Poll::Ready(None);
13456                    }
13457                    std::task::Poll::Ready(Err(e)) => {
13458                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
13459                            e.into(),
13460                        ))))
13461                    }
13462                }
13463
13464                // A message has been received from the channel
13465                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13466
13467                std::task::Poll::Ready(Some(match header.ordinal {
13468                    0x3b3a37fc34fe5b56 => {
13469                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13470                        let mut req = fidl::new_empty!(
13471                            StreamBufferSetAddPayloadBufferRequest,
13472                            fidl::encoding::DefaultFuchsiaResourceDialect
13473                        );
13474                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
13475                        let control_handle =
13476                            StreamBufferSetControlHandle { inner: this.inner.clone() };
13477                        Ok(StreamBufferSetRequest::AddPayloadBuffer {
13478                            id: req.id,
13479                            payload_buffer: req.payload_buffer,
13480
13481                            control_handle,
13482                        })
13483                    }
13484                    0x5d1e4f74c3658262 => {
13485                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13486                        let mut req = fidl::new_empty!(
13487                            StreamBufferSetRemovePayloadBufferRequest,
13488                            fidl::encoding::DefaultFuchsiaResourceDialect
13489                        );
13490                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
13491                        let control_handle =
13492                            StreamBufferSetControlHandle { inner: this.inner.clone() };
13493                        Ok(StreamBufferSetRequest::RemovePayloadBuffer {
13494                            id: req.id,
13495
13496                            control_handle,
13497                        })
13498                    }
13499                    _ => Err(fidl::Error::UnknownOrdinal {
13500                        ordinal: header.ordinal,
13501                        protocol_name:
13502                            <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
13503                    }),
13504                }))
13505            },
13506        )
13507    }
13508}
13509
13510/// Manages a set of payload buffers for a stream. This interface is typically
13511/// inherited along with `StreamSink` or `StreamSource` to enable the transport
13512/// of elementary streams between clients and services.
13513#[derive(Debug)]
13514pub enum StreamBufferSetRequest {
13515    /// Adds a payload buffer to the current buffer set associated with the
13516    /// connection. A `StreamPacket` struct reference a payload buffer in the
13517    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13518    ///
13519    /// A buffer with ID `id` must not be in the current set when this method is
13520    /// invoked, otherwise the service will close the connection.
13521    AddPayloadBuffer {
13522        id: u32,
13523        payload_buffer: fidl::Vmo,
13524        control_handle: StreamBufferSetControlHandle,
13525    },
13526    /// Removes a payload buffer from the current buffer set associated with the
13527    /// connection.
13528    ///
13529    /// A buffer with ID `id` must exist in the current set when this method is
13530    /// invoked, otherwise the service will will close the connection.
13531    RemovePayloadBuffer { id: u32, control_handle: StreamBufferSetControlHandle },
13532}
13533
13534impl StreamBufferSetRequest {
13535    #[allow(irrefutable_let_patterns)]
13536    pub fn into_add_payload_buffer(self) -> Option<(u32, fidl::Vmo, StreamBufferSetControlHandle)> {
13537        if let StreamBufferSetRequest::AddPayloadBuffer { id, payload_buffer, control_handle } =
13538            self
13539        {
13540            Some((id, payload_buffer, control_handle))
13541        } else {
13542            None
13543        }
13544    }
13545
13546    #[allow(irrefutable_let_patterns)]
13547    pub fn into_remove_payload_buffer(self) -> Option<(u32, StreamBufferSetControlHandle)> {
13548        if let StreamBufferSetRequest::RemovePayloadBuffer { id, control_handle } = self {
13549            Some((id, control_handle))
13550        } else {
13551            None
13552        }
13553    }
13554
13555    /// Name of the method defined in FIDL
13556    pub fn method_name(&self) -> &'static str {
13557        match *self {
13558            StreamBufferSetRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
13559            StreamBufferSetRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
13560        }
13561    }
13562}
13563
13564#[derive(Debug, Clone)]
13565pub struct StreamBufferSetControlHandle {
13566    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13567}
13568
13569impl fidl::endpoints::ControlHandle for StreamBufferSetControlHandle {
13570    fn shutdown(&self) {
13571        self.inner.shutdown()
13572    }
13573    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
13574        self.inner.shutdown_with_epitaph(status)
13575    }
13576
13577    fn is_closed(&self) -> bool {
13578        self.inner.channel().is_closed()
13579    }
13580    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
13581        self.inner.channel().on_closed()
13582    }
13583
13584    #[cfg(target_os = "fuchsia")]
13585    fn signal_peer(
13586        &self,
13587        clear_mask: zx::Signals,
13588        set_mask: zx::Signals,
13589    ) -> Result<(), zx_status::Status> {
13590        use fidl::Peered;
13591        self.inner.channel().signal_peer(clear_mask, set_mask)
13592    }
13593}
13594
13595impl StreamBufferSetControlHandle {}
13596
13597#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
13598pub struct StreamProcessorMarker;
13599
13600impl fidl::endpoints::ProtocolMarker for StreamProcessorMarker {
13601    type Proxy = StreamProcessorProxy;
13602    type RequestStream = StreamProcessorRequestStream;
13603    #[cfg(target_os = "fuchsia")]
13604    type SynchronousProxy = StreamProcessorSynchronousProxy;
13605
13606    const DEBUG_NAME: &'static str = "(anonymous) StreamProcessor";
13607}
13608
13609pub trait StreamProcessorProxyInterface: Send + Sync {
13610    fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error>;
13611    fn r#set_input_buffer_partial_settings(
13612        &self,
13613        input_settings: StreamBufferPartialSettings,
13614    ) -> Result<(), fidl::Error>;
13615    fn r#set_output_buffer_partial_settings(
13616        &self,
13617        output_settings: StreamBufferPartialSettings,
13618    ) -> Result<(), fidl::Error>;
13619    fn r#complete_output_buffer_partial_settings(
13620        &self,
13621        buffer_lifetime_ordinal: u64,
13622    ) -> Result<(), fidl::Error>;
13623    fn r#flush_end_of_stream_and_close_stream(
13624        &self,
13625        stream_lifetime_ordinal: u64,
13626    ) -> Result<(), fidl::Error>;
13627    fn r#close_current_stream(
13628        &self,
13629        stream_lifetime_ordinal: u64,
13630        release_input_buffers: bool,
13631        release_output_buffers: bool,
13632    ) -> Result<(), fidl::Error>;
13633    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
13634    fn r#sync(&self) -> Self::SyncResponseFut;
13635    fn r#recycle_output_packet(
13636        &self,
13637        available_output_packet: &PacketHeader,
13638    ) -> Result<(), fidl::Error>;
13639    fn r#queue_input_format_details(
13640        &self,
13641        stream_lifetime_ordinal: u64,
13642        format_details: &FormatDetails,
13643    ) -> Result<(), fidl::Error>;
13644    fn r#queue_input_packet(&self, packet: &Packet) -> Result<(), fidl::Error>;
13645    fn r#queue_input_end_of_stream(&self, stream_lifetime_ordinal: u64) -> Result<(), fidl::Error>;
13646}
13647#[derive(Debug)]
13648#[cfg(target_os = "fuchsia")]
13649pub struct StreamProcessorSynchronousProxy {
13650    client: fidl::client::sync::Client,
13651}
13652
13653#[cfg(target_os = "fuchsia")]
13654impl fidl::endpoints::SynchronousProxy for StreamProcessorSynchronousProxy {
13655    type Proxy = StreamProcessorProxy;
13656    type Protocol = StreamProcessorMarker;
13657
13658    fn from_channel(inner: fidl::Channel) -> Self {
13659        Self::new(inner)
13660    }
13661
13662    fn into_channel(self) -> fidl::Channel {
13663        self.client.into_channel()
13664    }
13665
13666    fn as_channel(&self) -> &fidl::Channel {
13667        self.client.as_channel()
13668    }
13669}
13670
13671#[cfg(target_os = "fuchsia")]
13672impl StreamProcessorSynchronousProxy {
13673    pub fn new(channel: fidl::Channel) -> Self {
13674        let protocol_name = <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
13675        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
13676    }
13677
13678    pub fn into_channel(self) -> fidl::Channel {
13679        self.client.into_channel()
13680    }
13681
13682    /// Waits until an event arrives and returns it. It is safe for other
13683    /// threads to make concurrent requests while waiting for an event.
13684    pub fn wait_for_event(
13685        &self,
13686        deadline: zx::MonotonicInstant,
13687    ) -> Result<StreamProcessorEvent, fidl::Error> {
13688        StreamProcessorEvent::decode(self.client.wait_for_event(deadline)?)
13689    }
13690
13691    /// Permit the server to use OnStreamFailed() instead of the server just
13692    /// closing the whole StreamProcessor channel on stream failure.
13693    ///
13694    /// If the server hasn't seen this message by the time a stream fails, the
13695    /// server will close the StreamProcessor channel instead of sending
13696    /// OnStreamFailed().
13697    pub fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
13698        self.client.send::<fidl::encoding::EmptyPayload>(
13699            (),
13700            0x3940929617dbf02b,
13701            fidl::encoding::DynamicFlags::empty(),
13702        )
13703    }
13704
13705    /// This is the replacement for SetInputBufferSettings().
13706    ///
13707    /// When the client is using sysmem to allocate buffers, this message is
13708    /// used instead of SetInputBufferSettings()+AddInputBuffer().  Instead, a
13709    /// single SetInputBufferPartialSettings() provides the StreamProcessor with
13710    /// the client-specified input settings and a BufferCollectionToken which
13711    /// the StreamProcessor will use to convey constraints to sysmem.  Both the
13712    /// client and the StreamProcessor will be informed of the allocated buffers
13713    /// directly by sysmem via their BufferCollection channel (not via the
13714    /// StreamProcessor channel).
13715    ///
13716    /// The client must not QueueInput...() until after sysmem informs the client
13717    /// that buffer allocation has completed and was successful.
13718    ///
13719    /// The server should be prepared to see QueueInput...() before the server
13720    /// has necessarily heard from sysmem that the buffers are allocated - the
13721    /// server must tolerate either ordering, as the QueueInput...() and
13722    /// notification of sysmem allocation completion arrive on different
13723    /// channels, so the client having heard that allocation is complete doesn't
13724    /// mean the server knows that allocation is complete yet.  However, the
13725    /// server can expect that allocation is in fact complete and can expect to
13726    /// get the allocation information from sysmem immediately upon requesting
13727    /// the information from sysmem.
13728    pub fn r#set_input_buffer_partial_settings(
13729        &self,
13730        mut input_settings: StreamBufferPartialSettings,
13731    ) -> Result<(), fidl::Error> {
13732        self.client.send::<StreamProcessorSetInputBufferPartialSettingsRequest>(
13733            (&mut input_settings,),
13734            0xb02e0663a40e4c4,
13735            fidl::encoding::DynamicFlags::empty(),
13736        )
13737    }
13738
13739    /// This is the replacement for SetOutputBufferSettings().
13740    ///
13741    /// When the client is using sysmem to allocate buffers, this message is
13742    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
13743    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
13744    /// with the client-specified output settings and a BufferCollectionToken
13745    /// which the StreamProcessor will use to convey constraints to sysmem.
13746    /// Both the client and the StreamProcessor will be informed of the
13747    /// allocated buffers directly by sysmem via their BufferCollection channel
13748    /// (not via the StreamProcessor channel).
13749    ///
13750    /// Configuring output buffers is _required_ after OnOutputConstraints() is
13751    /// received by the client with buffer_constraints_action_required true and
13752    /// stream_lifetime_ordinal equal to the client's current
13753    /// stream_lifetime_ordinal (even if there is an active stream), and is
13754    /// _permitted_ any time there is no current stream.
13755    ///
13756    /// Closing the current stream occurs on the StreamControl ordering domain,
13757    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
13758    /// subsequent Sync() completion must be received by the client before the
13759    /// client knows that there's no longer a current stream.
13760    ///
13761    /// See also CompleteOutputBufferPartialSettings().
13762    pub fn r#set_output_buffer_partial_settings(
13763        &self,
13764        mut output_settings: StreamBufferPartialSettings,
13765    ) -> Result<(), fidl::Error> {
13766        self.client.send::<StreamProcessorSetOutputBufferPartialSettingsRequest>(
13767            (&mut output_settings,),
13768            0x118bb8c819a7bbbb,
13769            fidl::encoding::DynamicFlags::empty(),
13770        )
13771    }
13772
13773    /// After SetOutputBufferPartialSettings(), the server won't send
13774    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
13775    /// OnOutputEndOfStream() until after the client sends
13776    /// CompleteOutputBufferPartialSettings().
13777    ///
13778    /// Some clients may be able to send
13779    /// CompleteOutputBufferPartialSettings() immediately after
13780    /// SetOutputBufferPartialSettings() - in that case the client needs to be
13781    /// prepared to receive output without knowing the buffer count or packet
13782    /// count yet - such clients may internally delay processing the received
13783    /// output until the client has heard from sysmem (which is when the client
13784    /// will learn the buffer count and packet count).
13785    ///
13786    /// Other clients may first wait for sysmem to allocate, prepare to receive
13787    /// output, and then send CompleteOutputBufferPartialSettings().
13788    pub fn r#complete_output_buffer_partial_settings(
13789        &self,
13790        mut buffer_lifetime_ordinal: u64,
13791    ) -> Result<(), fidl::Error> {
13792        self.client.send::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(
13793            (buffer_lifetime_ordinal,),
13794            0x50529e5c680ae3ab,
13795            fidl::encoding::DynamicFlags::empty(),
13796        )
13797    }
13798
13799    /// This message is optional.
13800    ///
13801    /// This message is only valid after QueueInputEndOfStream() for this stream.
13802    /// The stream_lifetime_ordinal input parameter must match the
13803    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
13804    /// will close the channel.
13805    ///
13806    /// A client can use this message to flush through (not discard) the last
13807    /// input data of a stream so that the stream processor server generates
13808    /// corresponding output data for all the input data before the server moves
13809    /// on to the next stream, without forcing the client to wait for
13810    /// OnOutputEndOfStream() before queueing data of another stream.
13811    ///
13812    /// The difference between QueueInputEndOfStream() and
13813    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
13814    /// from the client that there will not be any more input data for the
13815    /// stream (and this info is needed by some stream processors for the stream
13816    /// processor to ever emit the very last output data).  The
13817    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
13818    /// later completely discarding the rest of the current stream by closing
13819    /// the current stream (with or without a stream switch).  In contrast,
13820    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
13821    /// the previously-queued input data be processed including the logical
13822    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
13823    /// before moving on to any newer stream - this essentially changes the
13824    /// close-stream handling from discard to flush-through for this stream
13825    /// only.
13826    ///
13827    /// A client using this message can start providing input data for a new
13828    /// stream without that causing discard of old stream data.  That's the
13829    /// purpose of this message - to allow a client to flush through (not
13830    /// discard) the old stream's last data (instead of the default when closing
13831    /// or switching streams which is discard).
13832    ///
13833    /// Because the old stream is not done processing yet and the old stream's
13834    /// data is not being discarded, the client must be prepared to continue to
13835    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
13836    /// is done. The client will know the stream_lifetime_ordinal is done when
13837    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
13838    /// closes.
13839    pub fn r#flush_end_of_stream_and_close_stream(
13840        &self,
13841        mut stream_lifetime_ordinal: u64,
13842    ) -> Result<(), fidl::Error> {
13843        self.client.send::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(
13844            (stream_lifetime_ordinal,),
13845            0x2b62c3e26d0667e6,
13846            fidl::encoding::DynamicFlags::empty(),
13847        )
13848    }
13849
13850    /// This "closes" the current stream, leaving no current stream.  In
13851    /// addition, this message can optionally release input buffers or output
13852    /// buffers.
13853    ///
13854    /// If there has never been any active stream, the stream_lifetime_ordinal
13855    /// must be zero or the server will close the channel.  If there has been an
13856    /// active stream, the stream_lifetime_ordinal must be the most recent
13857    /// active stream whether that stream is still active or not.  Else the
13858    /// server will close the channel.
13859    ///
13860    /// Multiple of this message without any new active stream in between is not
13861    /// to be considered an error, which allows a client to use this message to
13862    /// close the current stream to stop wasting processing power on a stream the
13863    /// user no longer cares about, then later decide that buffers should be
13864    /// released and send this message again with release_input_buffers and/or
13865    /// release_output_buffers true to get the buffers released, if the client is
13866    /// interested in trying to avoid overlap in resource usage between old
13867    /// buffers and new buffers (not all clients are).
13868    ///
13869    /// See also Sync().
13870    pub fn r#close_current_stream(
13871        &self,
13872        mut stream_lifetime_ordinal: u64,
13873        mut release_input_buffers: bool,
13874        mut release_output_buffers: bool,
13875    ) -> Result<(), fidl::Error> {
13876        self.client.send::<StreamProcessorCloseCurrentStreamRequest>(
13877            (stream_lifetime_ordinal, release_input_buffers, release_output_buffers),
13878            0x1d8a67522170ca07,
13879            fidl::encoding::DynamicFlags::empty(),
13880        )
13881    }
13882
13883    /// On completion, all previous StreamProcessor calls have done what they're
13884    /// going to do server-side, _except_ for processing of data queued using
13885    /// QueueInputPacket().
13886    ///
13887    /// The main purpose of this call is to enable the client to wait until
13888    /// CloseCurrentStream() with release_input_buffers and/or
13889    /// release_output_buffers set to true to take effect, before the client
13890    /// allocates new buffers and re-sets-up input and/or output buffers.  This
13891    /// de-overlapping of resource usage can be worthwhile for media buffers
13892    /// which can consume resource types whose overall pools aren't necessarily
13893    /// vast in comparison to resources consumed.  Especially if a client is
13894    /// reconfiguring buffers multiple times.
13895    ///
13896    /// Note that Sync() prior to allocating new media buffers is not alone
13897    /// sufficient to achieve non-overlap of media buffer resource usage system
13898    /// wide, but it can be a useful part of achieving that.
13899    ///
13900    /// The Sync() transits the Output ordering domain and the StreamControl
13901    /// ordering domain, but not the InputData ordering domain.
13902    ///
13903    /// This request can be used to avoid hitting kMaxInFlightStreams which is
13904    /// presently 10.  A client that stays <= 8 in-flight streams will
13905    /// comfortably stay under the limit of 10.  While the protocol permits
13906    /// repeated SetInputBufferSettings() and the like, a client that spams the
13907    /// channel can expect that the channel will just close if the server or the
13908    /// channel itself gets too far behind.
13909    pub fn r#sync(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
13910        let _response =
13911            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
13912                (),
13913                0x4b3e44300b0ec6aa,
13914                fidl::encoding::DynamicFlags::empty(),
13915                ___deadline,
13916            )?;
13917        Ok(_response)
13918    }
13919
13920    /// After the client is done with an output packet, the client needs to tell
13921    /// the stream processor that the output packet can be re-used for more
13922    /// output, via this method.
13923    ///
13924    /// It's not permitted to recycle an output packet that's already free with
13925    /// the stream processor server.  It's permitted but discouraged for a
13926    /// client to recycle an output packet that has been deallocated by an
13927    /// explicit or implicit output buffer de-configuration().  See
13928    /// buffer_lifetime_ordinal for more on that. A server must ignore any such
13929    /// stale RecycleOutputPacket() calls.
13930    pub fn r#recycle_output_packet(
13931        &self,
13932        mut available_output_packet: &PacketHeader,
13933    ) -> Result<(), fidl::Error> {
13934        self.client.send::<StreamProcessorRecycleOutputPacketRequest>(
13935            (available_output_packet,),
13936            0x32763632b94e0bd5,
13937            fidl::encoding::DynamicFlags::empty(),
13938        )
13939    }
13940
13941    /// If the input format details are still the same as specified during
13942    /// StreamProcessor creation, this message is unnecessary and does not need
13943    /// to be sent.
13944    ///
13945    /// If the stream doesn't exist yet, this message creates the stream.
13946    ///
13947    /// The server won't send OnOutputConstraints() until after the client has
13948    /// sent at least one QueueInput* message.
13949    ///
13950    /// All servers must permit QueueInputFormatDetails() at the start of a
13951    /// stream without failing, as long as the new format is supported by the
13952    /// StreamProcessor instance.  Technically this allows for a server to only
13953    /// support the exact input format set during StreamProcessor creation, and
13954    /// that is by design.  A client that tries to switch formats and gets a
13955    /// StreamProcessor channel failure should try again one more time with a
13956    /// fresh StreamProcessor instance created with CodecFactory using the new
13957    /// input format during creation, before giving up.
13958    ///
13959    /// These format details override the format details specified during stream
13960    /// processor creation for this stream only.  The next stream will default
13961    /// back to the format details set during stream processor creation.
13962    ///
13963    /// This message is permitted at the start of the first stream (just like at
13964    /// the start of any stream).  The format specified need not match what was
13965    /// specified during stream processor creation, but if it doesn't match, the
13966    /// StreamProcessor channel might close as described above.
13967    pub fn r#queue_input_format_details(
13968        &self,
13969        mut stream_lifetime_ordinal: u64,
13970        mut format_details: &FormatDetails,
13971    ) -> Result<(), fidl::Error> {
13972        self.client.send::<StreamProcessorQueueInputFormatDetailsRequest>(
13973            (stream_lifetime_ordinal, format_details),
13974            0x170dc0979d52231,
13975            fidl::encoding::DynamicFlags::empty(),
13976        )
13977    }
13978
13979    /// This message queues input data to the stream processor for processing.
13980    ///
13981    /// If the stream doesn't exist yet, this message creates the new stream.
13982    ///
13983    /// The server won't send OnOutputConstraints() until after the client has
13984    /// sent at least one QueueInput* message.
13985    ///
13986    /// The client must continue to deliver input data via this message even if
13987    /// the stream processor has not yet generated the first OnOutputConstraints(),
13988    /// and even if the StreamProcessor is generating OnFreeInputPacket() for
13989    /// previously-queued input packets.  The input data must continue as long
13990    /// as there are free packets to be assured that the server will ever
13991    /// generate the first OnOutputConstraints().
13992    pub fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
13993        self.client.send::<StreamProcessorQueueInputPacketRequest>(
13994            (packet,),
13995            0x47173d2652d9df3b,
13996            fidl::encoding::DynamicFlags::empty(),
13997        )
13998    }
13999
14000    /// Inform the server that all QueueInputPacket() messages for this stream
14001    /// have been sent.
14002    ///
14003    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
14004    /// or StreamProcessor channel closing), there will later be a corresponding
14005    /// OnOutputEndOfStream().
14006    ///
14007    /// The corresponding OnOutputEndOfStream() message will be generated only if
14008    /// the server finishes processing the stream before the server sees the
14009    /// client close the stream (such as by starting a new stream).  A way to
14010    /// force the server to finish the stream before closing is to use
14011    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before any
14012    /// new stream.  Another way to force the server to finish the stream before
14013    /// closing is to wait for the OnOutputEndOfStream() before taking any action
14014    /// that closes the stream.
14015    ///
14016    /// In addition to serving as an "EndOfStream" marker to make it obvious
14017    /// client-side when all input data has been processed, if a client never
14018    /// sends QueueInputEndOfStream(), no amount of waiting will necessarily
14019    /// result in all input data getting processed through to the output.  Some
14020    /// stream processors have some internally-delayed data which only gets
14021    /// pushed through by additional input data _or_ by this EndOfStream marker.
14022    /// In that sense, this message can be viewed as a flush-through at
14023    /// InputData domain level, but the flush-through only takes effect if the
14024    /// stream processor even gets that far before the stream is just closed at
14025    /// StreamControl domain level.  This message is not alone sufficient to act
14026    /// as an overall flush-through at StreamControl level. For that, send this
14027    /// message first and then send FlushEndOfStreamAndCloseStream() (at which
14028    /// point it becomes possible to queue input data for a new stream without
14029    /// causing discard of this older stream's data), or wait for the
14030    /// OnOutputEndOfStream() before closing the current stream.
14031    ///
14032    /// If a client sends QueueInputPacket(), QueueInputFormatDetails(),
14033    /// QueueInputEndOfStream() for this stream after the first
14034    /// QueueInputEndOfStream() for this stream, a server should close the
14035    /// StreamProcessor channel.
14036    pub fn r#queue_input_end_of_stream(
14037        &self,
14038        mut stream_lifetime_ordinal: u64,
14039    ) -> Result<(), fidl::Error> {
14040        self.client.send::<StreamProcessorQueueInputEndOfStreamRequest>(
14041            (stream_lifetime_ordinal,),
14042            0x2051b6ad00f20b37,
14043            fidl::encoding::DynamicFlags::empty(),
14044        )
14045    }
14046}
14047
14048#[cfg(target_os = "fuchsia")]
14049impl From<StreamProcessorSynchronousProxy> for zx::Handle {
14050    fn from(value: StreamProcessorSynchronousProxy) -> Self {
14051        value.into_channel().into()
14052    }
14053}
14054
14055#[cfg(target_os = "fuchsia")]
14056impl From<fidl::Channel> for StreamProcessorSynchronousProxy {
14057    fn from(value: fidl::Channel) -> Self {
14058        Self::new(value)
14059    }
14060}
14061
14062#[cfg(target_os = "fuchsia")]
14063impl fidl::endpoints::FromClient for StreamProcessorSynchronousProxy {
14064    type Protocol = StreamProcessorMarker;
14065
14066    fn from_client(value: fidl::endpoints::ClientEnd<StreamProcessorMarker>) -> Self {
14067        Self::new(value.into_channel())
14068    }
14069}
14070
14071#[derive(Debug, Clone)]
14072pub struct StreamProcessorProxy {
14073    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
14074}
14075
14076impl fidl::endpoints::Proxy for StreamProcessorProxy {
14077    type Protocol = StreamProcessorMarker;
14078
14079    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
14080        Self::new(inner)
14081    }
14082
14083    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
14084        self.client.into_channel().map_err(|client| Self { client })
14085    }
14086
14087    fn as_channel(&self) -> &::fidl::AsyncChannel {
14088        self.client.as_channel()
14089    }
14090}
14091
14092impl StreamProcessorProxy {
14093    /// Create a new Proxy for fuchsia.media/StreamProcessor.
14094    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
14095        let protocol_name = <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
14096        Self { client: fidl::client::Client::new(channel, protocol_name) }
14097    }
14098
14099    /// Get a Stream of events from the remote end of the protocol.
14100    ///
14101    /// # Panics
14102    ///
14103    /// Panics if the event stream was already taken.
14104    pub fn take_event_stream(&self) -> StreamProcessorEventStream {
14105        StreamProcessorEventStream { event_receiver: self.client.take_event_receiver() }
14106    }
14107
14108    /// Permit the server to use OnStreamFailed() instead of the server just
14109    /// closing the whole StreamProcessor channel on stream failure.
14110    ///
14111    /// If the server hasn't seen this message by the time a stream fails, the
14112    /// server will close the StreamProcessor channel instead of sending
14113    /// OnStreamFailed().
14114    pub fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
14115        StreamProcessorProxyInterface::r#enable_on_stream_failed(self)
14116    }
14117
14118    /// This is the replacement for SetInputBufferSettings().
14119    ///
14120    /// When the client is using sysmem to allocate buffers, this message is
14121    /// used instead of SetInputBufferSettings()+AddInputBuffer().  Instead, a
14122    /// single SetInputBufferPartialSettings() provides the StreamProcessor with
14123    /// the client-specified input settings and a BufferCollectionToken which
14124    /// the StreamProcessor will use to convey constraints to sysmem.  Both the
14125    /// client and the StreamProcessor will be informed of the allocated buffers
14126    /// directly by sysmem via their BufferCollection channel (not via the
14127    /// StreamProcessor channel).
14128    ///
14129    /// The client must not QueueInput...() until after sysmem informs the client
14130    /// that buffer allocation has completed and was successful.
14131    ///
14132    /// The server should be prepared to see QueueInput...() before the server
14133    /// has necessarily heard from sysmem that the buffers are allocated - the
14134    /// server must tolerate either ordering, as the QueueInput...() and
14135    /// notification of sysmem allocation completion arrive on different
14136    /// channels, so the client having heard that allocation is complete doesn't
14137    /// mean the server knows that allocation is complete yet.  However, the
14138    /// server can expect that allocation is in fact complete and can expect to
14139    /// get the allocation information from sysmem immediately upon requesting
14140    /// the information from sysmem.
14141    pub fn r#set_input_buffer_partial_settings(
14142        &self,
14143        mut input_settings: StreamBufferPartialSettings,
14144    ) -> Result<(), fidl::Error> {
14145        StreamProcessorProxyInterface::r#set_input_buffer_partial_settings(self, input_settings)
14146    }
14147
14148    /// This is the replacement for SetOutputBufferSettings().
14149    ///
14150    /// When the client is using sysmem to allocate buffers, this message is
14151    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
14152    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
14153    /// with the client-specified output settings and a BufferCollectionToken
14154    /// which the StreamProcessor will use to convey constraints to sysmem.
14155    /// Both the client and the StreamProcessor will be informed of the
14156    /// allocated buffers directly by sysmem via their BufferCollection channel
14157    /// (not via the StreamProcessor channel).
14158    ///
14159    /// Configuring output buffers is _required_ after OnOutputConstraints() is
14160    /// received by the client with buffer_constraints_action_required true and
14161    /// stream_lifetime_ordinal equal to the client's current
14162    /// stream_lifetime_ordinal (even if there is an active stream), and is
14163    /// _permitted_ any time there is no current stream.
14164    ///
14165    /// Closing the current stream occurs on the StreamControl ordering domain,
14166    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
14167    /// subsequent Sync() completion must be received by the client before the
14168    /// client knows that there's no longer a current stream.
14169    ///
14170    /// See also CompleteOutputBufferPartialSettings().
14171    pub fn r#set_output_buffer_partial_settings(
14172        &self,
14173        mut output_settings: StreamBufferPartialSettings,
14174    ) -> Result<(), fidl::Error> {
14175        StreamProcessorProxyInterface::r#set_output_buffer_partial_settings(self, output_settings)
14176    }
14177
14178    /// After SetOutputBufferPartialSettings(), the server won't send
14179    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
14180    /// OnOutputEndOfStream() until after the client sends
14181    /// CompleteOutputBufferPartialSettings().
14182    ///
14183    /// Some clients may be able to send
14184    /// CompleteOutputBufferPartialSettings() immediately after
14185    /// SetOutputBufferPartialSettings() - in that case the client needs to be
14186    /// prepared to receive output without knowing the buffer count or packet
14187    /// count yet - such clients may internally delay processing the received
14188    /// output until the client has heard from sysmem (which is when the client
14189    /// will learn the buffer count and packet count).
14190    ///
14191    /// Other clients may first wait for sysmem to allocate, prepare to receive
14192    /// output, and then send CompleteOutputBufferPartialSettings().
14193    pub fn r#complete_output_buffer_partial_settings(
14194        &self,
14195        mut buffer_lifetime_ordinal: u64,
14196    ) -> Result<(), fidl::Error> {
14197        StreamProcessorProxyInterface::r#complete_output_buffer_partial_settings(
14198            self,
14199            buffer_lifetime_ordinal,
14200        )
14201    }
14202
14203    /// This message is optional.
14204    ///
14205    /// This message is only valid after QueueInputEndOfStream() for this stream.
14206    /// The stream_lifetime_ordinal input parameter must match the
14207    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
14208    /// will close the channel.
14209    ///
14210    /// A client can use this message to flush through (not discard) the last
14211    /// input data of a stream so that the stream processor server generates
14212    /// corresponding output data for all the input data before the server moves
14213    /// on to the next stream, without forcing the client to wait for
14214    /// OnOutputEndOfStream() before queueing data of another stream.
14215    ///
14216    /// The difference between QueueInputEndOfStream() and
14217    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
14218    /// from the client that there will not be any more input data for the
14219    /// stream (and this info is needed by some stream processors for the stream
14220    /// processor to ever emit the very last output data).  The
14221    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
14222    /// later completely discarding the rest of the current stream by closing
14223    /// the current stream (with or without a stream switch).  In contrast,
14224    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
14225    /// the previously-queued input data be processed including the logical
14226    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
14227    /// before moving on to any newer stream - this essentially changes the
14228    /// close-stream handling from discard to flush-through for this stream
14229    /// only.
14230    ///
14231    /// A client using this message can start providing input data for a new
14232    /// stream without that causing discard of old stream data.  That's the
14233    /// purpose of this message - to allow a client to flush through (not
14234    /// discard) the old stream's last data (instead of the default when closing
14235    /// or switching streams which is discard).
14236    ///
14237    /// Because the old stream is not done processing yet and the old stream's
14238    /// data is not being discarded, the client must be prepared to continue to
14239    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
14240    /// is done. The client will know the stream_lifetime_ordinal is done when
14241    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
14242    /// closes.
14243    pub fn r#flush_end_of_stream_and_close_stream(
14244        &self,
14245        mut stream_lifetime_ordinal: u64,
14246    ) -> Result<(), fidl::Error> {
14247        StreamProcessorProxyInterface::r#flush_end_of_stream_and_close_stream(
14248            self,
14249            stream_lifetime_ordinal,
14250        )
14251    }
14252
14253    /// This "closes" the current stream, leaving no current stream.  In
14254    /// addition, this message can optionally release input buffers or output
14255    /// buffers.
14256    ///
14257    /// If there has never been any active stream, the stream_lifetime_ordinal
14258    /// must be zero or the server will close the channel.  If there has been an
14259    /// active stream, the stream_lifetime_ordinal must be the most recent
14260    /// active stream whether that stream is still active or not.  Else the
14261    /// server will close the channel.
14262    ///
14263    /// Multiple of this message without any new active stream in between is not
14264    /// to be considered an error, which allows a client to use this message to
14265    /// close the current stream to stop wasting processing power on a stream the
14266    /// user no longer cares about, then later decide that buffers should be
14267    /// released and send this message again with release_input_buffers and/or
14268    /// release_output_buffers true to get the buffers released, if the client is
14269    /// interested in trying to avoid overlap in resource usage between old
14270    /// buffers and new buffers (not all clients are).
14271    ///
14272    /// See also Sync().
14273    pub fn r#close_current_stream(
14274        &self,
14275        mut stream_lifetime_ordinal: u64,
14276        mut release_input_buffers: bool,
14277        mut release_output_buffers: bool,
14278    ) -> Result<(), fidl::Error> {
14279        StreamProcessorProxyInterface::r#close_current_stream(
14280            self,
14281            stream_lifetime_ordinal,
14282            release_input_buffers,
14283            release_output_buffers,
14284        )
14285    }
14286
14287    /// On completion, all previous StreamProcessor calls have done what they're
14288    /// going to do server-side, _except_ for processing of data queued using
14289    /// QueueInputPacket().
14290    ///
14291    /// The main purpose of this call is to enable the client to wait until
14292    /// CloseCurrentStream() with release_input_buffers and/or
14293    /// release_output_buffers set to true to take effect, before the client
14294    /// allocates new buffers and re-sets-up input and/or output buffers.  This
14295    /// de-overlapping of resource usage can be worthwhile for media buffers
14296    /// which can consume resource types whose overall pools aren't necessarily
14297    /// vast in comparison to resources consumed.  Especially if a client is
14298    /// reconfiguring buffers multiple times.
14299    ///
14300    /// Note that Sync() prior to allocating new media buffers is not alone
14301    /// sufficient to achieve non-overlap of media buffer resource usage system
14302    /// wide, but it can be a useful part of achieving that.
14303    ///
14304    /// The Sync() transits the Output ordering domain and the StreamControl
14305    /// ordering domain, but not the InputData ordering domain.
14306    ///
14307    /// This request can be used to avoid hitting kMaxInFlightStreams which is
14308    /// presently 10.  A client that stays <= 8 in-flight streams will
14309    /// comfortably stay under the limit of 10.  While the protocol permits
14310    /// repeated SetInputBufferSettings() and the like, a client that spams the
14311    /// channel can expect that the channel will just close if the server or the
14312    /// channel itself gets too far behind.
14313    pub fn r#sync(
14314        &self,
14315    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
14316        StreamProcessorProxyInterface::r#sync(self)
14317    }
14318
14319    /// After the client is done with an output packet, the client needs to tell
14320    /// the stream processor that the output packet can be re-used for more
14321    /// output, via this method.
14322    ///
14323    /// It's not permitted to recycle an output packet that's already free with
14324    /// the stream processor server.  It's permitted but discouraged for a
14325    /// client to recycle an output packet that has been deallocated by an
14326    /// explicit or implicit output buffer de-configuration().  See
14327    /// buffer_lifetime_ordinal for more on that. A server must ignore any such
14328    /// stale RecycleOutputPacket() calls.
14329    pub fn r#recycle_output_packet(
14330        &self,
14331        mut available_output_packet: &PacketHeader,
14332    ) -> Result<(), fidl::Error> {
14333        StreamProcessorProxyInterface::r#recycle_output_packet(self, available_output_packet)
14334    }
14335
14336    /// If the input format details are still the same as specified during
14337    /// StreamProcessor creation, this message is unnecessary and does not need
14338    /// to be sent.
14339    ///
14340    /// If the stream doesn't exist yet, this message creates the stream.
14341    ///
14342    /// The server won't send OnOutputConstraints() until after the client has
14343    /// sent at least one QueueInput* message.
14344    ///
14345    /// All servers must permit QueueInputFormatDetails() at the start of a
14346    /// stream without failing, as long as the new format is supported by the
14347    /// StreamProcessor instance.  Technically this allows for a server to only
14348    /// support the exact input format set during StreamProcessor creation, and
14349    /// that is by design.  A client that tries to switch formats and gets a
14350    /// StreamProcessor channel failure should try again one more time with a
14351    /// fresh StreamProcessor instance created with CodecFactory using the new
14352    /// input format during creation, before giving up.
14353    ///
14354    /// These format details override the format details specified during stream
14355    /// processor creation for this stream only.  The next stream will default
14356    /// back to the format details set during stream processor creation.
14357    ///
14358    /// This message is permitted at the start of the first stream (just like at
14359    /// the start of any stream).  The format specified need not match what was
14360    /// specified during stream processor creation, but if it doesn't match, the
14361    /// StreamProcessor channel might close as described above.
14362    pub fn r#queue_input_format_details(
14363        &self,
14364        mut stream_lifetime_ordinal: u64,
14365        mut format_details: &FormatDetails,
14366    ) -> Result<(), fidl::Error> {
14367        StreamProcessorProxyInterface::r#queue_input_format_details(
14368            self,
14369            stream_lifetime_ordinal,
14370            format_details,
14371        )
14372    }
14373
14374    /// This message queues input data to the stream processor for processing.
14375    ///
14376    /// If the stream doesn't exist yet, this message creates the new stream.
14377    ///
14378    /// The server won't send OnOutputConstraints() until after the client has
14379    /// sent at least one QueueInput* message.
14380    ///
14381    /// The client must continue to deliver input data via this message even if
14382    /// the stream processor has not yet generated the first OnOutputConstraints(),
14383    /// and even if the StreamProcessor is generating OnFreeInputPacket() for
14384    /// previously-queued input packets.  The input data must continue as long
14385    /// as there are free packets to be assured that the server will ever
14386    /// generate the first OnOutputConstraints().
14387    pub fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
14388        StreamProcessorProxyInterface::r#queue_input_packet(self, packet)
14389    }
14390
14391    /// Inform the server that all QueueInputPacket() messages for this stream
14392    /// have been sent.
14393    ///
14394    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
14395    /// or StreamProcessor channel closing), there will later be a corresponding
14396    /// OnOutputEndOfStream().
14397    ///
14398    /// The corresponding OnOutputEndOfStream() message will be generated only if
14399    /// the server finishes processing the stream before the server sees the
14400    /// client close the stream (such as by starting a new stream).  A way to
14401    /// force the server to finish the stream before closing is to use
14402    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before any
14403    /// new stream.  Another way to force the server to finish the stream before
14404    /// closing is to wait for the OnOutputEndOfStream() before taking any action
14405    /// that closes the stream.
14406    ///
14407    /// In addition to serving as an "EndOfStream" marker to make it obvious
14408    /// client-side when all input data has been processed, if a client never
14409    /// sends QueueInputEndOfStream(), no amount of waiting will necessarily
14410    /// result in all input data getting processed through to the output.  Some
14411    /// stream processors have some internally-delayed data which only gets
14412    /// pushed through by additional input data _or_ by this EndOfStream marker.
14413    /// In that sense, this message can be viewed as a flush-through at
14414    /// InputData domain level, but the flush-through only takes effect if the
14415    /// stream processor even gets that far before the stream is just closed at
14416    /// StreamControl domain level.  This message is not alone sufficient to act
14417    /// as an overall flush-through at StreamControl level. For that, send this
14418    /// message first and then send FlushEndOfStreamAndCloseStream() (at which
14419    /// point it becomes possible to queue input data for a new stream without
14420    /// causing discard of this older stream's data), or wait for the
14421    /// OnOutputEndOfStream() before closing the current stream.
14422    ///
14423    /// If a client sends QueueInputPacket(), QueueInputFormatDetails(),
14424    /// QueueInputEndOfStream() for this stream after the first
14425    /// QueueInputEndOfStream() for this stream, a server should close the
14426    /// StreamProcessor channel.
14427    pub fn r#queue_input_end_of_stream(
14428        &self,
14429        mut stream_lifetime_ordinal: u64,
14430    ) -> Result<(), fidl::Error> {
14431        StreamProcessorProxyInterface::r#queue_input_end_of_stream(self, stream_lifetime_ordinal)
14432    }
14433}
14434
14435impl StreamProcessorProxyInterface for StreamProcessorProxy {
14436    fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
14437        self.client.send::<fidl::encoding::EmptyPayload>(
14438            (),
14439            0x3940929617dbf02b,
14440            fidl::encoding::DynamicFlags::empty(),
14441        )
14442    }
14443
14444    fn r#set_input_buffer_partial_settings(
14445        &self,
14446        mut input_settings: StreamBufferPartialSettings,
14447    ) -> Result<(), fidl::Error> {
14448        self.client.send::<StreamProcessorSetInputBufferPartialSettingsRequest>(
14449            (&mut input_settings,),
14450            0xb02e0663a40e4c4,
14451            fidl::encoding::DynamicFlags::empty(),
14452        )
14453    }
14454
14455    fn r#set_output_buffer_partial_settings(
14456        &self,
14457        mut output_settings: StreamBufferPartialSettings,
14458    ) -> Result<(), fidl::Error> {
14459        self.client.send::<StreamProcessorSetOutputBufferPartialSettingsRequest>(
14460            (&mut output_settings,),
14461            0x118bb8c819a7bbbb,
14462            fidl::encoding::DynamicFlags::empty(),
14463        )
14464    }
14465
14466    fn r#complete_output_buffer_partial_settings(
14467        &self,
14468        mut buffer_lifetime_ordinal: u64,
14469    ) -> Result<(), fidl::Error> {
14470        self.client.send::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(
14471            (buffer_lifetime_ordinal,),
14472            0x50529e5c680ae3ab,
14473            fidl::encoding::DynamicFlags::empty(),
14474        )
14475    }
14476
14477    fn r#flush_end_of_stream_and_close_stream(
14478        &self,
14479        mut stream_lifetime_ordinal: u64,
14480    ) -> Result<(), fidl::Error> {
14481        self.client.send::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(
14482            (stream_lifetime_ordinal,),
14483            0x2b62c3e26d0667e6,
14484            fidl::encoding::DynamicFlags::empty(),
14485        )
14486    }
14487
14488    fn r#close_current_stream(
14489        &self,
14490        mut stream_lifetime_ordinal: u64,
14491        mut release_input_buffers: bool,
14492        mut release_output_buffers: bool,
14493    ) -> Result<(), fidl::Error> {
14494        self.client.send::<StreamProcessorCloseCurrentStreamRequest>(
14495            (stream_lifetime_ordinal, release_input_buffers, release_output_buffers),
14496            0x1d8a67522170ca07,
14497            fidl::encoding::DynamicFlags::empty(),
14498        )
14499    }
14500
14501    type SyncResponseFut =
14502        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
14503    fn r#sync(&self) -> Self::SyncResponseFut {
14504        fn _decode(
14505            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
14506        ) -> Result<(), fidl::Error> {
14507            let _response = fidl::client::decode_transaction_body::<
14508                fidl::encoding::EmptyPayload,
14509                fidl::encoding::DefaultFuchsiaResourceDialect,
14510                0x4b3e44300b0ec6aa,
14511            >(_buf?)?;
14512            Ok(_response)
14513        }
14514        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
14515            (),
14516            0x4b3e44300b0ec6aa,
14517            fidl::encoding::DynamicFlags::empty(),
14518            _decode,
14519        )
14520    }
14521
14522    fn r#recycle_output_packet(
14523        &self,
14524        mut available_output_packet: &PacketHeader,
14525    ) -> Result<(), fidl::Error> {
14526        self.client.send::<StreamProcessorRecycleOutputPacketRequest>(
14527            (available_output_packet,),
14528            0x32763632b94e0bd5,
14529            fidl::encoding::DynamicFlags::empty(),
14530        )
14531    }
14532
14533    fn r#queue_input_format_details(
14534        &self,
14535        mut stream_lifetime_ordinal: u64,
14536        mut format_details: &FormatDetails,
14537    ) -> Result<(), fidl::Error> {
14538        self.client.send::<StreamProcessorQueueInputFormatDetailsRequest>(
14539            (stream_lifetime_ordinal, format_details),
14540            0x170dc0979d52231,
14541            fidl::encoding::DynamicFlags::empty(),
14542        )
14543    }
14544
14545    fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
14546        self.client.send::<StreamProcessorQueueInputPacketRequest>(
14547            (packet,),
14548            0x47173d2652d9df3b,
14549            fidl::encoding::DynamicFlags::empty(),
14550        )
14551    }
14552
14553    fn r#queue_input_end_of_stream(
14554        &self,
14555        mut stream_lifetime_ordinal: u64,
14556    ) -> Result<(), fidl::Error> {
14557        self.client.send::<StreamProcessorQueueInputEndOfStreamRequest>(
14558            (stream_lifetime_ordinal,),
14559            0x2051b6ad00f20b37,
14560            fidl::encoding::DynamicFlags::empty(),
14561        )
14562    }
14563}
14564
14565pub struct StreamProcessorEventStream {
14566    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
14567}
14568
14569impl std::marker::Unpin for StreamProcessorEventStream {}
14570
14571impl futures::stream::FusedStream for StreamProcessorEventStream {
14572    fn is_terminated(&self) -> bool {
14573        self.event_receiver.is_terminated()
14574    }
14575}
14576
14577impl futures::Stream for StreamProcessorEventStream {
14578    type Item = Result<StreamProcessorEvent, fidl::Error>;
14579
14580    fn poll_next(
14581        mut self: std::pin::Pin<&mut Self>,
14582        cx: &mut std::task::Context<'_>,
14583    ) -> std::task::Poll<Option<Self::Item>> {
14584        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
14585            &mut self.event_receiver,
14586            cx
14587        )?) {
14588            Some(buf) => std::task::Poll::Ready(Some(StreamProcessorEvent::decode(buf))),
14589            None => std::task::Poll::Ready(None),
14590        }
14591    }
14592}
14593
14594#[derive(Debug)]
14595pub enum StreamProcessorEvent {
14596    OnStreamFailed {
14597        stream_lifetime_ordinal: u64,
14598        error: StreamError,
14599    },
14600    OnInputConstraints {
14601        input_constraints: StreamBufferConstraints,
14602    },
14603    OnOutputConstraints {
14604        output_config: StreamOutputConstraints,
14605    },
14606    OnOutputFormat {
14607        output_format: StreamOutputFormat,
14608    },
14609    OnOutputPacket {
14610        output_packet: Packet,
14611        error_detected_before: bool,
14612        error_detected_during: bool,
14613    },
14614    OnOutputEndOfStream {
14615        stream_lifetime_ordinal: u64,
14616        error_detected_before: bool,
14617    },
14618    OnFreeInputPacket {
14619        free_input_packet: PacketHeader,
14620    },
14621}
14622
14623impl StreamProcessorEvent {
14624    #[allow(irrefutable_let_patterns)]
14625    pub fn into_on_stream_failed(self) -> Option<(u64, StreamError)> {
14626        if let StreamProcessorEvent::OnStreamFailed { stream_lifetime_ordinal, error } = self {
14627            Some((stream_lifetime_ordinal, error))
14628        } else {
14629            None
14630        }
14631    }
14632    #[allow(irrefutable_let_patterns)]
14633    pub fn into_on_input_constraints(self) -> Option<StreamBufferConstraints> {
14634        if let StreamProcessorEvent::OnInputConstraints { input_constraints } = self {
14635            Some((input_constraints))
14636        } else {
14637            None
14638        }
14639    }
14640    #[allow(irrefutable_let_patterns)]
14641    pub fn into_on_output_constraints(self) -> Option<StreamOutputConstraints> {
14642        if let StreamProcessorEvent::OnOutputConstraints { output_config } = self {
14643            Some((output_config))
14644        } else {
14645            None
14646        }
14647    }
14648    #[allow(irrefutable_let_patterns)]
14649    pub fn into_on_output_format(self) -> Option<StreamOutputFormat> {
14650        if let StreamProcessorEvent::OnOutputFormat { output_format } = self {
14651            Some((output_format))
14652        } else {
14653            None
14654        }
14655    }
14656    #[allow(irrefutable_let_patterns)]
14657    pub fn into_on_output_packet(self) -> Option<(Packet, bool, bool)> {
14658        if let StreamProcessorEvent::OnOutputPacket {
14659            output_packet,
14660            error_detected_before,
14661            error_detected_during,
14662        } = self
14663        {
14664            Some((output_packet, error_detected_before, error_detected_during))
14665        } else {
14666            None
14667        }
14668    }
14669    #[allow(irrefutable_let_patterns)]
14670    pub fn into_on_output_end_of_stream(self) -> Option<(u64, bool)> {
14671        if let StreamProcessorEvent::OnOutputEndOfStream {
14672            stream_lifetime_ordinal,
14673            error_detected_before,
14674        } = self
14675        {
14676            Some((stream_lifetime_ordinal, error_detected_before))
14677        } else {
14678            None
14679        }
14680    }
14681    #[allow(irrefutable_let_patterns)]
14682    pub fn into_on_free_input_packet(self) -> Option<PacketHeader> {
14683        if let StreamProcessorEvent::OnFreeInputPacket { free_input_packet } = self {
14684            Some((free_input_packet))
14685        } else {
14686            None
14687        }
14688    }
14689
14690    /// Decodes a message buffer as a [`StreamProcessorEvent`].
14691    fn decode(
14692        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
14693    ) -> Result<StreamProcessorEvent, fidl::Error> {
14694        let (bytes, _handles) = buf.split_mut();
14695        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14696        debug_assert_eq!(tx_header.tx_id, 0);
14697        match tx_header.ordinal {
14698            0x77ccf70bb061cf8e => {
14699                let mut out = fidl::new_empty!(
14700                    StreamProcessorOnStreamFailedRequest,
14701                    fidl::encoding::DefaultFuchsiaResourceDialect
14702                );
14703                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnStreamFailedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14704                Ok((StreamProcessorEvent::OnStreamFailed {
14705                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
14706                    error: out.error,
14707                }))
14708            }
14709            0x211da9966a8ca0 => {
14710                let mut out = fidl::new_empty!(
14711                    StreamProcessorOnInputConstraintsRequest,
14712                    fidl::encoding::DefaultFuchsiaResourceDialect
14713                );
14714                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnInputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14715                Ok((StreamProcessorEvent::OnInputConstraints {
14716                    input_constraints: out.input_constraints,
14717                }))
14718            }
14719            0x40d8234504c170f3 => {
14720                let mut out = fidl::new_empty!(
14721                    StreamProcessorOnOutputConstraintsRequest,
14722                    fidl::encoding::DefaultFuchsiaResourceDialect
14723                );
14724                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14725                Ok((StreamProcessorEvent::OnOutputConstraints { output_config: out.output_config }))
14726            }
14727            0x131b77ae120360bc => {
14728                let mut out = fidl::new_empty!(
14729                    StreamProcessorOnOutputFormatRequest,
14730                    fidl::encoding::DefaultFuchsiaResourceDialect
14731                );
14732                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputFormatRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14733                Ok((StreamProcessorEvent::OnOutputFormat { output_format: out.output_format }))
14734            }
14735            0x5c2029be1090ce93 => {
14736                let mut out = fidl::new_empty!(
14737                    StreamProcessorOnOutputPacketRequest,
14738                    fidl::encoding::DefaultFuchsiaResourceDialect
14739                );
14740                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14741                Ok((StreamProcessorEvent::OnOutputPacket {
14742                    output_packet: out.output_packet,
14743                    error_detected_before: out.error_detected_before,
14744                    error_detected_during: out.error_detected_during,
14745                }))
14746            }
14747            0x3bb65d237cfa50e6 => {
14748                let mut out = fidl::new_empty!(
14749                    StreamProcessorOnOutputEndOfStreamRequest,
14750                    fidl::encoding::DefaultFuchsiaResourceDialect
14751                );
14752                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputEndOfStreamRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14753                Ok((StreamProcessorEvent::OnOutputEndOfStream {
14754                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
14755                    error_detected_before: out.error_detected_before,
14756                }))
14757            }
14758            0xeef799b28708bbd => {
14759                let mut out = fidl::new_empty!(
14760                    StreamProcessorOnFreeInputPacketRequest,
14761                    fidl::encoding::DefaultFuchsiaResourceDialect
14762                );
14763                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnFreeInputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14764                Ok((StreamProcessorEvent::OnFreeInputPacket {
14765                    free_input_packet: out.free_input_packet,
14766                }))
14767            }
14768            _ => Err(fidl::Error::UnknownOrdinal {
14769                ordinal: tx_header.ordinal,
14770                protocol_name:
14771                    <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
14772            }),
14773        }
14774    }
14775}
14776
14777/// A Stream of incoming requests for fuchsia.media/StreamProcessor.
14778pub struct StreamProcessorRequestStream {
14779    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
14780    is_terminated: bool,
14781}
14782
14783impl std::marker::Unpin for StreamProcessorRequestStream {}
14784
14785impl futures::stream::FusedStream for StreamProcessorRequestStream {
14786    fn is_terminated(&self) -> bool {
14787        self.is_terminated
14788    }
14789}
14790
14791impl fidl::endpoints::RequestStream for StreamProcessorRequestStream {
14792    type Protocol = StreamProcessorMarker;
14793    type ControlHandle = StreamProcessorControlHandle;
14794
14795    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
14796        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
14797    }
14798
14799    fn control_handle(&self) -> Self::ControlHandle {
14800        StreamProcessorControlHandle { inner: self.inner.clone() }
14801    }
14802
14803    fn into_inner(
14804        self,
14805    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
14806    {
14807        (self.inner, self.is_terminated)
14808    }
14809
14810    fn from_inner(
14811        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
14812        is_terminated: bool,
14813    ) -> Self {
14814        Self { inner, is_terminated }
14815    }
14816}
14817
14818impl futures::Stream for StreamProcessorRequestStream {
14819    type Item = Result<StreamProcessorRequest, fidl::Error>;
14820
14821    fn poll_next(
14822        mut self: std::pin::Pin<&mut Self>,
14823        cx: &mut std::task::Context<'_>,
14824    ) -> std::task::Poll<Option<Self::Item>> {
14825        let this = &mut *self;
14826        if this.inner.check_shutdown(cx) {
14827            this.is_terminated = true;
14828            return std::task::Poll::Ready(None);
14829        }
14830        if this.is_terminated {
14831            panic!("polled StreamProcessorRequestStream after completion");
14832        }
14833        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
14834            |bytes, handles| {
14835                match this.inner.channel().read_etc(cx, bytes, handles) {
14836                    std::task::Poll::Ready(Ok(())) => {}
14837                    std::task::Poll::Pending => return std::task::Poll::Pending,
14838                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
14839                        this.is_terminated = true;
14840                        return std::task::Poll::Ready(None);
14841                    }
14842                    std::task::Poll::Ready(Err(e)) => {
14843                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
14844                            e.into(),
14845                        ))))
14846                    }
14847                }
14848
14849                // A message has been received from the channel
14850                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14851
14852                std::task::Poll::Ready(Some(match header.ordinal {
14853                    0x3940929617dbf02b => {
14854                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14855                        let mut req = fidl::new_empty!(
14856                            fidl::encoding::EmptyPayload,
14857                            fidl::encoding::DefaultFuchsiaResourceDialect
14858                        );
14859                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
14860                        let control_handle =
14861                            StreamProcessorControlHandle { inner: this.inner.clone() };
14862                        Ok(StreamProcessorRequest::EnableOnStreamFailed { control_handle })
14863                    }
14864                    0xb02e0663a40e4c4 => {
14865                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14866                        let mut req = fidl::new_empty!(
14867                            StreamProcessorSetInputBufferPartialSettingsRequest,
14868                            fidl::encoding::DefaultFuchsiaResourceDialect
14869                        );
14870                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorSetInputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
14871                        let control_handle =
14872                            StreamProcessorControlHandle { inner: this.inner.clone() };
14873                        Ok(StreamProcessorRequest::SetInputBufferPartialSettings {
14874                            input_settings: req.input_settings,
14875
14876                            control_handle,
14877                        })
14878                    }
14879                    0x118bb8c819a7bbbb => {
14880                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14881                        let mut req = fidl::new_empty!(
14882                            StreamProcessorSetOutputBufferPartialSettingsRequest,
14883                            fidl::encoding::DefaultFuchsiaResourceDialect
14884                        );
14885                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorSetOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
14886                        let control_handle =
14887                            StreamProcessorControlHandle { inner: this.inner.clone() };
14888                        Ok(StreamProcessorRequest::SetOutputBufferPartialSettings {
14889                            output_settings: req.output_settings,
14890
14891                            control_handle,
14892                        })
14893                    }
14894                    0x50529e5c680ae3ab => {
14895                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14896                        let mut req = fidl::new_empty!(
14897                            StreamProcessorCompleteOutputBufferPartialSettingsRequest,
14898                            fidl::encoding::DefaultFuchsiaResourceDialect
14899                        );
14900                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
14901                        let control_handle =
14902                            StreamProcessorControlHandle { inner: this.inner.clone() };
14903                        Ok(StreamProcessorRequest::CompleteOutputBufferPartialSettings {
14904                            buffer_lifetime_ordinal: req.buffer_lifetime_ordinal,
14905
14906                            control_handle,
14907                        })
14908                    }
14909                    0x2b62c3e26d0667e6 => {
14910                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14911                        let mut req = fidl::new_empty!(
14912                            StreamProcessorFlushEndOfStreamAndCloseStreamRequest,
14913                            fidl::encoding::DefaultFuchsiaResourceDialect
14914                        );
14915                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(&header, _body_bytes, handles, &mut req)?;
14916                        let control_handle =
14917                            StreamProcessorControlHandle { inner: this.inner.clone() };
14918                        Ok(StreamProcessorRequest::FlushEndOfStreamAndCloseStream {
14919                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
14920
14921                            control_handle,
14922                        })
14923                    }
14924                    0x1d8a67522170ca07 => {
14925                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14926                        let mut req = fidl::new_empty!(
14927                            StreamProcessorCloseCurrentStreamRequest,
14928                            fidl::encoding::DefaultFuchsiaResourceDialect
14929                        );
14930                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorCloseCurrentStreamRequest>(&header, _body_bytes, handles, &mut req)?;
14931                        let control_handle =
14932                            StreamProcessorControlHandle { inner: this.inner.clone() };
14933                        Ok(StreamProcessorRequest::CloseCurrentStream {
14934                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
14935                            release_input_buffers: req.release_input_buffers,
14936                            release_output_buffers: req.release_output_buffers,
14937
14938                            control_handle,
14939                        })
14940                    }
14941                    0x4b3e44300b0ec6aa => {
14942                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
14943                        let mut req = fidl::new_empty!(
14944                            fidl::encoding::EmptyPayload,
14945                            fidl::encoding::DefaultFuchsiaResourceDialect
14946                        );
14947                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
14948                        let control_handle =
14949                            StreamProcessorControlHandle { inner: this.inner.clone() };
14950                        Ok(StreamProcessorRequest::Sync {
14951                            responder: StreamProcessorSyncResponder {
14952                                control_handle: std::mem::ManuallyDrop::new(control_handle),
14953                                tx_id: header.tx_id,
14954                            },
14955                        })
14956                    }
14957                    0x32763632b94e0bd5 => {
14958                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14959                        let mut req = fidl::new_empty!(
14960                            StreamProcessorRecycleOutputPacketRequest,
14961                            fidl::encoding::DefaultFuchsiaResourceDialect
14962                        );
14963                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorRecycleOutputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
14964                        let control_handle =
14965                            StreamProcessorControlHandle { inner: this.inner.clone() };
14966                        Ok(StreamProcessorRequest::RecycleOutputPacket {
14967                            available_output_packet: req.available_output_packet,
14968
14969                            control_handle,
14970                        })
14971                    }
14972                    0x170dc0979d52231 => {
14973                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14974                        let mut req = fidl::new_empty!(
14975                            StreamProcessorQueueInputFormatDetailsRequest,
14976                            fidl::encoding::DefaultFuchsiaResourceDialect
14977                        );
14978                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputFormatDetailsRequest>(&header, _body_bytes, handles, &mut req)?;
14979                        let control_handle =
14980                            StreamProcessorControlHandle { inner: this.inner.clone() };
14981                        Ok(StreamProcessorRequest::QueueInputFormatDetails {
14982                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
14983                            format_details: req.format_details,
14984
14985                            control_handle,
14986                        })
14987                    }
14988                    0x47173d2652d9df3b => {
14989                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14990                        let mut req = fidl::new_empty!(
14991                            StreamProcessorQueueInputPacketRequest,
14992                            fidl::encoding::DefaultFuchsiaResourceDialect
14993                        );
14994                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
14995                        let control_handle =
14996                            StreamProcessorControlHandle { inner: this.inner.clone() };
14997                        Ok(StreamProcessorRequest::QueueInputPacket {
14998                            packet: req.packet,
14999
15000                            control_handle,
15001                        })
15002                    }
15003                    0x2051b6ad00f20b37 => {
15004                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
15005                        let mut req = fidl::new_empty!(
15006                            StreamProcessorQueueInputEndOfStreamRequest,
15007                            fidl::encoding::DefaultFuchsiaResourceDialect
15008                        );
15009                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputEndOfStreamRequest>(&header, _body_bytes, handles, &mut req)?;
15010                        let control_handle =
15011                            StreamProcessorControlHandle { inner: this.inner.clone() };
15012                        Ok(StreamProcessorRequest::QueueInputEndOfStream {
15013                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
15014
15015                            control_handle,
15016                        })
15017                    }
15018                    _ => Err(fidl::Error::UnknownOrdinal {
15019                        ordinal: header.ordinal,
15020                        protocol_name:
15021                            <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
15022                    }),
15023                }))
15024            },
15025        )
15026    }
15027}
15028
15029/// Overview of operation:
15030///
15031/// 1. Create
15032///   * create via CodecFactory - see CodecFactory
15033///   * create via LicenseSession - see LicenseSession
15034/// 2. Get input constraints
15035///   * OnInputConstraints() - sent unsolicited by stream processor shortly after
15036///     stream processor creation.
15037/// 3. Provide input buffers
15038///   * SetInputBufferPartialSettings()
15039/// 4. Deliver input data
15040///   * QueueInputPacket() + OnFreeInputPacket(), for as long as it takes,
15041///     possibly working through all input packets repeatedly before...
15042/// 5. Get output constraints and format
15043///   * OnOutputConstraints()
15044///   * This is not sent until after at least one QueueInput* message is sent by
15045///     the client, even if the underlying processor behind the StreamProcessor
15046///     doesn't fundamentally need any input data to determine its output
15047///     constraints.  This server behavior prevents clients taking an incorrect
15048///     dependency on the output constraints showing up before input is
15049///     delivered.
15050///   * A client must tolerate this arriving as late as after substantial input
15051///     data has been delivered, including lots of input packet recycling via
15052///     OnFreeInputPacket().
15053///   * This message can arrive more than once before the first output data.
15054/// 6. Provide output buffers
15055///   * SetOutputBufferPartialSettings() / CompleteOutputBufferPartialSettings()
15056/// 7. Data flows, with optional EndOfStream
15057///   * OnOutputPacket() / RecycleOutputPacket() / QueueInputPacket() /
15058///     OnFreeInputPacket() / QueueInputEndOfStream() / OnOutputEndOfStream()
15059///
15060/// Semi-trusted StreamProcessor server - SW decoders run in an isolate (with
15061/// very few capabilities) just in case the decoding SW has a vulnerability
15062/// which could be used to take over the StreamProcessor server.  Clients of the
15063/// stream processor interface using decoders and processing streams of separate
15064/// security contexts, to a greater extent than some other interfaces, need to
15065/// protect themselves against invalid server behavior, such as double-free of a
15066/// packet_index and any other invalid server behavior.  Having fed in
15067/// compressed data of one security context, don't place too much trust in a
15068/// single StreamProcessor instance to not mix data among any buffers that
15069/// StreamProcessor server has ever been told about.  Instead, create separate
15070/// StreamProcessor instances for use by security-separate client-side contexts.
15071/// While the picture for HW-based decoders looks somewhat different and is out
15072/// of scope of this paragraph, the client should always use separate
15073/// StreamProcessor instances for security-separate client-side contexts.
15074///
15075/// Descriptions of actions taken by methods of this protocol and the states of
15076/// things are given as if the methods are synchronously executed by the stream
15077/// processor server, but in reality, as is typical of FIDL interfaces, the
15078/// message processing is async.  The states described are to be read as the
15079/// state from the client's point of view unless otherwise stated.  Events
15080/// coming back from the server are of course delivered async, and a client that
15081/// processes more than one stream per StreamProcessor instance needs to care
15082/// whether a given event is from the current stream vs. some older
15083/// soon-to-be-gone stream.
15084///
15085/// The Sync() method's main purpose is to enable the client to robustly prevent
15086/// having both old and new buffers allocated in the system at the same time,
15087/// since media buffers can be significantly large, depending. The Sync() method
15088/// achieves this by only delivering it's response when all previous calls to
15089/// the StreamProcessor protocol have actually taken effect in the
15090/// StreamControl ordering domain. Sync() can also be used to wait for the
15091/// stream processor server to catch up if there's a possibility that a client
15092/// might otherwise get too far ahead of the StreamProcessor server, by for
15093/// example requesting creation of a large number of streams in a row.  It can
15094/// also be used during debugging to ensure that a stream processor server
15095/// hasn't gotten stuck.  Calling Sync() is entirely optional and never required
15096/// for correctness - only potentially required to de-overlap resource usage.
15097///
15098/// It's possible to re-use a StreamProcessor instance for another stream, and
15099/// doing so can sometimes skip over re-allocation of buffers. This can be a
15100/// useful thing to do for cases like seeking to a new location - at the
15101/// StreamProcessor interface that can look like switching to a new stream.
15102#[derive(Debug)]
15103pub enum StreamProcessorRequest {
15104    /// Permit the server to use OnStreamFailed() instead of the server just
15105    /// closing the whole StreamProcessor channel on stream failure.
15106    ///
15107    /// If the server hasn't seen this message by the time a stream fails, the
15108    /// server will close the StreamProcessor channel instead of sending
15109    /// OnStreamFailed().
15110    EnableOnStreamFailed { control_handle: StreamProcessorControlHandle },
15111    /// This is the replacement for SetInputBufferSettings().
15112    ///
15113    /// When the client is using sysmem to allocate buffers, this message is
15114    /// used instead of SetInputBufferSettings()+AddInputBuffer().  Instead, a
15115    /// single SetInputBufferPartialSettings() provides the StreamProcessor with
15116    /// the client-specified input settings and a BufferCollectionToken which
15117    /// the StreamProcessor will use to convey constraints to sysmem.  Both the
15118    /// client and the StreamProcessor will be informed of the allocated buffers
15119    /// directly by sysmem via their BufferCollection channel (not via the
15120    /// StreamProcessor channel).
15121    ///
15122    /// The client must not QueueInput...() until after sysmem informs the client
15123    /// that buffer allocation has completed and was successful.
15124    ///
15125    /// The server should be prepared to see QueueInput...() before the server
15126    /// has necessarily heard from sysmem that the buffers are allocated - the
15127    /// server must tolerate either ordering, as the QueueInput...() and
15128    /// notification of sysmem allocation completion arrive on different
15129    /// channels, so the client having heard that allocation is complete doesn't
15130    /// mean the server knows that allocation is complete yet.  However, the
15131    /// server can expect that allocation is in fact complete and can expect to
15132    /// get the allocation information from sysmem immediately upon requesting
15133    /// the information from sysmem.
15134    SetInputBufferPartialSettings {
15135        input_settings: StreamBufferPartialSettings,
15136        control_handle: StreamProcessorControlHandle,
15137    },
15138    /// This is the replacement for SetOutputBufferSettings().
15139    ///
15140    /// When the client is using sysmem to allocate buffers, this message is
15141    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
15142    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
15143    /// with the client-specified output settings and a BufferCollectionToken
15144    /// which the StreamProcessor will use to convey constraints to sysmem.
15145    /// Both the client and the StreamProcessor will be informed of the
15146    /// allocated buffers directly by sysmem via their BufferCollection channel
15147    /// (not via the StreamProcessor channel).
15148    ///
15149    /// Configuring output buffers is _required_ after OnOutputConstraints() is
15150    /// received by the client with buffer_constraints_action_required true and
15151    /// stream_lifetime_ordinal equal to the client's current
15152    /// stream_lifetime_ordinal (even if there is an active stream), and is
15153    /// _permitted_ any time there is no current stream.
15154    ///
15155    /// Closing the current stream occurs on the StreamControl ordering domain,
15156    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
15157    /// subsequent Sync() completion must be received by the client before the
15158    /// client knows that there's no longer a current stream.
15159    ///
15160    /// See also CompleteOutputBufferPartialSettings().
15161    SetOutputBufferPartialSettings {
15162        output_settings: StreamBufferPartialSettings,
15163        control_handle: StreamProcessorControlHandle,
15164    },
15165    /// After SetOutputBufferPartialSettings(), the server won't send
15166    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
15167    /// OnOutputEndOfStream() until after the client sends
15168    /// CompleteOutputBufferPartialSettings().
15169    ///
15170    /// Some clients may be able to send
15171    /// CompleteOutputBufferPartialSettings() immediately after
15172    /// SetOutputBufferPartialSettings() - in that case the client needs to be
15173    /// prepared to receive output without knowing the buffer count or packet
15174    /// count yet - such clients may internally delay processing the received
15175    /// output until the client has heard from sysmem (which is when the client
15176    /// will learn the buffer count and packet count).
15177    ///
15178    /// Other clients may first wait for sysmem to allocate, prepare to receive
15179    /// output, and then send CompleteOutputBufferPartialSettings().
15180    CompleteOutputBufferPartialSettings {
15181        buffer_lifetime_ordinal: u64,
15182        control_handle: StreamProcessorControlHandle,
15183    },
15184    /// This message is optional.
15185    ///
15186    /// This message is only valid after QueueInputEndOfStream() for this stream.
15187    /// The stream_lifetime_ordinal input parameter must match the
15188    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
15189    /// will close the channel.
15190    ///
15191    /// A client can use this message to flush through (not discard) the last
15192    /// input data of a stream so that the stream processor server generates
15193    /// corresponding output data for all the input data before the server moves
15194    /// on to the next stream, without forcing the client to wait for
15195    /// OnOutputEndOfStream() before queueing data of another stream.
15196    ///
15197    /// The difference between QueueInputEndOfStream() and
15198    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
15199    /// from the client that there will not be any more input data for the
15200    /// stream (and this info is needed by some stream processors for the stream
15201    /// processor to ever emit the very last output data).  The
15202    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
15203    /// later completely discarding the rest of the current stream by closing
15204    /// the current stream (with or without a stream switch).  In contrast,
15205    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
15206    /// the previously-queued input data be processed including the logical
15207    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
15208    /// before moving on to any newer stream - this essentially changes the
15209    /// close-stream handling from discard to flush-through for this stream
15210    /// only.
15211    ///
15212    /// A client using this message can start providing input data for a new
15213    /// stream without that causing discard of old stream data.  That's the
15214    /// purpose of this message - to allow a client to flush through (not
15215    /// discard) the old stream's last data (instead of the default when closing
15216    /// or switching streams which is discard).
15217    ///
15218    /// Because the old stream is not done processing yet and the old stream's
15219    /// data is not being discarded, the client must be prepared to continue to
15220    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
15221    /// is done. The client will know the stream_lifetime_ordinal is done when
15222    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
15223    /// closes.
15224    FlushEndOfStreamAndCloseStream {
15225        stream_lifetime_ordinal: u64,
15226        control_handle: StreamProcessorControlHandle,
15227    },
15228    /// This "closes" the current stream, leaving no current stream.  In
15229    /// addition, this message can optionally release input buffers or output
15230    /// buffers.
15231    ///
15232    /// If there has never been any active stream, the stream_lifetime_ordinal
15233    /// must be zero or the server will close the channel.  If there has been an
15234    /// active stream, the stream_lifetime_ordinal must be the most recent
15235    /// active stream whether that stream is still active or not.  Else the
15236    /// server will close the channel.
15237    ///
15238    /// Multiple of this message without any new active stream in between is not
15239    /// to be considered an error, which allows a client to use this message to
15240    /// close the current stream to stop wasting processing power on a stream the
15241    /// user no longer cares about, then later decide that buffers should be
15242    /// released and send this message again with release_input_buffers and/or
15243    /// release_output_buffers true to get the buffers released, if the client is
15244    /// interested in trying to avoid overlap in resource usage between old
15245    /// buffers and new buffers (not all clients are).
15246    ///
15247    /// See also Sync().
15248    CloseCurrentStream {
15249        stream_lifetime_ordinal: u64,
15250        release_input_buffers: bool,
15251        release_output_buffers: bool,
15252        control_handle: StreamProcessorControlHandle,
15253    },
15254    /// On completion, all previous StreamProcessor calls have done what they're
15255    /// going to do server-side, _except_ for processing of data queued using
15256    /// QueueInputPacket().
15257    ///
15258    /// The main purpose of this call is to enable the client to wait until
15259    /// CloseCurrentStream() with release_input_buffers and/or
15260    /// release_output_buffers set to true to take effect, before the client
15261    /// allocates new buffers and re-sets-up input and/or output buffers.  This
15262    /// de-overlapping of resource usage can be worthwhile for media buffers
15263    /// which can consume resource types whose overall pools aren't necessarily
15264    /// vast in comparison to resources consumed.  Especially if a client is
15265    /// reconfiguring buffers multiple times.
15266    ///
15267    /// Note that Sync() prior to allocating new media buffers is not alone
15268    /// sufficient to achieve non-overlap of media buffer resource usage system
15269    /// wide, but it can be a useful part of achieving that.
15270    ///
15271    /// The Sync() transits the Output ordering domain and the StreamControl
15272    /// ordering domain, but not the InputData ordering domain.
15273    ///
15274    /// This request can be used to avoid hitting kMaxInFlightStreams which is
15275    /// presently 10.  A client that stays <= 8 in-flight streams will
15276    /// comfortably stay under the limit of 10.  While the protocol permits
15277    /// repeated SetInputBufferSettings() and the like, a client that spams the
15278    /// channel can expect that the channel will just close if the server or the
15279    /// channel itself gets too far behind.
15280    Sync { responder: StreamProcessorSyncResponder },
15281    /// After the client is done with an output packet, the client needs to tell
15282    /// the stream processor that the output packet can be re-used for more
15283    /// output, via this method.
15284    ///
15285    /// It's not permitted to recycle an output packet that's already free with
15286    /// the stream processor server.  It's permitted but discouraged for a
15287    /// client to recycle an output packet that has been deallocated by an
15288    /// explicit or implicit output buffer de-configuration().  See
15289    /// buffer_lifetime_ordinal for more on that. A server must ignore any such
15290    /// stale RecycleOutputPacket() calls.
15291    RecycleOutputPacket {
15292        available_output_packet: PacketHeader,
15293        control_handle: StreamProcessorControlHandle,
15294    },
15295    /// If the input format details are still the same as specified during
15296    /// StreamProcessor creation, this message is unnecessary and does not need
15297    /// to be sent.
15298    ///
15299    /// If the stream doesn't exist yet, this message creates the stream.
15300    ///
15301    /// The server won't send OnOutputConstraints() until after the client has
15302    /// sent at least one QueueInput* message.
15303    ///
15304    /// All servers must permit QueueInputFormatDetails() at the start of a
15305    /// stream without failing, as long as the new format is supported by the
15306    /// StreamProcessor instance.  Technically this allows for a server to only
15307    /// support the exact input format set during StreamProcessor creation, and
15308    /// that is by design.  A client that tries to switch formats and gets a
15309    /// StreamProcessor channel failure should try again one more time with a
15310    /// fresh StreamProcessor instance created with CodecFactory using the new
15311    /// input format during creation, before giving up.
15312    ///
15313    /// These format details override the format details specified during stream
15314    /// processor creation for this stream only.  The next stream will default
15315    /// back to the format details set during stream processor creation.
15316    ///
15317    /// This message is permitted at the start of the first stream (just like at
15318    /// the start of any stream).  The format specified need not match what was
15319    /// specified during stream processor creation, but if it doesn't match, the
15320    /// StreamProcessor channel might close as described above.
15321    QueueInputFormatDetails {
15322        stream_lifetime_ordinal: u64,
15323        format_details: FormatDetails,
15324        control_handle: StreamProcessorControlHandle,
15325    },
15326    /// This message queues input data to the stream processor for processing.
15327    ///
15328    /// If the stream doesn't exist yet, this message creates the new stream.
15329    ///
15330    /// The server won't send OnOutputConstraints() until after the client has
15331    /// sent at least one QueueInput* message.
15332    ///
15333    /// The client must continue to deliver input data via this message even if
15334    /// the stream processor has not yet generated the first OnOutputConstraints(),
15335    /// and even if the StreamProcessor is generating OnFreeInputPacket() for
15336    /// previously-queued input packets.  The input data must continue as long
15337    /// as there are free packets to be assured that the server will ever
15338    /// generate the first OnOutputConstraints().
15339    QueueInputPacket { packet: Packet, control_handle: StreamProcessorControlHandle },
15340    /// Inform the server that all QueueInputPacket() messages for this stream
15341    /// have been sent.
15342    ///
15343    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
15344    /// or StreamProcessor channel closing), there will later be a corresponding
15345    /// OnOutputEndOfStream().
15346    ///
15347    /// The corresponding OnOutputEndOfStream() message will be generated only if
15348    /// the server finishes processing the stream before the server sees the
15349    /// client close the stream (such as by starting a new stream).  A way to
15350    /// force the server to finish the stream before closing is to use
15351    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before any
15352    /// new stream.  Another way to force the server to finish the stream before
15353    /// closing is to wait for the OnOutputEndOfStream() before taking any action
15354    /// that closes the stream.
15355    ///
15356    /// In addition to serving as an "EndOfStream" marker to make it obvious
15357    /// client-side when all input data has been processed, if a client never
15358    /// sends QueueInputEndOfStream(), no amount of waiting will necessarily
15359    /// result in all input data getting processed through to the output.  Some
15360    /// stream processors have some internally-delayed data which only gets
15361    /// pushed through by additional input data _or_ by this EndOfStream marker.
15362    /// In that sense, this message can be viewed as a flush-through at
15363    /// InputData domain level, but the flush-through only takes effect if the
15364    /// stream processor even gets that far before the stream is just closed at
15365    /// StreamControl domain level.  This message is not alone sufficient to act
15366    /// as an overall flush-through at StreamControl level. For that, send this
15367    /// message first and then send FlushEndOfStreamAndCloseStream() (at which
15368    /// point it becomes possible to queue input data for a new stream without
15369    /// causing discard of this older stream's data), or wait for the
15370    /// OnOutputEndOfStream() before closing the current stream.
15371    ///
15372    /// If a client sends QueueInputPacket(), QueueInputFormatDetails(),
15373    /// QueueInputEndOfStream() for this stream after the first
15374    /// QueueInputEndOfStream() for this stream, a server should close the
15375    /// StreamProcessor channel.
15376    QueueInputEndOfStream {
15377        stream_lifetime_ordinal: u64,
15378        control_handle: StreamProcessorControlHandle,
15379    },
15380}
15381
15382impl StreamProcessorRequest {
15383    #[allow(irrefutable_let_patterns)]
15384    pub fn into_enable_on_stream_failed(self) -> Option<(StreamProcessorControlHandle)> {
15385        if let StreamProcessorRequest::EnableOnStreamFailed { control_handle } = self {
15386            Some((control_handle))
15387        } else {
15388            None
15389        }
15390    }
15391
15392    #[allow(irrefutable_let_patterns)]
15393    pub fn into_set_input_buffer_partial_settings(
15394        self,
15395    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
15396        if let StreamProcessorRequest::SetInputBufferPartialSettings {
15397            input_settings,
15398            control_handle,
15399        } = self
15400        {
15401            Some((input_settings, control_handle))
15402        } else {
15403            None
15404        }
15405    }
15406
15407    #[allow(irrefutable_let_patterns)]
15408    pub fn into_set_output_buffer_partial_settings(
15409        self,
15410    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
15411        if let StreamProcessorRequest::SetOutputBufferPartialSettings {
15412            output_settings,
15413            control_handle,
15414        } = self
15415        {
15416            Some((output_settings, control_handle))
15417        } else {
15418            None
15419        }
15420    }
15421
15422    #[allow(irrefutable_let_patterns)]
15423    pub fn into_complete_output_buffer_partial_settings(
15424        self,
15425    ) -> Option<(u64, StreamProcessorControlHandle)> {
15426        if let StreamProcessorRequest::CompleteOutputBufferPartialSettings {
15427            buffer_lifetime_ordinal,
15428            control_handle,
15429        } = self
15430        {
15431            Some((buffer_lifetime_ordinal, control_handle))
15432        } else {
15433            None
15434        }
15435    }
15436
15437    #[allow(irrefutable_let_patterns)]
15438    pub fn into_flush_end_of_stream_and_close_stream(
15439        self,
15440    ) -> Option<(u64, StreamProcessorControlHandle)> {
15441        if let StreamProcessorRequest::FlushEndOfStreamAndCloseStream {
15442            stream_lifetime_ordinal,
15443            control_handle,
15444        } = self
15445        {
15446            Some((stream_lifetime_ordinal, control_handle))
15447        } else {
15448            None
15449        }
15450    }
15451
15452    #[allow(irrefutable_let_patterns)]
15453    pub fn into_close_current_stream(
15454        self,
15455    ) -> Option<(u64, bool, bool, StreamProcessorControlHandle)> {
15456        if let StreamProcessorRequest::CloseCurrentStream {
15457            stream_lifetime_ordinal,
15458            release_input_buffers,
15459            release_output_buffers,
15460            control_handle,
15461        } = self
15462        {
15463            Some((
15464                stream_lifetime_ordinal,
15465                release_input_buffers,
15466                release_output_buffers,
15467                control_handle,
15468            ))
15469        } else {
15470            None
15471        }
15472    }
15473
15474    #[allow(irrefutable_let_patterns)]
15475    pub fn into_sync(self) -> Option<(StreamProcessorSyncResponder)> {
15476        if let StreamProcessorRequest::Sync { responder } = self {
15477            Some((responder))
15478        } else {
15479            None
15480        }
15481    }
15482
15483    #[allow(irrefutable_let_patterns)]
15484    pub fn into_recycle_output_packet(
15485        self,
15486    ) -> Option<(PacketHeader, StreamProcessorControlHandle)> {
15487        if let StreamProcessorRequest::RecycleOutputPacket {
15488            available_output_packet,
15489            control_handle,
15490        } = self
15491        {
15492            Some((available_output_packet, control_handle))
15493        } else {
15494            None
15495        }
15496    }
15497
15498    #[allow(irrefutable_let_patterns)]
15499    pub fn into_queue_input_format_details(
15500        self,
15501    ) -> Option<(u64, FormatDetails, StreamProcessorControlHandle)> {
15502        if let StreamProcessorRequest::QueueInputFormatDetails {
15503            stream_lifetime_ordinal,
15504            format_details,
15505            control_handle,
15506        } = self
15507        {
15508            Some((stream_lifetime_ordinal, format_details, control_handle))
15509        } else {
15510            None
15511        }
15512    }
15513
15514    #[allow(irrefutable_let_patterns)]
15515    pub fn into_queue_input_packet(self) -> Option<(Packet, StreamProcessorControlHandle)> {
15516        if let StreamProcessorRequest::QueueInputPacket { packet, control_handle } = self {
15517            Some((packet, control_handle))
15518        } else {
15519            None
15520        }
15521    }
15522
15523    #[allow(irrefutable_let_patterns)]
15524    pub fn into_queue_input_end_of_stream(self) -> Option<(u64, StreamProcessorControlHandle)> {
15525        if let StreamProcessorRequest::QueueInputEndOfStream {
15526            stream_lifetime_ordinal,
15527            control_handle,
15528        } = self
15529        {
15530            Some((stream_lifetime_ordinal, control_handle))
15531        } else {
15532            None
15533        }
15534    }
15535
15536    /// Name of the method defined in FIDL
15537    pub fn method_name(&self) -> &'static str {
15538        match *self {
15539            StreamProcessorRequest::EnableOnStreamFailed { .. } => "enable_on_stream_failed",
15540            StreamProcessorRequest::SetInputBufferPartialSettings { .. } => {
15541                "set_input_buffer_partial_settings"
15542            }
15543            StreamProcessorRequest::SetOutputBufferPartialSettings { .. } => {
15544                "set_output_buffer_partial_settings"
15545            }
15546            StreamProcessorRequest::CompleteOutputBufferPartialSettings { .. } => {
15547                "complete_output_buffer_partial_settings"
15548            }
15549            StreamProcessorRequest::FlushEndOfStreamAndCloseStream { .. } => {
15550                "flush_end_of_stream_and_close_stream"
15551            }
15552            StreamProcessorRequest::CloseCurrentStream { .. } => "close_current_stream",
15553            StreamProcessorRequest::Sync { .. } => "sync",
15554            StreamProcessorRequest::RecycleOutputPacket { .. } => "recycle_output_packet",
15555            StreamProcessorRequest::QueueInputFormatDetails { .. } => "queue_input_format_details",
15556            StreamProcessorRequest::QueueInputPacket { .. } => "queue_input_packet",
15557            StreamProcessorRequest::QueueInputEndOfStream { .. } => "queue_input_end_of_stream",
15558        }
15559    }
15560}
15561
15562#[derive(Debug, Clone)]
15563pub struct StreamProcessorControlHandle {
15564    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
15565}
15566
15567impl fidl::endpoints::ControlHandle for StreamProcessorControlHandle {
15568    fn shutdown(&self) {
15569        self.inner.shutdown()
15570    }
15571    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
15572        self.inner.shutdown_with_epitaph(status)
15573    }
15574
15575    fn is_closed(&self) -> bool {
15576        self.inner.channel().is_closed()
15577    }
15578    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
15579        self.inner.channel().on_closed()
15580    }
15581
15582    #[cfg(target_os = "fuchsia")]
15583    fn signal_peer(
15584        &self,
15585        clear_mask: zx::Signals,
15586        set_mask: zx::Signals,
15587    ) -> Result<(), zx_status::Status> {
15588        use fidl::Peered;
15589        self.inner.channel().signal_peer(clear_mask, set_mask)
15590    }
15591}
15592
15593impl StreamProcessorControlHandle {
15594    pub fn send_on_stream_failed(
15595        &self,
15596        mut stream_lifetime_ordinal: u64,
15597        mut error: StreamError,
15598    ) -> Result<(), fidl::Error> {
15599        self.inner.send::<StreamProcessorOnStreamFailedRequest>(
15600            (stream_lifetime_ordinal, error),
15601            0,
15602            0x77ccf70bb061cf8e,
15603            fidl::encoding::DynamicFlags::empty(),
15604        )
15605    }
15606
15607    pub fn send_on_input_constraints(
15608        &self,
15609        mut input_constraints: &StreamBufferConstraints,
15610    ) -> Result<(), fidl::Error> {
15611        self.inner.send::<StreamProcessorOnInputConstraintsRequest>(
15612            (input_constraints,),
15613            0,
15614            0x211da9966a8ca0,
15615            fidl::encoding::DynamicFlags::empty(),
15616        )
15617    }
15618
15619    pub fn send_on_output_constraints(
15620        &self,
15621        mut output_config: &StreamOutputConstraints,
15622    ) -> Result<(), fidl::Error> {
15623        self.inner.send::<StreamProcessorOnOutputConstraintsRequest>(
15624            (output_config,),
15625            0,
15626            0x40d8234504c170f3,
15627            fidl::encoding::DynamicFlags::empty(),
15628        )
15629    }
15630
15631    pub fn send_on_output_format(
15632        &self,
15633        mut output_format: &StreamOutputFormat,
15634    ) -> Result<(), fidl::Error> {
15635        self.inner.send::<StreamProcessorOnOutputFormatRequest>(
15636            (output_format,),
15637            0,
15638            0x131b77ae120360bc,
15639            fidl::encoding::DynamicFlags::empty(),
15640        )
15641    }
15642
15643    pub fn send_on_output_packet(
15644        &self,
15645        mut output_packet: &Packet,
15646        mut error_detected_before: bool,
15647        mut error_detected_during: bool,
15648    ) -> Result<(), fidl::Error> {
15649        self.inner.send::<StreamProcessorOnOutputPacketRequest>(
15650            (output_packet, error_detected_before, error_detected_during),
15651            0,
15652            0x5c2029be1090ce93,
15653            fidl::encoding::DynamicFlags::empty(),
15654        )
15655    }
15656
15657    pub fn send_on_output_end_of_stream(
15658        &self,
15659        mut stream_lifetime_ordinal: u64,
15660        mut error_detected_before: bool,
15661    ) -> Result<(), fidl::Error> {
15662        self.inner.send::<StreamProcessorOnOutputEndOfStreamRequest>(
15663            (stream_lifetime_ordinal, error_detected_before),
15664            0,
15665            0x3bb65d237cfa50e6,
15666            fidl::encoding::DynamicFlags::empty(),
15667        )
15668    }
15669
15670    pub fn send_on_free_input_packet(
15671        &self,
15672        mut free_input_packet: &PacketHeader,
15673    ) -> Result<(), fidl::Error> {
15674        self.inner.send::<StreamProcessorOnFreeInputPacketRequest>(
15675            (free_input_packet,),
15676            0,
15677            0xeef799b28708bbd,
15678            fidl::encoding::DynamicFlags::empty(),
15679        )
15680    }
15681}
15682
15683#[must_use = "FIDL methods require a response to be sent"]
15684#[derive(Debug)]
15685pub struct StreamProcessorSyncResponder {
15686    control_handle: std::mem::ManuallyDrop<StreamProcessorControlHandle>,
15687    tx_id: u32,
15688}
15689
15690/// Set the the channel to be shutdown (see [`StreamProcessorControlHandle::shutdown`])
15691/// if the responder is dropped without sending a response, so that the client
15692/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
15693impl std::ops::Drop for StreamProcessorSyncResponder {
15694    fn drop(&mut self) {
15695        self.control_handle.shutdown();
15696        // Safety: drops once, never accessed again
15697        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
15698    }
15699}
15700
15701impl fidl::endpoints::Responder for StreamProcessorSyncResponder {
15702    type ControlHandle = StreamProcessorControlHandle;
15703
15704    fn control_handle(&self) -> &StreamProcessorControlHandle {
15705        &self.control_handle
15706    }
15707
15708    fn drop_without_shutdown(mut self) {
15709        // Safety: drops once, never accessed again due to mem::forget
15710        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
15711        // Prevent Drop from running (which would shut down the channel)
15712        std::mem::forget(self);
15713    }
15714}
15715
15716impl StreamProcessorSyncResponder {
15717    /// Sends a response to the FIDL transaction.
15718    ///
15719    /// Sets the channel to shutdown if an error occurs.
15720    pub fn send(self) -> Result<(), fidl::Error> {
15721        let _result = self.send_raw();
15722        if _result.is_err() {
15723            self.control_handle.shutdown();
15724        }
15725        self.drop_without_shutdown();
15726        _result
15727    }
15728
15729    /// Similar to "send" but does not shutdown the channel if an error occurs.
15730    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
15731        let _result = self.send_raw();
15732        self.drop_without_shutdown();
15733        _result
15734    }
15735
15736    fn send_raw(&self) -> Result<(), fidl::Error> {
15737        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
15738            (),
15739            self.tx_id,
15740            0x4b3e44300b0ec6aa,
15741            fidl::encoding::DynamicFlags::empty(),
15742        )
15743    }
15744}
15745
15746#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15747pub struct StreamSinkMarker;
15748
15749impl fidl::endpoints::ProtocolMarker for StreamSinkMarker {
15750    type Proxy = StreamSinkProxy;
15751    type RequestStream = StreamSinkRequestStream;
15752    #[cfg(target_os = "fuchsia")]
15753    type SynchronousProxy = StreamSinkSynchronousProxy;
15754
15755    const DEBUG_NAME: &'static str = "(anonymous) StreamSink";
15756}
15757
15758pub trait StreamSinkProxyInterface: Send + Sync {
15759    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
15760    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
15761    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
15762    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
15763    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
15764    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
15765    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
15766}
15767#[derive(Debug)]
15768#[cfg(target_os = "fuchsia")]
15769pub struct StreamSinkSynchronousProxy {
15770    client: fidl::client::sync::Client,
15771}
15772
15773#[cfg(target_os = "fuchsia")]
15774impl fidl::endpoints::SynchronousProxy for StreamSinkSynchronousProxy {
15775    type Proxy = StreamSinkProxy;
15776    type Protocol = StreamSinkMarker;
15777
15778    fn from_channel(inner: fidl::Channel) -> Self {
15779        Self::new(inner)
15780    }
15781
15782    fn into_channel(self) -> fidl::Channel {
15783        self.client.into_channel()
15784    }
15785
15786    fn as_channel(&self) -> &fidl::Channel {
15787        self.client.as_channel()
15788    }
15789}
15790
15791#[cfg(target_os = "fuchsia")]
15792impl StreamSinkSynchronousProxy {
15793    pub fn new(channel: fidl::Channel) -> Self {
15794        let protocol_name = <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
15795        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
15796    }
15797
15798    pub fn into_channel(self) -> fidl::Channel {
15799        self.client.into_channel()
15800    }
15801
15802    /// Waits until an event arrives and returns it. It is safe for other
15803    /// threads to make concurrent requests while waiting for an event.
15804    pub fn wait_for_event(
15805        &self,
15806        deadline: zx::MonotonicInstant,
15807    ) -> Result<StreamSinkEvent, fidl::Error> {
15808        StreamSinkEvent::decode(self.client.wait_for_event(deadline)?)
15809    }
15810
15811    /// Sends a packet to the service. The response is sent when the service is
15812    /// done with the associated payload memory.
15813    ///
15814    /// `packet` must be valid for the current buffer set, otherwise the service
15815    /// will close the connection.
15816    pub fn r#send_packet(
15817        &self,
15818        mut packet: &StreamPacket,
15819        ___deadline: zx::MonotonicInstant,
15820    ) -> Result<(), fidl::Error> {
15821        let _response =
15822            self.client.send_query::<StreamSinkSendPacketRequest, fidl::encoding::EmptyPayload>(
15823                (packet,),
15824                0x67cddd607442775f,
15825                fidl::encoding::DynamicFlags::empty(),
15826                ___deadline,
15827            )?;
15828        Ok(_response)
15829    }
15830
15831    /// Sends a packet to the service. This interface doesn't define how the
15832    /// client knows when the sink is done with the associated payload memory.
15833    /// The inheriting interface must define that.
15834    ///
15835    /// `packet` must be valid for the current buffer set, otherwise the service
15836    /// will close the connection.
15837    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
15838        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
15839            (packet,),
15840            0x8d9b8b413ceba9d,
15841            fidl::encoding::DynamicFlags::empty(),
15842        )
15843    }
15844
15845    /// Indicates the stream has ended. The precise semantics of this method are
15846    /// determined by the inheriting interface.
15847    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
15848        self.client.send::<fidl::encoding::EmptyPayload>(
15849            (),
15850            0x6180fd6f7e793b71,
15851            fidl::encoding::DynamicFlags::empty(),
15852        )
15853    }
15854
15855    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
15856    /// and not yet released. The response is sent after all packets have been
15857    /// released.
15858    pub fn r#discard_all_packets(
15859        &self,
15860        ___deadline: zx::MonotonicInstant,
15861    ) -> Result<(), fidl::Error> {
15862        let _response =
15863            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
15864                (),
15865                0x6f4dad7af2917665,
15866                fidl::encoding::DynamicFlags::empty(),
15867                ___deadline,
15868            )?;
15869        Ok(_response)
15870    }
15871
15872    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
15873    /// and not yet released.
15874    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
15875        self.client.send::<fidl::encoding::EmptyPayload>(
15876            (),
15877            0x50d36d0d23081bc4,
15878            fidl::encoding::DynamicFlags::empty(),
15879        )
15880    }
15881}
15882
15883#[cfg(target_os = "fuchsia")]
15884impl From<StreamSinkSynchronousProxy> for zx::Handle {
15885    fn from(value: StreamSinkSynchronousProxy) -> Self {
15886        value.into_channel().into()
15887    }
15888}
15889
15890#[cfg(target_os = "fuchsia")]
15891impl From<fidl::Channel> for StreamSinkSynchronousProxy {
15892    fn from(value: fidl::Channel) -> Self {
15893        Self::new(value)
15894    }
15895}
15896
15897#[cfg(target_os = "fuchsia")]
15898impl fidl::endpoints::FromClient for StreamSinkSynchronousProxy {
15899    type Protocol = StreamSinkMarker;
15900
15901    fn from_client(value: fidl::endpoints::ClientEnd<StreamSinkMarker>) -> Self {
15902        Self::new(value.into_channel())
15903    }
15904}
15905
15906#[derive(Debug, Clone)]
15907pub struct StreamSinkProxy {
15908    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
15909}
15910
15911impl fidl::endpoints::Proxy for StreamSinkProxy {
15912    type Protocol = StreamSinkMarker;
15913
15914    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
15915        Self::new(inner)
15916    }
15917
15918    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
15919        self.client.into_channel().map_err(|client| Self { client })
15920    }
15921
15922    fn as_channel(&self) -> &::fidl::AsyncChannel {
15923        self.client.as_channel()
15924    }
15925}
15926
15927impl StreamSinkProxy {
15928    /// Create a new Proxy for fuchsia.media/StreamSink.
15929    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
15930        let protocol_name = <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
15931        Self { client: fidl::client::Client::new(channel, protocol_name) }
15932    }
15933
15934    /// Get a Stream of events from the remote end of the protocol.
15935    ///
15936    /// # Panics
15937    ///
15938    /// Panics if the event stream was already taken.
15939    pub fn take_event_stream(&self) -> StreamSinkEventStream {
15940        StreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
15941    }
15942
15943    /// Sends a packet to the service. The response is sent when the service is
15944    /// done with the associated payload memory.
15945    ///
15946    /// `packet` must be valid for the current buffer set, otherwise the service
15947    /// will close the connection.
15948    pub fn r#send_packet(
15949        &self,
15950        mut packet: &StreamPacket,
15951    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
15952        StreamSinkProxyInterface::r#send_packet(self, packet)
15953    }
15954
15955    /// Sends a packet to the service. This interface doesn't define how the
15956    /// client knows when the sink is done with the associated payload memory.
15957    /// The inheriting interface must define that.
15958    ///
15959    /// `packet` must be valid for the current buffer set, otherwise the service
15960    /// will close the connection.
15961    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
15962        StreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
15963    }
15964
15965    /// Indicates the stream has ended. The precise semantics of this method are
15966    /// determined by the inheriting interface.
15967    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
15968        StreamSinkProxyInterface::r#end_of_stream(self)
15969    }
15970
15971    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
15972    /// and not yet released. The response is sent after all packets have been
15973    /// released.
15974    pub fn r#discard_all_packets(
15975        &self,
15976    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
15977        StreamSinkProxyInterface::r#discard_all_packets(self)
15978    }
15979
15980    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
15981    /// and not yet released.
15982    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
15983        StreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
15984    }
15985}
15986
15987impl StreamSinkProxyInterface for StreamSinkProxy {
15988    type SendPacketResponseFut =
15989        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
15990    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
15991        fn _decode(
15992            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
15993        ) -> Result<(), fidl::Error> {
15994            let _response = fidl::client::decode_transaction_body::<
15995                fidl::encoding::EmptyPayload,
15996                fidl::encoding::DefaultFuchsiaResourceDialect,
15997                0x67cddd607442775f,
15998            >(_buf?)?;
15999            Ok(_response)
16000        }
16001        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
16002            (packet,),
16003            0x67cddd607442775f,
16004            fidl::encoding::DynamicFlags::empty(),
16005            _decode,
16006        )
16007    }
16008
16009    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16010        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
16011            (packet,),
16012            0x8d9b8b413ceba9d,
16013            fidl::encoding::DynamicFlags::empty(),
16014        )
16015    }
16016
16017    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
16018        self.client.send::<fidl::encoding::EmptyPayload>(
16019            (),
16020            0x6180fd6f7e793b71,
16021            fidl::encoding::DynamicFlags::empty(),
16022        )
16023    }
16024
16025    type DiscardAllPacketsResponseFut =
16026        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
16027    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
16028        fn _decode(
16029            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
16030        ) -> Result<(), fidl::Error> {
16031            let _response = fidl::client::decode_transaction_body::<
16032                fidl::encoding::EmptyPayload,
16033                fidl::encoding::DefaultFuchsiaResourceDialect,
16034                0x6f4dad7af2917665,
16035            >(_buf?)?;
16036            Ok(_response)
16037        }
16038        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
16039            (),
16040            0x6f4dad7af2917665,
16041            fidl::encoding::DynamicFlags::empty(),
16042            _decode,
16043        )
16044    }
16045
16046    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16047        self.client.send::<fidl::encoding::EmptyPayload>(
16048            (),
16049            0x50d36d0d23081bc4,
16050            fidl::encoding::DynamicFlags::empty(),
16051        )
16052    }
16053}
16054
16055pub struct StreamSinkEventStream {
16056    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
16057}
16058
16059impl std::marker::Unpin for StreamSinkEventStream {}
16060
16061impl futures::stream::FusedStream for StreamSinkEventStream {
16062    fn is_terminated(&self) -> bool {
16063        self.event_receiver.is_terminated()
16064    }
16065}
16066
16067impl futures::Stream for StreamSinkEventStream {
16068    type Item = Result<StreamSinkEvent, fidl::Error>;
16069
16070    fn poll_next(
16071        mut self: std::pin::Pin<&mut Self>,
16072        cx: &mut std::task::Context<'_>,
16073    ) -> std::task::Poll<Option<Self::Item>> {
16074        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
16075            &mut self.event_receiver,
16076            cx
16077        )?) {
16078            Some(buf) => std::task::Poll::Ready(Some(StreamSinkEvent::decode(buf))),
16079            None => std::task::Poll::Ready(None),
16080        }
16081    }
16082}
16083
16084#[derive(Debug)]
16085pub enum StreamSinkEvent {}
16086
16087impl StreamSinkEvent {
16088    /// Decodes a message buffer as a [`StreamSinkEvent`].
16089    fn decode(
16090        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
16091    ) -> Result<StreamSinkEvent, fidl::Error> {
16092        let (bytes, _handles) = buf.split_mut();
16093        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16094        debug_assert_eq!(tx_header.tx_id, 0);
16095        match tx_header.ordinal {
16096            _ => Err(fidl::Error::UnknownOrdinal {
16097                ordinal: tx_header.ordinal,
16098                protocol_name: <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16099            }),
16100        }
16101    }
16102}
16103
16104/// A Stream of incoming requests for fuchsia.media/StreamSink.
16105pub struct StreamSinkRequestStream {
16106    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16107    is_terminated: bool,
16108}
16109
16110impl std::marker::Unpin for StreamSinkRequestStream {}
16111
16112impl futures::stream::FusedStream for StreamSinkRequestStream {
16113    fn is_terminated(&self) -> bool {
16114        self.is_terminated
16115    }
16116}
16117
16118impl fidl::endpoints::RequestStream for StreamSinkRequestStream {
16119    type Protocol = StreamSinkMarker;
16120    type ControlHandle = StreamSinkControlHandle;
16121
16122    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
16123        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
16124    }
16125
16126    fn control_handle(&self) -> Self::ControlHandle {
16127        StreamSinkControlHandle { inner: self.inner.clone() }
16128    }
16129
16130    fn into_inner(
16131        self,
16132    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
16133    {
16134        (self.inner, self.is_terminated)
16135    }
16136
16137    fn from_inner(
16138        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16139        is_terminated: bool,
16140    ) -> Self {
16141        Self { inner, is_terminated }
16142    }
16143}
16144
16145impl futures::Stream for StreamSinkRequestStream {
16146    type Item = Result<StreamSinkRequest, fidl::Error>;
16147
16148    fn poll_next(
16149        mut self: std::pin::Pin<&mut Self>,
16150        cx: &mut std::task::Context<'_>,
16151    ) -> std::task::Poll<Option<Self::Item>> {
16152        let this = &mut *self;
16153        if this.inner.check_shutdown(cx) {
16154            this.is_terminated = true;
16155            return std::task::Poll::Ready(None);
16156        }
16157        if this.is_terminated {
16158            panic!("polled StreamSinkRequestStream after completion");
16159        }
16160        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
16161            |bytes, handles| {
16162                match this.inner.channel().read_etc(cx, bytes, handles) {
16163                    std::task::Poll::Ready(Ok(())) => {}
16164                    std::task::Poll::Pending => return std::task::Poll::Pending,
16165                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
16166                        this.is_terminated = true;
16167                        return std::task::Poll::Ready(None);
16168                    }
16169                    std::task::Poll::Ready(Err(e)) => {
16170                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
16171                            e.into(),
16172                        ))))
16173                    }
16174                }
16175
16176                // A message has been received from the channel
16177                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16178
16179                std::task::Poll::Ready(Some(match header.ordinal {
16180                    0x67cddd607442775f => {
16181                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16182                        let mut req = fidl::new_empty!(
16183                            StreamSinkSendPacketRequest,
16184                            fidl::encoding::DefaultFuchsiaResourceDialect
16185                        );
16186                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
16187                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16188                        Ok(StreamSinkRequest::SendPacket {
16189                            packet: req.packet,
16190
16191                            responder: StreamSinkSendPacketResponder {
16192                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16193                                tx_id: header.tx_id,
16194                            },
16195                        })
16196                    }
16197                    0x8d9b8b413ceba9d => {
16198                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16199                        let mut req = fidl::new_empty!(
16200                            StreamSinkSendPacketNoReplyRequest,
16201                            fidl::encoding::DefaultFuchsiaResourceDialect
16202                        );
16203                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
16204                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16205                        Ok(StreamSinkRequest::SendPacketNoReply {
16206                            packet: req.packet,
16207
16208                            control_handle,
16209                        })
16210                    }
16211                    0x6180fd6f7e793b71 => {
16212                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16213                        let mut req = fidl::new_empty!(
16214                            fidl::encoding::EmptyPayload,
16215                            fidl::encoding::DefaultFuchsiaResourceDialect
16216                        );
16217                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16218                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16219                        Ok(StreamSinkRequest::EndOfStream { control_handle })
16220                    }
16221                    0x6f4dad7af2917665 => {
16222                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16223                        let mut req = fidl::new_empty!(
16224                            fidl::encoding::EmptyPayload,
16225                            fidl::encoding::DefaultFuchsiaResourceDialect
16226                        );
16227                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16228                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16229                        Ok(StreamSinkRequest::DiscardAllPackets {
16230                            responder: StreamSinkDiscardAllPacketsResponder {
16231                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16232                                tx_id: header.tx_id,
16233                            },
16234                        })
16235                    }
16236                    0x50d36d0d23081bc4 => {
16237                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16238                        let mut req = fidl::new_empty!(
16239                            fidl::encoding::EmptyPayload,
16240                            fidl::encoding::DefaultFuchsiaResourceDialect
16241                        );
16242                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16243                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16244                        Ok(StreamSinkRequest::DiscardAllPacketsNoReply { control_handle })
16245                    }
16246                    _ => Err(fidl::Error::UnknownOrdinal {
16247                        ordinal: header.ordinal,
16248                        protocol_name:
16249                            <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16250                    }),
16251                }))
16252            },
16253        )
16254    }
16255}
16256
16257/// Consumes a stream of packets. This interface is typically inherited along
16258/// with `StreamBufferSet` to enable the transport of elementary streams from
16259/// clients to services.
16260#[derive(Debug)]
16261pub enum StreamSinkRequest {
16262    /// Sends a packet to the service. The response is sent when the service is
16263    /// done with the associated payload memory.
16264    ///
16265    /// `packet` must be valid for the current buffer set, otherwise the service
16266    /// will close the connection.
16267    SendPacket { packet: StreamPacket, responder: StreamSinkSendPacketResponder },
16268    /// Sends a packet to the service. This interface doesn't define how the
16269    /// client knows when the sink is done with the associated payload memory.
16270    /// The inheriting interface must define that.
16271    ///
16272    /// `packet` must be valid for the current buffer set, otherwise the service
16273    /// will close the connection.
16274    SendPacketNoReply { packet: StreamPacket, control_handle: StreamSinkControlHandle },
16275    /// Indicates the stream has ended. The precise semantics of this method are
16276    /// determined by the inheriting interface.
16277    EndOfStream { control_handle: StreamSinkControlHandle },
16278    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
16279    /// and not yet released. The response is sent after all packets have been
16280    /// released.
16281    DiscardAllPackets { responder: StreamSinkDiscardAllPacketsResponder },
16282    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
16283    /// and not yet released.
16284    DiscardAllPacketsNoReply { control_handle: StreamSinkControlHandle },
16285}
16286
16287impl StreamSinkRequest {
16288    #[allow(irrefutable_let_patterns)]
16289    pub fn into_send_packet(self) -> Option<(StreamPacket, StreamSinkSendPacketResponder)> {
16290        if let StreamSinkRequest::SendPacket { packet, responder } = self {
16291            Some((packet, responder))
16292        } else {
16293            None
16294        }
16295    }
16296
16297    #[allow(irrefutable_let_patterns)]
16298    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, StreamSinkControlHandle)> {
16299        if let StreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
16300            Some((packet, control_handle))
16301        } else {
16302            None
16303        }
16304    }
16305
16306    #[allow(irrefutable_let_patterns)]
16307    pub fn into_end_of_stream(self) -> Option<(StreamSinkControlHandle)> {
16308        if let StreamSinkRequest::EndOfStream { control_handle } = self {
16309            Some((control_handle))
16310        } else {
16311            None
16312        }
16313    }
16314
16315    #[allow(irrefutable_let_patterns)]
16316    pub fn into_discard_all_packets(self) -> Option<(StreamSinkDiscardAllPacketsResponder)> {
16317        if let StreamSinkRequest::DiscardAllPackets { responder } = self {
16318            Some((responder))
16319        } else {
16320            None
16321        }
16322    }
16323
16324    #[allow(irrefutable_let_patterns)]
16325    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSinkControlHandle)> {
16326        if let StreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
16327            Some((control_handle))
16328        } else {
16329            None
16330        }
16331    }
16332
16333    /// Name of the method defined in FIDL
16334    pub fn method_name(&self) -> &'static str {
16335        match *self {
16336            StreamSinkRequest::SendPacket { .. } => "send_packet",
16337            StreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
16338            StreamSinkRequest::EndOfStream { .. } => "end_of_stream",
16339            StreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
16340            StreamSinkRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
16341        }
16342    }
16343}
16344
16345#[derive(Debug, Clone)]
16346pub struct StreamSinkControlHandle {
16347    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16348}
16349
16350impl fidl::endpoints::ControlHandle for StreamSinkControlHandle {
16351    fn shutdown(&self) {
16352        self.inner.shutdown()
16353    }
16354    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
16355        self.inner.shutdown_with_epitaph(status)
16356    }
16357
16358    fn is_closed(&self) -> bool {
16359        self.inner.channel().is_closed()
16360    }
16361    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
16362        self.inner.channel().on_closed()
16363    }
16364
16365    #[cfg(target_os = "fuchsia")]
16366    fn signal_peer(
16367        &self,
16368        clear_mask: zx::Signals,
16369        set_mask: zx::Signals,
16370    ) -> Result<(), zx_status::Status> {
16371        use fidl::Peered;
16372        self.inner.channel().signal_peer(clear_mask, set_mask)
16373    }
16374}
16375
16376impl StreamSinkControlHandle {}
16377
16378#[must_use = "FIDL methods require a response to be sent"]
16379#[derive(Debug)]
16380pub struct StreamSinkSendPacketResponder {
16381    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
16382    tx_id: u32,
16383}
16384
16385/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
16386/// if the responder is dropped without sending a response, so that the client
16387/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
16388impl std::ops::Drop for StreamSinkSendPacketResponder {
16389    fn drop(&mut self) {
16390        self.control_handle.shutdown();
16391        // Safety: drops once, never accessed again
16392        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16393    }
16394}
16395
16396impl fidl::endpoints::Responder for StreamSinkSendPacketResponder {
16397    type ControlHandle = StreamSinkControlHandle;
16398
16399    fn control_handle(&self) -> &StreamSinkControlHandle {
16400        &self.control_handle
16401    }
16402
16403    fn drop_without_shutdown(mut self) {
16404        // Safety: drops once, never accessed again due to mem::forget
16405        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16406        // Prevent Drop from running (which would shut down the channel)
16407        std::mem::forget(self);
16408    }
16409}
16410
16411impl StreamSinkSendPacketResponder {
16412    /// Sends a response to the FIDL transaction.
16413    ///
16414    /// Sets the channel to shutdown if an error occurs.
16415    pub fn send(self) -> Result<(), fidl::Error> {
16416        let _result = self.send_raw();
16417        if _result.is_err() {
16418            self.control_handle.shutdown();
16419        }
16420        self.drop_without_shutdown();
16421        _result
16422    }
16423
16424    /// Similar to "send" but does not shutdown the channel if an error occurs.
16425    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
16426        let _result = self.send_raw();
16427        self.drop_without_shutdown();
16428        _result
16429    }
16430
16431    fn send_raw(&self) -> Result<(), fidl::Error> {
16432        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
16433            (),
16434            self.tx_id,
16435            0x67cddd607442775f,
16436            fidl::encoding::DynamicFlags::empty(),
16437        )
16438    }
16439}
16440
16441#[must_use = "FIDL methods require a response to be sent"]
16442#[derive(Debug)]
16443pub struct StreamSinkDiscardAllPacketsResponder {
16444    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
16445    tx_id: u32,
16446}
16447
16448/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
16449/// if the responder is dropped without sending a response, so that the client
16450/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
16451impl std::ops::Drop for StreamSinkDiscardAllPacketsResponder {
16452    fn drop(&mut self) {
16453        self.control_handle.shutdown();
16454        // Safety: drops once, never accessed again
16455        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16456    }
16457}
16458
16459impl fidl::endpoints::Responder for StreamSinkDiscardAllPacketsResponder {
16460    type ControlHandle = StreamSinkControlHandle;
16461
16462    fn control_handle(&self) -> &StreamSinkControlHandle {
16463        &self.control_handle
16464    }
16465
16466    fn drop_without_shutdown(mut self) {
16467        // Safety: drops once, never accessed again due to mem::forget
16468        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16469        // Prevent Drop from running (which would shut down the channel)
16470        std::mem::forget(self);
16471    }
16472}
16473
16474impl StreamSinkDiscardAllPacketsResponder {
16475    /// Sends a response to the FIDL transaction.
16476    ///
16477    /// Sets the channel to shutdown if an error occurs.
16478    pub fn send(self) -> Result<(), fidl::Error> {
16479        let _result = self.send_raw();
16480        if _result.is_err() {
16481            self.control_handle.shutdown();
16482        }
16483        self.drop_without_shutdown();
16484        _result
16485    }
16486
16487    /// Similar to "send" but does not shutdown the channel if an error occurs.
16488    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
16489        let _result = self.send_raw();
16490        self.drop_without_shutdown();
16491        _result
16492    }
16493
16494    fn send_raw(&self) -> Result<(), fidl::Error> {
16495        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
16496            (),
16497            self.tx_id,
16498            0x6f4dad7af2917665,
16499            fidl::encoding::DynamicFlags::empty(),
16500        )
16501    }
16502}
16503
16504#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
16505pub struct StreamSourceMarker;
16506
16507impl fidl::endpoints::ProtocolMarker for StreamSourceMarker {
16508    type Proxy = StreamSourceProxy;
16509    type RequestStream = StreamSourceRequestStream;
16510    #[cfg(target_os = "fuchsia")]
16511    type SynchronousProxy = StreamSourceSynchronousProxy;
16512
16513    const DEBUG_NAME: &'static str = "(anonymous) StreamSource";
16514}
16515
16516pub trait StreamSourceProxyInterface: Send + Sync {
16517    fn r#release_packet(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
16518    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
16519    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
16520    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
16521}
16522#[derive(Debug)]
16523#[cfg(target_os = "fuchsia")]
16524pub struct StreamSourceSynchronousProxy {
16525    client: fidl::client::sync::Client,
16526}
16527
16528#[cfg(target_os = "fuchsia")]
16529impl fidl::endpoints::SynchronousProxy for StreamSourceSynchronousProxy {
16530    type Proxy = StreamSourceProxy;
16531    type Protocol = StreamSourceMarker;
16532
16533    fn from_channel(inner: fidl::Channel) -> Self {
16534        Self::new(inner)
16535    }
16536
16537    fn into_channel(self) -> fidl::Channel {
16538        self.client.into_channel()
16539    }
16540
16541    fn as_channel(&self) -> &fidl::Channel {
16542        self.client.as_channel()
16543    }
16544}
16545
16546#[cfg(target_os = "fuchsia")]
16547impl StreamSourceSynchronousProxy {
16548    pub fn new(channel: fidl::Channel) -> Self {
16549        let protocol_name = <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
16550        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
16551    }
16552
16553    pub fn into_channel(self) -> fidl::Channel {
16554        self.client.into_channel()
16555    }
16556
16557    /// Waits until an event arrives and returns it. It is safe for other
16558    /// threads to make concurrent requests while waiting for an event.
16559    pub fn wait_for_event(
16560        &self,
16561        deadline: zx::MonotonicInstant,
16562    ) -> Result<StreamSourceEvent, fidl::Error> {
16563        StreamSourceEvent::decode(self.client.wait_for_event(deadline)?)
16564    }
16565
16566    /// Releases payload memory associated with a packet previously delivered
16567    /// via `OnPacketProduced`.
16568    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16569        self.client.send::<StreamSourceReleasePacketRequest>(
16570            (packet,),
16571            0x7a7b57f0f7d9e4bb,
16572            fidl::encoding::DynamicFlags::empty(),
16573        )
16574    }
16575
16576    pub fn r#discard_all_packets(
16577        &self,
16578        ___deadline: zx::MonotonicInstant,
16579    ) -> Result<(), fidl::Error> {
16580        let _response =
16581            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
16582                (),
16583                0x27afd605e97b09d2,
16584                fidl::encoding::DynamicFlags::empty(),
16585                ___deadline,
16586            )?;
16587        Ok(_response)
16588    }
16589
16590    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16591        self.client.send::<fidl::encoding::EmptyPayload>(
16592            (),
16593            0x35f9d721e905b831,
16594            fidl::encoding::DynamicFlags::empty(),
16595        )
16596    }
16597}
16598
16599#[cfg(target_os = "fuchsia")]
16600impl From<StreamSourceSynchronousProxy> for zx::Handle {
16601    fn from(value: StreamSourceSynchronousProxy) -> Self {
16602        value.into_channel().into()
16603    }
16604}
16605
16606#[cfg(target_os = "fuchsia")]
16607impl From<fidl::Channel> for StreamSourceSynchronousProxy {
16608    fn from(value: fidl::Channel) -> Self {
16609        Self::new(value)
16610    }
16611}
16612
16613#[cfg(target_os = "fuchsia")]
16614impl fidl::endpoints::FromClient for StreamSourceSynchronousProxy {
16615    type Protocol = StreamSourceMarker;
16616
16617    fn from_client(value: fidl::endpoints::ClientEnd<StreamSourceMarker>) -> Self {
16618        Self::new(value.into_channel())
16619    }
16620}
16621
16622#[derive(Debug, Clone)]
16623pub struct StreamSourceProxy {
16624    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
16625}
16626
16627impl fidl::endpoints::Proxy for StreamSourceProxy {
16628    type Protocol = StreamSourceMarker;
16629
16630    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
16631        Self::new(inner)
16632    }
16633
16634    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
16635        self.client.into_channel().map_err(|client| Self { client })
16636    }
16637
16638    fn as_channel(&self) -> &::fidl::AsyncChannel {
16639        self.client.as_channel()
16640    }
16641}
16642
16643impl StreamSourceProxy {
16644    /// Create a new Proxy for fuchsia.media/StreamSource.
16645    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
16646        let protocol_name = <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
16647        Self { client: fidl::client::Client::new(channel, protocol_name) }
16648    }
16649
16650    /// Get a Stream of events from the remote end of the protocol.
16651    ///
16652    /// # Panics
16653    ///
16654    /// Panics if the event stream was already taken.
16655    pub fn take_event_stream(&self) -> StreamSourceEventStream {
16656        StreamSourceEventStream { event_receiver: self.client.take_event_receiver() }
16657    }
16658
16659    /// Releases payload memory associated with a packet previously delivered
16660    /// via `OnPacketProduced`.
16661    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16662        StreamSourceProxyInterface::r#release_packet(self, packet)
16663    }
16664
16665    pub fn r#discard_all_packets(
16666        &self,
16667    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
16668        StreamSourceProxyInterface::r#discard_all_packets(self)
16669    }
16670
16671    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16672        StreamSourceProxyInterface::r#discard_all_packets_no_reply(self)
16673    }
16674}
16675
16676impl StreamSourceProxyInterface for StreamSourceProxy {
16677    fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16678        self.client.send::<StreamSourceReleasePacketRequest>(
16679            (packet,),
16680            0x7a7b57f0f7d9e4bb,
16681            fidl::encoding::DynamicFlags::empty(),
16682        )
16683    }
16684
16685    type DiscardAllPacketsResponseFut =
16686        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
16687    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
16688        fn _decode(
16689            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
16690        ) -> Result<(), fidl::Error> {
16691            let _response = fidl::client::decode_transaction_body::<
16692                fidl::encoding::EmptyPayload,
16693                fidl::encoding::DefaultFuchsiaResourceDialect,
16694                0x27afd605e97b09d2,
16695            >(_buf?)?;
16696            Ok(_response)
16697        }
16698        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
16699            (),
16700            0x27afd605e97b09d2,
16701            fidl::encoding::DynamicFlags::empty(),
16702            _decode,
16703        )
16704    }
16705
16706    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16707        self.client.send::<fidl::encoding::EmptyPayload>(
16708            (),
16709            0x35f9d721e905b831,
16710            fidl::encoding::DynamicFlags::empty(),
16711        )
16712    }
16713}
16714
16715pub struct StreamSourceEventStream {
16716    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
16717}
16718
16719impl std::marker::Unpin for StreamSourceEventStream {}
16720
16721impl futures::stream::FusedStream for StreamSourceEventStream {
16722    fn is_terminated(&self) -> bool {
16723        self.event_receiver.is_terminated()
16724    }
16725}
16726
16727impl futures::Stream for StreamSourceEventStream {
16728    type Item = Result<StreamSourceEvent, fidl::Error>;
16729
16730    fn poll_next(
16731        mut self: std::pin::Pin<&mut Self>,
16732        cx: &mut std::task::Context<'_>,
16733    ) -> std::task::Poll<Option<Self::Item>> {
16734        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
16735            &mut self.event_receiver,
16736            cx
16737        )?) {
16738            Some(buf) => std::task::Poll::Ready(Some(StreamSourceEvent::decode(buf))),
16739            None => std::task::Poll::Ready(None),
16740        }
16741    }
16742}
16743
16744#[derive(Debug)]
16745pub enum StreamSourceEvent {
16746    OnPacketProduced { packet: StreamPacket },
16747    OnEndOfStream {},
16748}
16749
16750impl StreamSourceEvent {
16751    #[allow(irrefutable_let_patterns)]
16752    pub fn into_on_packet_produced(self) -> Option<StreamPacket> {
16753        if let StreamSourceEvent::OnPacketProduced { packet } = self {
16754            Some((packet))
16755        } else {
16756            None
16757        }
16758    }
16759    #[allow(irrefutable_let_patterns)]
16760    pub fn into_on_end_of_stream(self) -> Option<()> {
16761        if let StreamSourceEvent::OnEndOfStream {} = self {
16762            Some(())
16763        } else {
16764            None
16765        }
16766    }
16767
16768    /// Decodes a message buffer as a [`StreamSourceEvent`].
16769    fn decode(
16770        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
16771    ) -> Result<StreamSourceEvent, fidl::Error> {
16772        let (bytes, _handles) = buf.split_mut();
16773        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16774        debug_assert_eq!(tx_header.tx_id, 0);
16775        match tx_header.ordinal {
16776            0x6bbe69746a3c8bd9 => {
16777                let mut out = fidl::new_empty!(
16778                    StreamSourceOnPacketProducedRequest,
16779                    fidl::encoding::DefaultFuchsiaResourceDialect
16780                );
16781                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16782                Ok((StreamSourceEvent::OnPacketProduced { packet: out.packet }))
16783            }
16784            0x550e69b41d03e2c2 => {
16785                let mut out = fidl::new_empty!(
16786                    fidl::encoding::EmptyPayload,
16787                    fidl::encoding::DefaultFuchsiaResourceDialect
16788                );
16789                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
16790                Ok((StreamSourceEvent::OnEndOfStream {}))
16791            }
16792            _ => Err(fidl::Error::UnknownOrdinal {
16793                ordinal: tx_header.ordinal,
16794                protocol_name: <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16795            }),
16796        }
16797    }
16798}
16799
16800/// A Stream of incoming requests for fuchsia.media/StreamSource.
16801pub struct StreamSourceRequestStream {
16802    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16803    is_terminated: bool,
16804}
16805
16806impl std::marker::Unpin for StreamSourceRequestStream {}
16807
16808impl futures::stream::FusedStream for StreamSourceRequestStream {
16809    fn is_terminated(&self) -> bool {
16810        self.is_terminated
16811    }
16812}
16813
16814impl fidl::endpoints::RequestStream for StreamSourceRequestStream {
16815    type Protocol = StreamSourceMarker;
16816    type ControlHandle = StreamSourceControlHandle;
16817
16818    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
16819        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
16820    }
16821
16822    fn control_handle(&self) -> Self::ControlHandle {
16823        StreamSourceControlHandle { inner: self.inner.clone() }
16824    }
16825
16826    fn into_inner(
16827        self,
16828    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
16829    {
16830        (self.inner, self.is_terminated)
16831    }
16832
16833    fn from_inner(
16834        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16835        is_terminated: bool,
16836    ) -> Self {
16837        Self { inner, is_terminated }
16838    }
16839}
16840
16841impl futures::Stream for StreamSourceRequestStream {
16842    type Item = Result<StreamSourceRequest, fidl::Error>;
16843
16844    fn poll_next(
16845        mut self: std::pin::Pin<&mut Self>,
16846        cx: &mut std::task::Context<'_>,
16847    ) -> std::task::Poll<Option<Self::Item>> {
16848        let this = &mut *self;
16849        if this.inner.check_shutdown(cx) {
16850            this.is_terminated = true;
16851            return std::task::Poll::Ready(None);
16852        }
16853        if this.is_terminated {
16854            panic!("polled StreamSourceRequestStream after completion");
16855        }
16856        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
16857            |bytes, handles| {
16858                match this.inner.channel().read_etc(cx, bytes, handles) {
16859                    std::task::Poll::Ready(Ok(())) => {}
16860                    std::task::Poll::Pending => return std::task::Poll::Pending,
16861                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
16862                        this.is_terminated = true;
16863                        return std::task::Poll::Ready(None);
16864                    }
16865                    std::task::Poll::Ready(Err(e)) => {
16866                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
16867                            e.into(),
16868                        ))))
16869                    }
16870                }
16871
16872                // A message has been received from the channel
16873                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16874
16875                std::task::Poll::Ready(Some(match header.ordinal {
16876                    0x7a7b57f0f7d9e4bb => {
16877                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16878                        let mut req = fidl::new_empty!(
16879                            StreamSourceReleasePacketRequest,
16880                            fidl::encoding::DefaultFuchsiaResourceDialect
16881                        );
16882                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
16883                        let control_handle =
16884                            StreamSourceControlHandle { inner: this.inner.clone() };
16885                        Ok(StreamSourceRequest::ReleasePacket {
16886                            packet: req.packet,
16887
16888                            control_handle,
16889                        })
16890                    }
16891                    0x27afd605e97b09d2 => {
16892                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16893                        let mut req = fidl::new_empty!(
16894                            fidl::encoding::EmptyPayload,
16895                            fidl::encoding::DefaultFuchsiaResourceDialect
16896                        );
16897                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16898                        let control_handle =
16899                            StreamSourceControlHandle { inner: this.inner.clone() };
16900                        Ok(StreamSourceRequest::DiscardAllPackets {
16901                            responder: StreamSourceDiscardAllPacketsResponder {
16902                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16903                                tx_id: header.tx_id,
16904                            },
16905                        })
16906                    }
16907                    0x35f9d721e905b831 => {
16908                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16909                        let mut req = fidl::new_empty!(
16910                            fidl::encoding::EmptyPayload,
16911                            fidl::encoding::DefaultFuchsiaResourceDialect
16912                        );
16913                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16914                        let control_handle =
16915                            StreamSourceControlHandle { inner: this.inner.clone() };
16916                        Ok(StreamSourceRequest::DiscardAllPacketsNoReply { control_handle })
16917                    }
16918                    _ => Err(fidl::Error::UnknownOrdinal {
16919                        ordinal: header.ordinal,
16920                        protocol_name:
16921                            <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16922                    }),
16923                }))
16924            },
16925        )
16926    }
16927}
16928
16929/// Produces a stream of packets. This interface is typically inherited along
16930/// with `StreamBufferSet` to enable the transport of elementary streams from
16931/// services to clients.
16932#[derive(Debug)]
16933pub enum StreamSourceRequest {
16934    /// Releases payload memory associated with a packet previously delivered
16935    /// via `OnPacketProduced`.
16936    ReleasePacket {
16937        packet: StreamPacket,
16938        control_handle: StreamSourceControlHandle,
16939    },
16940    DiscardAllPackets {
16941        responder: StreamSourceDiscardAllPacketsResponder,
16942    },
16943    DiscardAllPacketsNoReply {
16944        control_handle: StreamSourceControlHandle,
16945    },
16946}
16947
16948impl StreamSourceRequest {
16949    #[allow(irrefutable_let_patterns)]
16950    pub fn into_release_packet(self) -> Option<(StreamPacket, StreamSourceControlHandle)> {
16951        if let StreamSourceRequest::ReleasePacket { packet, control_handle } = self {
16952            Some((packet, control_handle))
16953        } else {
16954            None
16955        }
16956    }
16957
16958    #[allow(irrefutable_let_patterns)]
16959    pub fn into_discard_all_packets(self) -> Option<(StreamSourceDiscardAllPacketsResponder)> {
16960        if let StreamSourceRequest::DiscardAllPackets { responder } = self {
16961            Some((responder))
16962        } else {
16963            None
16964        }
16965    }
16966
16967    #[allow(irrefutable_let_patterns)]
16968    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSourceControlHandle)> {
16969        if let StreamSourceRequest::DiscardAllPacketsNoReply { control_handle } = self {
16970            Some((control_handle))
16971        } else {
16972            None
16973        }
16974    }
16975
16976    /// Name of the method defined in FIDL
16977    pub fn method_name(&self) -> &'static str {
16978        match *self {
16979            StreamSourceRequest::ReleasePacket { .. } => "release_packet",
16980            StreamSourceRequest::DiscardAllPackets { .. } => "discard_all_packets",
16981            StreamSourceRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
16982        }
16983    }
16984}
16985
16986#[derive(Debug, Clone)]
16987pub struct StreamSourceControlHandle {
16988    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16989}
16990
16991impl fidl::endpoints::ControlHandle for StreamSourceControlHandle {
16992    fn shutdown(&self) {
16993        self.inner.shutdown()
16994    }
16995    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
16996        self.inner.shutdown_with_epitaph(status)
16997    }
16998
16999    fn is_closed(&self) -> bool {
17000        self.inner.channel().is_closed()
17001    }
17002    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
17003        self.inner.channel().on_closed()
17004    }
17005
17006    #[cfg(target_os = "fuchsia")]
17007    fn signal_peer(
17008        &self,
17009        clear_mask: zx::Signals,
17010        set_mask: zx::Signals,
17011    ) -> Result<(), zx_status::Status> {
17012        use fidl::Peered;
17013        self.inner.channel().signal_peer(clear_mask, set_mask)
17014    }
17015}
17016
17017impl StreamSourceControlHandle {
17018    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
17019        self.inner.send::<StreamSourceOnPacketProducedRequest>(
17020            (packet,),
17021            0,
17022            0x6bbe69746a3c8bd9,
17023            fidl::encoding::DynamicFlags::empty(),
17024        )
17025    }
17026
17027    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
17028        self.inner.send::<fidl::encoding::EmptyPayload>(
17029            (),
17030            0,
17031            0x550e69b41d03e2c2,
17032            fidl::encoding::DynamicFlags::empty(),
17033        )
17034    }
17035}
17036
17037#[must_use = "FIDL methods require a response to be sent"]
17038#[derive(Debug)]
17039pub struct StreamSourceDiscardAllPacketsResponder {
17040    control_handle: std::mem::ManuallyDrop<StreamSourceControlHandle>,
17041    tx_id: u32,
17042}
17043
17044/// Set the the channel to be shutdown (see [`StreamSourceControlHandle::shutdown`])
17045/// if the responder is dropped without sending a response, so that the client
17046/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
17047impl std::ops::Drop for StreamSourceDiscardAllPacketsResponder {
17048    fn drop(&mut self) {
17049        self.control_handle.shutdown();
17050        // Safety: drops once, never accessed again
17051        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17052    }
17053}
17054
17055impl fidl::endpoints::Responder for StreamSourceDiscardAllPacketsResponder {
17056    type ControlHandle = StreamSourceControlHandle;
17057
17058    fn control_handle(&self) -> &StreamSourceControlHandle {
17059        &self.control_handle
17060    }
17061
17062    fn drop_without_shutdown(mut self) {
17063        // Safety: drops once, never accessed again due to mem::forget
17064        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17065        // Prevent Drop from running (which would shut down the channel)
17066        std::mem::forget(self);
17067    }
17068}
17069
17070impl StreamSourceDiscardAllPacketsResponder {
17071    /// Sends a response to the FIDL transaction.
17072    ///
17073    /// Sets the channel to shutdown if an error occurs.
17074    pub fn send(self) -> Result<(), fidl::Error> {
17075        let _result = self.send_raw();
17076        if _result.is_err() {
17077            self.control_handle.shutdown();
17078        }
17079        self.drop_without_shutdown();
17080        _result
17081    }
17082
17083    /// Similar to "send" but does not shutdown the channel if an error occurs.
17084    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
17085        let _result = self.send_raw();
17086        self.drop_without_shutdown();
17087        _result
17088    }
17089
17090    fn send_raw(&self) -> Result<(), fidl::Error> {
17091        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
17092            (),
17093            self.tx_id,
17094            0x27afd605e97b09d2,
17095            fidl::encoding::DynamicFlags::empty(),
17096        )
17097    }
17098}
17099
17100#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17101pub struct Usage2AudioConsumerFactoryMarker;
17102
17103impl fidl::endpoints::ProtocolMarker for Usage2AudioConsumerFactoryMarker {
17104    type Proxy = Usage2AudioConsumerFactoryProxy;
17105    type RequestStream = Usage2AudioConsumerFactoryRequestStream;
17106    #[cfg(target_os = "fuchsia")]
17107    type SynchronousProxy = Usage2AudioConsumerFactorySynchronousProxy;
17108
17109    const DEBUG_NAME: &'static str = "fuchsia.media.Usage2AudioConsumerFactory";
17110}
17111impl fidl::endpoints::DiscoverableProtocolMarker for Usage2AudioConsumerFactoryMarker {}
17112
17113pub trait Usage2AudioConsumerFactoryProxyInterface: Send + Sync {
17114    fn r#create_audio_consumer(
17115        &self,
17116        usage: AudioRenderUsage2,
17117        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17118    ) -> Result<(), fidl::Error>;
17119}
17120#[derive(Debug)]
17121#[cfg(target_os = "fuchsia")]
17122pub struct Usage2AudioConsumerFactorySynchronousProxy {
17123    client: fidl::client::sync::Client,
17124}
17125
17126#[cfg(target_os = "fuchsia")]
17127impl fidl::endpoints::SynchronousProxy for Usage2AudioConsumerFactorySynchronousProxy {
17128    type Proxy = Usage2AudioConsumerFactoryProxy;
17129    type Protocol = Usage2AudioConsumerFactoryMarker;
17130
17131    fn from_channel(inner: fidl::Channel) -> Self {
17132        Self::new(inner)
17133    }
17134
17135    fn into_channel(self) -> fidl::Channel {
17136        self.client.into_channel()
17137    }
17138
17139    fn as_channel(&self) -> &fidl::Channel {
17140        self.client.as_channel()
17141    }
17142}
17143
17144#[cfg(target_os = "fuchsia")]
17145impl Usage2AudioConsumerFactorySynchronousProxy {
17146    pub fn new(channel: fidl::Channel) -> Self {
17147        let protocol_name =
17148            <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17149        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
17150    }
17151
17152    pub fn into_channel(self) -> fidl::Channel {
17153        self.client.into_channel()
17154    }
17155
17156    /// Waits until an event arrives and returns it. It is safe for other
17157    /// threads to make concurrent requests while waiting for an event.
17158    pub fn wait_for_event(
17159        &self,
17160        deadline: zx::MonotonicInstant,
17161    ) -> Result<Usage2AudioConsumerFactoryEvent, fidl::Error> {
17162        Usage2AudioConsumerFactoryEvent::decode(self.client.wait_for_event(deadline)?)
17163    }
17164
17165    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
17166    /// Audio submitted to such a consumer is always rendered locally.
17167    pub fn r#create_audio_consumer(
17168        &self,
17169        mut usage: AudioRenderUsage2,
17170        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17171    ) -> Result<(), fidl::Error> {
17172        self.client.send::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(
17173            (usage, audio_consumer_request),
17174            0x767722302a171873,
17175            fidl::encoding::DynamicFlags::FLEXIBLE,
17176        )
17177    }
17178}
17179
17180#[cfg(target_os = "fuchsia")]
17181impl From<Usage2AudioConsumerFactorySynchronousProxy> for zx::Handle {
17182    fn from(value: Usage2AudioConsumerFactorySynchronousProxy) -> Self {
17183        value.into_channel().into()
17184    }
17185}
17186
17187#[cfg(target_os = "fuchsia")]
17188impl From<fidl::Channel> for Usage2AudioConsumerFactorySynchronousProxy {
17189    fn from(value: fidl::Channel) -> Self {
17190        Self::new(value)
17191    }
17192}
17193
17194#[cfg(target_os = "fuchsia")]
17195impl fidl::endpoints::FromClient for Usage2AudioConsumerFactorySynchronousProxy {
17196    type Protocol = Usage2AudioConsumerFactoryMarker;
17197
17198    fn from_client(value: fidl::endpoints::ClientEnd<Usage2AudioConsumerFactoryMarker>) -> Self {
17199        Self::new(value.into_channel())
17200    }
17201}
17202
17203#[derive(Debug, Clone)]
17204pub struct Usage2AudioConsumerFactoryProxy {
17205    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
17206}
17207
17208impl fidl::endpoints::Proxy for Usage2AudioConsumerFactoryProxy {
17209    type Protocol = Usage2AudioConsumerFactoryMarker;
17210
17211    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
17212        Self::new(inner)
17213    }
17214
17215    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
17216        self.client.into_channel().map_err(|client| Self { client })
17217    }
17218
17219    fn as_channel(&self) -> &::fidl::AsyncChannel {
17220        self.client.as_channel()
17221    }
17222}
17223
17224impl Usage2AudioConsumerFactoryProxy {
17225    /// Create a new Proxy for fuchsia.media/Usage2AudioConsumerFactory.
17226    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
17227        let protocol_name =
17228            <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17229        Self { client: fidl::client::Client::new(channel, protocol_name) }
17230    }
17231
17232    /// Get a Stream of events from the remote end of the protocol.
17233    ///
17234    /// # Panics
17235    ///
17236    /// Panics if the event stream was already taken.
17237    pub fn take_event_stream(&self) -> Usage2AudioConsumerFactoryEventStream {
17238        Usage2AudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
17239    }
17240
17241    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
17242    /// Audio submitted to such a consumer is always rendered locally.
17243    pub fn r#create_audio_consumer(
17244        &self,
17245        mut usage: AudioRenderUsage2,
17246        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17247    ) -> Result<(), fidl::Error> {
17248        Usage2AudioConsumerFactoryProxyInterface::r#create_audio_consumer(
17249            self,
17250            usage,
17251            audio_consumer_request,
17252        )
17253    }
17254}
17255
17256impl Usage2AudioConsumerFactoryProxyInterface for Usage2AudioConsumerFactoryProxy {
17257    fn r#create_audio_consumer(
17258        &self,
17259        mut usage: AudioRenderUsage2,
17260        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17261    ) -> Result<(), fidl::Error> {
17262        self.client.send::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(
17263            (usage, audio_consumer_request),
17264            0x767722302a171873,
17265            fidl::encoding::DynamicFlags::FLEXIBLE,
17266        )
17267    }
17268}
17269
17270pub struct Usage2AudioConsumerFactoryEventStream {
17271    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
17272}
17273
17274impl std::marker::Unpin for Usage2AudioConsumerFactoryEventStream {}
17275
17276impl futures::stream::FusedStream for Usage2AudioConsumerFactoryEventStream {
17277    fn is_terminated(&self) -> bool {
17278        self.event_receiver.is_terminated()
17279    }
17280}
17281
17282impl futures::Stream for Usage2AudioConsumerFactoryEventStream {
17283    type Item = Result<Usage2AudioConsumerFactoryEvent, fidl::Error>;
17284
17285    fn poll_next(
17286        mut self: std::pin::Pin<&mut Self>,
17287        cx: &mut std::task::Context<'_>,
17288    ) -> std::task::Poll<Option<Self::Item>> {
17289        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
17290            &mut self.event_receiver,
17291            cx
17292        )?) {
17293            Some(buf) => std::task::Poll::Ready(Some(Usage2AudioConsumerFactoryEvent::decode(buf))),
17294            None => std::task::Poll::Ready(None),
17295        }
17296    }
17297}
17298
17299#[derive(Debug)]
17300pub enum Usage2AudioConsumerFactoryEvent {
17301    #[non_exhaustive]
17302    _UnknownEvent {
17303        /// Ordinal of the event that was sent.
17304        ordinal: u64,
17305    },
17306}
17307
17308impl Usage2AudioConsumerFactoryEvent {
17309    /// Decodes a message buffer as a [`Usage2AudioConsumerFactoryEvent`].
17310    fn decode(
17311        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
17312    ) -> Result<Usage2AudioConsumerFactoryEvent, fidl::Error> {
17313        let (bytes, _handles) = buf.split_mut();
17314        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17315        debug_assert_eq!(tx_header.tx_id, 0);
17316        match tx_header.ordinal {
17317            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17318                Ok(Usage2AudioConsumerFactoryEvent::_UnknownEvent {
17319                    ordinal: tx_header.ordinal,
17320                })
17321            }
17322            _ => Err(fidl::Error::UnknownOrdinal {
17323                ordinal: tx_header.ordinal,
17324                protocol_name: <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17325            })
17326        }
17327    }
17328}
17329
17330/// A Stream of incoming requests for fuchsia.media/Usage2AudioConsumerFactory.
17331pub struct Usage2AudioConsumerFactoryRequestStream {
17332    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17333    is_terminated: bool,
17334}
17335
17336impl std::marker::Unpin for Usage2AudioConsumerFactoryRequestStream {}
17337
17338impl futures::stream::FusedStream for Usage2AudioConsumerFactoryRequestStream {
17339    fn is_terminated(&self) -> bool {
17340        self.is_terminated
17341    }
17342}
17343
17344impl fidl::endpoints::RequestStream for Usage2AudioConsumerFactoryRequestStream {
17345    type Protocol = Usage2AudioConsumerFactoryMarker;
17346    type ControlHandle = Usage2AudioConsumerFactoryControlHandle;
17347
17348    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
17349        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
17350    }
17351
17352    fn control_handle(&self) -> Self::ControlHandle {
17353        Usage2AudioConsumerFactoryControlHandle { inner: self.inner.clone() }
17354    }
17355
17356    fn into_inner(
17357        self,
17358    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
17359    {
17360        (self.inner, self.is_terminated)
17361    }
17362
17363    fn from_inner(
17364        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17365        is_terminated: bool,
17366    ) -> Self {
17367        Self { inner, is_terminated }
17368    }
17369}
17370
17371impl futures::Stream for Usage2AudioConsumerFactoryRequestStream {
17372    type Item = Result<Usage2AudioConsumerFactoryRequest, fidl::Error>;
17373
17374    fn poll_next(
17375        mut self: std::pin::Pin<&mut Self>,
17376        cx: &mut std::task::Context<'_>,
17377    ) -> std::task::Poll<Option<Self::Item>> {
17378        let this = &mut *self;
17379        if this.inner.check_shutdown(cx) {
17380            this.is_terminated = true;
17381            return std::task::Poll::Ready(None);
17382        }
17383        if this.is_terminated {
17384            panic!("polled Usage2AudioConsumerFactoryRequestStream after completion");
17385        }
17386        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
17387            |bytes, handles| {
17388                match this.inner.channel().read_etc(cx, bytes, handles) {
17389                    std::task::Poll::Ready(Ok(())) => {}
17390                    std::task::Poll::Pending => return std::task::Poll::Pending,
17391                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
17392                        this.is_terminated = true;
17393                        return std::task::Poll::Ready(None);
17394                    }
17395                    std::task::Poll::Ready(Err(e)) => {
17396                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
17397                            e.into(),
17398                        ))))
17399                    }
17400                }
17401
17402                // A message has been received from the channel
17403                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17404
17405                std::task::Poll::Ready(Some(match header.ordinal {
17406                0x767722302a171873 => {
17407                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
17408                    let mut req = fidl::new_empty!(Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
17409                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
17410                    let control_handle = Usage2AudioConsumerFactoryControlHandle {
17411                        inner: this.inner.clone(),
17412                    };
17413                    Ok(Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
17414audio_consumer_request: req.audio_consumer_request,
17415
17416                        control_handle,
17417                    })
17418                }
17419                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17420                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17421                        ordinal: header.ordinal,
17422                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
17423                        method_type: fidl::MethodType::OneWay,
17424                    })
17425                }
17426                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17427                    this.inner.send_framework_err(
17428                        fidl::encoding::FrameworkErr::UnknownMethod,
17429                        header.tx_id,
17430                        header.ordinal,
17431                        header.dynamic_flags(),
17432                        (bytes, handles),
17433                    )?;
17434                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17435                        ordinal: header.ordinal,
17436                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
17437                        method_type: fidl::MethodType::TwoWay,
17438                    })
17439                }
17440                _ => Err(fidl::Error::UnknownOrdinal {
17441                    ordinal: header.ordinal,
17442                    protocol_name: <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17443                }),
17444            }))
17445            },
17446        )
17447    }
17448}
17449
17450/// Interface for creating audio consumers for local rendering.
17451#[derive(Debug)]
17452pub enum Usage2AudioConsumerFactoryRequest {
17453    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
17454    /// Audio submitted to such a consumer is always rendered locally.
17455    CreateAudioConsumer {
17456        usage: AudioRenderUsage2,
17457        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17458        control_handle: Usage2AudioConsumerFactoryControlHandle,
17459    },
17460    /// An interaction was received which does not match any known method.
17461    #[non_exhaustive]
17462    _UnknownMethod {
17463        /// Ordinal of the method that was called.
17464        ordinal: u64,
17465        control_handle: Usage2AudioConsumerFactoryControlHandle,
17466        method_type: fidl::MethodType,
17467    },
17468}
17469
17470impl Usage2AudioConsumerFactoryRequest {
17471    #[allow(irrefutable_let_patterns)]
17472    pub fn into_create_audio_consumer(
17473        self,
17474    ) -> Option<(
17475        AudioRenderUsage2,
17476        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17477        Usage2AudioConsumerFactoryControlHandle,
17478    )> {
17479        if let Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {
17480            usage,
17481            audio_consumer_request,
17482            control_handle,
17483        } = self
17484        {
17485            Some((usage, audio_consumer_request, control_handle))
17486        } else {
17487            None
17488        }
17489    }
17490
17491    /// Name of the method defined in FIDL
17492    pub fn method_name(&self) -> &'static str {
17493        match *self {
17494            Usage2AudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
17495                "create_audio_consumer"
17496            }
17497            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17498                method_type: fidl::MethodType::OneWay,
17499                ..
17500            } => "unknown one-way method",
17501            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17502                method_type: fidl::MethodType::TwoWay,
17503                ..
17504            } => "unknown two-way method",
17505        }
17506    }
17507}
17508
17509#[derive(Debug, Clone)]
17510pub struct Usage2AudioConsumerFactoryControlHandle {
17511    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17512}
17513
17514impl fidl::endpoints::ControlHandle for Usage2AudioConsumerFactoryControlHandle {
17515    fn shutdown(&self) {
17516        self.inner.shutdown()
17517    }
17518    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
17519        self.inner.shutdown_with_epitaph(status)
17520    }
17521
17522    fn is_closed(&self) -> bool {
17523        self.inner.channel().is_closed()
17524    }
17525    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
17526        self.inner.channel().on_closed()
17527    }
17528
17529    #[cfg(target_os = "fuchsia")]
17530    fn signal_peer(
17531        &self,
17532        clear_mask: zx::Signals,
17533        set_mask: zx::Signals,
17534    ) -> Result<(), zx_status::Status> {
17535        use fidl::Peered;
17536        self.inner.channel().signal_peer(clear_mask, set_mask)
17537    }
17538}
17539
17540impl Usage2AudioConsumerFactoryControlHandle {}
17541
17542#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17543pub struct UsageAudioConsumerFactoryMarker;
17544
17545impl fidl::endpoints::ProtocolMarker for UsageAudioConsumerFactoryMarker {
17546    type Proxy = UsageAudioConsumerFactoryProxy;
17547    type RequestStream = UsageAudioConsumerFactoryRequestStream;
17548    #[cfg(target_os = "fuchsia")]
17549    type SynchronousProxy = UsageAudioConsumerFactorySynchronousProxy;
17550
17551    const DEBUG_NAME: &'static str = "fuchsia.media.UsageAudioConsumerFactory";
17552}
17553impl fidl::endpoints::DiscoverableProtocolMarker for UsageAudioConsumerFactoryMarker {}
17554
17555pub trait UsageAudioConsumerFactoryProxyInterface: Send + Sync {
17556    fn r#create_audio_consumer(
17557        &self,
17558        usage: AudioRenderUsage,
17559        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17560    ) -> Result<(), fidl::Error>;
17561}
17562#[derive(Debug)]
17563#[cfg(target_os = "fuchsia")]
17564pub struct UsageAudioConsumerFactorySynchronousProxy {
17565    client: fidl::client::sync::Client,
17566}
17567
17568#[cfg(target_os = "fuchsia")]
17569impl fidl::endpoints::SynchronousProxy for UsageAudioConsumerFactorySynchronousProxy {
17570    type Proxy = UsageAudioConsumerFactoryProxy;
17571    type Protocol = UsageAudioConsumerFactoryMarker;
17572
17573    fn from_channel(inner: fidl::Channel) -> Self {
17574        Self::new(inner)
17575    }
17576
17577    fn into_channel(self) -> fidl::Channel {
17578        self.client.into_channel()
17579    }
17580
17581    fn as_channel(&self) -> &fidl::Channel {
17582        self.client.as_channel()
17583    }
17584}
17585
17586#[cfg(target_os = "fuchsia")]
17587impl UsageAudioConsumerFactorySynchronousProxy {
17588    pub fn new(channel: fidl::Channel) -> Self {
17589        let protocol_name =
17590            <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17591        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
17592    }
17593
17594    pub fn into_channel(self) -> fidl::Channel {
17595        self.client.into_channel()
17596    }
17597
17598    /// Waits until an event arrives and returns it. It is safe for other
17599    /// threads to make concurrent requests while waiting for an event.
17600    pub fn wait_for_event(
17601        &self,
17602        deadline: zx::MonotonicInstant,
17603    ) -> Result<UsageAudioConsumerFactoryEvent, fidl::Error> {
17604        UsageAudioConsumerFactoryEvent::decode(self.client.wait_for_event(deadline)?)
17605    }
17606
17607    pub fn r#create_audio_consumer(
17608        &self,
17609        mut usage: AudioRenderUsage,
17610        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17611    ) -> Result<(), fidl::Error> {
17612        self.client.send::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(
17613            (usage, audio_consumer_request),
17614            0x4d975ca9b8f625a3,
17615            fidl::encoding::DynamicFlags::empty(),
17616        )
17617    }
17618}
17619
17620#[cfg(target_os = "fuchsia")]
17621impl From<UsageAudioConsumerFactorySynchronousProxy> for zx::Handle {
17622    fn from(value: UsageAudioConsumerFactorySynchronousProxy) -> Self {
17623        value.into_channel().into()
17624    }
17625}
17626
17627#[cfg(target_os = "fuchsia")]
17628impl From<fidl::Channel> for UsageAudioConsumerFactorySynchronousProxy {
17629    fn from(value: fidl::Channel) -> Self {
17630        Self::new(value)
17631    }
17632}
17633
17634#[cfg(target_os = "fuchsia")]
17635impl fidl::endpoints::FromClient for UsageAudioConsumerFactorySynchronousProxy {
17636    type Protocol = UsageAudioConsumerFactoryMarker;
17637
17638    fn from_client(value: fidl::endpoints::ClientEnd<UsageAudioConsumerFactoryMarker>) -> Self {
17639        Self::new(value.into_channel())
17640    }
17641}
17642
17643#[derive(Debug, Clone)]
17644pub struct UsageAudioConsumerFactoryProxy {
17645    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
17646}
17647
17648impl fidl::endpoints::Proxy for UsageAudioConsumerFactoryProxy {
17649    type Protocol = UsageAudioConsumerFactoryMarker;
17650
17651    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
17652        Self::new(inner)
17653    }
17654
17655    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
17656        self.client.into_channel().map_err(|client| Self { client })
17657    }
17658
17659    fn as_channel(&self) -> &::fidl::AsyncChannel {
17660        self.client.as_channel()
17661    }
17662}
17663
17664impl UsageAudioConsumerFactoryProxy {
17665    /// Create a new Proxy for fuchsia.media/UsageAudioConsumerFactory.
17666    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
17667        let protocol_name =
17668            <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17669        Self { client: fidl::client::Client::new(channel, protocol_name) }
17670    }
17671
17672    /// Get a Stream of events from the remote end of the protocol.
17673    ///
17674    /// # Panics
17675    ///
17676    /// Panics if the event stream was already taken.
17677    pub fn take_event_stream(&self) -> UsageAudioConsumerFactoryEventStream {
17678        UsageAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
17679    }
17680
17681    pub fn r#create_audio_consumer(
17682        &self,
17683        mut usage: AudioRenderUsage,
17684        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17685    ) -> Result<(), fidl::Error> {
17686        UsageAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
17687            self,
17688            usage,
17689            audio_consumer_request,
17690        )
17691    }
17692}
17693
17694impl UsageAudioConsumerFactoryProxyInterface for UsageAudioConsumerFactoryProxy {
17695    fn r#create_audio_consumer(
17696        &self,
17697        mut usage: AudioRenderUsage,
17698        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17699    ) -> Result<(), fidl::Error> {
17700        self.client.send::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(
17701            (usage, audio_consumer_request),
17702            0x4d975ca9b8f625a3,
17703            fidl::encoding::DynamicFlags::empty(),
17704        )
17705    }
17706}
17707
17708pub struct UsageAudioConsumerFactoryEventStream {
17709    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
17710}
17711
17712impl std::marker::Unpin for UsageAudioConsumerFactoryEventStream {}
17713
17714impl futures::stream::FusedStream for UsageAudioConsumerFactoryEventStream {
17715    fn is_terminated(&self) -> bool {
17716        self.event_receiver.is_terminated()
17717    }
17718}
17719
17720impl futures::Stream for UsageAudioConsumerFactoryEventStream {
17721    type Item = Result<UsageAudioConsumerFactoryEvent, fidl::Error>;
17722
17723    fn poll_next(
17724        mut self: std::pin::Pin<&mut Self>,
17725        cx: &mut std::task::Context<'_>,
17726    ) -> std::task::Poll<Option<Self::Item>> {
17727        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
17728            &mut self.event_receiver,
17729            cx
17730        )?) {
17731            Some(buf) => std::task::Poll::Ready(Some(UsageAudioConsumerFactoryEvent::decode(buf))),
17732            None => std::task::Poll::Ready(None),
17733        }
17734    }
17735}
17736
17737#[derive(Debug)]
17738pub enum UsageAudioConsumerFactoryEvent {}
17739
17740impl UsageAudioConsumerFactoryEvent {
17741    /// Decodes a message buffer as a [`UsageAudioConsumerFactoryEvent`].
17742    fn decode(
17743        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
17744    ) -> Result<UsageAudioConsumerFactoryEvent, fidl::Error> {
17745        let (bytes, _handles) = buf.split_mut();
17746        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17747        debug_assert_eq!(tx_header.tx_id, 0);
17748        match tx_header.ordinal {
17749            _ => Err(fidl::Error::UnknownOrdinal {
17750                ordinal: tx_header.ordinal,
17751                protocol_name:
17752                    <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17753            }),
17754        }
17755    }
17756}
17757
17758/// A Stream of incoming requests for fuchsia.media/UsageAudioConsumerFactory.
17759pub struct UsageAudioConsumerFactoryRequestStream {
17760    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17761    is_terminated: bool,
17762}
17763
17764impl std::marker::Unpin for UsageAudioConsumerFactoryRequestStream {}
17765
17766impl futures::stream::FusedStream for UsageAudioConsumerFactoryRequestStream {
17767    fn is_terminated(&self) -> bool {
17768        self.is_terminated
17769    }
17770}
17771
17772impl fidl::endpoints::RequestStream for UsageAudioConsumerFactoryRequestStream {
17773    type Protocol = UsageAudioConsumerFactoryMarker;
17774    type ControlHandle = UsageAudioConsumerFactoryControlHandle;
17775
17776    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
17777        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
17778    }
17779
17780    fn control_handle(&self) -> Self::ControlHandle {
17781        UsageAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
17782    }
17783
17784    fn into_inner(
17785        self,
17786    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
17787    {
17788        (self.inner, self.is_terminated)
17789    }
17790
17791    fn from_inner(
17792        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17793        is_terminated: bool,
17794    ) -> Self {
17795        Self { inner, is_terminated }
17796    }
17797}
17798
17799impl futures::Stream for UsageAudioConsumerFactoryRequestStream {
17800    type Item = Result<UsageAudioConsumerFactoryRequest, fidl::Error>;
17801
17802    fn poll_next(
17803        mut self: std::pin::Pin<&mut Self>,
17804        cx: &mut std::task::Context<'_>,
17805    ) -> std::task::Poll<Option<Self::Item>> {
17806        let this = &mut *self;
17807        if this.inner.check_shutdown(cx) {
17808            this.is_terminated = true;
17809            return std::task::Poll::Ready(None);
17810        }
17811        if this.is_terminated {
17812            panic!("polled UsageAudioConsumerFactoryRequestStream after completion");
17813        }
17814        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
17815            |bytes, handles| {
17816                match this.inner.channel().read_etc(cx, bytes, handles) {
17817                    std::task::Poll::Ready(Ok(())) => {}
17818                    std::task::Poll::Pending => return std::task::Poll::Pending,
17819                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
17820                        this.is_terminated = true;
17821                        return std::task::Poll::Ready(None);
17822                    }
17823                    std::task::Poll::Ready(Err(e)) => {
17824                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
17825                            e.into(),
17826                        ))))
17827                    }
17828                }
17829
17830                // A message has been received from the channel
17831                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17832
17833                std::task::Poll::Ready(Some(match header.ordinal {
17834                0x4d975ca9b8f625a3 => {
17835                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
17836                    let mut req = fidl::new_empty!(UsageAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
17837                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
17838                    let control_handle = UsageAudioConsumerFactoryControlHandle {
17839                        inner: this.inner.clone(),
17840                    };
17841                    Ok(UsageAudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
17842audio_consumer_request: req.audio_consumer_request,
17843
17844                        control_handle,
17845                    })
17846                }
17847                _ => Err(fidl::Error::UnknownOrdinal {
17848                    ordinal: header.ordinal,
17849                    protocol_name: <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17850                }),
17851            }))
17852            },
17853        )
17854    }
17855}
17856
17857/// Interface for creating audio consumers for local rendering.
17858#[derive(Debug)]
17859pub enum UsageAudioConsumerFactoryRequest {
17860    CreateAudioConsumer {
17861        usage: AudioRenderUsage,
17862        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17863        control_handle: UsageAudioConsumerFactoryControlHandle,
17864    },
17865}
17866
17867impl UsageAudioConsumerFactoryRequest {
17868    #[allow(irrefutable_let_patterns)]
17869    pub fn into_create_audio_consumer(
17870        self,
17871    ) -> Option<(
17872        AudioRenderUsage,
17873        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17874        UsageAudioConsumerFactoryControlHandle,
17875    )> {
17876        if let UsageAudioConsumerFactoryRequest::CreateAudioConsumer {
17877            usage,
17878            audio_consumer_request,
17879            control_handle,
17880        } = self
17881        {
17882            Some((usage, audio_consumer_request, control_handle))
17883        } else {
17884            None
17885        }
17886    }
17887
17888    /// Name of the method defined in FIDL
17889    pub fn method_name(&self) -> &'static str {
17890        match *self {
17891            UsageAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => "create_audio_consumer",
17892        }
17893    }
17894}
17895
17896#[derive(Debug, Clone)]
17897pub struct UsageAudioConsumerFactoryControlHandle {
17898    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17899}
17900
17901impl fidl::endpoints::ControlHandle for UsageAudioConsumerFactoryControlHandle {
17902    fn shutdown(&self) {
17903        self.inner.shutdown()
17904    }
17905    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
17906        self.inner.shutdown_with_epitaph(status)
17907    }
17908
17909    fn is_closed(&self) -> bool {
17910        self.inner.channel().is_closed()
17911    }
17912    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
17913        self.inner.channel().on_closed()
17914    }
17915
17916    #[cfg(target_os = "fuchsia")]
17917    fn signal_peer(
17918        &self,
17919        clear_mask: zx::Signals,
17920        set_mask: zx::Signals,
17921    ) -> Result<(), zx_status::Status> {
17922        use fidl::Peered;
17923        self.inner.channel().signal_peer(clear_mask, set_mask)
17924    }
17925}
17926
17927impl UsageAudioConsumerFactoryControlHandle {}
17928
17929#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17930pub struct UsageGainListenerMarker;
17931
17932impl fidl::endpoints::ProtocolMarker for UsageGainListenerMarker {
17933    type Proxy = UsageGainListenerProxy;
17934    type RequestStream = UsageGainListenerRequestStream;
17935    #[cfg(target_os = "fuchsia")]
17936    type SynchronousProxy = UsageGainListenerSynchronousProxy;
17937
17938    const DEBUG_NAME: &'static str = "(anonymous) UsageGainListener";
17939}
17940
17941pub trait UsageGainListenerProxyInterface: Send + Sync {
17942    type OnGainMuteChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
17943    fn r#on_gain_mute_changed(
17944        &self,
17945        muted: bool,
17946        gain_dbfs: f32,
17947    ) -> Self::OnGainMuteChangedResponseFut;
17948}
17949#[derive(Debug)]
17950#[cfg(target_os = "fuchsia")]
17951pub struct UsageGainListenerSynchronousProxy {
17952    client: fidl::client::sync::Client,
17953}
17954
17955#[cfg(target_os = "fuchsia")]
17956impl fidl::endpoints::SynchronousProxy for UsageGainListenerSynchronousProxy {
17957    type Proxy = UsageGainListenerProxy;
17958    type Protocol = UsageGainListenerMarker;
17959
17960    fn from_channel(inner: fidl::Channel) -> Self {
17961        Self::new(inner)
17962    }
17963
17964    fn into_channel(self) -> fidl::Channel {
17965        self.client.into_channel()
17966    }
17967
17968    fn as_channel(&self) -> &fidl::Channel {
17969        self.client.as_channel()
17970    }
17971}
17972
17973#[cfg(target_os = "fuchsia")]
17974impl UsageGainListenerSynchronousProxy {
17975    pub fn new(channel: fidl::Channel) -> Self {
17976        let protocol_name =
17977            <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17978        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
17979    }
17980
17981    pub fn into_channel(self) -> fidl::Channel {
17982        self.client.into_channel()
17983    }
17984
17985    /// Waits until an event arrives and returns it. It is safe for other
17986    /// threads to make concurrent requests while waiting for an event.
17987    pub fn wait_for_event(
17988        &self,
17989        deadline: zx::MonotonicInstant,
17990    ) -> Result<UsageGainListenerEvent, fidl::Error> {
17991        UsageGainListenerEvent::decode(self.client.wait_for_event(deadline)?)
17992    }
17993
17994    /// Called immediately on connection and afterward any time
17995    /// the usage gain setting changes.
17996    ///
17997    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
17998    /// events will eventually be disconnected.
17999    ///
18000    /// Note: This API does not have mute reporting implemented; `muted` is always false.
18001    pub fn r#on_gain_mute_changed(
18002        &self,
18003        mut muted: bool,
18004        mut gain_dbfs: f32,
18005        ___deadline: zx::MonotonicInstant,
18006    ) -> Result<(), fidl::Error> {
18007        let _response = self
18008            .client
18009            .send_query::<UsageGainListenerOnGainMuteChangedRequest, fidl::encoding::EmptyPayload>(
18010                (muted, gain_dbfs),
18011                0x681570258eac3a8d,
18012                fidl::encoding::DynamicFlags::empty(),
18013                ___deadline,
18014            )?;
18015        Ok(_response)
18016    }
18017}
18018
18019#[cfg(target_os = "fuchsia")]
18020impl From<UsageGainListenerSynchronousProxy> for zx::Handle {
18021    fn from(value: UsageGainListenerSynchronousProxy) -> Self {
18022        value.into_channel().into()
18023    }
18024}
18025
18026#[cfg(target_os = "fuchsia")]
18027impl From<fidl::Channel> for UsageGainListenerSynchronousProxy {
18028    fn from(value: fidl::Channel) -> Self {
18029        Self::new(value)
18030    }
18031}
18032
18033#[cfg(target_os = "fuchsia")]
18034impl fidl::endpoints::FromClient for UsageGainListenerSynchronousProxy {
18035    type Protocol = UsageGainListenerMarker;
18036
18037    fn from_client(value: fidl::endpoints::ClientEnd<UsageGainListenerMarker>) -> Self {
18038        Self::new(value.into_channel())
18039    }
18040}
18041
18042#[derive(Debug, Clone)]
18043pub struct UsageGainListenerProxy {
18044    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
18045}
18046
18047impl fidl::endpoints::Proxy for UsageGainListenerProxy {
18048    type Protocol = UsageGainListenerMarker;
18049
18050    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
18051        Self::new(inner)
18052    }
18053
18054    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
18055        self.client.into_channel().map_err(|client| Self { client })
18056    }
18057
18058    fn as_channel(&self) -> &::fidl::AsyncChannel {
18059        self.client.as_channel()
18060    }
18061}
18062
18063impl UsageGainListenerProxy {
18064    /// Create a new Proxy for fuchsia.media/UsageGainListener.
18065    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
18066        let protocol_name =
18067            <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
18068        Self { client: fidl::client::Client::new(channel, protocol_name) }
18069    }
18070
18071    /// Get a Stream of events from the remote end of the protocol.
18072    ///
18073    /// # Panics
18074    ///
18075    /// Panics if the event stream was already taken.
18076    pub fn take_event_stream(&self) -> UsageGainListenerEventStream {
18077        UsageGainListenerEventStream { event_receiver: self.client.take_event_receiver() }
18078    }
18079
18080    /// Called immediately on connection and afterward any time
18081    /// the usage gain setting changes.
18082    ///
18083    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
18084    /// events will eventually be disconnected.
18085    ///
18086    /// Note: This API does not have mute reporting implemented; `muted` is always false.
18087    pub fn r#on_gain_mute_changed(
18088        &self,
18089        mut muted: bool,
18090        mut gain_dbfs: f32,
18091    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
18092        UsageGainListenerProxyInterface::r#on_gain_mute_changed(self, muted, gain_dbfs)
18093    }
18094}
18095
18096impl UsageGainListenerProxyInterface for UsageGainListenerProxy {
18097    type OnGainMuteChangedResponseFut =
18098        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
18099    fn r#on_gain_mute_changed(
18100        &self,
18101        mut muted: bool,
18102        mut gain_dbfs: f32,
18103    ) -> Self::OnGainMuteChangedResponseFut {
18104        fn _decode(
18105            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
18106        ) -> Result<(), fidl::Error> {
18107            let _response = fidl::client::decode_transaction_body::<
18108                fidl::encoding::EmptyPayload,
18109                fidl::encoding::DefaultFuchsiaResourceDialect,
18110                0x681570258eac3a8d,
18111            >(_buf?)?;
18112            Ok(_response)
18113        }
18114        self.client.send_query_and_decode::<UsageGainListenerOnGainMuteChangedRequest, ()>(
18115            (muted, gain_dbfs),
18116            0x681570258eac3a8d,
18117            fidl::encoding::DynamicFlags::empty(),
18118            _decode,
18119        )
18120    }
18121}
18122
18123pub struct UsageGainListenerEventStream {
18124    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
18125}
18126
18127impl std::marker::Unpin for UsageGainListenerEventStream {}
18128
18129impl futures::stream::FusedStream for UsageGainListenerEventStream {
18130    fn is_terminated(&self) -> bool {
18131        self.event_receiver.is_terminated()
18132    }
18133}
18134
18135impl futures::Stream for UsageGainListenerEventStream {
18136    type Item = Result<UsageGainListenerEvent, fidl::Error>;
18137
18138    fn poll_next(
18139        mut self: std::pin::Pin<&mut Self>,
18140        cx: &mut std::task::Context<'_>,
18141    ) -> std::task::Poll<Option<Self::Item>> {
18142        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
18143            &mut self.event_receiver,
18144            cx
18145        )?) {
18146            Some(buf) => std::task::Poll::Ready(Some(UsageGainListenerEvent::decode(buf))),
18147            None => std::task::Poll::Ready(None),
18148        }
18149    }
18150}
18151
18152#[derive(Debug)]
18153pub enum UsageGainListenerEvent {}
18154
18155impl UsageGainListenerEvent {
18156    /// Decodes a message buffer as a [`UsageGainListenerEvent`].
18157    fn decode(
18158        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
18159    ) -> Result<UsageGainListenerEvent, fidl::Error> {
18160        let (bytes, _handles) = buf.split_mut();
18161        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18162        debug_assert_eq!(tx_header.tx_id, 0);
18163        match tx_header.ordinal {
18164            _ => Err(fidl::Error::UnknownOrdinal {
18165                ordinal: tx_header.ordinal,
18166                protocol_name:
18167                    <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18168            }),
18169        }
18170    }
18171}
18172
18173/// A Stream of incoming requests for fuchsia.media/UsageGainListener.
18174pub struct UsageGainListenerRequestStream {
18175    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18176    is_terminated: bool,
18177}
18178
18179impl std::marker::Unpin for UsageGainListenerRequestStream {}
18180
18181impl futures::stream::FusedStream for UsageGainListenerRequestStream {
18182    fn is_terminated(&self) -> bool {
18183        self.is_terminated
18184    }
18185}
18186
18187impl fidl::endpoints::RequestStream for UsageGainListenerRequestStream {
18188    type Protocol = UsageGainListenerMarker;
18189    type ControlHandle = UsageGainListenerControlHandle;
18190
18191    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
18192        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
18193    }
18194
18195    fn control_handle(&self) -> Self::ControlHandle {
18196        UsageGainListenerControlHandle { inner: self.inner.clone() }
18197    }
18198
18199    fn into_inner(
18200        self,
18201    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
18202    {
18203        (self.inner, self.is_terminated)
18204    }
18205
18206    fn from_inner(
18207        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18208        is_terminated: bool,
18209    ) -> Self {
18210        Self { inner, is_terminated }
18211    }
18212}
18213
18214impl futures::Stream for UsageGainListenerRequestStream {
18215    type Item = Result<UsageGainListenerRequest, fidl::Error>;
18216
18217    fn poll_next(
18218        mut self: std::pin::Pin<&mut Self>,
18219        cx: &mut std::task::Context<'_>,
18220    ) -> std::task::Poll<Option<Self::Item>> {
18221        let this = &mut *self;
18222        if this.inner.check_shutdown(cx) {
18223            this.is_terminated = true;
18224            return std::task::Poll::Ready(None);
18225        }
18226        if this.is_terminated {
18227            panic!("polled UsageGainListenerRequestStream after completion");
18228        }
18229        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
18230            |bytes, handles| {
18231                match this.inner.channel().read_etc(cx, bytes, handles) {
18232                    std::task::Poll::Ready(Ok(())) => {}
18233                    std::task::Poll::Pending => return std::task::Poll::Pending,
18234                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
18235                        this.is_terminated = true;
18236                        return std::task::Poll::Ready(None);
18237                    }
18238                    std::task::Poll::Ready(Err(e)) => {
18239                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
18240                            e.into(),
18241                        ))))
18242                    }
18243                }
18244
18245                // A message has been received from the channel
18246                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18247
18248                std::task::Poll::Ready(Some(match header.ordinal {
18249                    0x681570258eac3a8d => {
18250                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
18251                        let mut req = fidl::new_empty!(
18252                            UsageGainListenerOnGainMuteChangedRequest,
18253                            fidl::encoding::DefaultFuchsiaResourceDialect
18254                        );
18255                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainListenerOnGainMuteChangedRequest>(&header, _body_bytes, handles, &mut req)?;
18256                        let control_handle =
18257                            UsageGainListenerControlHandle { inner: this.inner.clone() };
18258                        Ok(UsageGainListenerRequest::OnGainMuteChanged {
18259                            muted: req.muted,
18260                            gain_dbfs: req.gain_dbfs,
18261
18262                            responder: UsageGainListenerOnGainMuteChangedResponder {
18263                                control_handle: std::mem::ManuallyDrop::new(control_handle),
18264                                tx_id: header.tx_id,
18265                            },
18266                        })
18267                    }
18268                    _ => Err(fidl::Error::UnknownOrdinal {
18269                        ordinal: header.ordinal,
18270                        protocol_name:
18271                            <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18272                    }),
18273                }))
18274            },
18275        )
18276    }
18277}
18278
18279/// A protocol for watching changes to usage gain settings.
18280///
18281/// The channel will close when the device is not present.
18282#[derive(Debug)]
18283pub enum UsageGainListenerRequest {
18284    /// Called immediately on connection and afterward any time
18285    /// the usage gain setting changes.
18286    ///
18287    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
18288    /// events will eventually be disconnected.
18289    ///
18290    /// Note: This API does not have mute reporting implemented; `muted` is always false.
18291    OnGainMuteChanged {
18292        muted: bool,
18293        gain_dbfs: f32,
18294        responder: UsageGainListenerOnGainMuteChangedResponder,
18295    },
18296}
18297
18298impl UsageGainListenerRequest {
18299    #[allow(irrefutable_let_patterns)]
18300    pub fn into_on_gain_mute_changed(
18301        self,
18302    ) -> Option<(bool, f32, UsageGainListenerOnGainMuteChangedResponder)> {
18303        if let UsageGainListenerRequest::OnGainMuteChanged { muted, gain_dbfs, responder } = self {
18304            Some((muted, gain_dbfs, responder))
18305        } else {
18306            None
18307        }
18308    }
18309
18310    /// Name of the method defined in FIDL
18311    pub fn method_name(&self) -> &'static str {
18312        match *self {
18313            UsageGainListenerRequest::OnGainMuteChanged { .. } => "on_gain_mute_changed",
18314        }
18315    }
18316}
18317
18318#[derive(Debug, Clone)]
18319pub struct UsageGainListenerControlHandle {
18320    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18321}
18322
18323impl fidl::endpoints::ControlHandle for UsageGainListenerControlHandle {
18324    fn shutdown(&self) {
18325        self.inner.shutdown()
18326    }
18327    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
18328        self.inner.shutdown_with_epitaph(status)
18329    }
18330
18331    fn is_closed(&self) -> bool {
18332        self.inner.channel().is_closed()
18333    }
18334    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
18335        self.inner.channel().on_closed()
18336    }
18337
18338    #[cfg(target_os = "fuchsia")]
18339    fn signal_peer(
18340        &self,
18341        clear_mask: zx::Signals,
18342        set_mask: zx::Signals,
18343    ) -> Result<(), zx_status::Status> {
18344        use fidl::Peered;
18345        self.inner.channel().signal_peer(clear_mask, set_mask)
18346    }
18347}
18348
18349impl UsageGainListenerControlHandle {}
18350
18351#[must_use = "FIDL methods require a response to be sent"]
18352#[derive(Debug)]
18353pub struct UsageGainListenerOnGainMuteChangedResponder {
18354    control_handle: std::mem::ManuallyDrop<UsageGainListenerControlHandle>,
18355    tx_id: u32,
18356}
18357
18358/// Set the the channel to be shutdown (see [`UsageGainListenerControlHandle::shutdown`])
18359/// if the responder is dropped without sending a response, so that the client
18360/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
18361impl std::ops::Drop for UsageGainListenerOnGainMuteChangedResponder {
18362    fn drop(&mut self) {
18363        self.control_handle.shutdown();
18364        // Safety: drops once, never accessed again
18365        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18366    }
18367}
18368
18369impl fidl::endpoints::Responder for UsageGainListenerOnGainMuteChangedResponder {
18370    type ControlHandle = UsageGainListenerControlHandle;
18371
18372    fn control_handle(&self) -> &UsageGainListenerControlHandle {
18373        &self.control_handle
18374    }
18375
18376    fn drop_without_shutdown(mut self) {
18377        // Safety: drops once, never accessed again due to mem::forget
18378        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18379        // Prevent Drop from running (which would shut down the channel)
18380        std::mem::forget(self);
18381    }
18382}
18383
18384impl UsageGainListenerOnGainMuteChangedResponder {
18385    /// Sends a response to the FIDL transaction.
18386    ///
18387    /// Sets the channel to shutdown if an error occurs.
18388    pub fn send(self) -> Result<(), fidl::Error> {
18389        let _result = self.send_raw();
18390        if _result.is_err() {
18391            self.control_handle.shutdown();
18392        }
18393        self.drop_without_shutdown();
18394        _result
18395    }
18396
18397    /// Similar to "send" but does not shutdown the channel if an error occurs.
18398    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
18399        let _result = self.send_raw();
18400        self.drop_without_shutdown();
18401        _result
18402    }
18403
18404    fn send_raw(&self) -> Result<(), fidl::Error> {
18405        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
18406            (),
18407            self.tx_id,
18408            0x681570258eac3a8d,
18409            fidl::encoding::DynamicFlags::empty(),
18410        )
18411    }
18412}
18413
18414#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
18415pub struct UsageGainReporterMarker;
18416
18417impl fidl::endpoints::ProtocolMarker for UsageGainReporterMarker {
18418    type Proxy = UsageGainReporterProxy;
18419    type RequestStream = UsageGainReporterRequestStream;
18420    #[cfg(target_os = "fuchsia")]
18421    type SynchronousProxy = UsageGainReporterSynchronousProxy;
18422
18423    const DEBUG_NAME: &'static str = "fuchsia.media.UsageGainReporter";
18424}
18425impl fidl::endpoints::DiscoverableProtocolMarker for UsageGainReporterMarker {}
18426
18427pub trait UsageGainReporterProxyInterface: Send + Sync {
18428    fn r#register_listener(
18429        &self,
18430        device_unique_id: &str,
18431        usage: &Usage,
18432        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18433    ) -> Result<(), fidl::Error>;
18434    fn r#register_listener2(
18435        &self,
18436        device_unique_id: &str,
18437        usage: &Usage2,
18438        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18439    ) -> Result<(), fidl::Error>;
18440}
18441#[derive(Debug)]
18442#[cfg(target_os = "fuchsia")]
18443pub struct UsageGainReporterSynchronousProxy {
18444    client: fidl::client::sync::Client,
18445}
18446
18447#[cfg(target_os = "fuchsia")]
18448impl fidl::endpoints::SynchronousProxy for UsageGainReporterSynchronousProxy {
18449    type Proxy = UsageGainReporterProxy;
18450    type Protocol = UsageGainReporterMarker;
18451
18452    fn from_channel(inner: fidl::Channel) -> Self {
18453        Self::new(inner)
18454    }
18455
18456    fn into_channel(self) -> fidl::Channel {
18457        self.client.into_channel()
18458    }
18459
18460    fn as_channel(&self) -> &fidl::Channel {
18461        self.client.as_channel()
18462    }
18463}
18464
18465#[cfg(target_os = "fuchsia")]
18466impl UsageGainReporterSynchronousProxy {
18467    pub fn new(channel: fidl::Channel) -> Self {
18468        let protocol_name =
18469            <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
18470        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
18471    }
18472
18473    pub fn into_channel(self) -> fidl::Channel {
18474        self.client.into_channel()
18475    }
18476
18477    /// Waits until an event arrives and returns it. It is safe for other
18478    /// threads to make concurrent requests while waiting for an event.
18479    pub fn wait_for_event(
18480        &self,
18481        deadline: zx::MonotonicInstant,
18482    ) -> Result<UsageGainReporterEvent, fidl::Error> {
18483        UsageGainReporterEvent::decode(self.client.wait_for_event(deadline)?)
18484    }
18485
18486    /// Connects a listener to a stream of usage gain setting changes
18487    /// for `usage` on the device identified by `device_token`. Usage
18488    /// Gain is not set directly by any client; it is a translation of
18489    /// the usage volume setting for each device, summed with active
18490    /// muting/ducking gain adjustments.
18491    ///
18492    /// Devices may map the same volume level to different dbfs, so
18493    /// a `device_unique_id` is needed to identify the device.
18494    ///
18495    /// `AudioDeviceEnumerator` provides programmatic access to devices
18496    /// and their unique ids if it is necessary for a client to select
18497    /// an id at runtime.
18498    pub fn r#register_listener(
18499        &self,
18500        mut device_unique_id: &str,
18501        mut usage: &Usage,
18502        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18503    ) -> Result<(), fidl::Error> {
18504        self.client.send::<UsageGainReporterRegisterListenerRequest>(
18505            (device_unique_id, usage, usage_gain_listener),
18506            0x767107c168c226af,
18507            fidl::encoding::DynamicFlags::empty(),
18508        )
18509    }
18510
18511    /// Connects a listener to a stream of usage gain setting changes
18512    /// for `usage` on the device identified by `device_token`. Usage
18513    /// Gain is not set directly by any client; it is a translation of
18514    /// the usage volume setting for each device, summed with active
18515    /// muting/ducking gain adjustments.
18516    ///
18517    /// Devices may map the same volume level to different dbfs, so
18518    /// a `device_unique_id` is needed to identify the device.
18519    ///
18520    /// `AudioDeviceEnumerator` provides programmatic access to devices
18521    /// and their unique ids if it is necessary for a client to select
18522    /// an id at runtime.
18523    pub fn r#register_listener2(
18524        &self,
18525        mut device_unique_id: &str,
18526        mut usage: &Usage2,
18527        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18528    ) -> Result<(), fidl::Error> {
18529        self.client.send::<UsageGainReporterRegisterListener2Request>(
18530            (device_unique_id, usage, usage_gain_listener),
18531            0x760a8e1c5873629c,
18532            fidl::encoding::DynamicFlags::FLEXIBLE,
18533        )
18534    }
18535}
18536
18537#[cfg(target_os = "fuchsia")]
18538impl From<UsageGainReporterSynchronousProxy> for zx::Handle {
18539    fn from(value: UsageGainReporterSynchronousProxy) -> Self {
18540        value.into_channel().into()
18541    }
18542}
18543
18544#[cfg(target_os = "fuchsia")]
18545impl From<fidl::Channel> for UsageGainReporterSynchronousProxy {
18546    fn from(value: fidl::Channel) -> Self {
18547        Self::new(value)
18548    }
18549}
18550
18551#[cfg(target_os = "fuchsia")]
18552impl fidl::endpoints::FromClient for UsageGainReporterSynchronousProxy {
18553    type Protocol = UsageGainReporterMarker;
18554
18555    fn from_client(value: fidl::endpoints::ClientEnd<UsageGainReporterMarker>) -> Self {
18556        Self::new(value.into_channel())
18557    }
18558}
18559
18560#[derive(Debug, Clone)]
18561pub struct UsageGainReporterProxy {
18562    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
18563}
18564
18565impl fidl::endpoints::Proxy for UsageGainReporterProxy {
18566    type Protocol = UsageGainReporterMarker;
18567
18568    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
18569        Self::new(inner)
18570    }
18571
18572    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
18573        self.client.into_channel().map_err(|client| Self { client })
18574    }
18575
18576    fn as_channel(&self) -> &::fidl::AsyncChannel {
18577        self.client.as_channel()
18578    }
18579}
18580
18581impl UsageGainReporterProxy {
18582    /// Create a new Proxy for fuchsia.media/UsageGainReporter.
18583    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
18584        let protocol_name =
18585            <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
18586        Self { client: fidl::client::Client::new(channel, protocol_name) }
18587    }
18588
18589    /// Get a Stream of events from the remote end of the protocol.
18590    ///
18591    /// # Panics
18592    ///
18593    /// Panics if the event stream was already taken.
18594    pub fn take_event_stream(&self) -> UsageGainReporterEventStream {
18595        UsageGainReporterEventStream { event_receiver: self.client.take_event_receiver() }
18596    }
18597
18598    /// Connects a listener to a stream of usage gain setting changes
18599    /// for `usage` on the device identified by `device_token`. Usage
18600    /// Gain is not set directly by any client; it is a translation of
18601    /// the usage volume setting for each device, summed with active
18602    /// muting/ducking gain adjustments.
18603    ///
18604    /// Devices may map the same volume level to different dbfs, so
18605    /// a `device_unique_id` is needed to identify the device.
18606    ///
18607    /// `AudioDeviceEnumerator` provides programmatic access to devices
18608    /// and their unique ids if it is necessary for a client to select
18609    /// an id at runtime.
18610    pub fn r#register_listener(
18611        &self,
18612        mut device_unique_id: &str,
18613        mut usage: &Usage,
18614        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18615    ) -> Result<(), fidl::Error> {
18616        UsageGainReporterProxyInterface::r#register_listener(
18617            self,
18618            device_unique_id,
18619            usage,
18620            usage_gain_listener,
18621        )
18622    }
18623
18624    /// Connects a listener to a stream of usage gain setting changes
18625    /// for `usage` on the device identified by `device_token`. Usage
18626    /// Gain is not set directly by any client; it is a translation of
18627    /// the usage volume setting for each device, summed with active
18628    /// muting/ducking gain adjustments.
18629    ///
18630    /// Devices may map the same volume level to different dbfs, so
18631    /// a `device_unique_id` is needed to identify the device.
18632    ///
18633    /// `AudioDeviceEnumerator` provides programmatic access to devices
18634    /// and their unique ids if it is necessary for a client to select
18635    /// an id at runtime.
18636    pub fn r#register_listener2(
18637        &self,
18638        mut device_unique_id: &str,
18639        mut usage: &Usage2,
18640        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18641    ) -> Result<(), fidl::Error> {
18642        UsageGainReporterProxyInterface::r#register_listener2(
18643            self,
18644            device_unique_id,
18645            usage,
18646            usage_gain_listener,
18647        )
18648    }
18649}
18650
18651impl UsageGainReporterProxyInterface for UsageGainReporterProxy {
18652    fn r#register_listener(
18653        &self,
18654        mut device_unique_id: &str,
18655        mut usage: &Usage,
18656        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18657    ) -> Result<(), fidl::Error> {
18658        self.client.send::<UsageGainReporterRegisterListenerRequest>(
18659            (device_unique_id, usage, usage_gain_listener),
18660            0x767107c168c226af,
18661            fidl::encoding::DynamicFlags::empty(),
18662        )
18663    }
18664
18665    fn r#register_listener2(
18666        &self,
18667        mut device_unique_id: &str,
18668        mut usage: &Usage2,
18669        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18670    ) -> Result<(), fidl::Error> {
18671        self.client.send::<UsageGainReporterRegisterListener2Request>(
18672            (device_unique_id, usage, usage_gain_listener),
18673            0x760a8e1c5873629c,
18674            fidl::encoding::DynamicFlags::FLEXIBLE,
18675        )
18676    }
18677}
18678
18679pub struct UsageGainReporterEventStream {
18680    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
18681}
18682
18683impl std::marker::Unpin for UsageGainReporterEventStream {}
18684
18685impl futures::stream::FusedStream for UsageGainReporterEventStream {
18686    fn is_terminated(&self) -> bool {
18687        self.event_receiver.is_terminated()
18688    }
18689}
18690
18691impl futures::Stream for UsageGainReporterEventStream {
18692    type Item = Result<UsageGainReporterEvent, fidl::Error>;
18693
18694    fn poll_next(
18695        mut self: std::pin::Pin<&mut Self>,
18696        cx: &mut std::task::Context<'_>,
18697    ) -> std::task::Poll<Option<Self::Item>> {
18698        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
18699            &mut self.event_receiver,
18700            cx
18701        )?) {
18702            Some(buf) => std::task::Poll::Ready(Some(UsageGainReporterEvent::decode(buf))),
18703            None => std::task::Poll::Ready(None),
18704        }
18705    }
18706}
18707
18708#[derive(Debug)]
18709pub enum UsageGainReporterEvent {
18710    #[non_exhaustive]
18711    _UnknownEvent {
18712        /// Ordinal of the event that was sent.
18713        ordinal: u64,
18714    },
18715}
18716
18717impl UsageGainReporterEvent {
18718    /// Decodes a message buffer as a [`UsageGainReporterEvent`].
18719    fn decode(
18720        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
18721    ) -> Result<UsageGainReporterEvent, fidl::Error> {
18722        let (bytes, _handles) = buf.split_mut();
18723        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18724        debug_assert_eq!(tx_header.tx_id, 0);
18725        match tx_header.ordinal {
18726            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
18727                Ok(UsageGainReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
18728            }
18729            _ => Err(fidl::Error::UnknownOrdinal {
18730                ordinal: tx_header.ordinal,
18731                protocol_name:
18732                    <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18733            }),
18734        }
18735    }
18736}
18737
18738/// A Stream of incoming requests for fuchsia.media/UsageGainReporter.
18739pub struct UsageGainReporterRequestStream {
18740    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18741    is_terminated: bool,
18742}
18743
18744impl std::marker::Unpin for UsageGainReporterRequestStream {}
18745
18746impl futures::stream::FusedStream for UsageGainReporterRequestStream {
18747    fn is_terminated(&self) -> bool {
18748        self.is_terminated
18749    }
18750}
18751
18752impl fidl::endpoints::RequestStream for UsageGainReporterRequestStream {
18753    type Protocol = UsageGainReporterMarker;
18754    type ControlHandle = UsageGainReporterControlHandle;
18755
18756    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
18757        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
18758    }
18759
18760    fn control_handle(&self) -> Self::ControlHandle {
18761        UsageGainReporterControlHandle { inner: self.inner.clone() }
18762    }
18763
18764    fn into_inner(
18765        self,
18766    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
18767    {
18768        (self.inner, self.is_terminated)
18769    }
18770
18771    fn from_inner(
18772        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18773        is_terminated: bool,
18774    ) -> Self {
18775        Self { inner, is_terminated }
18776    }
18777}
18778
18779impl futures::Stream for UsageGainReporterRequestStream {
18780    type Item = Result<UsageGainReporterRequest, fidl::Error>;
18781
18782    fn poll_next(
18783        mut self: std::pin::Pin<&mut Self>,
18784        cx: &mut std::task::Context<'_>,
18785    ) -> std::task::Poll<Option<Self::Item>> {
18786        let this = &mut *self;
18787        if this.inner.check_shutdown(cx) {
18788            this.is_terminated = true;
18789            return std::task::Poll::Ready(None);
18790        }
18791        if this.is_terminated {
18792            panic!("polled UsageGainReporterRequestStream after completion");
18793        }
18794        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
18795            |bytes, handles| {
18796                match this.inner.channel().read_etc(cx, bytes, handles) {
18797                    std::task::Poll::Ready(Ok(())) => {}
18798                    std::task::Poll::Pending => return std::task::Poll::Pending,
18799                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
18800                        this.is_terminated = true;
18801                        return std::task::Poll::Ready(None);
18802                    }
18803                    std::task::Poll::Ready(Err(e)) => {
18804                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
18805                            e.into(),
18806                        ))))
18807                    }
18808                }
18809
18810                // A message has been received from the channel
18811                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18812
18813                std::task::Poll::Ready(Some(match header.ordinal {
18814                    0x767107c168c226af => {
18815                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
18816                        let mut req = fidl::new_empty!(
18817                            UsageGainReporterRegisterListenerRequest,
18818                            fidl::encoding::DefaultFuchsiaResourceDialect
18819                        );
18820                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainReporterRegisterListenerRequest>(&header, _body_bytes, handles, &mut req)?;
18821                        let control_handle =
18822                            UsageGainReporterControlHandle { inner: this.inner.clone() };
18823                        Ok(UsageGainReporterRequest::RegisterListener {
18824                            device_unique_id: req.device_unique_id,
18825                            usage: req.usage,
18826                            usage_gain_listener: req.usage_gain_listener,
18827
18828                            control_handle,
18829                        })
18830                    }
18831                    0x760a8e1c5873629c => {
18832                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
18833                        let mut req = fidl::new_empty!(
18834                            UsageGainReporterRegisterListener2Request,
18835                            fidl::encoding::DefaultFuchsiaResourceDialect
18836                        );
18837                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainReporterRegisterListener2Request>(&header, _body_bytes, handles, &mut req)?;
18838                        let control_handle =
18839                            UsageGainReporterControlHandle { inner: this.inner.clone() };
18840                        Ok(UsageGainReporterRequest::RegisterListener2 {
18841                            device_unique_id: req.device_unique_id,
18842                            usage: req.usage,
18843                            usage_gain_listener: req.usage_gain_listener,
18844
18845                            control_handle,
18846                        })
18847                    }
18848                    _ if header.tx_id == 0
18849                        && header
18850                            .dynamic_flags()
18851                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
18852                    {
18853                        Ok(UsageGainReporterRequest::_UnknownMethod {
18854                            ordinal: header.ordinal,
18855                            control_handle: UsageGainReporterControlHandle {
18856                                inner: this.inner.clone(),
18857                            },
18858                            method_type: fidl::MethodType::OneWay,
18859                        })
18860                    }
18861                    _ if header
18862                        .dynamic_flags()
18863                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
18864                    {
18865                        this.inner.send_framework_err(
18866                            fidl::encoding::FrameworkErr::UnknownMethod,
18867                            header.tx_id,
18868                            header.ordinal,
18869                            header.dynamic_flags(),
18870                            (bytes, handles),
18871                        )?;
18872                        Ok(UsageGainReporterRequest::_UnknownMethod {
18873                            ordinal: header.ordinal,
18874                            control_handle: UsageGainReporterControlHandle {
18875                                inner: this.inner.clone(),
18876                            },
18877                            method_type: fidl::MethodType::TwoWay,
18878                        })
18879                    }
18880                    _ => Err(fidl::Error::UnknownOrdinal {
18881                        ordinal: header.ordinal,
18882                        protocol_name:
18883                            <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18884                    }),
18885                }))
18886            },
18887        )
18888    }
18889}
18890
18891/// A protocol for setting up watchers of usage gain.
18892#[derive(Debug)]
18893pub enum UsageGainReporterRequest {
18894    /// Connects a listener to a stream of usage gain setting changes
18895    /// for `usage` on the device identified by `device_token`. Usage
18896    /// Gain is not set directly by any client; it is a translation of
18897    /// the usage volume setting for each device, summed with active
18898    /// muting/ducking gain adjustments.
18899    ///
18900    /// Devices may map the same volume level to different dbfs, so
18901    /// a `device_unique_id` is needed to identify the device.
18902    ///
18903    /// `AudioDeviceEnumerator` provides programmatic access to devices
18904    /// and their unique ids if it is necessary for a client to select
18905    /// an id at runtime.
18906    RegisterListener {
18907        device_unique_id: String,
18908        usage: Usage,
18909        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18910        control_handle: UsageGainReporterControlHandle,
18911    },
18912    /// Connects a listener to a stream of usage gain setting changes
18913    /// for `usage` on the device identified by `device_token`. Usage
18914    /// Gain is not set directly by any client; it is a translation of
18915    /// the usage volume setting for each device, summed with active
18916    /// muting/ducking gain adjustments.
18917    ///
18918    /// Devices may map the same volume level to different dbfs, so
18919    /// a `device_unique_id` is needed to identify the device.
18920    ///
18921    /// `AudioDeviceEnumerator` provides programmatic access to devices
18922    /// and their unique ids if it is necessary for a client to select
18923    /// an id at runtime.
18924    RegisterListener2 {
18925        device_unique_id: String,
18926        usage: Usage2,
18927        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18928        control_handle: UsageGainReporterControlHandle,
18929    },
18930    /// An interaction was received which does not match any known method.
18931    #[non_exhaustive]
18932    _UnknownMethod {
18933        /// Ordinal of the method that was called.
18934        ordinal: u64,
18935        control_handle: UsageGainReporterControlHandle,
18936        method_type: fidl::MethodType,
18937    },
18938}
18939
18940impl UsageGainReporterRequest {
18941    #[allow(irrefutable_let_patterns)]
18942    pub fn into_register_listener(
18943        self,
18944    ) -> Option<(
18945        String,
18946        Usage,
18947        fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18948        UsageGainReporterControlHandle,
18949    )> {
18950        if let UsageGainReporterRequest::RegisterListener {
18951            device_unique_id,
18952            usage,
18953            usage_gain_listener,
18954            control_handle,
18955        } = self
18956        {
18957            Some((device_unique_id, usage, usage_gain_listener, control_handle))
18958        } else {
18959            None
18960        }
18961    }
18962
18963    #[allow(irrefutable_let_patterns)]
18964    pub fn into_register_listener2(
18965        self,
18966    ) -> Option<(
18967        String,
18968        Usage2,
18969        fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18970        UsageGainReporterControlHandle,
18971    )> {
18972        if let UsageGainReporterRequest::RegisterListener2 {
18973            device_unique_id,
18974            usage,
18975            usage_gain_listener,
18976            control_handle,
18977        } = self
18978        {
18979            Some((device_unique_id, usage, usage_gain_listener, control_handle))
18980        } else {
18981            None
18982        }
18983    }
18984
18985    /// Name of the method defined in FIDL
18986    pub fn method_name(&self) -> &'static str {
18987        match *self {
18988            UsageGainReporterRequest::RegisterListener { .. } => "register_listener",
18989            UsageGainReporterRequest::RegisterListener2 { .. } => "register_listener2",
18990            UsageGainReporterRequest::_UnknownMethod {
18991                method_type: fidl::MethodType::OneWay,
18992                ..
18993            } => "unknown one-way method",
18994            UsageGainReporterRequest::_UnknownMethod {
18995                method_type: fidl::MethodType::TwoWay,
18996                ..
18997            } => "unknown two-way method",
18998        }
18999    }
19000}
19001
19002#[derive(Debug, Clone)]
19003pub struct UsageGainReporterControlHandle {
19004    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19005}
19006
19007impl fidl::endpoints::ControlHandle for UsageGainReporterControlHandle {
19008    fn shutdown(&self) {
19009        self.inner.shutdown()
19010    }
19011    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
19012        self.inner.shutdown_with_epitaph(status)
19013    }
19014
19015    fn is_closed(&self) -> bool {
19016        self.inner.channel().is_closed()
19017    }
19018    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
19019        self.inner.channel().on_closed()
19020    }
19021
19022    #[cfg(target_os = "fuchsia")]
19023    fn signal_peer(
19024        &self,
19025        clear_mask: zx::Signals,
19026        set_mask: zx::Signals,
19027    ) -> Result<(), zx_status::Status> {
19028        use fidl::Peered;
19029        self.inner.channel().signal_peer(clear_mask, set_mask)
19030    }
19031}
19032
19033impl UsageGainReporterControlHandle {}
19034
19035#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
19036pub struct UsageReporterMarker;
19037
19038impl fidl::endpoints::ProtocolMarker for UsageReporterMarker {
19039    type Proxy = UsageReporterProxy;
19040    type RequestStream = UsageReporterRequestStream;
19041    #[cfg(target_os = "fuchsia")]
19042    type SynchronousProxy = UsageReporterSynchronousProxy;
19043
19044    const DEBUG_NAME: &'static str = "fuchsia.media.UsageReporter";
19045}
19046impl fidl::endpoints::DiscoverableProtocolMarker for UsageReporterMarker {}
19047
19048pub trait UsageReporterProxyInterface: Send + Sync {
19049    fn r#watch(
19050        &self,
19051        usage: &Usage,
19052        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19053    ) -> Result<(), fidl::Error>;
19054    fn r#watch2(
19055        &self,
19056        usage: &Usage2,
19057        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19058    ) -> Result<(), fidl::Error>;
19059}
19060#[derive(Debug)]
19061#[cfg(target_os = "fuchsia")]
19062pub struct UsageReporterSynchronousProxy {
19063    client: fidl::client::sync::Client,
19064}
19065
19066#[cfg(target_os = "fuchsia")]
19067impl fidl::endpoints::SynchronousProxy for UsageReporterSynchronousProxy {
19068    type Proxy = UsageReporterProxy;
19069    type Protocol = UsageReporterMarker;
19070
19071    fn from_channel(inner: fidl::Channel) -> Self {
19072        Self::new(inner)
19073    }
19074
19075    fn into_channel(self) -> fidl::Channel {
19076        self.client.into_channel()
19077    }
19078
19079    fn as_channel(&self) -> &fidl::Channel {
19080        self.client.as_channel()
19081    }
19082}
19083
19084#[cfg(target_os = "fuchsia")]
19085impl UsageReporterSynchronousProxy {
19086    pub fn new(channel: fidl::Channel) -> Self {
19087        let protocol_name = <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19088        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
19089    }
19090
19091    pub fn into_channel(self) -> fidl::Channel {
19092        self.client.into_channel()
19093    }
19094
19095    /// Waits until an event arrives and returns it. It is safe for other
19096    /// threads to make concurrent requests while waiting for an event.
19097    pub fn wait_for_event(
19098        &self,
19099        deadline: zx::MonotonicInstant,
19100    ) -> Result<UsageReporterEvent, fidl::Error> {
19101        UsageReporterEvent::decode(self.client.wait_for_event(deadline)?)
19102    }
19103
19104    pub fn r#watch(
19105        &self,
19106        mut usage: &Usage,
19107        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19108    ) -> Result<(), fidl::Error> {
19109        self.client.send::<UsageReporterWatchRequest>(
19110            (usage, usage_watcher),
19111            0x769e6fb17075c959,
19112            fidl::encoding::DynamicFlags::empty(),
19113        )
19114    }
19115
19116    pub fn r#watch2(
19117        &self,
19118        mut usage: &Usage2,
19119        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19120    ) -> Result<(), fidl::Error> {
19121        self.client.send::<UsageReporterWatch2Request>(
19122            (usage, usage_watcher),
19123            0x4a43c4c82f5d8ce8,
19124            fidl::encoding::DynamicFlags::FLEXIBLE,
19125        )
19126    }
19127}
19128
19129#[cfg(target_os = "fuchsia")]
19130impl From<UsageReporterSynchronousProxy> for zx::Handle {
19131    fn from(value: UsageReporterSynchronousProxy) -> Self {
19132        value.into_channel().into()
19133    }
19134}
19135
19136#[cfg(target_os = "fuchsia")]
19137impl From<fidl::Channel> for UsageReporterSynchronousProxy {
19138    fn from(value: fidl::Channel) -> Self {
19139        Self::new(value)
19140    }
19141}
19142
19143#[cfg(target_os = "fuchsia")]
19144impl fidl::endpoints::FromClient for UsageReporterSynchronousProxy {
19145    type Protocol = UsageReporterMarker;
19146
19147    fn from_client(value: fidl::endpoints::ClientEnd<UsageReporterMarker>) -> Self {
19148        Self::new(value.into_channel())
19149    }
19150}
19151
19152#[derive(Debug, Clone)]
19153pub struct UsageReporterProxy {
19154    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
19155}
19156
19157impl fidl::endpoints::Proxy for UsageReporterProxy {
19158    type Protocol = UsageReporterMarker;
19159
19160    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
19161        Self::new(inner)
19162    }
19163
19164    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
19165        self.client.into_channel().map_err(|client| Self { client })
19166    }
19167
19168    fn as_channel(&self) -> &::fidl::AsyncChannel {
19169        self.client.as_channel()
19170    }
19171}
19172
19173impl UsageReporterProxy {
19174    /// Create a new Proxy for fuchsia.media/UsageReporter.
19175    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
19176        let protocol_name = <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19177        Self { client: fidl::client::Client::new(channel, protocol_name) }
19178    }
19179
19180    /// Get a Stream of events from the remote end of the protocol.
19181    ///
19182    /// # Panics
19183    ///
19184    /// Panics if the event stream was already taken.
19185    pub fn take_event_stream(&self) -> UsageReporterEventStream {
19186        UsageReporterEventStream { event_receiver: self.client.take_event_receiver() }
19187    }
19188
19189    pub fn r#watch(
19190        &self,
19191        mut usage: &Usage,
19192        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19193    ) -> Result<(), fidl::Error> {
19194        UsageReporterProxyInterface::r#watch(self, usage, usage_watcher)
19195    }
19196
19197    pub fn r#watch2(
19198        &self,
19199        mut usage: &Usage2,
19200        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19201    ) -> Result<(), fidl::Error> {
19202        UsageReporterProxyInterface::r#watch2(self, usage, usage_watcher)
19203    }
19204}
19205
19206impl UsageReporterProxyInterface for UsageReporterProxy {
19207    fn r#watch(
19208        &self,
19209        mut usage: &Usage,
19210        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19211    ) -> Result<(), fidl::Error> {
19212        self.client.send::<UsageReporterWatchRequest>(
19213            (usage, usage_watcher),
19214            0x769e6fb17075c959,
19215            fidl::encoding::DynamicFlags::empty(),
19216        )
19217    }
19218
19219    fn r#watch2(
19220        &self,
19221        mut usage: &Usage2,
19222        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19223    ) -> Result<(), fidl::Error> {
19224        self.client.send::<UsageReporterWatch2Request>(
19225            (usage, usage_watcher),
19226            0x4a43c4c82f5d8ce8,
19227            fidl::encoding::DynamicFlags::FLEXIBLE,
19228        )
19229    }
19230}
19231
19232pub struct UsageReporterEventStream {
19233    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
19234}
19235
19236impl std::marker::Unpin for UsageReporterEventStream {}
19237
19238impl futures::stream::FusedStream for UsageReporterEventStream {
19239    fn is_terminated(&self) -> bool {
19240        self.event_receiver.is_terminated()
19241    }
19242}
19243
19244impl futures::Stream for UsageReporterEventStream {
19245    type Item = Result<UsageReporterEvent, fidl::Error>;
19246
19247    fn poll_next(
19248        mut self: std::pin::Pin<&mut Self>,
19249        cx: &mut std::task::Context<'_>,
19250    ) -> std::task::Poll<Option<Self::Item>> {
19251        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
19252            &mut self.event_receiver,
19253            cx
19254        )?) {
19255            Some(buf) => std::task::Poll::Ready(Some(UsageReporterEvent::decode(buf))),
19256            None => std::task::Poll::Ready(None),
19257        }
19258    }
19259}
19260
19261#[derive(Debug)]
19262pub enum UsageReporterEvent {
19263    #[non_exhaustive]
19264    _UnknownEvent {
19265        /// Ordinal of the event that was sent.
19266        ordinal: u64,
19267    },
19268}
19269
19270impl UsageReporterEvent {
19271    /// Decodes a message buffer as a [`UsageReporterEvent`].
19272    fn decode(
19273        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
19274    ) -> Result<UsageReporterEvent, fidl::Error> {
19275        let (bytes, _handles) = buf.split_mut();
19276        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19277        debug_assert_eq!(tx_header.tx_id, 0);
19278        match tx_header.ordinal {
19279            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
19280                Ok(UsageReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
19281            }
19282            _ => Err(fidl::Error::UnknownOrdinal {
19283                ordinal: tx_header.ordinal,
19284                protocol_name: <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19285            }),
19286        }
19287    }
19288}
19289
19290/// A Stream of incoming requests for fuchsia.media/UsageReporter.
19291pub struct UsageReporterRequestStream {
19292    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19293    is_terminated: bool,
19294}
19295
19296impl std::marker::Unpin for UsageReporterRequestStream {}
19297
19298impl futures::stream::FusedStream for UsageReporterRequestStream {
19299    fn is_terminated(&self) -> bool {
19300        self.is_terminated
19301    }
19302}
19303
19304impl fidl::endpoints::RequestStream for UsageReporterRequestStream {
19305    type Protocol = UsageReporterMarker;
19306    type ControlHandle = UsageReporterControlHandle;
19307
19308    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
19309        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
19310    }
19311
19312    fn control_handle(&self) -> Self::ControlHandle {
19313        UsageReporterControlHandle { inner: self.inner.clone() }
19314    }
19315
19316    fn into_inner(
19317        self,
19318    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
19319    {
19320        (self.inner, self.is_terminated)
19321    }
19322
19323    fn from_inner(
19324        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19325        is_terminated: bool,
19326    ) -> Self {
19327        Self { inner, is_terminated }
19328    }
19329}
19330
19331impl futures::Stream for UsageReporterRequestStream {
19332    type Item = Result<UsageReporterRequest, fidl::Error>;
19333
19334    fn poll_next(
19335        mut self: std::pin::Pin<&mut Self>,
19336        cx: &mut std::task::Context<'_>,
19337    ) -> std::task::Poll<Option<Self::Item>> {
19338        let this = &mut *self;
19339        if this.inner.check_shutdown(cx) {
19340            this.is_terminated = true;
19341            return std::task::Poll::Ready(None);
19342        }
19343        if this.is_terminated {
19344            panic!("polled UsageReporterRequestStream after completion");
19345        }
19346        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
19347            |bytes, handles| {
19348                match this.inner.channel().read_etc(cx, bytes, handles) {
19349                    std::task::Poll::Ready(Ok(())) => {}
19350                    std::task::Poll::Pending => return std::task::Poll::Pending,
19351                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
19352                        this.is_terminated = true;
19353                        return std::task::Poll::Ready(None);
19354                    }
19355                    std::task::Poll::Ready(Err(e)) => {
19356                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
19357                            e.into(),
19358                        ))))
19359                    }
19360                }
19361
19362                // A message has been received from the channel
19363                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19364
19365                std::task::Poll::Ready(Some(match header.ordinal {
19366                    0x769e6fb17075c959 => {
19367                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
19368                        let mut req = fidl::new_empty!(
19369                            UsageReporterWatchRequest,
19370                            fidl::encoding::DefaultFuchsiaResourceDialect
19371                        );
19372                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageReporterWatchRequest>(&header, _body_bytes, handles, &mut req)?;
19373                        let control_handle =
19374                            UsageReporterControlHandle { inner: this.inner.clone() };
19375                        Ok(UsageReporterRequest::Watch {
19376                            usage: req.usage,
19377                            usage_watcher: req.usage_watcher,
19378
19379                            control_handle,
19380                        })
19381                    }
19382                    0x4a43c4c82f5d8ce8 => {
19383                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
19384                        let mut req = fidl::new_empty!(
19385                            UsageReporterWatch2Request,
19386                            fidl::encoding::DefaultFuchsiaResourceDialect
19387                        );
19388                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageReporterWatch2Request>(&header, _body_bytes, handles, &mut req)?;
19389                        let control_handle =
19390                            UsageReporterControlHandle { inner: this.inner.clone() };
19391                        Ok(UsageReporterRequest::Watch2 {
19392                            usage: req.usage,
19393                            usage_watcher: req.usage_watcher,
19394
19395                            control_handle,
19396                        })
19397                    }
19398                    _ if header.tx_id == 0
19399                        && header
19400                            .dynamic_flags()
19401                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
19402                    {
19403                        Ok(UsageReporterRequest::_UnknownMethod {
19404                            ordinal: header.ordinal,
19405                            control_handle: UsageReporterControlHandle {
19406                                inner: this.inner.clone(),
19407                            },
19408                            method_type: fidl::MethodType::OneWay,
19409                        })
19410                    }
19411                    _ if header
19412                        .dynamic_flags()
19413                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
19414                    {
19415                        this.inner.send_framework_err(
19416                            fidl::encoding::FrameworkErr::UnknownMethod,
19417                            header.tx_id,
19418                            header.ordinal,
19419                            header.dynamic_flags(),
19420                            (bytes, handles),
19421                        )?;
19422                        Ok(UsageReporterRequest::_UnknownMethod {
19423                            ordinal: header.ordinal,
19424                            control_handle: UsageReporterControlHandle {
19425                                inner: this.inner.clone(),
19426                            },
19427                            method_type: fidl::MethodType::TwoWay,
19428                        })
19429                    }
19430                    _ => Err(fidl::Error::UnknownOrdinal {
19431                        ordinal: header.ordinal,
19432                        protocol_name:
19433                            <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19434                    }),
19435                }))
19436            },
19437        )
19438    }
19439}
19440
19441/// A protocol for setting up watchers of audio usages.
19442#[derive(Debug)]
19443pub enum UsageReporterRequest {
19444    Watch {
19445        usage: Usage,
19446        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19447        control_handle: UsageReporterControlHandle,
19448    },
19449    Watch2 {
19450        usage: Usage2,
19451        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19452        control_handle: UsageReporterControlHandle,
19453    },
19454    /// An interaction was received which does not match any known method.
19455    #[non_exhaustive]
19456    _UnknownMethod {
19457        /// Ordinal of the method that was called.
19458        ordinal: u64,
19459        control_handle: UsageReporterControlHandle,
19460        method_type: fidl::MethodType,
19461    },
19462}
19463
19464impl UsageReporterRequest {
19465    #[allow(irrefutable_let_patterns)]
19466    pub fn into_watch(
19467        self,
19468    ) -> Option<(Usage, fidl::endpoints::ClientEnd<UsageWatcherMarker>, UsageReporterControlHandle)>
19469    {
19470        if let UsageReporterRequest::Watch { usage, usage_watcher, control_handle } = self {
19471            Some((usage, usage_watcher, control_handle))
19472        } else {
19473            None
19474        }
19475    }
19476
19477    #[allow(irrefutable_let_patterns)]
19478    pub fn into_watch2(
19479        self,
19480    ) -> Option<(Usage2, fidl::endpoints::ClientEnd<UsageWatcher2Marker>, UsageReporterControlHandle)>
19481    {
19482        if let UsageReporterRequest::Watch2 { usage, usage_watcher, control_handle } = self {
19483            Some((usage, usage_watcher, control_handle))
19484        } else {
19485            None
19486        }
19487    }
19488
19489    /// Name of the method defined in FIDL
19490    pub fn method_name(&self) -> &'static str {
19491        match *self {
19492            UsageReporterRequest::Watch { .. } => "watch",
19493            UsageReporterRequest::Watch2 { .. } => "watch2",
19494            UsageReporterRequest::_UnknownMethod {
19495                method_type: fidl::MethodType::OneWay, ..
19496            } => "unknown one-way method",
19497            UsageReporterRequest::_UnknownMethod {
19498                method_type: fidl::MethodType::TwoWay, ..
19499            } => "unknown two-way method",
19500        }
19501    }
19502}
19503
19504#[derive(Debug, Clone)]
19505pub struct UsageReporterControlHandle {
19506    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19507}
19508
19509impl fidl::endpoints::ControlHandle for UsageReporterControlHandle {
19510    fn shutdown(&self) {
19511        self.inner.shutdown()
19512    }
19513    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
19514        self.inner.shutdown_with_epitaph(status)
19515    }
19516
19517    fn is_closed(&self) -> bool {
19518        self.inner.channel().is_closed()
19519    }
19520    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
19521        self.inner.channel().on_closed()
19522    }
19523
19524    #[cfg(target_os = "fuchsia")]
19525    fn signal_peer(
19526        &self,
19527        clear_mask: zx::Signals,
19528        set_mask: zx::Signals,
19529    ) -> Result<(), zx_status::Status> {
19530        use fidl::Peered;
19531        self.inner.channel().signal_peer(clear_mask, set_mask)
19532    }
19533}
19534
19535impl UsageReporterControlHandle {}
19536
19537#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
19538pub struct UsageWatcherMarker;
19539
19540impl fidl::endpoints::ProtocolMarker for UsageWatcherMarker {
19541    type Proxy = UsageWatcherProxy;
19542    type RequestStream = UsageWatcherRequestStream;
19543    #[cfg(target_os = "fuchsia")]
19544    type SynchronousProxy = UsageWatcherSynchronousProxy;
19545
19546    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher";
19547}
19548
19549pub trait UsageWatcherProxyInterface: Send + Sync {
19550    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
19551    fn r#on_state_changed(
19552        &self,
19553        usage: &Usage,
19554        state: &UsageState,
19555    ) -> Self::OnStateChangedResponseFut;
19556}
19557#[derive(Debug)]
19558#[cfg(target_os = "fuchsia")]
19559pub struct UsageWatcherSynchronousProxy {
19560    client: fidl::client::sync::Client,
19561}
19562
19563#[cfg(target_os = "fuchsia")]
19564impl fidl::endpoints::SynchronousProxy for UsageWatcherSynchronousProxy {
19565    type Proxy = UsageWatcherProxy;
19566    type Protocol = UsageWatcherMarker;
19567
19568    fn from_channel(inner: fidl::Channel) -> Self {
19569        Self::new(inner)
19570    }
19571
19572    fn into_channel(self) -> fidl::Channel {
19573        self.client.into_channel()
19574    }
19575
19576    fn as_channel(&self) -> &fidl::Channel {
19577        self.client.as_channel()
19578    }
19579}
19580
19581#[cfg(target_os = "fuchsia")]
19582impl UsageWatcherSynchronousProxy {
19583    pub fn new(channel: fidl::Channel) -> Self {
19584        let protocol_name = <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19585        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
19586    }
19587
19588    pub fn into_channel(self) -> fidl::Channel {
19589        self.client.into_channel()
19590    }
19591
19592    /// Waits until an event arrives and returns it. It is safe for other
19593    /// threads to make concurrent requests while waiting for an event.
19594    pub fn wait_for_event(
19595        &self,
19596        deadline: zx::MonotonicInstant,
19597    ) -> Result<UsageWatcherEvent, fidl::Error> {
19598        UsageWatcherEvent::decode(self.client.wait_for_event(deadline)?)
19599    }
19600
19601    /// Called on first connection and whenever the watched usage changes. The provided
19602    /// usage will always be the bound usage; it is provided so that an implementation of
19603    /// this protocol may be bound to more than one usage.
19604    ///
19605    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
19606    /// events will eventually be disconnected.
19607    pub fn r#on_state_changed(
19608        &self,
19609        mut usage: &Usage,
19610        mut state: &UsageState,
19611        ___deadline: zx::MonotonicInstant,
19612    ) -> Result<(), fidl::Error> {
19613        let _response = self
19614            .client
19615            .send_query::<UsageWatcherOnStateChangedRequest, fidl::encoding::EmptyPayload>(
19616                (usage, state),
19617                0x5b955c5768ec75c5,
19618                fidl::encoding::DynamicFlags::empty(),
19619                ___deadline,
19620            )?;
19621        Ok(_response)
19622    }
19623}
19624
19625#[cfg(target_os = "fuchsia")]
19626impl From<UsageWatcherSynchronousProxy> for zx::Handle {
19627    fn from(value: UsageWatcherSynchronousProxy) -> Self {
19628        value.into_channel().into()
19629    }
19630}
19631
19632#[cfg(target_os = "fuchsia")]
19633impl From<fidl::Channel> for UsageWatcherSynchronousProxy {
19634    fn from(value: fidl::Channel) -> Self {
19635        Self::new(value)
19636    }
19637}
19638
19639#[cfg(target_os = "fuchsia")]
19640impl fidl::endpoints::FromClient for UsageWatcherSynchronousProxy {
19641    type Protocol = UsageWatcherMarker;
19642
19643    fn from_client(value: fidl::endpoints::ClientEnd<UsageWatcherMarker>) -> Self {
19644        Self::new(value.into_channel())
19645    }
19646}
19647
19648#[derive(Debug, Clone)]
19649pub struct UsageWatcherProxy {
19650    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
19651}
19652
19653impl fidl::endpoints::Proxy for UsageWatcherProxy {
19654    type Protocol = UsageWatcherMarker;
19655
19656    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
19657        Self::new(inner)
19658    }
19659
19660    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
19661        self.client.into_channel().map_err(|client| Self { client })
19662    }
19663
19664    fn as_channel(&self) -> &::fidl::AsyncChannel {
19665        self.client.as_channel()
19666    }
19667}
19668
19669impl UsageWatcherProxy {
19670    /// Create a new Proxy for fuchsia.media/UsageWatcher.
19671    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
19672        let protocol_name = <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19673        Self { client: fidl::client::Client::new(channel, protocol_name) }
19674    }
19675
19676    /// Get a Stream of events from the remote end of the protocol.
19677    ///
19678    /// # Panics
19679    ///
19680    /// Panics if the event stream was already taken.
19681    pub fn take_event_stream(&self) -> UsageWatcherEventStream {
19682        UsageWatcherEventStream { event_receiver: self.client.take_event_receiver() }
19683    }
19684
19685    /// Called on first connection and whenever the watched usage changes. The provided
19686    /// usage will always be the bound usage; it is provided so that an implementation of
19687    /// this protocol may be bound to more than one usage.
19688    ///
19689    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
19690    /// events will eventually be disconnected.
19691    pub fn r#on_state_changed(
19692        &self,
19693        mut usage: &Usage,
19694        mut state: &UsageState,
19695    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
19696        UsageWatcherProxyInterface::r#on_state_changed(self, usage, state)
19697    }
19698}
19699
19700impl UsageWatcherProxyInterface for UsageWatcherProxy {
19701    type OnStateChangedResponseFut =
19702        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
19703    fn r#on_state_changed(
19704        &self,
19705        mut usage: &Usage,
19706        mut state: &UsageState,
19707    ) -> Self::OnStateChangedResponseFut {
19708        fn _decode(
19709            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
19710        ) -> Result<(), fidl::Error> {
19711            let _response = fidl::client::decode_transaction_body::<
19712                fidl::encoding::EmptyPayload,
19713                fidl::encoding::DefaultFuchsiaResourceDialect,
19714                0x5b955c5768ec75c5,
19715            >(_buf?)?;
19716            Ok(_response)
19717        }
19718        self.client.send_query_and_decode::<UsageWatcherOnStateChangedRequest, ()>(
19719            (usage, state),
19720            0x5b955c5768ec75c5,
19721            fidl::encoding::DynamicFlags::empty(),
19722            _decode,
19723        )
19724    }
19725}
19726
19727pub struct UsageWatcherEventStream {
19728    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
19729}
19730
19731impl std::marker::Unpin for UsageWatcherEventStream {}
19732
19733impl futures::stream::FusedStream for UsageWatcherEventStream {
19734    fn is_terminated(&self) -> bool {
19735        self.event_receiver.is_terminated()
19736    }
19737}
19738
19739impl futures::Stream for UsageWatcherEventStream {
19740    type Item = Result<UsageWatcherEvent, fidl::Error>;
19741
19742    fn poll_next(
19743        mut self: std::pin::Pin<&mut Self>,
19744        cx: &mut std::task::Context<'_>,
19745    ) -> std::task::Poll<Option<Self::Item>> {
19746        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
19747            &mut self.event_receiver,
19748            cx
19749        )?) {
19750            Some(buf) => std::task::Poll::Ready(Some(UsageWatcherEvent::decode(buf))),
19751            None => std::task::Poll::Ready(None),
19752        }
19753    }
19754}
19755
19756#[derive(Debug)]
19757pub enum UsageWatcherEvent {}
19758
19759impl UsageWatcherEvent {
19760    /// Decodes a message buffer as a [`UsageWatcherEvent`].
19761    fn decode(
19762        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
19763    ) -> Result<UsageWatcherEvent, fidl::Error> {
19764        let (bytes, _handles) = buf.split_mut();
19765        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19766        debug_assert_eq!(tx_header.tx_id, 0);
19767        match tx_header.ordinal {
19768            _ => Err(fidl::Error::UnknownOrdinal {
19769                ordinal: tx_header.ordinal,
19770                protocol_name: <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19771            }),
19772        }
19773    }
19774}
19775
19776/// A Stream of incoming requests for fuchsia.media/UsageWatcher.
19777pub struct UsageWatcherRequestStream {
19778    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19779    is_terminated: bool,
19780}
19781
19782impl std::marker::Unpin for UsageWatcherRequestStream {}
19783
19784impl futures::stream::FusedStream for UsageWatcherRequestStream {
19785    fn is_terminated(&self) -> bool {
19786        self.is_terminated
19787    }
19788}
19789
19790impl fidl::endpoints::RequestStream for UsageWatcherRequestStream {
19791    type Protocol = UsageWatcherMarker;
19792    type ControlHandle = UsageWatcherControlHandle;
19793
19794    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
19795        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
19796    }
19797
19798    fn control_handle(&self) -> Self::ControlHandle {
19799        UsageWatcherControlHandle { inner: self.inner.clone() }
19800    }
19801
19802    fn into_inner(
19803        self,
19804    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
19805    {
19806        (self.inner, self.is_terminated)
19807    }
19808
19809    fn from_inner(
19810        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19811        is_terminated: bool,
19812    ) -> Self {
19813        Self { inner, is_terminated }
19814    }
19815}
19816
19817impl futures::Stream for UsageWatcherRequestStream {
19818    type Item = Result<UsageWatcherRequest, fidl::Error>;
19819
19820    fn poll_next(
19821        mut self: std::pin::Pin<&mut Self>,
19822        cx: &mut std::task::Context<'_>,
19823    ) -> std::task::Poll<Option<Self::Item>> {
19824        let this = &mut *self;
19825        if this.inner.check_shutdown(cx) {
19826            this.is_terminated = true;
19827            return std::task::Poll::Ready(None);
19828        }
19829        if this.is_terminated {
19830            panic!("polled UsageWatcherRequestStream after completion");
19831        }
19832        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
19833            |bytes, handles| {
19834                match this.inner.channel().read_etc(cx, bytes, handles) {
19835                    std::task::Poll::Ready(Ok(())) => {}
19836                    std::task::Poll::Pending => return std::task::Poll::Pending,
19837                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
19838                        this.is_terminated = true;
19839                        return std::task::Poll::Ready(None);
19840                    }
19841                    std::task::Poll::Ready(Err(e)) => {
19842                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
19843                            e.into(),
19844                        ))))
19845                    }
19846                }
19847
19848                // A message has been received from the channel
19849                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19850
19851                std::task::Poll::Ready(Some(match header.ordinal {
19852                    0x5b955c5768ec75c5 => {
19853                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
19854                        let mut req = fidl::new_empty!(
19855                            UsageWatcherOnStateChangedRequest,
19856                            fidl::encoding::DefaultFuchsiaResourceDialect
19857                        );
19858                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageWatcherOnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
19859                        let control_handle =
19860                            UsageWatcherControlHandle { inner: this.inner.clone() };
19861                        Ok(UsageWatcherRequest::OnStateChanged {
19862                            usage: req.usage,
19863                            state: req.state,
19864
19865                            responder: UsageWatcherOnStateChangedResponder {
19866                                control_handle: std::mem::ManuallyDrop::new(control_handle),
19867                                tx_id: header.tx_id,
19868                            },
19869                        })
19870                    }
19871                    _ => Err(fidl::Error::UnknownOrdinal {
19872                        ordinal: header.ordinal,
19873                        protocol_name:
19874                            <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19875                    }),
19876                }))
19877            },
19878        )
19879    }
19880}
19881
19882/// A protocol for listening to changes to the policy state of an audio usage.
19883///
19884/// User actions, such as lowering the volume or muting a stream, are not reflected in this API.
19885#[derive(Debug)]
19886pub enum UsageWatcherRequest {
19887    /// Called on first connection and whenever the watched usage changes. The provided
19888    /// usage will always be the bound usage; it is provided so that an implementation of
19889    /// this protocol may be bound to more than one usage.
19890    ///
19891    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
19892    /// events will eventually be disconnected.
19893    OnStateChanged {
19894        usage: Usage,
19895        state: UsageState,
19896        responder: UsageWatcherOnStateChangedResponder,
19897    },
19898}
19899
19900impl UsageWatcherRequest {
19901    #[allow(irrefutable_let_patterns)]
19902    pub fn into_on_state_changed(
19903        self,
19904    ) -> Option<(Usage, UsageState, UsageWatcherOnStateChangedResponder)> {
19905        if let UsageWatcherRequest::OnStateChanged { usage, state, responder } = self {
19906            Some((usage, state, responder))
19907        } else {
19908            None
19909        }
19910    }
19911
19912    /// Name of the method defined in FIDL
19913    pub fn method_name(&self) -> &'static str {
19914        match *self {
19915            UsageWatcherRequest::OnStateChanged { .. } => "on_state_changed",
19916        }
19917    }
19918}
19919
19920#[derive(Debug, Clone)]
19921pub struct UsageWatcherControlHandle {
19922    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19923}
19924
19925impl fidl::endpoints::ControlHandle for UsageWatcherControlHandle {
19926    fn shutdown(&self) {
19927        self.inner.shutdown()
19928    }
19929    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
19930        self.inner.shutdown_with_epitaph(status)
19931    }
19932
19933    fn is_closed(&self) -> bool {
19934        self.inner.channel().is_closed()
19935    }
19936    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
19937        self.inner.channel().on_closed()
19938    }
19939
19940    #[cfg(target_os = "fuchsia")]
19941    fn signal_peer(
19942        &self,
19943        clear_mask: zx::Signals,
19944        set_mask: zx::Signals,
19945    ) -> Result<(), zx_status::Status> {
19946        use fidl::Peered;
19947        self.inner.channel().signal_peer(clear_mask, set_mask)
19948    }
19949}
19950
19951impl UsageWatcherControlHandle {}
19952
19953#[must_use = "FIDL methods require a response to be sent"]
19954#[derive(Debug)]
19955pub struct UsageWatcherOnStateChangedResponder {
19956    control_handle: std::mem::ManuallyDrop<UsageWatcherControlHandle>,
19957    tx_id: u32,
19958}
19959
19960/// Set the the channel to be shutdown (see [`UsageWatcherControlHandle::shutdown`])
19961/// if the responder is dropped without sending a response, so that the client
19962/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
19963impl std::ops::Drop for UsageWatcherOnStateChangedResponder {
19964    fn drop(&mut self) {
19965        self.control_handle.shutdown();
19966        // Safety: drops once, never accessed again
19967        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
19968    }
19969}
19970
19971impl fidl::endpoints::Responder for UsageWatcherOnStateChangedResponder {
19972    type ControlHandle = UsageWatcherControlHandle;
19973
19974    fn control_handle(&self) -> &UsageWatcherControlHandle {
19975        &self.control_handle
19976    }
19977
19978    fn drop_without_shutdown(mut self) {
19979        // Safety: drops once, never accessed again due to mem::forget
19980        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
19981        // Prevent Drop from running (which would shut down the channel)
19982        std::mem::forget(self);
19983    }
19984}
19985
19986impl UsageWatcherOnStateChangedResponder {
19987    /// Sends a response to the FIDL transaction.
19988    ///
19989    /// Sets the channel to shutdown if an error occurs.
19990    pub fn send(self) -> Result<(), fidl::Error> {
19991        let _result = self.send_raw();
19992        if _result.is_err() {
19993            self.control_handle.shutdown();
19994        }
19995        self.drop_without_shutdown();
19996        _result
19997    }
19998
19999    /// Similar to "send" but does not shutdown the channel if an error occurs.
20000    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
20001        let _result = self.send_raw();
20002        self.drop_without_shutdown();
20003        _result
20004    }
20005
20006    fn send_raw(&self) -> Result<(), fidl::Error> {
20007        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
20008            (),
20009            self.tx_id,
20010            0x5b955c5768ec75c5,
20011            fidl::encoding::DynamicFlags::empty(),
20012        )
20013    }
20014}
20015
20016#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
20017pub struct UsageWatcher2Marker;
20018
20019impl fidl::endpoints::ProtocolMarker for UsageWatcher2Marker {
20020    type Proxy = UsageWatcher2Proxy;
20021    type RequestStream = UsageWatcher2RequestStream;
20022    #[cfg(target_os = "fuchsia")]
20023    type SynchronousProxy = UsageWatcher2SynchronousProxy;
20024
20025    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher2";
20026}
20027
20028pub trait UsageWatcher2ProxyInterface: Send + Sync {
20029    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
20030    fn r#on_state_changed(
20031        &self,
20032        usage: &Usage2,
20033        state: &UsageState,
20034    ) -> Self::OnStateChangedResponseFut;
20035}
20036#[derive(Debug)]
20037#[cfg(target_os = "fuchsia")]
20038pub struct UsageWatcher2SynchronousProxy {
20039    client: fidl::client::sync::Client,
20040}
20041
20042#[cfg(target_os = "fuchsia")]
20043impl fidl::endpoints::SynchronousProxy for UsageWatcher2SynchronousProxy {
20044    type Proxy = UsageWatcher2Proxy;
20045    type Protocol = UsageWatcher2Marker;
20046
20047    fn from_channel(inner: fidl::Channel) -> Self {
20048        Self::new(inner)
20049    }
20050
20051    fn into_channel(self) -> fidl::Channel {
20052        self.client.into_channel()
20053    }
20054
20055    fn as_channel(&self) -> &fidl::Channel {
20056        self.client.as_channel()
20057    }
20058}
20059
20060#[cfg(target_os = "fuchsia")]
20061impl UsageWatcher2SynchronousProxy {
20062    pub fn new(channel: fidl::Channel) -> Self {
20063        let protocol_name = <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
20064        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
20065    }
20066
20067    pub fn into_channel(self) -> fidl::Channel {
20068        self.client.into_channel()
20069    }
20070
20071    /// Waits until an event arrives and returns it. It is safe for other
20072    /// threads to make concurrent requests while waiting for an event.
20073    pub fn wait_for_event(
20074        &self,
20075        deadline: zx::MonotonicInstant,
20076    ) -> Result<UsageWatcher2Event, fidl::Error> {
20077        UsageWatcher2Event::decode(self.client.wait_for_event(deadline)?)
20078    }
20079
20080    /// Called on first connection and whenever the watched usage changes. The provided
20081    /// usage will always be the bound usage; it is provided so that an implementation of
20082    /// this protocol may be bound to more than one usage.
20083    ///
20084    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20085    /// events will eventually be disconnected.
20086    pub fn r#on_state_changed(
20087        &self,
20088        mut usage: &Usage2,
20089        mut state: &UsageState,
20090        ___deadline: zx::MonotonicInstant,
20091    ) -> Result<(), fidl::Error> {
20092        let _response = self
20093            .client
20094            .send_query::<UsageWatcher2OnStateChangedRequest, fidl::encoding::EmptyPayload>(
20095                (usage, state),
20096                0xca31a8b13c324d4,
20097                fidl::encoding::DynamicFlags::empty(),
20098                ___deadline,
20099            )?;
20100        Ok(_response)
20101    }
20102}
20103
20104#[cfg(target_os = "fuchsia")]
20105impl From<UsageWatcher2SynchronousProxy> for zx::Handle {
20106    fn from(value: UsageWatcher2SynchronousProxy) -> Self {
20107        value.into_channel().into()
20108    }
20109}
20110
20111#[cfg(target_os = "fuchsia")]
20112impl From<fidl::Channel> for UsageWatcher2SynchronousProxy {
20113    fn from(value: fidl::Channel) -> Self {
20114        Self::new(value)
20115    }
20116}
20117
20118#[cfg(target_os = "fuchsia")]
20119impl fidl::endpoints::FromClient for UsageWatcher2SynchronousProxy {
20120    type Protocol = UsageWatcher2Marker;
20121
20122    fn from_client(value: fidl::endpoints::ClientEnd<UsageWatcher2Marker>) -> Self {
20123        Self::new(value.into_channel())
20124    }
20125}
20126
20127#[derive(Debug, Clone)]
20128pub struct UsageWatcher2Proxy {
20129    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
20130}
20131
20132impl fidl::endpoints::Proxy for UsageWatcher2Proxy {
20133    type Protocol = UsageWatcher2Marker;
20134
20135    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
20136        Self::new(inner)
20137    }
20138
20139    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
20140        self.client.into_channel().map_err(|client| Self { client })
20141    }
20142
20143    fn as_channel(&self) -> &::fidl::AsyncChannel {
20144        self.client.as_channel()
20145    }
20146}
20147
20148impl UsageWatcher2Proxy {
20149    /// Create a new Proxy for fuchsia.media/UsageWatcher2.
20150    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
20151        let protocol_name = <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
20152        Self { client: fidl::client::Client::new(channel, protocol_name) }
20153    }
20154
20155    /// Get a Stream of events from the remote end of the protocol.
20156    ///
20157    /// # Panics
20158    ///
20159    /// Panics if the event stream was already taken.
20160    pub fn take_event_stream(&self) -> UsageWatcher2EventStream {
20161        UsageWatcher2EventStream { event_receiver: self.client.take_event_receiver() }
20162    }
20163
20164    /// Called on first connection and whenever the watched usage changes. The provided
20165    /// usage will always be the bound usage; it is provided so that an implementation of
20166    /// this protocol may be bound to more than one usage.
20167    ///
20168    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20169    /// events will eventually be disconnected.
20170    pub fn r#on_state_changed(
20171        &self,
20172        mut usage: &Usage2,
20173        mut state: &UsageState,
20174    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
20175        UsageWatcher2ProxyInterface::r#on_state_changed(self, usage, state)
20176    }
20177}
20178
20179impl UsageWatcher2ProxyInterface for UsageWatcher2Proxy {
20180    type OnStateChangedResponseFut =
20181        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
20182    fn r#on_state_changed(
20183        &self,
20184        mut usage: &Usage2,
20185        mut state: &UsageState,
20186    ) -> Self::OnStateChangedResponseFut {
20187        fn _decode(
20188            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
20189        ) -> Result<(), fidl::Error> {
20190            let _response = fidl::client::decode_transaction_body::<
20191                fidl::encoding::EmptyPayload,
20192                fidl::encoding::DefaultFuchsiaResourceDialect,
20193                0xca31a8b13c324d4,
20194            >(_buf?)?;
20195            Ok(_response)
20196        }
20197        self.client.send_query_and_decode::<UsageWatcher2OnStateChangedRequest, ()>(
20198            (usage, state),
20199            0xca31a8b13c324d4,
20200            fidl::encoding::DynamicFlags::empty(),
20201            _decode,
20202        )
20203    }
20204}
20205
20206pub struct UsageWatcher2EventStream {
20207    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
20208}
20209
20210impl std::marker::Unpin for UsageWatcher2EventStream {}
20211
20212impl futures::stream::FusedStream for UsageWatcher2EventStream {
20213    fn is_terminated(&self) -> bool {
20214        self.event_receiver.is_terminated()
20215    }
20216}
20217
20218impl futures::Stream for UsageWatcher2EventStream {
20219    type Item = Result<UsageWatcher2Event, fidl::Error>;
20220
20221    fn poll_next(
20222        mut self: std::pin::Pin<&mut Self>,
20223        cx: &mut std::task::Context<'_>,
20224    ) -> std::task::Poll<Option<Self::Item>> {
20225        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
20226            &mut self.event_receiver,
20227            cx
20228        )?) {
20229            Some(buf) => std::task::Poll::Ready(Some(UsageWatcher2Event::decode(buf))),
20230            None => std::task::Poll::Ready(None),
20231        }
20232    }
20233}
20234
20235#[derive(Debug)]
20236pub enum UsageWatcher2Event {}
20237
20238impl UsageWatcher2Event {
20239    /// Decodes a message buffer as a [`UsageWatcher2Event`].
20240    fn decode(
20241        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
20242    ) -> Result<UsageWatcher2Event, fidl::Error> {
20243        let (bytes, _handles) = buf.split_mut();
20244        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
20245        debug_assert_eq!(tx_header.tx_id, 0);
20246        match tx_header.ordinal {
20247            _ => Err(fidl::Error::UnknownOrdinal {
20248                ordinal: tx_header.ordinal,
20249                protocol_name: <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
20250            }),
20251        }
20252    }
20253}
20254
20255/// A Stream of incoming requests for fuchsia.media/UsageWatcher2.
20256pub struct UsageWatcher2RequestStream {
20257    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20258    is_terminated: bool,
20259}
20260
20261impl std::marker::Unpin for UsageWatcher2RequestStream {}
20262
20263impl futures::stream::FusedStream for UsageWatcher2RequestStream {
20264    fn is_terminated(&self) -> bool {
20265        self.is_terminated
20266    }
20267}
20268
20269impl fidl::endpoints::RequestStream for UsageWatcher2RequestStream {
20270    type Protocol = UsageWatcher2Marker;
20271    type ControlHandle = UsageWatcher2ControlHandle;
20272
20273    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
20274        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
20275    }
20276
20277    fn control_handle(&self) -> Self::ControlHandle {
20278        UsageWatcher2ControlHandle { inner: self.inner.clone() }
20279    }
20280
20281    fn into_inner(
20282        self,
20283    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
20284    {
20285        (self.inner, self.is_terminated)
20286    }
20287
20288    fn from_inner(
20289        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20290        is_terminated: bool,
20291    ) -> Self {
20292        Self { inner, is_terminated }
20293    }
20294}
20295
20296impl futures::Stream for UsageWatcher2RequestStream {
20297    type Item = Result<UsageWatcher2Request, fidl::Error>;
20298
20299    fn poll_next(
20300        mut self: std::pin::Pin<&mut Self>,
20301        cx: &mut std::task::Context<'_>,
20302    ) -> std::task::Poll<Option<Self::Item>> {
20303        let this = &mut *self;
20304        if this.inner.check_shutdown(cx) {
20305            this.is_terminated = true;
20306            return std::task::Poll::Ready(None);
20307        }
20308        if this.is_terminated {
20309            panic!("polled UsageWatcher2RequestStream after completion");
20310        }
20311        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
20312            |bytes, handles| {
20313                match this.inner.channel().read_etc(cx, bytes, handles) {
20314                    std::task::Poll::Ready(Ok(())) => {}
20315                    std::task::Poll::Pending => return std::task::Poll::Pending,
20316                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
20317                        this.is_terminated = true;
20318                        return std::task::Poll::Ready(None);
20319                    }
20320                    std::task::Poll::Ready(Err(e)) => {
20321                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
20322                            e.into(),
20323                        ))))
20324                    }
20325                }
20326
20327                // A message has been received from the channel
20328                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
20329
20330                std::task::Poll::Ready(Some(match header.ordinal {
20331                    0xca31a8b13c324d4 => {
20332                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
20333                        let mut req = fidl::new_empty!(
20334                            UsageWatcher2OnStateChangedRequest,
20335                            fidl::encoding::DefaultFuchsiaResourceDialect
20336                        );
20337                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageWatcher2OnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
20338                        let control_handle =
20339                            UsageWatcher2ControlHandle { inner: this.inner.clone() };
20340                        Ok(UsageWatcher2Request::OnStateChanged {
20341                            usage: req.usage,
20342                            state: req.state,
20343
20344                            responder: UsageWatcher2OnStateChangedResponder {
20345                                control_handle: std::mem::ManuallyDrop::new(control_handle),
20346                                tx_id: header.tx_id,
20347                            },
20348                        })
20349                    }
20350                    _ => Err(fidl::Error::UnknownOrdinal {
20351                        ordinal: header.ordinal,
20352                        protocol_name:
20353                            <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
20354                    }),
20355                }))
20356            },
20357        )
20358    }
20359}
20360
20361#[derive(Debug)]
20362pub enum UsageWatcher2Request {
20363    /// Called on first connection and whenever the watched usage changes. The provided
20364    /// usage will always be the bound usage; it is provided so that an implementation of
20365    /// this protocol may be bound to more than one usage.
20366    ///
20367    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20368    /// events will eventually be disconnected.
20369    OnStateChanged {
20370        usage: Usage2,
20371        state: UsageState,
20372        responder: UsageWatcher2OnStateChangedResponder,
20373    },
20374}
20375
20376impl UsageWatcher2Request {
20377    #[allow(irrefutable_let_patterns)]
20378    pub fn into_on_state_changed(
20379        self,
20380    ) -> Option<(Usage2, UsageState, UsageWatcher2OnStateChangedResponder)> {
20381        if let UsageWatcher2Request::OnStateChanged { usage, state, responder } = self {
20382            Some((usage, state, responder))
20383        } else {
20384            None
20385        }
20386    }
20387
20388    /// Name of the method defined in FIDL
20389    pub fn method_name(&self) -> &'static str {
20390        match *self {
20391            UsageWatcher2Request::OnStateChanged { .. } => "on_state_changed",
20392        }
20393    }
20394}
20395
20396#[derive(Debug, Clone)]
20397pub struct UsageWatcher2ControlHandle {
20398    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20399}
20400
20401impl fidl::endpoints::ControlHandle for UsageWatcher2ControlHandle {
20402    fn shutdown(&self) {
20403        self.inner.shutdown()
20404    }
20405    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
20406        self.inner.shutdown_with_epitaph(status)
20407    }
20408
20409    fn is_closed(&self) -> bool {
20410        self.inner.channel().is_closed()
20411    }
20412    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
20413        self.inner.channel().on_closed()
20414    }
20415
20416    #[cfg(target_os = "fuchsia")]
20417    fn signal_peer(
20418        &self,
20419        clear_mask: zx::Signals,
20420        set_mask: zx::Signals,
20421    ) -> Result<(), zx_status::Status> {
20422        use fidl::Peered;
20423        self.inner.channel().signal_peer(clear_mask, set_mask)
20424    }
20425}
20426
20427impl UsageWatcher2ControlHandle {}
20428
20429#[must_use = "FIDL methods require a response to be sent"]
20430#[derive(Debug)]
20431pub struct UsageWatcher2OnStateChangedResponder {
20432    control_handle: std::mem::ManuallyDrop<UsageWatcher2ControlHandle>,
20433    tx_id: u32,
20434}
20435
20436/// Set the the channel to be shutdown (see [`UsageWatcher2ControlHandle::shutdown`])
20437/// if the responder is dropped without sending a response, so that the client
20438/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
20439impl std::ops::Drop for UsageWatcher2OnStateChangedResponder {
20440    fn drop(&mut self) {
20441        self.control_handle.shutdown();
20442        // Safety: drops once, never accessed again
20443        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
20444    }
20445}
20446
20447impl fidl::endpoints::Responder for UsageWatcher2OnStateChangedResponder {
20448    type ControlHandle = UsageWatcher2ControlHandle;
20449
20450    fn control_handle(&self) -> &UsageWatcher2ControlHandle {
20451        &self.control_handle
20452    }
20453
20454    fn drop_without_shutdown(mut self) {
20455        // Safety: drops once, never accessed again due to mem::forget
20456        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
20457        // Prevent Drop from running (which would shut down the channel)
20458        std::mem::forget(self);
20459    }
20460}
20461
20462impl UsageWatcher2OnStateChangedResponder {
20463    /// Sends a response to the FIDL transaction.
20464    ///
20465    /// Sets the channel to shutdown if an error occurs.
20466    pub fn send(self) -> Result<(), fidl::Error> {
20467        let _result = self.send_raw();
20468        if _result.is_err() {
20469            self.control_handle.shutdown();
20470        }
20471        self.drop_without_shutdown();
20472        _result
20473    }
20474
20475    /// Similar to "send" but does not shutdown the channel if an error occurs.
20476    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
20477        let _result = self.send_raw();
20478        self.drop_without_shutdown();
20479        _result
20480    }
20481
20482    fn send_raw(&self) -> Result<(), fidl::Error> {
20483        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
20484            (),
20485            self.tx_id,
20486            0xca31a8b13c324d4,
20487            fidl::encoding::DynamicFlags::empty(),
20488        )
20489    }
20490}
20491
20492mod internal {
20493    use super::*;
20494
20495    impl fidl::encoding::ResourceTypeMarker for AudioCapturerBindGainControlRequest {
20496        type Borrowed<'a> = &'a mut Self;
20497        fn take_or_borrow<'a>(
20498            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20499        ) -> Self::Borrowed<'a> {
20500            value
20501        }
20502    }
20503
20504    unsafe impl fidl::encoding::TypeMarker for AudioCapturerBindGainControlRequest {
20505        type Owned = Self;
20506
20507        #[inline(always)]
20508        fn inline_align(_context: fidl::encoding::Context) -> usize {
20509            4
20510        }
20511
20512        #[inline(always)]
20513        fn inline_size(_context: fidl::encoding::Context) -> usize {
20514            4
20515        }
20516    }
20517
20518    unsafe impl
20519        fidl::encoding::Encode<
20520            AudioCapturerBindGainControlRequest,
20521            fidl::encoding::DefaultFuchsiaResourceDialect,
20522        > for &mut AudioCapturerBindGainControlRequest
20523    {
20524        #[inline]
20525        unsafe fn encode(
20526            self,
20527            encoder: &mut fidl::encoding::Encoder<
20528                '_,
20529                fidl::encoding::DefaultFuchsiaResourceDialect,
20530            >,
20531            offset: usize,
20532            _depth: fidl::encoding::Depth,
20533        ) -> fidl::Result<()> {
20534            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
20535            // Delegate to tuple encoding.
20536            fidl::encoding::Encode::<
20537                AudioCapturerBindGainControlRequest,
20538                fidl::encoding::DefaultFuchsiaResourceDialect,
20539            >::encode(
20540                (<fidl::encoding::Endpoint<
20541                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20542                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20543                    &mut self.gain_control_request,
20544                ),),
20545                encoder,
20546                offset,
20547                _depth,
20548            )
20549        }
20550    }
20551    unsafe impl<
20552            T0: fidl::encoding::Encode<
20553                fidl::encoding::Endpoint<
20554                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20555                >,
20556                fidl::encoding::DefaultFuchsiaResourceDialect,
20557            >,
20558        >
20559        fidl::encoding::Encode<
20560            AudioCapturerBindGainControlRequest,
20561            fidl::encoding::DefaultFuchsiaResourceDialect,
20562        > for (T0,)
20563    {
20564        #[inline]
20565        unsafe fn encode(
20566            self,
20567            encoder: &mut fidl::encoding::Encoder<
20568                '_,
20569                fidl::encoding::DefaultFuchsiaResourceDialect,
20570            >,
20571            offset: usize,
20572            depth: fidl::encoding::Depth,
20573        ) -> fidl::Result<()> {
20574            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
20575            // Zero out padding regions. There's no need to apply masks
20576            // because the unmasked parts will be overwritten by fields.
20577            // Write the fields.
20578            self.0.encode(encoder, offset + 0, depth)?;
20579            Ok(())
20580        }
20581    }
20582
20583    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20584        for AudioCapturerBindGainControlRequest
20585    {
20586        #[inline(always)]
20587        fn new_empty() -> Self {
20588            Self {
20589                gain_control_request: fidl::new_empty!(
20590                    fidl::encoding::Endpoint<
20591                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20592                    >,
20593                    fidl::encoding::DefaultFuchsiaResourceDialect
20594                ),
20595            }
20596        }
20597
20598        #[inline]
20599        unsafe fn decode(
20600            &mut self,
20601            decoder: &mut fidl::encoding::Decoder<
20602                '_,
20603                fidl::encoding::DefaultFuchsiaResourceDialect,
20604            >,
20605            offset: usize,
20606            _depth: fidl::encoding::Depth,
20607        ) -> fidl::Result<()> {
20608            decoder.debug_check_bounds::<Self>(offset);
20609            // Verify that padding bytes are zero.
20610            fidl::decode!(
20611                fidl::encoding::Endpoint<
20612                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20613                >,
20614                fidl::encoding::DefaultFuchsiaResourceDialect,
20615                &mut self.gain_control_request,
20616                decoder,
20617                offset + 0,
20618                _depth
20619            )?;
20620            Ok(())
20621        }
20622    }
20623
20624    impl fidl::encoding::ResourceTypeMarker for AudioCapturerGetReferenceClockResponse {
20625        type Borrowed<'a> = &'a mut Self;
20626        fn take_or_borrow<'a>(
20627            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20628        ) -> Self::Borrowed<'a> {
20629            value
20630        }
20631    }
20632
20633    unsafe impl fidl::encoding::TypeMarker for AudioCapturerGetReferenceClockResponse {
20634        type Owned = Self;
20635
20636        #[inline(always)]
20637        fn inline_align(_context: fidl::encoding::Context) -> usize {
20638            4
20639        }
20640
20641        #[inline(always)]
20642        fn inline_size(_context: fidl::encoding::Context) -> usize {
20643            4
20644        }
20645    }
20646
20647    unsafe impl
20648        fidl::encoding::Encode<
20649            AudioCapturerGetReferenceClockResponse,
20650            fidl::encoding::DefaultFuchsiaResourceDialect,
20651        > for &mut AudioCapturerGetReferenceClockResponse
20652    {
20653        #[inline]
20654        unsafe fn encode(
20655            self,
20656            encoder: &mut fidl::encoding::Encoder<
20657                '_,
20658                fidl::encoding::DefaultFuchsiaResourceDialect,
20659            >,
20660            offset: usize,
20661            _depth: fidl::encoding::Depth,
20662        ) -> fidl::Result<()> {
20663            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
20664            // Delegate to tuple encoding.
20665            fidl::encoding::Encode::<
20666                AudioCapturerGetReferenceClockResponse,
20667                fidl::encoding::DefaultFuchsiaResourceDialect,
20668            >::encode(
20669                (<fidl::encoding::HandleType<
20670                    fidl::Clock,
20671                    { fidl::ObjectType::CLOCK.into_raw() },
20672                    2147483648,
20673                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20674                    &mut self.reference_clock,
20675                ),),
20676                encoder,
20677                offset,
20678                _depth,
20679            )
20680        }
20681    }
20682    unsafe impl<
20683            T0: fidl::encoding::Encode<
20684                fidl::encoding::HandleType<
20685                    fidl::Clock,
20686                    { fidl::ObjectType::CLOCK.into_raw() },
20687                    2147483648,
20688                >,
20689                fidl::encoding::DefaultFuchsiaResourceDialect,
20690            >,
20691        >
20692        fidl::encoding::Encode<
20693            AudioCapturerGetReferenceClockResponse,
20694            fidl::encoding::DefaultFuchsiaResourceDialect,
20695        > for (T0,)
20696    {
20697        #[inline]
20698        unsafe fn encode(
20699            self,
20700            encoder: &mut fidl::encoding::Encoder<
20701                '_,
20702                fidl::encoding::DefaultFuchsiaResourceDialect,
20703            >,
20704            offset: usize,
20705            depth: fidl::encoding::Depth,
20706        ) -> fidl::Result<()> {
20707            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
20708            // Zero out padding regions. There's no need to apply masks
20709            // because the unmasked parts will be overwritten by fields.
20710            // Write the fields.
20711            self.0.encode(encoder, offset + 0, depth)?;
20712            Ok(())
20713        }
20714    }
20715
20716    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20717        for AudioCapturerGetReferenceClockResponse
20718    {
20719        #[inline(always)]
20720        fn new_empty() -> Self {
20721            Self {
20722                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
20723            }
20724        }
20725
20726        #[inline]
20727        unsafe fn decode(
20728            &mut self,
20729            decoder: &mut fidl::encoding::Decoder<
20730                '_,
20731                fidl::encoding::DefaultFuchsiaResourceDialect,
20732            >,
20733            offset: usize,
20734            _depth: fidl::encoding::Depth,
20735        ) -> fidl::Result<()> {
20736            decoder.debug_check_bounds::<Self>(offset);
20737            // Verify that padding bytes are zero.
20738            fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
20739            Ok(())
20740        }
20741    }
20742
20743    impl fidl::encoding::ResourceTypeMarker for AudioCapturerSetReferenceClockRequest {
20744        type Borrowed<'a> = &'a mut Self;
20745        fn take_or_borrow<'a>(
20746            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20747        ) -> Self::Borrowed<'a> {
20748            value
20749        }
20750    }
20751
20752    unsafe impl fidl::encoding::TypeMarker for AudioCapturerSetReferenceClockRequest {
20753        type Owned = Self;
20754
20755        #[inline(always)]
20756        fn inline_align(_context: fidl::encoding::Context) -> usize {
20757            4
20758        }
20759
20760        #[inline(always)]
20761        fn inline_size(_context: fidl::encoding::Context) -> usize {
20762            4
20763        }
20764    }
20765
20766    unsafe impl
20767        fidl::encoding::Encode<
20768            AudioCapturerSetReferenceClockRequest,
20769            fidl::encoding::DefaultFuchsiaResourceDialect,
20770        > for &mut AudioCapturerSetReferenceClockRequest
20771    {
20772        #[inline]
20773        unsafe fn encode(
20774            self,
20775            encoder: &mut fidl::encoding::Encoder<
20776                '_,
20777                fidl::encoding::DefaultFuchsiaResourceDialect,
20778            >,
20779            offset: usize,
20780            _depth: fidl::encoding::Depth,
20781        ) -> fidl::Result<()> {
20782            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
20783            // Delegate to tuple encoding.
20784            fidl::encoding::Encode::<
20785                AudioCapturerSetReferenceClockRequest,
20786                fidl::encoding::DefaultFuchsiaResourceDialect,
20787            >::encode(
20788                (<fidl::encoding::Optional<
20789                    fidl::encoding::HandleType<
20790                        fidl::Clock,
20791                        { fidl::ObjectType::CLOCK.into_raw() },
20792                        2147483648,
20793                    >,
20794                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20795                    &mut self.reference_clock,
20796                ),),
20797                encoder,
20798                offset,
20799                _depth,
20800            )
20801        }
20802    }
20803    unsafe impl<
20804            T0: fidl::encoding::Encode<
20805                fidl::encoding::Optional<
20806                    fidl::encoding::HandleType<
20807                        fidl::Clock,
20808                        { fidl::ObjectType::CLOCK.into_raw() },
20809                        2147483648,
20810                    >,
20811                >,
20812                fidl::encoding::DefaultFuchsiaResourceDialect,
20813            >,
20814        >
20815        fidl::encoding::Encode<
20816            AudioCapturerSetReferenceClockRequest,
20817            fidl::encoding::DefaultFuchsiaResourceDialect,
20818        > for (T0,)
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            // Zero out padding regions. There's no need to apply masks
20832            // because the unmasked parts will be overwritten by fields.
20833            // Write the fields.
20834            self.0.encode(encoder, offset + 0, depth)?;
20835            Ok(())
20836        }
20837    }
20838
20839    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20840        for AudioCapturerSetReferenceClockRequest
20841    {
20842        #[inline(always)]
20843        fn new_empty() -> Self {
20844            Self {
20845                reference_clock: fidl::new_empty!(
20846                    fidl::encoding::Optional<
20847                        fidl::encoding::HandleType<
20848                            fidl::Clock,
20849                            { fidl::ObjectType::CLOCK.into_raw() },
20850                            2147483648,
20851                        >,
20852                    >,
20853                    fidl::encoding::DefaultFuchsiaResourceDialect
20854                ),
20855            }
20856        }
20857
20858        #[inline]
20859        unsafe fn decode(
20860            &mut self,
20861            decoder: &mut fidl::encoding::Decoder<
20862                '_,
20863                fidl::encoding::DefaultFuchsiaResourceDialect,
20864            >,
20865            offset: usize,
20866            _depth: fidl::encoding::Depth,
20867        ) -> fidl::Result<()> {
20868            decoder.debug_check_bounds::<Self>(offset);
20869            // Verify that padding bytes are zero.
20870            fidl::decode!(
20871                fidl::encoding::Optional<
20872                    fidl::encoding::HandleType<
20873                        fidl::Clock,
20874                        { fidl::ObjectType::CLOCK.into_raw() },
20875                        2147483648,
20876                    >,
20877                >,
20878                fidl::encoding::DefaultFuchsiaResourceDialect,
20879                &mut self.reference_clock,
20880                decoder,
20881                offset + 0,
20882                _depth
20883            )?;
20884            Ok(())
20885        }
20886    }
20887
20888    impl fidl::encoding::ResourceTypeMarker for AudioConsumerBindVolumeControlRequest {
20889        type Borrowed<'a> = &'a mut Self;
20890        fn take_or_borrow<'a>(
20891            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20892        ) -> Self::Borrowed<'a> {
20893            value
20894        }
20895    }
20896
20897    unsafe impl fidl::encoding::TypeMarker for AudioConsumerBindVolumeControlRequest {
20898        type Owned = Self;
20899
20900        #[inline(always)]
20901        fn inline_align(_context: fidl::encoding::Context) -> usize {
20902            4
20903        }
20904
20905        #[inline(always)]
20906        fn inline_size(_context: fidl::encoding::Context) -> usize {
20907            4
20908        }
20909    }
20910
20911    unsafe impl
20912        fidl::encoding::Encode<
20913            AudioConsumerBindVolumeControlRequest,
20914            fidl::encoding::DefaultFuchsiaResourceDialect,
20915        > for &mut AudioConsumerBindVolumeControlRequest
20916    {
20917        #[inline]
20918        unsafe fn encode(
20919            self,
20920            encoder: &mut fidl::encoding::Encoder<
20921                '_,
20922                fidl::encoding::DefaultFuchsiaResourceDialect,
20923            >,
20924            offset: usize,
20925            _depth: fidl::encoding::Depth,
20926        ) -> fidl::Result<()> {
20927            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
20928            // Delegate to tuple encoding.
20929            fidl::encoding::Encode::<
20930                AudioConsumerBindVolumeControlRequest,
20931                fidl::encoding::DefaultFuchsiaResourceDialect,
20932            >::encode(
20933                (<fidl::encoding::Endpoint<
20934                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
20935                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20936                    &mut self.volume_control_request,
20937                ),),
20938                encoder,
20939                offset,
20940                _depth,
20941            )
20942        }
20943    }
20944    unsafe impl<
20945            T0: fidl::encoding::Encode<
20946                fidl::encoding::Endpoint<
20947                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
20948                >,
20949                fidl::encoding::DefaultFuchsiaResourceDialect,
20950            >,
20951        >
20952        fidl::encoding::Encode<
20953            AudioConsumerBindVolumeControlRequest,
20954            fidl::encoding::DefaultFuchsiaResourceDialect,
20955        > for (T0,)
20956    {
20957        #[inline]
20958        unsafe fn encode(
20959            self,
20960            encoder: &mut fidl::encoding::Encoder<
20961                '_,
20962                fidl::encoding::DefaultFuchsiaResourceDialect,
20963            >,
20964            offset: usize,
20965            depth: fidl::encoding::Depth,
20966        ) -> fidl::Result<()> {
20967            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
20968            // Zero out padding regions. There's no need to apply masks
20969            // because the unmasked parts will be overwritten by fields.
20970            // Write the fields.
20971            self.0.encode(encoder, offset + 0, depth)?;
20972            Ok(())
20973        }
20974    }
20975
20976    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20977        for AudioConsumerBindVolumeControlRequest
20978    {
20979        #[inline(always)]
20980        fn new_empty() -> Self {
20981            Self {
20982                volume_control_request: fidl::new_empty!(
20983                    fidl::encoding::Endpoint<
20984                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
20985                    >,
20986                    fidl::encoding::DefaultFuchsiaResourceDialect
20987                ),
20988            }
20989        }
20990
20991        #[inline]
20992        unsafe fn decode(
20993            &mut self,
20994            decoder: &mut fidl::encoding::Decoder<
20995                '_,
20996                fidl::encoding::DefaultFuchsiaResourceDialect,
20997            >,
20998            offset: usize,
20999            _depth: fidl::encoding::Depth,
21000        ) -> fidl::Result<()> {
21001            decoder.debug_check_bounds::<Self>(offset);
21002            // Verify that padding bytes are zero.
21003            fidl::decode!(
21004                fidl::encoding::Endpoint<
21005                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21006                >,
21007                fidl::encoding::DefaultFuchsiaResourceDialect,
21008                &mut self.volume_control_request,
21009                decoder,
21010                offset + 0,
21011                _depth
21012            )?;
21013            Ok(())
21014        }
21015    }
21016
21017    impl fidl::encoding::ResourceTypeMarker for AudioConsumerCreateStreamSinkRequest {
21018        type Borrowed<'a> = &'a mut Self;
21019        fn take_or_borrow<'a>(
21020            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21021        ) -> Self::Borrowed<'a> {
21022            value
21023        }
21024    }
21025
21026    unsafe impl fidl::encoding::TypeMarker for AudioConsumerCreateStreamSinkRequest {
21027        type Owned = Self;
21028
21029        #[inline(always)]
21030        fn inline_align(_context: fidl::encoding::Context) -> usize {
21031            8
21032        }
21033
21034        #[inline(always)]
21035        fn inline_size(_context: fidl::encoding::Context) -> usize {
21036            48
21037        }
21038    }
21039
21040    unsafe impl
21041        fidl::encoding::Encode<
21042            AudioConsumerCreateStreamSinkRequest,
21043            fidl::encoding::DefaultFuchsiaResourceDialect,
21044        > for &mut AudioConsumerCreateStreamSinkRequest
21045    {
21046        #[inline]
21047        unsafe fn encode(
21048            self,
21049            encoder: &mut fidl::encoding::Encoder<
21050                '_,
21051                fidl::encoding::DefaultFuchsiaResourceDialect,
21052            >,
21053            offset: usize,
21054            _depth: fidl::encoding::Depth,
21055        ) -> fidl::Result<()> {
21056            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
21057            // Delegate to tuple encoding.
21058            fidl::encoding::Encode::<AudioConsumerCreateStreamSinkRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21059                (
21060                    <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),
21061                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
21062                    <fidl::encoding::Boxed<Compression> as fidl::encoding::ValueTypeMarker>::borrow(&self.compression),
21063                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.stream_sink_request),
21064                ),
21065                encoder, offset, _depth
21066            )
21067        }
21068    }
21069    unsafe impl<
21070            T0: fidl::encoding::Encode<
21071                fidl::encoding::Vector<
21072                    fidl::encoding::HandleType<
21073                        fidl::Vmo,
21074                        { fidl::ObjectType::VMO.into_raw() },
21075                        2147483648,
21076                    >,
21077                    16,
21078                >,
21079                fidl::encoding::DefaultFuchsiaResourceDialect,
21080            >,
21081            T1: fidl::encoding::Encode<AudioStreamType, fidl::encoding::DefaultFuchsiaResourceDialect>,
21082            T2: fidl::encoding::Encode<
21083                fidl::encoding::Boxed<Compression>,
21084                fidl::encoding::DefaultFuchsiaResourceDialect,
21085            >,
21086            T3: fidl::encoding::Encode<
21087                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
21088                fidl::encoding::DefaultFuchsiaResourceDialect,
21089            >,
21090        >
21091        fidl::encoding::Encode<
21092            AudioConsumerCreateStreamSinkRequest,
21093            fidl::encoding::DefaultFuchsiaResourceDialect,
21094        > for (T0, T1, T2, T3)
21095    {
21096        #[inline]
21097        unsafe fn encode(
21098            self,
21099            encoder: &mut fidl::encoding::Encoder<
21100                '_,
21101                fidl::encoding::DefaultFuchsiaResourceDialect,
21102            >,
21103            offset: usize,
21104            depth: fidl::encoding::Depth,
21105        ) -> fidl::Result<()> {
21106            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
21107            // Zero out padding regions. There's no need to apply masks
21108            // because the unmasked parts will be overwritten by fields.
21109            unsafe {
21110                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
21111                (ptr as *mut u64).write_unaligned(0);
21112            }
21113            unsafe {
21114                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
21115                (ptr as *mut u64).write_unaligned(0);
21116            }
21117            // Write the fields.
21118            self.0.encode(encoder, offset + 0, depth)?;
21119            self.1.encode(encoder, offset + 16, depth)?;
21120            self.2.encode(encoder, offset + 32, depth)?;
21121            self.3.encode(encoder, offset + 40, depth)?;
21122            Ok(())
21123        }
21124    }
21125
21126    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21127        for AudioConsumerCreateStreamSinkRequest
21128    {
21129        #[inline(always)]
21130        fn new_empty() -> Self {
21131            Self {
21132                buffers: fidl::new_empty!(
21133                    fidl::encoding::Vector<
21134                        fidl::encoding::HandleType<
21135                            fidl::Vmo,
21136                            { fidl::ObjectType::VMO.into_raw() },
21137                            2147483648,
21138                        >,
21139                        16,
21140                    >,
21141                    fidl::encoding::DefaultFuchsiaResourceDialect
21142                ),
21143                stream_type: fidl::new_empty!(
21144                    AudioStreamType,
21145                    fidl::encoding::DefaultFuchsiaResourceDialect
21146                ),
21147                compression: fidl::new_empty!(
21148                    fidl::encoding::Boxed<Compression>,
21149                    fidl::encoding::DefaultFuchsiaResourceDialect
21150                ),
21151                stream_sink_request: fidl::new_empty!(
21152                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
21153                    fidl::encoding::DefaultFuchsiaResourceDialect
21154                ),
21155            }
21156        }
21157
21158        #[inline]
21159        unsafe fn decode(
21160            &mut self,
21161            decoder: &mut fidl::encoding::Decoder<
21162                '_,
21163                fidl::encoding::DefaultFuchsiaResourceDialect,
21164            >,
21165            offset: usize,
21166            _depth: fidl::encoding::Depth,
21167        ) -> fidl::Result<()> {
21168            decoder.debug_check_bounds::<Self>(offset);
21169            // Verify that padding bytes are zero.
21170            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
21171            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21172            let mask = 0xffffffff00000000u64;
21173            let maskedval = padval & mask;
21174            if maskedval != 0 {
21175                return Err(fidl::Error::NonZeroPadding {
21176                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
21177                });
21178            }
21179            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
21180            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21181            let mask = 0xffffffff00000000u64;
21182            let maskedval = padval & mask;
21183            if maskedval != 0 {
21184                return Err(fidl::Error::NonZeroPadding {
21185                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
21186                });
21187            }
21188            fidl::decode!(
21189                fidl::encoding::Vector<
21190                    fidl::encoding::HandleType<
21191                        fidl::Vmo,
21192                        { fidl::ObjectType::VMO.into_raw() },
21193                        2147483648,
21194                    >,
21195                    16,
21196                >,
21197                fidl::encoding::DefaultFuchsiaResourceDialect,
21198                &mut self.buffers,
21199                decoder,
21200                offset + 0,
21201                _depth
21202            )?;
21203            fidl::decode!(
21204                AudioStreamType,
21205                fidl::encoding::DefaultFuchsiaResourceDialect,
21206                &mut self.stream_type,
21207                decoder,
21208                offset + 16,
21209                _depth
21210            )?;
21211            fidl::decode!(
21212                fidl::encoding::Boxed<Compression>,
21213                fidl::encoding::DefaultFuchsiaResourceDialect,
21214                &mut self.compression,
21215                decoder,
21216                offset + 32,
21217                _depth
21218            )?;
21219            fidl::decode!(
21220                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
21221                fidl::encoding::DefaultFuchsiaResourceDialect,
21222                &mut self.stream_sink_request,
21223                decoder,
21224                offset + 40,
21225                _depth
21226            )?;
21227            Ok(())
21228        }
21229    }
21230
21231    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControl2Request {
21232        type Borrowed<'a> = &'a mut Self;
21233        fn take_or_borrow<'a>(
21234            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21235        ) -> Self::Borrowed<'a> {
21236            value
21237        }
21238    }
21239
21240    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControl2Request {
21241        type Owned = Self;
21242
21243        #[inline(always)]
21244        fn inline_align(_context: fidl::encoding::Context) -> usize {
21245            8
21246        }
21247
21248        #[inline(always)]
21249        fn inline_size(_context: fidl::encoding::Context) -> usize {
21250            24
21251        }
21252    }
21253
21254    unsafe impl
21255        fidl::encoding::Encode<
21256            AudioCoreBindUsageVolumeControl2Request,
21257            fidl::encoding::DefaultFuchsiaResourceDialect,
21258        > for &mut AudioCoreBindUsageVolumeControl2Request
21259    {
21260        #[inline]
21261        unsafe fn encode(
21262            self,
21263            encoder: &mut fidl::encoding::Encoder<
21264                '_,
21265                fidl::encoding::DefaultFuchsiaResourceDialect,
21266            >,
21267            offset: usize,
21268            _depth: fidl::encoding::Depth,
21269        ) -> fidl::Result<()> {
21270            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
21271            // Delegate to tuple encoding.
21272            fidl::encoding::Encode::<
21273                AudioCoreBindUsageVolumeControl2Request,
21274                fidl::encoding::DefaultFuchsiaResourceDialect,
21275            >::encode(
21276                (
21277                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21278                    <fidl::encoding::Endpoint<
21279                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21280                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
21281                        &mut self.volume_control,
21282                    ),
21283                ),
21284                encoder,
21285                offset,
21286                _depth,
21287            )
21288        }
21289    }
21290    unsafe impl<
21291            T0: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
21292            T1: fidl::encoding::Encode<
21293                fidl::encoding::Endpoint<
21294                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21295                >,
21296                fidl::encoding::DefaultFuchsiaResourceDialect,
21297            >,
21298        >
21299        fidl::encoding::Encode<
21300            AudioCoreBindUsageVolumeControl2Request,
21301            fidl::encoding::DefaultFuchsiaResourceDialect,
21302        > for (T0, T1)
21303    {
21304        #[inline]
21305        unsafe fn encode(
21306            self,
21307            encoder: &mut fidl::encoding::Encoder<
21308                '_,
21309                fidl::encoding::DefaultFuchsiaResourceDialect,
21310            >,
21311            offset: usize,
21312            depth: fidl::encoding::Depth,
21313        ) -> fidl::Result<()> {
21314            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
21315            // Zero out padding regions. There's no need to apply masks
21316            // because the unmasked parts will be overwritten by fields.
21317            unsafe {
21318                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
21319                (ptr as *mut u64).write_unaligned(0);
21320            }
21321            // Write the fields.
21322            self.0.encode(encoder, offset + 0, depth)?;
21323            self.1.encode(encoder, offset + 16, depth)?;
21324            Ok(())
21325        }
21326    }
21327
21328    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21329        for AudioCoreBindUsageVolumeControl2Request
21330    {
21331        #[inline(always)]
21332        fn new_empty() -> Self {
21333            Self {
21334                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
21335                volume_control: fidl::new_empty!(
21336                    fidl::encoding::Endpoint<
21337                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21338                    >,
21339                    fidl::encoding::DefaultFuchsiaResourceDialect
21340                ),
21341            }
21342        }
21343
21344        #[inline]
21345        unsafe fn decode(
21346            &mut self,
21347            decoder: &mut fidl::encoding::Decoder<
21348                '_,
21349                fidl::encoding::DefaultFuchsiaResourceDialect,
21350            >,
21351            offset: usize,
21352            _depth: fidl::encoding::Depth,
21353        ) -> fidl::Result<()> {
21354            decoder.debug_check_bounds::<Self>(offset);
21355            // Verify that padding bytes are zero.
21356            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
21357            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21358            let mask = 0xffffffff00000000u64;
21359            let maskedval = padval & mask;
21360            if maskedval != 0 {
21361                return Err(fidl::Error::NonZeroPadding {
21362                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
21363                });
21364            }
21365            fidl::decode!(
21366                Usage2,
21367                fidl::encoding::DefaultFuchsiaResourceDialect,
21368                &mut self.usage,
21369                decoder,
21370                offset + 0,
21371                _depth
21372            )?;
21373            fidl::decode!(
21374                fidl::encoding::Endpoint<
21375                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21376                >,
21377                fidl::encoding::DefaultFuchsiaResourceDialect,
21378                &mut self.volume_control,
21379                decoder,
21380                offset + 16,
21381                _depth
21382            )?;
21383            Ok(())
21384        }
21385    }
21386
21387    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControlRequest {
21388        type Borrowed<'a> = &'a mut Self;
21389        fn take_or_borrow<'a>(
21390            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21391        ) -> Self::Borrowed<'a> {
21392            value
21393        }
21394    }
21395
21396    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControlRequest {
21397        type Owned = Self;
21398
21399        #[inline(always)]
21400        fn inline_align(_context: fidl::encoding::Context) -> usize {
21401            8
21402        }
21403
21404        #[inline(always)]
21405        fn inline_size(_context: fidl::encoding::Context) -> usize {
21406            24
21407        }
21408    }
21409
21410    unsafe impl
21411        fidl::encoding::Encode<
21412            AudioCoreBindUsageVolumeControlRequest,
21413            fidl::encoding::DefaultFuchsiaResourceDialect,
21414        > for &mut AudioCoreBindUsageVolumeControlRequest
21415    {
21416        #[inline]
21417        unsafe fn encode(
21418            self,
21419            encoder: &mut fidl::encoding::Encoder<
21420                '_,
21421                fidl::encoding::DefaultFuchsiaResourceDialect,
21422            >,
21423            offset: usize,
21424            _depth: fidl::encoding::Depth,
21425        ) -> fidl::Result<()> {
21426            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
21427            // Delegate to tuple encoding.
21428            fidl::encoding::Encode::<
21429                AudioCoreBindUsageVolumeControlRequest,
21430                fidl::encoding::DefaultFuchsiaResourceDialect,
21431            >::encode(
21432                (
21433                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21434                    <fidl::encoding::Endpoint<
21435                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21436                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
21437                        &mut self.volume_control,
21438                    ),
21439                ),
21440                encoder,
21441                offset,
21442                _depth,
21443            )
21444        }
21445    }
21446    unsafe impl<
21447            T0: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
21448            T1: fidl::encoding::Encode<
21449                fidl::encoding::Endpoint<
21450                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21451                >,
21452                fidl::encoding::DefaultFuchsiaResourceDialect,
21453            >,
21454        >
21455        fidl::encoding::Encode<
21456            AudioCoreBindUsageVolumeControlRequest,
21457            fidl::encoding::DefaultFuchsiaResourceDialect,
21458        > for (T0, T1)
21459    {
21460        #[inline]
21461        unsafe fn encode(
21462            self,
21463            encoder: &mut fidl::encoding::Encoder<
21464                '_,
21465                fidl::encoding::DefaultFuchsiaResourceDialect,
21466            >,
21467            offset: usize,
21468            depth: fidl::encoding::Depth,
21469        ) -> fidl::Result<()> {
21470            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
21471            // Zero out padding regions. There's no need to apply masks
21472            // because the unmasked parts will be overwritten by fields.
21473            unsafe {
21474                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
21475                (ptr as *mut u64).write_unaligned(0);
21476            }
21477            // Write the fields.
21478            self.0.encode(encoder, offset + 0, depth)?;
21479            self.1.encode(encoder, offset + 16, depth)?;
21480            Ok(())
21481        }
21482    }
21483
21484    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21485        for AudioCoreBindUsageVolumeControlRequest
21486    {
21487        #[inline(always)]
21488        fn new_empty() -> Self {
21489            Self {
21490                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
21491                volume_control: fidl::new_empty!(
21492                    fidl::encoding::Endpoint<
21493                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21494                    >,
21495                    fidl::encoding::DefaultFuchsiaResourceDialect
21496                ),
21497            }
21498        }
21499
21500        #[inline]
21501        unsafe fn decode(
21502            &mut self,
21503            decoder: &mut fidl::encoding::Decoder<
21504                '_,
21505                fidl::encoding::DefaultFuchsiaResourceDialect,
21506            >,
21507            offset: usize,
21508            _depth: fidl::encoding::Depth,
21509        ) -> fidl::Result<()> {
21510            decoder.debug_check_bounds::<Self>(offset);
21511            // Verify that padding bytes are zero.
21512            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
21513            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21514            let mask = 0xffffffff00000000u64;
21515            let maskedval = padval & mask;
21516            if maskedval != 0 {
21517                return Err(fidl::Error::NonZeroPadding {
21518                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
21519                });
21520            }
21521            fidl::decode!(
21522                Usage,
21523                fidl::encoding::DefaultFuchsiaResourceDialect,
21524                &mut self.usage,
21525                decoder,
21526                offset + 0,
21527                _depth
21528            )?;
21529            fidl::decode!(
21530                fidl::encoding::Endpoint<
21531                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21532                >,
21533                fidl::encoding::DefaultFuchsiaResourceDialect,
21534                &mut self.volume_control,
21535                decoder,
21536                offset + 16,
21537                _depth
21538            )?;
21539            Ok(())
21540        }
21541    }
21542
21543    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerRequest {
21544        type Borrowed<'a> = &'a mut Self;
21545        fn take_or_borrow<'a>(
21546            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21547        ) -> Self::Borrowed<'a> {
21548            value
21549        }
21550    }
21551
21552    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerRequest {
21553        type Owned = Self;
21554
21555        #[inline(always)]
21556        fn inline_align(_context: fidl::encoding::Context) -> usize {
21557            4
21558        }
21559
21560        #[inline(always)]
21561        fn inline_size(_context: fidl::encoding::Context) -> usize {
21562            8
21563        }
21564    }
21565
21566    unsafe impl
21567        fidl::encoding::Encode<
21568            AudioCoreCreateAudioCapturerRequest,
21569            fidl::encoding::DefaultFuchsiaResourceDialect,
21570        > for &mut AudioCoreCreateAudioCapturerRequest
21571    {
21572        #[inline]
21573        unsafe fn encode(
21574            self,
21575            encoder: &mut fidl::encoding::Encoder<
21576                '_,
21577                fidl::encoding::DefaultFuchsiaResourceDialect,
21578            >,
21579            offset: usize,
21580            _depth: fidl::encoding::Depth,
21581        ) -> fidl::Result<()> {
21582            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
21583            // Delegate to tuple encoding.
21584            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21585                (
21586                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
21587                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_in_request),
21588                ),
21589                encoder, offset, _depth
21590            )
21591        }
21592    }
21593    unsafe impl<
21594            T0: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
21595            T1: fidl::encoding::Encode<
21596                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21597                fidl::encoding::DefaultFuchsiaResourceDialect,
21598            >,
21599        >
21600        fidl::encoding::Encode<
21601            AudioCoreCreateAudioCapturerRequest,
21602            fidl::encoding::DefaultFuchsiaResourceDialect,
21603        > for (T0, T1)
21604    {
21605        #[inline]
21606        unsafe fn encode(
21607            self,
21608            encoder: &mut fidl::encoding::Encoder<
21609                '_,
21610                fidl::encoding::DefaultFuchsiaResourceDialect,
21611            >,
21612            offset: usize,
21613            depth: fidl::encoding::Depth,
21614        ) -> fidl::Result<()> {
21615            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
21616            // Zero out padding regions. There's no need to apply masks
21617            // because the unmasked parts will be overwritten by fields.
21618            unsafe {
21619                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
21620                (ptr as *mut u32).write_unaligned(0);
21621            }
21622            // Write the fields.
21623            self.0.encode(encoder, offset + 0, depth)?;
21624            self.1.encode(encoder, offset + 4, depth)?;
21625            Ok(())
21626        }
21627    }
21628
21629    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21630        for AudioCoreCreateAudioCapturerRequest
21631    {
21632        #[inline(always)]
21633        fn new_empty() -> Self {
21634            Self {
21635                loopback: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
21636                audio_in_request: fidl::new_empty!(
21637                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21638                    fidl::encoding::DefaultFuchsiaResourceDialect
21639                ),
21640            }
21641        }
21642
21643        #[inline]
21644        unsafe fn decode(
21645            &mut self,
21646            decoder: &mut fidl::encoding::Decoder<
21647                '_,
21648                fidl::encoding::DefaultFuchsiaResourceDialect,
21649            >,
21650            offset: usize,
21651            _depth: fidl::encoding::Depth,
21652        ) -> fidl::Result<()> {
21653            decoder.debug_check_bounds::<Self>(offset);
21654            // Verify that padding bytes are zero.
21655            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
21656            let padval = unsafe { (ptr as *const u32).read_unaligned() };
21657            let mask = 0xffffff00u32;
21658            let maskedval = padval & mask;
21659            if maskedval != 0 {
21660                return Err(fidl::Error::NonZeroPadding {
21661                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
21662                });
21663            }
21664            fidl::decode!(
21665                bool,
21666                fidl::encoding::DefaultFuchsiaResourceDialect,
21667                &mut self.loopback,
21668                decoder,
21669                offset + 0,
21670                _depth
21671            )?;
21672            fidl::decode!(
21673                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21674                fidl::encoding::DefaultFuchsiaResourceDialect,
21675                &mut self.audio_in_request,
21676                decoder,
21677                offset + 4,
21678                _depth
21679            )?;
21680            Ok(())
21681        }
21682    }
21683
21684    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
21685        type Borrowed<'a> = &'a mut Self;
21686        fn take_or_borrow<'a>(
21687            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21688        ) -> Self::Borrowed<'a> {
21689            value
21690        }
21691    }
21692
21693    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
21694        type Owned = Self;
21695
21696        #[inline(always)]
21697        fn inline_align(_context: fidl::encoding::Context) -> usize {
21698            8
21699        }
21700
21701        #[inline(always)]
21702        fn inline_size(_context: fidl::encoding::Context) -> usize {
21703            40
21704        }
21705    }
21706
21707    unsafe impl
21708        fidl::encoding::Encode<
21709            AudioCoreCreateAudioCapturerWithConfigurationRequest,
21710            fidl::encoding::DefaultFuchsiaResourceDialect,
21711        > for &mut AudioCoreCreateAudioCapturerWithConfigurationRequest
21712    {
21713        #[inline]
21714        unsafe fn encode(
21715            self,
21716            encoder: &mut fidl::encoding::Encoder<
21717                '_,
21718                fidl::encoding::DefaultFuchsiaResourceDialect,
21719            >,
21720            offset: usize,
21721            _depth: fidl::encoding::Depth,
21722        ) -> fidl::Result<()> {
21723            encoder
21724                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
21725            // Delegate to tuple encoding.
21726            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerWithConfigurationRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21727                (
21728                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
21729                    <AudioCapturerConfiguration as fidl::encoding::ValueTypeMarker>::borrow(&self.configuration),
21730                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
21731                ),
21732                encoder, offset, _depth
21733            )
21734        }
21735    }
21736    unsafe impl<
21737            T0: fidl::encoding::Encode<AudioStreamType, fidl::encoding::DefaultFuchsiaResourceDialect>,
21738            T1: fidl::encoding::Encode<
21739                AudioCapturerConfiguration,
21740                fidl::encoding::DefaultFuchsiaResourceDialect,
21741            >,
21742            T2: fidl::encoding::Encode<
21743                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21744                fidl::encoding::DefaultFuchsiaResourceDialect,
21745            >,
21746        >
21747        fidl::encoding::Encode<
21748            AudioCoreCreateAudioCapturerWithConfigurationRequest,
21749            fidl::encoding::DefaultFuchsiaResourceDialect,
21750        > for (T0, T1, T2)
21751    {
21752        #[inline]
21753        unsafe fn encode(
21754            self,
21755            encoder: &mut fidl::encoding::Encoder<
21756                '_,
21757                fidl::encoding::DefaultFuchsiaResourceDialect,
21758            >,
21759            offset: usize,
21760            depth: fidl::encoding::Depth,
21761        ) -> fidl::Result<()> {
21762            encoder
21763                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
21764            // Zero out padding regions. There's no need to apply masks
21765            // because the unmasked parts will be overwritten by fields.
21766            unsafe {
21767                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
21768                (ptr as *mut u64).write_unaligned(0);
21769            }
21770            unsafe {
21771                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
21772                (ptr as *mut u64).write_unaligned(0);
21773            }
21774            // Write the fields.
21775            self.0.encode(encoder, offset + 0, depth)?;
21776            self.1.encode(encoder, offset + 16, depth)?;
21777            self.2.encode(encoder, offset + 32, depth)?;
21778            Ok(())
21779        }
21780    }
21781
21782    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21783        for AudioCoreCreateAudioCapturerWithConfigurationRequest
21784    {
21785        #[inline(always)]
21786        fn new_empty() -> Self {
21787            Self {
21788                stream_type: fidl::new_empty!(
21789                    AudioStreamType,
21790                    fidl::encoding::DefaultFuchsiaResourceDialect
21791                ),
21792                configuration: fidl::new_empty!(
21793                    AudioCapturerConfiguration,
21794                    fidl::encoding::DefaultFuchsiaResourceDialect
21795                ),
21796                audio_capturer_request: fidl::new_empty!(
21797                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21798                    fidl::encoding::DefaultFuchsiaResourceDialect
21799                ),
21800            }
21801        }
21802
21803        #[inline]
21804        unsafe fn decode(
21805            &mut self,
21806            decoder: &mut fidl::encoding::Decoder<
21807                '_,
21808                fidl::encoding::DefaultFuchsiaResourceDialect,
21809            >,
21810            offset: usize,
21811            _depth: fidl::encoding::Depth,
21812        ) -> fidl::Result<()> {
21813            decoder.debug_check_bounds::<Self>(offset);
21814            // Verify that padding bytes are zero.
21815            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
21816            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21817            let mask = 0xffffffff00000000u64;
21818            let maskedval = padval & mask;
21819            if maskedval != 0 {
21820                return Err(fidl::Error::NonZeroPadding {
21821                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
21822                });
21823            }
21824            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
21825            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21826            let mask = 0xffffffff00000000u64;
21827            let maskedval = padval & mask;
21828            if maskedval != 0 {
21829                return Err(fidl::Error::NonZeroPadding {
21830                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
21831                });
21832            }
21833            fidl::decode!(
21834                AudioStreamType,
21835                fidl::encoding::DefaultFuchsiaResourceDialect,
21836                &mut self.stream_type,
21837                decoder,
21838                offset + 0,
21839                _depth
21840            )?;
21841            fidl::decode!(
21842                AudioCapturerConfiguration,
21843                fidl::encoding::DefaultFuchsiaResourceDialect,
21844                &mut self.configuration,
21845                decoder,
21846                offset + 16,
21847                _depth
21848            )?;
21849            fidl::decode!(
21850                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21851                fidl::encoding::DefaultFuchsiaResourceDialect,
21852                &mut self.audio_capturer_request,
21853                decoder,
21854                offset + 32,
21855                _depth
21856            )?;
21857            Ok(())
21858        }
21859    }
21860
21861    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioRendererRequest {
21862        type Borrowed<'a> = &'a mut Self;
21863        fn take_or_borrow<'a>(
21864            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21865        ) -> Self::Borrowed<'a> {
21866            value
21867        }
21868    }
21869
21870    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioRendererRequest {
21871        type Owned = Self;
21872
21873        #[inline(always)]
21874        fn inline_align(_context: fidl::encoding::Context) -> usize {
21875            4
21876        }
21877
21878        #[inline(always)]
21879        fn inline_size(_context: fidl::encoding::Context) -> usize {
21880            4
21881        }
21882    }
21883
21884    unsafe impl
21885        fidl::encoding::Encode<
21886            AudioCoreCreateAudioRendererRequest,
21887            fidl::encoding::DefaultFuchsiaResourceDialect,
21888        > for &mut AudioCoreCreateAudioRendererRequest
21889    {
21890        #[inline]
21891        unsafe fn encode(
21892            self,
21893            encoder: &mut fidl::encoding::Encoder<
21894                '_,
21895                fidl::encoding::DefaultFuchsiaResourceDialect,
21896            >,
21897            offset: usize,
21898            _depth: fidl::encoding::Depth,
21899        ) -> fidl::Result<()> {
21900            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
21901            // Delegate to tuple encoding.
21902            fidl::encoding::Encode::<AudioCoreCreateAudioRendererRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21903                (
21904                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_out_request),
21905                ),
21906                encoder, offset, _depth
21907            )
21908        }
21909    }
21910    unsafe impl<
21911            T0: fidl::encoding::Encode<
21912                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
21913                fidl::encoding::DefaultFuchsiaResourceDialect,
21914            >,
21915        >
21916        fidl::encoding::Encode<
21917            AudioCoreCreateAudioRendererRequest,
21918            fidl::encoding::DefaultFuchsiaResourceDialect,
21919        > for (T0,)
21920    {
21921        #[inline]
21922        unsafe fn encode(
21923            self,
21924            encoder: &mut fidl::encoding::Encoder<
21925                '_,
21926                fidl::encoding::DefaultFuchsiaResourceDialect,
21927            >,
21928            offset: usize,
21929            depth: fidl::encoding::Depth,
21930        ) -> fidl::Result<()> {
21931            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
21932            // Zero out padding regions. There's no need to apply masks
21933            // because the unmasked parts will be overwritten by fields.
21934            // Write the fields.
21935            self.0.encode(encoder, offset + 0, depth)?;
21936            Ok(())
21937        }
21938    }
21939
21940    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21941        for AudioCoreCreateAudioRendererRequest
21942    {
21943        #[inline(always)]
21944        fn new_empty() -> Self {
21945            Self {
21946                audio_out_request: fidl::new_empty!(
21947                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
21948                    fidl::encoding::DefaultFuchsiaResourceDialect
21949                ),
21950            }
21951        }
21952
21953        #[inline]
21954        unsafe fn decode(
21955            &mut self,
21956            decoder: &mut fidl::encoding::Decoder<
21957                '_,
21958                fidl::encoding::DefaultFuchsiaResourceDialect,
21959            >,
21960            offset: usize,
21961            _depth: fidl::encoding::Depth,
21962        ) -> fidl::Result<()> {
21963            decoder.debug_check_bounds::<Self>(offset);
21964            // Verify that padding bytes are zero.
21965            fidl::decode!(
21966                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
21967                fidl::encoding::DefaultFuchsiaResourceDialect,
21968                &mut self.audio_out_request,
21969                decoder,
21970                offset + 0,
21971                _depth
21972            )?;
21973            Ok(())
21974        }
21975    }
21976
21977    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioCapturerRequest {
21978        type Borrowed<'a> = &'a mut Self;
21979        fn take_or_borrow<'a>(
21980            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21981        ) -> Self::Borrowed<'a> {
21982            value
21983        }
21984    }
21985
21986    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioCapturerRequest {
21987        type Owned = Self;
21988
21989        #[inline(always)]
21990        fn inline_align(_context: fidl::encoding::Context) -> usize {
21991            4
21992        }
21993
21994        #[inline(always)]
21995        fn inline_size(_context: fidl::encoding::Context) -> usize {
21996            8
21997        }
21998    }
21999
22000    unsafe impl
22001        fidl::encoding::Encode<
22002            AudioCreateAudioCapturerRequest,
22003            fidl::encoding::DefaultFuchsiaResourceDialect,
22004        > for &mut AudioCreateAudioCapturerRequest
22005    {
22006        #[inline]
22007        unsafe fn encode(
22008            self,
22009            encoder: &mut fidl::encoding::Encoder<
22010                '_,
22011                fidl::encoding::DefaultFuchsiaResourceDialect,
22012            >,
22013            offset: usize,
22014            _depth: fidl::encoding::Depth,
22015        ) -> fidl::Result<()> {
22016            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
22017            // Delegate to tuple encoding.
22018            fidl::encoding::Encode::<AudioCreateAudioCapturerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
22019                (
22020                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
22021                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
22022                ),
22023                encoder, offset, _depth
22024            )
22025        }
22026    }
22027    unsafe impl<
22028            T0: fidl::encoding::Encode<
22029                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
22030                fidl::encoding::DefaultFuchsiaResourceDialect,
22031            >,
22032            T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
22033        >
22034        fidl::encoding::Encode<
22035            AudioCreateAudioCapturerRequest,
22036            fidl::encoding::DefaultFuchsiaResourceDialect,
22037        > for (T0, T1)
22038    {
22039        #[inline]
22040        unsafe fn encode(
22041            self,
22042            encoder: &mut fidl::encoding::Encoder<
22043                '_,
22044                fidl::encoding::DefaultFuchsiaResourceDialect,
22045            >,
22046            offset: usize,
22047            depth: fidl::encoding::Depth,
22048        ) -> fidl::Result<()> {
22049            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
22050            // Zero out padding regions. There's no need to apply masks
22051            // because the unmasked parts will be overwritten by fields.
22052            unsafe {
22053                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
22054                (ptr as *mut u32).write_unaligned(0);
22055            }
22056            // Write the fields.
22057            self.0.encode(encoder, offset + 0, depth)?;
22058            self.1.encode(encoder, offset + 4, depth)?;
22059            Ok(())
22060        }
22061    }
22062
22063    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22064        for AudioCreateAudioCapturerRequest
22065    {
22066        #[inline(always)]
22067        fn new_empty() -> Self {
22068            Self {
22069                audio_capturer_request: fidl::new_empty!(
22070                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
22071                    fidl::encoding::DefaultFuchsiaResourceDialect
22072                ),
22073                loopback: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
22074            }
22075        }
22076
22077        #[inline]
22078        unsafe fn decode(
22079            &mut self,
22080            decoder: &mut fidl::encoding::Decoder<
22081                '_,
22082                fidl::encoding::DefaultFuchsiaResourceDialect,
22083            >,
22084            offset: usize,
22085            _depth: fidl::encoding::Depth,
22086        ) -> fidl::Result<()> {
22087            decoder.debug_check_bounds::<Self>(offset);
22088            // Verify that padding bytes are zero.
22089            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(4) };
22090            let padval = unsafe { (ptr as *const u32).read_unaligned() };
22091            let mask = 0xffffff00u32;
22092            let maskedval = padval & mask;
22093            if maskedval != 0 {
22094                return Err(fidl::Error::NonZeroPadding {
22095                    padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
22096                });
22097            }
22098            fidl::decode!(
22099                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
22100                fidl::encoding::DefaultFuchsiaResourceDialect,
22101                &mut self.audio_capturer_request,
22102                decoder,
22103                offset + 0,
22104                _depth
22105            )?;
22106            fidl::decode!(
22107                bool,
22108                fidl::encoding::DefaultFuchsiaResourceDialect,
22109                &mut self.loopback,
22110                decoder,
22111                offset + 4,
22112                _depth
22113            )?;
22114            Ok(())
22115        }
22116    }
22117
22118    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioRendererRequest {
22119        type Borrowed<'a> = &'a mut Self;
22120        fn take_or_borrow<'a>(
22121            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22122        ) -> Self::Borrowed<'a> {
22123            value
22124        }
22125    }
22126
22127    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioRendererRequest {
22128        type Owned = Self;
22129
22130        #[inline(always)]
22131        fn inline_align(_context: fidl::encoding::Context) -> usize {
22132            4
22133        }
22134
22135        #[inline(always)]
22136        fn inline_size(_context: fidl::encoding::Context) -> usize {
22137            4
22138        }
22139    }
22140
22141    unsafe impl
22142        fidl::encoding::Encode<
22143            AudioCreateAudioRendererRequest,
22144            fidl::encoding::DefaultFuchsiaResourceDialect,
22145        > for &mut AudioCreateAudioRendererRequest
22146    {
22147        #[inline]
22148        unsafe fn encode(
22149            self,
22150            encoder: &mut fidl::encoding::Encoder<
22151                '_,
22152                fidl::encoding::DefaultFuchsiaResourceDialect,
22153            >,
22154            offset: usize,
22155            _depth: fidl::encoding::Depth,
22156        ) -> fidl::Result<()> {
22157            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
22158            // Delegate to tuple encoding.
22159            fidl::encoding::Encode::<AudioCreateAudioRendererRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
22160                (
22161                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_renderer_request),
22162                ),
22163                encoder, offset, _depth
22164            )
22165        }
22166    }
22167    unsafe impl<
22168            T0: fidl::encoding::Encode<
22169                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
22170                fidl::encoding::DefaultFuchsiaResourceDialect,
22171            >,
22172        >
22173        fidl::encoding::Encode<
22174            AudioCreateAudioRendererRequest,
22175            fidl::encoding::DefaultFuchsiaResourceDialect,
22176        > for (T0,)
22177    {
22178        #[inline]
22179        unsafe fn encode(
22180            self,
22181            encoder: &mut fidl::encoding::Encoder<
22182                '_,
22183                fidl::encoding::DefaultFuchsiaResourceDialect,
22184            >,
22185            offset: usize,
22186            depth: fidl::encoding::Depth,
22187        ) -> fidl::Result<()> {
22188            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
22189            // Zero out padding regions. There's no need to apply masks
22190            // because the unmasked parts will be overwritten by fields.
22191            // Write the fields.
22192            self.0.encode(encoder, offset + 0, depth)?;
22193            Ok(())
22194        }
22195    }
22196
22197    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22198        for AudioCreateAudioRendererRequest
22199    {
22200        #[inline(always)]
22201        fn new_empty() -> Self {
22202            Self {
22203                audio_renderer_request: fidl::new_empty!(
22204                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
22205                    fidl::encoding::DefaultFuchsiaResourceDialect
22206                ),
22207            }
22208        }
22209
22210        #[inline]
22211        unsafe fn decode(
22212            &mut self,
22213            decoder: &mut fidl::encoding::Decoder<
22214                '_,
22215                fidl::encoding::DefaultFuchsiaResourceDialect,
22216            >,
22217            offset: usize,
22218            _depth: fidl::encoding::Depth,
22219        ) -> fidl::Result<()> {
22220            decoder.debug_check_bounds::<Self>(offset);
22221            // Verify that padding bytes are zero.
22222            fidl::decode!(
22223                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
22224                fidl::encoding::DefaultFuchsiaResourceDialect,
22225                &mut self.audio_renderer_request,
22226                decoder,
22227                offset + 0,
22228                _depth
22229            )?;
22230            Ok(())
22231        }
22232    }
22233
22234    impl fidl::encoding::ResourceTypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
22235        type Borrowed<'a> = &'a mut Self;
22236        fn take_or_borrow<'a>(
22237            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22238        ) -> Self::Borrowed<'a> {
22239            value
22240        }
22241    }
22242
22243    unsafe impl fidl::encoding::TypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
22244        type Owned = Self;
22245
22246        #[inline(always)]
22247        fn inline_align(_context: fidl::encoding::Context) -> usize {
22248            8
22249        }
22250
22251        #[inline(always)]
22252        fn inline_size(_context: fidl::encoding::Context) -> usize {
22253            24
22254        }
22255    }
22256
22257    unsafe impl
22258        fidl::encoding::Encode<
22259            AudioDeviceEnumeratorAddDeviceByChannelRequest,
22260            fidl::encoding::DefaultFuchsiaResourceDialect,
22261        > for &mut AudioDeviceEnumeratorAddDeviceByChannelRequest
22262    {
22263        #[inline]
22264        unsafe fn encode(
22265            self,
22266            encoder: &mut fidl::encoding::Encoder<
22267                '_,
22268                fidl::encoding::DefaultFuchsiaResourceDialect,
22269            >,
22270            offset: usize,
22271            _depth: fidl::encoding::Depth,
22272        ) -> fidl::Result<()> {
22273            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
22274            // Delegate to tuple encoding.
22275            fidl::encoding::Encode::<
22276                AudioDeviceEnumeratorAddDeviceByChannelRequest,
22277                fidl::encoding::DefaultFuchsiaResourceDialect,
22278            >::encode(
22279                (
22280                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow(
22281                        &self.device_name,
22282                    ),
22283                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.is_input),
22284                    <fidl::encoding::Endpoint<
22285                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22286                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22287                        &mut self.channel
22288                    ),
22289                ),
22290                encoder,
22291                offset,
22292                _depth,
22293            )
22294        }
22295    }
22296    unsafe impl<
22297            T0: fidl::encoding::Encode<
22298                fidl::encoding::BoundedString<256>,
22299                fidl::encoding::DefaultFuchsiaResourceDialect,
22300            >,
22301            T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
22302            T2: fidl::encoding::Encode<
22303                fidl::encoding::Endpoint<
22304                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22305                >,
22306                fidl::encoding::DefaultFuchsiaResourceDialect,
22307            >,
22308        >
22309        fidl::encoding::Encode<
22310            AudioDeviceEnumeratorAddDeviceByChannelRequest,
22311            fidl::encoding::DefaultFuchsiaResourceDialect,
22312        > for (T0, T1, T2)
22313    {
22314        #[inline]
22315        unsafe fn encode(
22316            self,
22317            encoder: &mut fidl::encoding::Encoder<
22318                '_,
22319                fidl::encoding::DefaultFuchsiaResourceDialect,
22320            >,
22321            offset: usize,
22322            depth: fidl::encoding::Depth,
22323        ) -> fidl::Result<()> {
22324            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
22325            // Zero out padding regions. There's no need to apply masks
22326            // because the unmasked parts will be overwritten by fields.
22327            unsafe {
22328                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
22329                (ptr as *mut u64).write_unaligned(0);
22330            }
22331            // Write the fields.
22332            self.0.encode(encoder, offset + 0, depth)?;
22333            self.1.encode(encoder, offset + 16, depth)?;
22334            self.2.encode(encoder, offset + 20, depth)?;
22335            Ok(())
22336        }
22337    }
22338
22339    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22340        for AudioDeviceEnumeratorAddDeviceByChannelRequest
22341    {
22342        #[inline(always)]
22343        fn new_empty() -> Self {
22344            Self {
22345                device_name: fidl::new_empty!(
22346                    fidl::encoding::BoundedString<256>,
22347                    fidl::encoding::DefaultFuchsiaResourceDialect
22348                ),
22349                is_input: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
22350                channel: fidl::new_empty!(
22351                    fidl::encoding::Endpoint<
22352                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22353                    >,
22354                    fidl::encoding::DefaultFuchsiaResourceDialect
22355                ),
22356            }
22357        }
22358
22359        #[inline]
22360        unsafe fn decode(
22361            &mut self,
22362            decoder: &mut fidl::encoding::Decoder<
22363                '_,
22364                fidl::encoding::DefaultFuchsiaResourceDialect,
22365            >,
22366            offset: usize,
22367            _depth: fidl::encoding::Depth,
22368        ) -> fidl::Result<()> {
22369            decoder.debug_check_bounds::<Self>(offset);
22370            // Verify that padding bytes are zero.
22371            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
22372            let padval = unsafe { (ptr as *const u64).read_unaligned() };
22373            let mask = 0xffffff00u64;
22374            let maskedval = padval & mask;
22375            if maskedval != 0 {
22376                return Err(fidl::Error::NonZeroPadding {
22377                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
22378                });
22379            }
22380            fidl::decode!(
22381                fidl::encoding::BoundedString<256>,
22382                fidl::encoding::DefaultFuchsiaResourceDialect,
22383                &mut self.device_name,
22384                decoder,
22385                offset + 0,
22386                _depth
22387            )?;
22388            fidl::decode!(
22389                bool,
22390                fidl::encoding::DefaultFuchsiaResourceDialect,
22391                &mut self.is_input,
22392                decoder,
22393                offset + 16,
22394                _depth
22395            )?;
22396            fidl::decode!(
22397                fidl::encoding::Endpoint<
22398                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22399                >,
22400                fidl::encoding::DefaultFuchsiaResourceDialect,
22401                &mut self.channel,
22402                decoder,
22403                offset + 20,
22404                _depth
22405            )?;
22406            Ok(())
22407        }
22408    }
22409
22410    impl fidl::encoding::ResourceTypeMarker for AudioRendererBindGainControlRequest {
22411        type Borrowed<'a> = &'a mut Self;
22412        fn take_or_borrow<'a>(
22413            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22414        ) -> Self::Borrowed<'a> {
22415            value
22416        }
22417    }
22418
22419    unsafe impl fidl::encoding::TypeMarker for AudioRendererBindGainControlRequest {
22420        type Owned = Self;
22421
22422        #[inline(always)]
22423        fn inline_align(_context: fidl::encoding::Context) -> usize {
22424            4
22425        }
22426
22427        #[inline(always)]
22428        fn inline_size(_context: fidl::encoding::Context) -> usize {
22429            4
22430        }
22431    }
22432
22433    unsafe impl
22434        fidl::encoding::Encode<
22435            AudioRendererBindGainControlRequest,
22436            fidl::encoding::DefaultFuchsiaResourceDialect,
22437        > for &mut AudioRendererBindGainControlRequest
22438    {
22439        #[inline]
22440        unsafe fn encode(
22441            self,
22442            encoder: &mut fidl::encoding::Encoder<
22443                '_,
22444                fidl::encoding::DefaultFuchsiaResourceDialect,
22445            >,
22446            offset: usize,
22447            _depth: fidl::encoding::Depth,
22448        ) -> fidl::Result<()> {
22449            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
22450            // Delegate to tuple encoding.
22451            fidl::encoding::Encode::<
22452                AudioRendererBindGainControlRequest,
22453                fidl::encoding::DefaultFuchsiaResourceDialect,
22454            >::encode(
22455                (<fidl::encoding::Endpoint<
22456                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22457                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22458                    &mut self.gain_control_request,
22459                ),),
22460                encoder,
22461                offset,
22462                _depth,
22463            )
22464        }
22465    }
22466    unsafe impl<
22467            T0: fidl::encoding::Encode<
22468                fidl::encoding::Endpoint<
22469                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22470                >,
22471                fidl::encoding::DefaultFuchsiaResourceDialect,
22472            >,
22473        >
22474        fidl::encoding::Encode<
22475            AudioRendererBindGainControlRequest,
22476            fidl::encoding::DefaultFuchsiaResourceDialect,
22477        > for (T0,)
22478    {
22479        #[inline]
22480        unsafe fn encode(
22481            self,
22482            encoder: &mut fidl::encoding::Encoder<
22483                '_,
22484                fidl::encoding::DefaultFuchsiaResourceDialect,
22485            >,
22486            offset: usize,
22487            depth: fidl::encoding::Depth,
22488        ) -> fidl::Result<()> {
22489            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
22490            // Zero out padding regions. There's no need to apply masks
22491            // because the unmasked parts will be overwritten by fields.
22492            // Write the fields.
22493            self.0.encode(encoder, offset + 0, depth)?;
22494            Ok(())
22495        }
22496    }
22497
22498    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22499        for AudioRendererBindGainControlRequest
22500    {
22501        #[inline(always)]
22502        fn new_empty() -> Self {
22503            Self {
22504                gain_control_request: fidl::new_empty!(
22505                    fidl::encoding::Endpoint<
22506                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22507                    >,
22508                    fidl::encoding::DefaultFuchsiaResourceDialect
22509                ),
22510            }
22511        }
22512
22513        #[inline]
22514        unsafe fn decode(
22515            &mut self,
22516            decoder: &mut fidl::encoding::Decoder<
22517                '_,
22518                fidl::encoding::DefaultFuchsiaResourceDialect,
22519            >,
22520            offset: usize,
22521            _depth: fidl::encoding::Depth,
22522        ) -> fidl::Result<()> {
22523            decoder.debug_check_bounds::<Self>(offset);
22524            // Verify that padding bytes are zero.
22525            fidl::decode!(
22526                fidl::encoding::Endpoint<
22527                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22528                >,
22529                fidl::encoding::DefaultFuchsiaResourceDialect,
22530                &mut self.gain_control_request,
22531                decoder,
22532                offset + 0,
22533                _depth
22534            )?;
22535            Ok(())
22536        }
22537    }
22538
22539    impl fidl::encoding::ResourceTypeMarker for AudioRendererGetReferenceClockResponse {
22540        type Borrowed<'a> = &'a mut Self;
22541        fn take_or_borrow<'a>(
22542            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22543        ) -> Self::Borrowed<'a> {
22544            value
22545        }
22546    }
22547
22548    unsafe impl fidl::encoding::TypeMarker for AudioRendererGetReferenceClockResponse {
22549        type Owned = Self;
22550
22551        #[inline(always)]
22552        fn inline_align(_context: fidl::encoding::Context) -> usize {
22553            4
22554        }
22555
22556        #[inline(always)]
22557        fn inline_size(_context: fidl::encoding::Context) -> usize {
22558            4
22559        }
22560    }
22561
22562    unsafe impl
22563        fidl::encoding::Encode<
22564            AudioRendererGetReferenceClockResponse,
22565            fidl::encoding::DefaultFuchsiaResourceDialect,
22566        > for &mut AudioRendererGetReferenceClockResponse
22567    {
22568        #[inline]
22569        unsafe fn encode(
22570            self,
22571            encoder: &mut fidl::encoding::Encoder<
22572                '_,
22573                fidl::encoding::DefaultFuchsiaResourceDialect,
22574            >,
22575            offset: usize,
22576            _depth: fidl::encoding::Depth,
22577        ) -> fidl::Result<()> {
22578            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
22579            // Delegate to tuple encoding.
22580            fidl::encoding::Encode::<
22581                AudioRendererGetReferenceClockResponse,
22582                fidl::encoding::DefaultFuchsiaResourceDialect,
22583            >::encode(
22584                (<fidl::encoding::HandleType<
22585                    fidl::Clock,
22586                    { fidl::ObjectType::CLOCK.into_raw() },
22587                    2147483648,
22588                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22589                    &mut self.reference_clock,
22590                ),),
22591                encoder,
22592                offset,
22593                _depth,
22594            )
22595        }
22596    }
22597    unsafe impl<
22598            T0: fidl::encoding::Encode<
22599                fidl::encoding::HandleType<
22600                    fidl::Clock,
22601                    { fidl::ObjectType::CLOCK.into_raw() },
22602                    2147483648,
22603                >,
22604                fidl::encoding::DefaultFuchsiaResourceDialect,
22605            >,
22606        >
22607        fidl::encoding::Encode<
22608            AudioRendererGetReferenceClockResponse,
22609            fidl::encoding::DefaultFuchsiaResourceDialect,
22610        > for (T0,)
22611    {
22612        #[inline]
22613        unsafe fn encode(
22614            self,
22615            encoder: &mut fidl::encoding::Encoder<
22616                '_,
22617                fidl::encoding::DefaultFuchsiaResourceDialect,
22618            >,
22619            offset: usize,
22620            depth: fidl::encoding::Depth,
22621        ) -> fidl::Result<()> {
22622            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
22623            // Zero out padding regions. There's no need to apply masks
22624            // because the unmasked parts will be overwritten by fields.
22625            // Write the fields.
22626            self.0.encode(encoder, offset + 0, depth)?;
22627            Ok(())
22628        }
22629    }
22630
22631    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22632        for AudioRendererGetReferenceClockResponse
22633    {
22634        #[inline(always)]
22635        fn new_empty() -> Self {
22636            Self {
22637                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
22638            }
22639        }
22640
22641        #[inline]
22642        unsafe fn decode(
22643            &mut self,
22644            decoder: &mut fidl::encoding::Decoder<
22645                '_,
22646                fidl::encoding::DefaultFuchsiaResourceDialect,
22647            >,
22648            offset: usize,
22649            _depth: fidl::encoding::Depth,
22650        ) -> fidl::Result<()> {
22651            decoder.debug_check_bounds::<Self>(offset);
22652            // Verify that padding bytes are zero.
22653            fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
22654            Ok(())
22655        }
22656    }
22657
22658    impl fidl::encoding::ResourceTypeMarker for AudioRendererSetReferenceClockRequest {
22659        type Borrowed<'a> = &'a mut Self;
22660        fn take_or_borrow<'a>(
22661            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22662        ) -> Self::Borrowed<'a> {
22663            value
22664        }
22665    }
22666
22667    unsafe impl fidl::encoding::TypeMarker for AudioRendererSetReferenceClockRequest {
22668        type Owned = Self;
22669
22670        #[inline(always)]
22671        fn inline_align(_context: fidl::encoding::Context) -> usize {
22672            4
22673        }
22674
22675        #[inline(always)]
22676        fn inline_size(_context: fidl::encoding::Context) -> usize {
22677            4
22678        }
22679    }
22680
22681    unsafe impl
22682        fidl::encoding::Encode<
22683            AudioRendererSetReferenceClockRequest,
22684            fidl::encoding::DefaultFuchsiaResourceDialect,
22685        > for &mut AudioRendererSetReferenceClockRequest
22686    {
22687        #[inline]
22688        unsafe fn encode(
22689            self,
22690            encoder: &mut fidl::encoding::Encoder<
22691                '_,
22692                fidl::encoding::DefaultFuchsiaResourceDialect,
22693            >,
22694            offset: usize,
22695            _depth: fidl::encoding::Depth,
22696        ) -> fidl::Result<()> {
22697            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
22698            // Delegate to tuple encoding.
22699            fidl::encoding::Encode::<
22700                AudioRendererSetReferenceClockRequest,
22701                fidl::encoding::DefaultFuchsiaResourceDialect,
22702            >::encode(
22703                (<fidl::encoding::Optional<
22704                    fidl::encoding::HandleType<
22705                        fidl::Clock,
22706                        { fidl::ObjectType::CLOCK.into_raw() },
22707                        2147483648,
22708                    >,
22709                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22710                    &mut self.reference_clock,
22711                ),),
22712                encoder,
22713                offset,
22714                _depth,
22715            )
22716        }
22717    }
22718    unsafe impl<
22719            T0: fidl::encoding::Encode<
22720                fidl::encoding::Optional<
22721                    fidl::encoding::HandleType<
22722                        fidl::Clock,
22723                        { fidl::ObjectType::CLOCK.into_raw() },
22724                        2147483648,
22725                    >,
22726                >,
22727                fidl::encoding::DefaultFuchsiaResourceDialect,
22728            >,
22729        >
22730        fidl::encoding::Encode<
22731            AudioRendererSetReferenceClockRequest,
22732            fidl::encoding::DefaultFuchsiaResourceDialect,
22733        > for (T0,)
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            // Zero out padding regions. There's no need to apply masks
22747            // because the unmasked parts will be overwritten by fields.
22748            // Write the fields.
22749            self.0.encode(encoder, offset + 0, depth)?;
22750            Ok(())
22751        }
22752    }
22753
22754    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22755        for AudioRendererSetReferenceClockRequest
22756    {
22757        #[inline(always)]
22758        fn new_empty() -> Self {
22759            Self {
22760                reference_clock: fidl::new_empty!(
22761                    fidl::encoding::Optional<
22762                        fidl::encoding::HandleType<
22763                            fidl::Clock,
22764                            { fidl::ObjectType::CLOCK.into_raw() },
22765                            2147483648,
22766                        >,
22767                    >,
22768                    fidl::encoding::DefaultFuchsiaResourceDialect
22769                ),
22770            }
22771        }
22772
22773        #[inline]
22774        unsafe fn decode(
22775            &mut self,
22776            decoder: &mut fidl::encoding::Decoder<
22777                '_,
22778                fidl::encoding::DefaultFuchsiaResourceDialect,
22779            >,
22780            offset: usize,
22781            _depth: fidl::encoding::Depth,
22782        ) -> fidl::Result<()> {
22783            decoder.debug_check_bounds::<Self>(offset);
22784            // Verify that padding bytes are zero.
22785            fidl::decode!(
22786                fidl::encoding::Optional<
22787                    fidl::encoding::HandleType<
22788                        fidl::Clock,
22789                        { fidl::ObjectType::CLOCK.into_raw() },
22790                        2147483648,
22791                    >,
22792                >,
22793                fidl::encoding::DefaultFuchsiaResourceDialect,
22794                &mut self.reference_clock,
22795                decoder,
22796                offset + 0,
22797                _depth
22798            )?;
22799            Ok(())
22800        }
22801    }
22802
22803    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
22804        type Borrowed<'a> = &'a mut Self;
22805        fn take_or_borrow<'a>(
22806            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22807        ) -> Self::Borrowed<'a> {
22808            value
22809        }
22810    }
22811
22812    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
22813        type Owned = Self;
22814
22815        #[inline(always)]
22816        fn inline_align(_context: fidl::encoding::Context) -> usize {
22817            8
22818        }
22819
22820        #[inline(always)]
22821        fn inline_size(_context: fidl::encoding::Context) -> usize {
22822            40
22823        }
22824    }
22825
22826    unsafe impl
22827        fidl::encoding::Encode<
22828            ProfileProviderRegisterHandlerWithCapacityRequest,
22829            fidl::encoding::DefaultFuchsiaResourceDialect,
22830        > for &mut ProfileProviderRegisterHandlerWithCapacityRequest
22831    {
22832        #[inline]
22833        unsafe fn encode(
22834            self,
22835            encoder: &mut fidl::encoding::Encoder<
22836                '_,
22837                fidl::encoding::DefaultFuchsiaResourceDialect,
22838            >,
22839            offset: usize,
22840            _depth: fidl::encoding::Depth,
22841        ) -> fidl::Result<()> {
22842            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
22843            // Delegate to tuple encoding.
22844            fidl::encoding::Encode::<
22845                ProfileProviderRegisterHandlerWithCapacityRequest,
22846                fidl::encoding::DefaultFuchsiaResourceDialect,
22847            >::encode(
22848                (
22849                    <fidl::encoding::HandleType<
22850                        fidl::Thread,
22851                        { fidl::ObjectType::THREAD.into_raw() },
22852                        2147483648,
22853                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22854                        &mut self.thread_handle,
22855                    ),
22856                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
22857                        &self.name,
22858                    ),
22859                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.period),
22860                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.capacity),
22861                ),
22862                encoder,
22863                offset,
22864                _depth,
22865            )
22866        }
22867    }
22868    unsafe impl<
22869            T0: fidl::encoding::Encode<
22870                fidl::encoding::HandleType<
22871                    fidl::Thread,
22872                    { fidl::ObjectType::THREAD.into_raw() },
22873                    2147483648,
22874                >,
22875                fidl::encoding::DefaultFuchsiaResourceDialect,
22876            >,
22877            T1: fidl::encoding::Encode<
22878                fidl::encoding::BoundedString<64>,
22879                fidl::encoding::DefaultFuchsiaResourceDialect,
22880            >,
22881            T2: fidl::encoding::Encode<i64, fidl::encoding::DefaultFuchsiaResourceDialect>,
22882            T3: fidl::encoding::Encode<f32, fidl::encoding::DefaultFuchsiaResourceDialect>,
22883        >
22884        fidl::encoding::Encode<
22885            ProfileProviderRegisterHandlerWithCapacityRequest,
22886            fidl::encoding::DefaultFuchsiaResourceDialect,
22887        > for (T0, T1, T2, T3)
22888    {
22889        #[inline]
22890        unsafe fn encode(
22891            self,
22892            encoder: &mut fidl::encoding::Encoder<
22893                '_,
22894                fidl::encoding::DefaultFuchsiaResourceDialect,
22895            >,
22896            offset: usize,
22897            depth: fidl::encoding::Depth,
22898        ) -> fidl::Result<()> {
22899            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
22900            // Zero out padding regions. There's no need to apply masks
22901            // because the unmasked parts will be overwritten by fields.
22902            unsafe {
22903                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
22904                (ptr as *mut u64).write_unaligned(0);
22905            }
22906            unsafe {
22907                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
22908                (ptr as *mut u64).write_unaligned(0);
22909            }
22910            // Write the fields.
22911            self.0.encode(encoder, offset + 0, depth)?;
22912            self.1.encode(encoder, offset + 8, depth)?;
22913            self.2.encode(encoder, offset + 24, depth)?;
22914            self.3.encode(encoder, offset + 32, depth)?;
22915            Ok(())
22916        }
22917    }
22918
22919    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22920        for ProfileProviderRegisterHandlerWithCapacityRequest
22921    {
22922        #[inline(always)]
22923        fn new_empty() -> Self {
22924            Self {
22925                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
22926                name: fidl::new_empty!(
22927                    fidl::encoding::BoundedString<64>,
22928                    fidl::encoding::DefaultFuchsiaResourceDialect
22929                ),
22930                period: fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect),
22931                capacity: fidl::new_empty!(f32, fidl::encoding::DefaultFuchsiaResourceDialect),
22932            }
22933        }
22934
22935        #[inline]
22936        unsafe fn decode(
22937            &mut self,
22938            decoder: &mut fidl::encoding::Decoder<
22939                '_,
22940                fidl::encoding::DefaultFuchsiaResourceDialect,
22941            >,
22942            offset: usize,
22943            _depth: fidl::encoding::Depth,
22944        ) -> fidl::Result<()> {
22945            decoder.debug_check_bounds::<Self>(offset);
22946            // Verify that padding bytes are zero.
22947            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
22948            let padval = unsafe { (ptr as *const u64).read_unaligned() };
22949            let mask = 0xffffffff00000000u64;
22950            let maskedval = padval & mask;
22951            if maskedval != 0 {
22952                return Err(fidl::Error::NonZeroPadding {
22953                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
22954                });
22955            }
22956            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
22957            let padval = unsafe { (ptr as *const u64).read_unaligned() };
22958            let mask = 0xffffffff00000000u64;
22959            let maskedval = padval & mask;
22960            if maskedval != 0 {
22961                return Err(fidl::Error::NonZeroPadding {
22962                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
22963                });
22964            }
22965            fidl::decode!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
22966            fidl::decode!(
22967                fidl::encoding::BoundedString<64>,
22968                fidl::encoding::DefaultFuchsiaResourceDialect,
22969                &mut self.name,
22970                decoder,
22971                offset + 8,
22972                _depth
22973            )?;
22974            fidl::decode!(
22975                i64,
22976                fidl::encoding::DefaultFuchsiaResourceDialect,
22977                &mut self.period,
22978                decoder,
22979                offset + 24,
22980                _depth
22981            )?;
22982            fidl::decode!(
22983                f32,
22984                fidl::encoding::DefaultFuchsiaResourceDialect,
22985                &mut self.capacity,
22986                decoder,
22987                offset + 32,
22988                _depth
22989            )?;
22990            Ok(())
22991        }
22992    }
22993
22994    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterMemoryRangeRequest {
22995        type Borrowed<'a> = &'a mut Self;
22996        fn take_or_borrow<'a>(
22997            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22998        ) -> Self::Borrowed<'a> {
22999            value
23000        }
23001    }
23002
23003    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterMemoryRangeRequest {
23004        type Owned = Self;
23005
23006        #[inline(always)]
23007        fn inline_align(_context: fidl::encoding::Context) -> usize {
23008            8
23009        }
23010
23011        #[inline(always)]
23012        fn inline_size(_context: fidl::encoding::Context) -> usize {
23013            24
23014        }
23015    }
23016
23017    unsafe impl
23018        fidl::encoding::Encode<
23019            ProfileProviderRegisterMemoryRangeRequest,
23020            fidl::encoding::DefaultFuchsiaResourceDialect,
23021        > for &mut ProfileProviderRegisterMemoryRangeRequest
23022    {
23023        #[inline]
23024        unsafe fn encode(
23025            self,
23026            encoder: &mut fidl::encoding::Encoder<
23027                '_,
23028                fidl::encoding::DefaultFuchsiaResourceDialect,
23029            >,
23030            offset: usize,
23031            _depth: fidl::encoding::Depth,
23032        ) -> fidl::Result<()> {
23033            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
23034            // Delegate to tuple encoding.
23035            fidl::encoding::Encode::<
23036                ProfileProviderRegisterMemoryRangeRequest,
23037                fidl::encoding::DefaultFuchsiaResourceDialect,
23038            >::encode(
23039                (
23040                    <fidl::encoding::HandleType<
23041                        fidl::Vmar,
23042                        { fidl::ObjectType::VMAR.into_raw() },
23043                        2147483648,
23044                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23045                        &mut self.vmar_handle
23046                    ),
23047                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
23048                        &self.name,
23049                    ),
23050                ),
23051                encoder,
23052                offset,
23053                _depth,
23054            )
23055        }
23056    }
23057    unsafe impl<
23058            T0: fidl::encoding::Encode<
23059                fidl::encoding::HandleType<
23060                    fidl::Vmar,
23061                    { fidl::ObjectType::VMAR.into_raw() },
23062                    2147483648,
23063                >,
23064                fidl::encoding::DefaultFuchsiaResourceDialect,
23065            >,
23066            T1: fidl::encoding::Encode<
23067                fidl::encoding::BoundedString<64>,
23068                fidl::encoding::DefaultFuchsiaResourceDialect,
23069            >,
23070        >
23071        fidl::encoding::Encode<
23072            ProfileProviderRegisterMemoryRangeRequest,
23073            fidl::encoding::DefaultFuchsiaResourceDialect,
23074        > for (T0, T1)
23075    {
23076        #[inline]
23077        unsafe fn encode(
23078            self,
23079            encoder: &mut fidl::encoding::Encoder<
23080                '_,
23081                fidl::encoding::DefaultFuchsiaResourceDialect,
23082            >,
23083            offset: usize,
23084            depth: fidl::encoding::Depth,
23085        ) -> fidl::Result<()> {
23086            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
23087            // Zero out padding regions. There's no need to apply masks
23088            // because the unmasked parts will be overwritten by fields.
23089            unsafe {
23090                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
23091                (ptr as *mut u64).write_unaligned(0);
23092            }
23093            // Write the fields.
23094            self.0.encode(encoder, offset + 0, depth)?;
23095            self.1.encode(encoder, offset + 8, depth)?;
23096            Ok(())
23097        }
23098    }
23099
23100    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23101        for ProfileProviderRegisterMemoryRangeRequest
23102    {
23103        #[inline(always)]
23104        fn new_empty() -> Self {
23105            Self {
23106                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23107                name: fidl::new_empty!(
23108                    fidl::encoding::BoundedString<64>,
23109                    fidl::encoding::DefaultFuchsiaResourceDialect
23110                ),
23111            }
23112        }
23113
23114        #[inline]
23115        unsafe fn decode(
23116            &mut self,
23117            decoder: &mut fidl::encoding::Decoder<
23118                '_,
23119                fidl::encoding::DefaultFuchsiaResourceDialect,
23120            >,
23121            offset: usize,
23122            _depth: fidl::encoding::Depth,
23123        ) -> fidl::Result<()> {
23124            decoder.debug_check_bounds::<Self>(offset);
23125            // Verify that padding bytes are zero.
23126            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
23127            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23128            let mask = 0xffffffff00000000u64;
23129            let maskedval = padval & mask;
23130            if maskedval != 0 {
23131                return Err(fidl::Error::NonZeroPadding {
23132                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
23133                });
23134            }
23135            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
23136            fidl::decode!(
23137                fidl::encoding::BoundedString<64>,
23138                fidl::encoding::DefaultFuchsiaResourceDialect,
23139                &mut self.name,
23140                decoder,
23141                offset + 8,
23142                _depth
23143            )?;
23144            Ok(())
23145        }
23146    }
23147
23148    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterHandlerRequest {
23149        type Borrowed<'a> = &'a mut Self;
23150        fn take_or_borrow<'a>(
23151            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23152        ) -> Self::Borrowed<'a> {
23153            value
23154        }
23155    }
23156
23157    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterHandlerRequest {
23158        type Owned = Self;
23159
23160        #[inline(always)]
23161        fn inline_align(_context: fidl::encoding::Context) -> usize {
23162            8
23163        }
23164
23165        #[inline(always)]
23166        fn inline_size(_context: fidl::encoding::Context) -> usize {
23167            24
23168        }
23169    }
23170
23171    unsafe impl
23172        fidl::encoding::Encode<
23173            ProfileProviderUnregisterHandlerRequest,
23174            fidl::encoding::DefaultFuchsiaResourceDialect,
23175        > for &mut ProfileProviderUnregisterHandlerRequest
23176    {
23177        #[inline]
23178        unsafe fn encode(
23179            self,
23180            encoder: &mut fidl::encoding::Encoder<
23181                '_,
23182                fidl::encoding::DefaultFuchsiaResourceDialect,
23183            >,
23184            offset: usize,
23185            _depth: fidl::encoding::Depth,
23186        ) -> fidl::Result<()> {
23187            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
23188            // Delegate to tuple encoding.
23189            fidl::encoding::Encode::<
23190                ProfileProviderUnregisterHandlerRequest,
23191                fidl::encoding::DefaultFuchsiaResourceDialect,
23192            >::encode(
23193                (
23194                    <fidl::encoding::HandleType<
23195                        fidl::Thread,
23196                        { fidl::ObjectType::THREAD.into_raw() },
23197                        2147483648,
23198                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23199                        &mut self.thread_handle,
23200                    ),
23201                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
23202                        &self.name,
23203                    ),
23204                ),
23205                encoder,
23206                offset,
23207                _depth,
23208            )
23209        }
23210    }
23211    unsafe impl<
23212            T0: fidl::encoding::Encode<
23213                fidl::encoding::HandleType<
23214                    fidl::Thread,
23215                    { fidl::ObjectType::THREAD.into_raw() },
23216                    2147483648,
23217                >,
23218                fidl::encoding::DefaultFuchsiaResourceDialect,
23219            >,
23220            T1: fidl::encoding::Encode<
23221                fidl::encoding::BoundedString<64>,
23222                fidl::encoding::DefaultFuchsiaResourceDialect,
23223            >,
23224        >
23225        fidl::encoding::Encode<
23226            ProfileProviderUnregisterHandlerRequest,
23227            fidl::encoding::DefaultFuchsiaResourceDialect,
23228        > for (T0, T1)
23229    {
23230        #[inline]
23231        unsafe fn encode(
23232            self,
23233            encoder: &mut fidl::encoding::Encoder<
23234                '_,
23235                fidl::encoding::DefaultFuchsiaResourceDialect,
23236            >,
23237            offset: usize,
23238            depth: fidl::encoding::Depth,
23239        ) -> fidl::Result<()> {
23240            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
23241            // Zero out padding regions. There's no need to apply masks
23242            // because the unmasked parts will be overwritten by fields.
23243            unsafe {
23244                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
23245                (ptr as *mut u64).write_unaligned(0);
23246            }
23247            // Write the fields.
23248            self.0.encode(encoder, offset + 0, depth)?;
23249            self.1.encode(encoder, offset + 8, depth)?;
23250            Ok(())
23251        }
23252    }
23253
23254    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23255        for ProfileProviderUnregisterHandlerRequest
23256    {
23257        #[inline(always)]
23258        fn new_empty() -> Self {
23259            Self {
23260                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23261                name: fidl::new_empty!(
23262                    fidl::encoding::BoundedString<64>,
23263                    fidl::encoding::DefaultFuchsiaResourceDialect
23264                ),
23265            }
23266        }
23267
23268        #[inline]
23269        unsafe fn decode(
23270            &mut self,
23271            decoder: &mut fidl::encoding::Decoder<
23272                '_,
23273                fidl::encoding::DefaultFuchsiaResourceDialect,
23274            >,
23275            offset: usize,
23276            _depth: fidl::encoding::Depth,
23277        ) -> fidl::Result<()> {
23278            decoder.debug_check_bounds::<Self>(offset);
23279            // Verify that padding bytes are zero.
23280            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
23281            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23282            let mask = 0xffffffff00000000u64;
23283            let maskedval = padval & mask;
23284            if maskedval != 0 {
23285                return Err(fidl::Error::NonZeroPadding {
23286                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
23287                });
23288            }
23289            fidl::decode!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
23290            fidl::decode!(
23291                fidl::encoding::BoundedString<64>,
23292                fidl::encoding::DefaultFuchsiaResourceDialect,
23293                &mut self.name,
23294                decoder,
23295                offset + 8,
23296                _depth
23297            )?;
23298            Ok(())
23299        }
23300    }
23301
23302    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
23303        type Borrowed<'a> = &'a mut Self;
23304        fn take_or_borrow<'a>(
23305            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23306        ) -> Self::Borrowed<'a> {
23307            value
23308        }
23309    }
23310
23311    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
23312        type Owned = Self;
23313
23314        #[inline(always)]
23315        fn inline_align(_context: fidl::encoding::Context) -> usize {
23316            4
23317        }
23318
23319        #[inline(always)]
23320        fn inline_size(_context: fidl::encoding::Context) -> usize {
23321            4
23322        }
23323    }
23324
23325    unsafe impl
23326        fidl::encoding::Encode<
23327            ProfileProviderUnregisterMemoryRangeRequest,
23328            fidl::encoding::DefaultFuchsiaResourceDialect,
23329        > for &mut ProfileProviderUnregisterMemoryRangeRequest
23330    {
23331        #[inline]
23332        unsafe fn encode(
23333            self,
23334            encoder: &mut fidl::encoding::Encoder<
23335                '_,
23336                fidl::encoding::DefaultFuchsiaResourceDialect,
23337            >,
23338            offset: usize,
23339            _depth: fidl::encoding::Depth,
23340        ) -> fidl::Result<()> {
23341            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
23342            // Delegate to tuple encoding.
23343            fidl::encoding::Encode::<
23344                ProfileProviderUnregisterMemoryRangeRequest,
23345                fidl::encoding::DefaultFuchsiaResourceDialect,
23346            >::encode(
23347                (<fidl::encoding::HandleType<
23348                    fidl::Vmar,
23349                    { fidl::ObjectType::VMAR.into_raw() },
23350                    2147483648,
23351                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23352                    &mut self.vmar_handle
23353                ),),
23354                encoder,
23355                offset,
23356                _depth,
23357            )
23358        }
23359    }
23360    unsafe impl<
23361            T0: fidl::encoding::Encode<
23362                fidl::encoding::HandleType<
23363                    fidl::Vmar,
23364                    { fidl::ObjectType::VMAR.into_raw() },
23365                    2147483648,
23366                >,
23367                fidl::encoding::DefaultFuchsiaResourceDialect,
23368            >,
23369        >
23370        fidl::encoding::Encode<
23371            ProfileProviderUnregisterMemoryRangeRequest,
23372            fidl::encoding::DefaultFuchsiaResourceDialect,
23373        > for (T0,)
23374    {
23375        #[inline]
23376        unsafe fn encode(
23377            self,
23378            encoder: &mut fidl::encoding::Encoder<
23379                '_,
23380                fidl::encoding::DefaultFuchsiaResourceDialect,
23381            >,
23382            offset: usize,
23383            depth: fidl::encoding::Depth,
23384        ) -> fidl::Result<()> {
23385            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
23386            // Zero out padding regions. There's no need to apply masks
23387            // because the unmasked parts will be overwritten by fields.
23388            // Write the fields.
23389            self.0.encode(encoder, offset + 0, depth)?;
23390            Ok(())
23391        }
23392    }
23393
23394    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23395        for ProfileProviderUnregisterMemoryRangeRequest
23396    {
23397        #[inline(always)]
23398        fn new_empty() -> Self {
23399            Self {
23400                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23401            }
23402        }
23403
23404        #[inline]
23405        unsafe fn decode(
23406            &mut self,
23407            decoder: &mut fidl::encoding::Decoder<
23408                '_,
23409                fidl::encoding::DefaultFuchsiaResourceDialect,
23410            >,
23411            offset: usize,
23412            _depth: fidl::encoding::Depth,
23413        ) -> fidl::Result<()> {
23414            decoder.debug_check_bounds::<Self>(offset);
23415            // Verify that padding bytes are zero.
23416            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
23417            Ok(())
23418        }
23419    }
23420
23421    impl fidl::encoding::ResourceTypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
23422        type Borrowed<'a> = &'a mut Self;
23423        fn take_or_borrow<'a>(
23424            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23425        ) -> Self::Borrowed<'a> {
23426            value
23427        }
23428    }
23429
23430    unsafe impl fidl::encoding::TypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
23431        type Owned = Self;
23432
23433        #[inline(always)]
23434        fn inline_align(_context: fidl::encoding::Context) -> usize {
23435            8
23436        }
23437
23438        #[inline(always)]
23439        fn inline_size(_context: fidl::encoding::Context) -> usize {
23440            16
23441        }
23442    }
23443
23444    unsafe impl
23445        fidl::encoding::Encode<
23446            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
23447            fidl::encoding::DefaultFuchsiaResourceDialect,
23448        > for &mut SessionAudioConsumerFactoryCreateAudioConsumerRequest
23449    {
23450        #[inline]
23451        unsafe fn encode(
23452            self,
23453            encoder: &mut fidl::encoding::Encoder<
23454                '_,
23455                fidl::encoding::DefaultFuchsiaResourceDialect,
23456            >,
23457            offset: usize,
23458            _depth: fidl::encoding::Depth,
23459        ) -> fidl::Result<()> {
23460            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
23461                offset,
23462            );
23463            // Delegate to tuple encoding.
23464            fidl::encoding::Encode::<SessionAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23465                (
23466                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.session_id),
23467                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
23468                ),
23469                encoder, offset, _depth
23470            )
23471        }
23472    }
23473    unsafe impl<
23474            T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
23475            T1: fidl::encoding::Encode<
23476                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23477                fidl::encoding::DefaultFuchsiaResourceDialect,
23478            >,
23479        >
23480        fidl::encoding::Encode<
23481            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
23482            fidl::encoding::DefaultFuchsiaResourceDialect,
23483        > for (T0, T1)
23484    {
23485        #[inline]
23486        unsafe fn encode(
23487            self,
23488            encoder: &mut fidl::encoding::Encoder<
23489                '_,
23490                fidl::encoding::DefaultFuchsiaResourceDialect,
23491            >,
23492            offset: usize,
23493            depth: fidl::encoding::Depth,
23494        ) -> fidl::Result<()> {
23495            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
23496                offset,
23497            );
23498            // Zero out padding regions. There's no need to apply masks
23499            // because the unmasked parts will be overwritten by fields.
23500            unsafe {
23501                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
23502                (ptr as *mut u64).write_unaligned(0);
23503            }
23504            // Write the fields.
23505            self.0.encode(encoder, offset + 0, depth)?;
23506            self.1.encode(encoder, offset + 8, depth)?;
23507            Ok(())
23508        }
23509    }
23510
23511    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23512        for SessionAudioConsumerFactoryCreateAudioConsumerRequest
23513    {
23514        #[inline(always)]
23515        fn new_empty() -> Self {
23516            Self {
23517                session_id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
23518                audio_consumer_request: fidl::new_empty!(
23519                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23520                    fidl::encoding::DefaultFuchsiaResourceDialect
23521                ),
23522            }
23523        }
23524
23525        #[inline]
23526        unsafe fn decode(
23527            &mut self,
23528            decoder: &mut fidl::encoding::Decoder<
23529                '_,
23530                fidl::encoding::DefaultFuchsiaResourceDialect,
23531            >,
23532            offset: usize,
23533            _depth: fidl::encoding::Depth,
23534        ) -> fidl::Result<()> {
23535            decoder.debug_check_bounds::<Self>(offset);
23536            // Verify that padding bytes are zero.
23537            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
23538            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23539            let mask = 0xffffffff00000000u64;
23540            let maskedval = padval & mask;
23541            if maskedval != 0 {
23542                return Err(fidl::Error::NonZeroPadding {
23543                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
23544                });
23545            }
23546            fidl::decode!(
23547                u64,
23548                fidl::encoding::DefaultFuchsiaResourceDialect,
23549                &mut self.session_id,
23550                decoder,
23551                offset + 0,
23552                _depth
23553            )?;
23554            fidl::decode!(
23555                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23556                fidl::encoding::DefaultFuchsiaResourceDialect,
23557                &mut self.audio_consumer_request,
23558                decoder,
23559                offset + 8,
23560                _depth
23561            )?;
23562            Ok(())
23563        }
23564    }
23565
23566    impl fidl::encoding::ResourceTypeMarker for StreamBufferSetAddPayloadBufferRequest {
23567        type Borrowed<'a> = &'a mut Self;
23568        fn take_or_borrow<'a>(
23569            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23570        ) -> Self::Borrowed<'a> {
23571            value
23572        }
23573    }
23574
23575    unsafe impl fidl::encoding::TypeMarker for StreamBufferSetAddPayloadBufferRequest {
23576        type Owned = Self;
23577
23578        #[inline(always)]
23579        fn inline_align(_context: fidl::encoding::Context) -> usize {
23580            4
23581        }
23582
23583        #[inline(always)]
23584        fn inline_size(_context: fidl::encoding::Context) -> usize {
23585            8
23586        }
23587    }
23588
23589    unsafe impl
23590        fidl::encoding::Encode<
23591            StreamBufferSetAddPayloadBufferRequest,
23592            fidl::encoding::DefaultFuchsiaResourceDialect,
23593        > for &mut StreamBufferSetAddPayloadBufferRequest
23594    {
23595        #[inline]
23596        unsafe fn encode(
23597            self,
23598            encoder: &mut fidl::encoding::Encoder<
23599                '_,
23600                fidl::encoding::DefaultFuchsiaResourceDialect,
23601            >,
23602            offset: usize,
23603            _depth: fidl::encoding::Depth,
23604        ) -> fidl::Result<()> {
23605            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
23606            // Delegate to tuple encoding.
23607            fidl::encoding::Encode::<
23608                StreamBufferSetAddPayloadBufferRequest,
23609                fidl::encoding::DefaultFuchsiaResourceDialect,
23610            >::encode(
23611                (
23612                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
23613                    <fidl::encoding::HandleType<
23614                        fidl::Vmo,
23615                        { fidl::ObjectType::VMO.into_raw() },
23616                        2147483648,
23617                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23618                        &mut self.payload_buffer,
23619                    ),
23620                ),
23621                encoder,
23622                offset,
23623                _depth,
23624            )
23625        }
23626    }
23627    unsafe impl<
23628            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
23629            T1: fidl::encoding::Encode<
23630                fidl::encoding::HandleType<
23631                    fidl::Vmo,
23632                    { fidl::ObjectType::VMO.into_raw() },
23633                    2147483648,
23634                >,
23635                fidl::encoding::DefaultFuchsiaResourceDialect,
23636            >,
23637        >
23638        fidl::encoding::Encode<
23639            StreamBufferSetAddPayloadBufferRequest,
23640            fidl::encoding::DefaultFuchsiaResourceDialect,
23641        > for (T0, T1)
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            // Zero out padding regions. There's no need to apply masks
23655            // because the unmasked parts will be overwritten by fields.
23656            // Write the fields.
23657            self.0.encode(encoder, offset + 0, depth)?;
23658            self.1.encode(encoder, offset + 4, depth)?;
23659            Ok(())
23660        }
23661    }
23662
23663    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23664        for StreamBufferSetAddPayloadBufferRequest
23665    {
23666        #[inline(always)]
23667        fn new_empty() -> Self {
23668            Self {
23669                id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
23670                payload_buffer: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23671            }
23672        }
23673
23674        #[inline]
23675        unsafe fn decode(
23676            &mut self,
23677            decoder: &mut fidl::encoding::Decoder<
23678                '_,
23679                fidl::encoding::DefaultFuchsiaResourceDialect,
23680            >,
23681            offset: usize,
23682            _depth: fidl::encoding::Depth,
23683        ) -> fidl::Result<()> {
23684            decoder.debug_check_bounds::<Self>(offset);
23685            // Verify that padding bytes are zero.
23686            fidl::decode!(
23687                u32,
23688                fidl::encoding::DefaultFuchsiaResourceDialect,
23689                &mut self.id,
23690                decoder,
23691                offset + 0,
23692                _depth
23693            )?;
23694            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.payload_buffer, decoder, offset + 4, _depth)?;
23695            Ok(())
23696        }
23697    }
23698
23699    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
23700        type Borrowed<'a> = &'a mut Self;
23701        fn take_or_borrow<'a>(
23702            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23703        ) -> Self::Borrowed<'a> {
23704            value
23705        }
23706    }
23707
23708    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
23709        type Owned = Self;
23710
23711        #[inline(always)]
23712        fn inline_align(_context: fidl::encoding::Context) -> usize {
23713            8
23714        }
23715
23716        #[inline(always)]
23717        fn inline_size(_context: fidl::encoding::Context) -> usize {
23718            16
23719        }
23720    }
23721
23722    unsafe impl
23723        fidl::encoding::Encode<
23724            StreamProcessorSetInputBufferPartialSettingsRequest,
23725            fidl::encoding::DefaultFuchsiaResourceDialect,
23726        > for &mut StreamProcessorSetInputBufferPartialSettingsRequest
23727    {
23728        #[inline]
23729        unsafe fn encode(
23730            self,
23731            encoder: &mut fidl::encoding::Encoder<
23732                '_,
23733                fidl::encoding::DefaultFuchsiaResourceDialect,
23734            >,
23735            offset: usize,
23736            _depth: fidl::encoding::Depth,
23737        ) -> fidl::Result<()> {
23738            encoder
23739                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
23740            // Delegate to tuple encoding.
23741            fidl::encoding::Encode::<StreamProcessorSetInputBufferPartialSettingsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23742                (
23743                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.input_settings),
23744                ),
23745                encoder, offset, _depth
23746            )
23747        }
23748    }
23749    unsafe impl<
23750            T0: fidl::encoding::Encode<
23751                StreamBufferPartialSettings,
23752                fidl::encoding::DefaultFuchsiaResourceDialect,
23753            >,
23754        >
23755        fidl::encoding::Encode<
23756            StreamProcessorSetInputBufferPartialSettingsRequest,
23757            fidl::encoding::DefaultFuchsiaResourceDialect,
23758        > for (T0,)
23759    {
23760        #[inline]
23761        unsafe fn encode(
23762            self,
23763            encoder: &mut fidl::encoding::Encoder<
23764                '_,
23765                fidl::encoding::DefaultFuchsiaResourceDialect,
23766            >,
23767            offset: usize,
23768            depth: fidl::encoding::Depth,
23769        ) -> fidl::Result<()> {
23770            encoder
23771                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
23772            // Zero out padding regions. There's no need to apply masks
23773            // because the unmasked parts will be overwritten by fields.
23774            // Write the fields.
23775            self.0.encode(encoder, offset + 0, depth)?;
23776            Ok(())
23777        }
23778    }
23779
23780    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23781        for StreamProcessorSetInputBufferPartialSettingsRequest
23782    {
23783        #[inline(always)]
23784        fn new_empty() -> Self {
23785            Self {
23786                input_settings: fidl::new_empty!(
23787                    StreamBufferPartialSettings,
23788                    fidl::encoding::DefaultFuchsiaResourceDialect
23789                ),
23790            }
23791        }
23792
23793        #[inline]
23794        unsafe fn decode(
23795            &mut self,
23796            decoder: &mut fidl::encoding::Decoder<
23797                '_,
23798                fidl::encoding::DefaultFuchsiaResourceDialect,
23799            >,
23800            offset: usize,
23801            _depth: fidl::encoding::Depth,
23802        ) -> fidl::Result<()> {
23803            decoder.debug_check_bounds::<Self>(offset);
23804            // Verify that padding bytes are zero.
23805            fidl::decode!(
23806                StreamBufferPartialSettings,
23807                fidl::encoding::DefaultFuchsiaResourceDialect,
23808                &mut self.input_settings,
23809                decoder,
23810                offset + 0,
23811                _depth
23812            )?;
23813            Ok(())
23814        }
23815    }
23816
23817    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
23818        type Borrowed<'a> = &'a mut Self;
23819        fn take_or_borrow<'a>(
23820            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23821        ) -> Self::Borrowed<'a> {
23822            value
23823        }
23824    }
23825
23826    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
23827        type Owned = Self;
23828
23829        #[inline(always)]
23830        fn inline_align(_context: fidl::encoding::Context) -> usize {
23831            8
23832        }
23833
23834        #[inline(always)]
23835        fn inline_size(_context: fidl::encoding::Context) -> usize {
23836            16
23837        }
23838    }
23839
23840    unsafe impl
23841        fidl::encoding::Encode<
23842            StreamProcessorSetOutputBufferPartialSettingsRequest,
23843            fidl::encoding::DefaultFuchsiaResourceDialect,
23844        > for &mut StreamProcessorSetOutputBufferPartialSettingsRequest
23845    {
23846        #[inline]
23847        unsafe fn encode(
23848            self,
23849            encoder: &mut fidl::encoding::Encoder<
23850                '_,
23851                fidl::encoding::DefaultFuchsiaResourceDialect,
23852            >,
23853            offset: usize,
23854            _depth: fidl::encoding::Depth,
23855        ) -> fidl::Result<()> {
23856            encoder
23857                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
23858            // Delegate to tuple encoding.
23859            fidl::encoding::Encode::<StreamProcessorSetOutputBufferPartialSettingsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23860                (
23861                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.output_settings),
23862                ),
23863                encoder, offset, _depth
23864            )
23865        }
23866    }
23867    unsafe impl<
23868            T0: fidl::encoding::Encode<
23869                StreamBufferPartialSettings,
23870                fidl::encoding::DefaultFuchsiaResourceDialect,
23871            >,
23872        >
23873        fidl::encoding::Encode<
23874            StreamProcessorSetOutputBufferPartialSettingsRequest,
23875            fidl::encoding::DefaultFuchsiaResourceDialect,
23876        > for (T0,)
23877    {
23878        #[inline]
23879        unsafe fn encode(
23880            self,
23881            encoder: &mut fidl::encoding::Encoder<
23882                '_,
23883                fidl::encoding::DefaultFuchsiaResourceDialect,
23884            >,
23885            offset: usize,
23886            depth: fidl::encoding::Depth,
23887        ) -> fidl::Result<()> {
23888            encoder
23889                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
23890            // Zero out padding regions. There's no need to apply masks
23891            // because the unmasked parts will be overwritten by fields.
23892            // Write the fields.
23893            self.0.encode(encoder, offset + 0, depth)?;
23894            Ok(())
23895        }
23896    }
23897
23898    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23899        for StreamProcessorSetOutputBufferPartialSettingsRequest
23900    {
23901        #[inline(always)]
23902        fn new_empty() -> Self {
23903            Self {
23904                output_settings: fidl::new_empty!(
23905                    StreamBufferPartialSettings,
23906                    fidl::encoding::DefaultFuchsiaResourceDialect
23907                ),
23908            }
23909        }
23910
23911        #[inline]
23912        unsafe fn decode(
23913            &mut self,
23914            decoder: &mut fidl::encoding::Decoder<
23915                '_,
23916                fidl::encoding::DefaultFuchsiaResourceDialect,
23917            >,
23918            offset: usize,
23919            _depth: fidl::encoding::Depth,
23920        ) -> fidl::Result<()> {
23921            decoder.debug_check_bounds::<Self>(offset);
23922            // Verify that padding bytes are zero.
23923            fidl::decode!(
23924                StreamBufferPartialSettings,
23925                fidl::encoding::DefaultFuchsiaResourceDialect,
23926                &mut self.output_settings,
23927                decoder,
23928                offset + 0,
23929                _depth
23930            )?;
23931            Ok(())
23932        }
23933    }
23934
23935    impl fidl::encoding::ResourceTypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
23936        type Borrowed<'a> = &'a mut Self;
23937        fn take_or_borrow<'a>(
23938            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23939        ) -> Self::Borrowed<'a> {
23940            value
23941        }
23942    }
23943
23944    unsafe impl fidl::encoding::TypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
23945        type Owned = Self;
23946
23947        #[inline(always)]
23948        fn inline_align(_context: fidl::encoding::Context) -> usize {
23949            4
23950        }
23951
23952        #[inline(always)]
23953        fn inline_size(_context: fidl::encoding::Context) -> usize {
23954            8
23955        }
23956    }
23957
23958    unsafe impl
23959        fidl::encoding::Encode<
23960            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
23961            fidl::encoding::DefaultFuchsiaResourceDialect,
23962        > for &mut Usage2AudioConsumerFactoryCreateAudioConsumerRequest
23963    {
23964        #[inline]
23965        unsafe fn encode(
23966            self,
23967            encoder: &mut fidl::encoding::Encoder<
23968                '_,
23969                fidl::encoding::DefaultFuchsiaResourceDialect,
23970            >,
23971            offset: usize,
23972            _depth: fidl::encoding::Depth,
23973        ) -> fidl::Result<()> {
23974            encoder
23975                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
23976            // Delegate to tuple encoding.
23977            fidl::encoding::Encode::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23978                (
23979                    <AudioRenderUsage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
23980                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
23981                ),
23982                encoder, offset, _depth
23983            )
23984        }
23985    }
23986    unsafe impl<
23987            T0: fidl::encoding::Encode<
23988                AudioRenderUsage2,
23989                fidl::encoding::DefaultFuchsiaResourceDialect,
23990            >,
23991            T1: fidl::encoding::Encode<
23992                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23993                fidl::encoding::DefaultFuchsiaResourceDialect,
23994            >,
23995        >
23996        fidl::encoding::Encode<
23997            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
23998            fidl::encoding::DefaultFuchsiaResourceDialect,
23999        > for (T0, T1)
24000    {
24001        #[inline]
24002        unsafe fn encode(
24003            self,
24004            encoder: &mut fidl::encoding::Encoder<
24005                '_,
24006                fidl::encoding::DefaultFuchsiaResourceDialect,
24007            >,
24008            offset: usize,
24009            depth: fidl::encoding::Depth,
24010        ) -> fidl::Result<()> {
24011            encoder
24012                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
24013            // Zero out padding regions. There's no need to apply masks
24014            // because the unmasked parts will be overwritten by fields.
24015            // Write the fields.
24016            self.0.encode(encoder, offset + 0, depth)?;
24017            self.1.encode(encoder, offset + 4, depth)?;
24018            Ok(())
24019        }
24020    }
24021
24022    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24023        for Usage2AudioConsumerFactoryCreateAudioConsumerRequest
24024    {
24025        #[inline(always)]
24026        fn new_empty() -> Self {
24027            Self {
24028                usage: fidl::new_empty!(
24029                    AudioRenderUsage2,
24030                    fidl::encoding::DefaultFuchsiaResourceDialect
24031                ),
24032                audio_consumer_request: fidl::new_empty!(
24033                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24034                    fidl::encoding::DefaultFuchsiaResourceDialect
24035                ),
24036            }
24037        }
24038
24039        #[inline]
24040        unsafe fn decode(
24041            &mut self,
24042            decoder: &mut fidl::encoding::Decoder<
24043                '_,
24044                fidl::encoding::DefaultFuchsiaResourceDialect,
24045            >,
24046            offset: usize,
24047            _depth: fidl::encoding::Depth,
24048        ) -> fidl::Result<()> {
24049            decoder.debug_check_bounds::<Self>(offset);
24050            // Verify that padding bytes are zero.
24051            fidl::decode!(
24052                AudioRenderUsage2,
24053                fidl::encoding::DefaultFuchsiaResourceDialect,
24054                &mut self.usage,
24055                decoder,
24056                offset + 0,
24057                _depth
24058            )?;
24059            fidl::decode!(
24060                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24061                fidl::encoding::DefaultFuchsiaResourceDialect,
24062                &mut self.audio_consumer_request,
24063                decoder,
24064                offset + 4,
24065                _depth
24066            )?;
24067            Ok(())
24068        }
24069    }
24070
24071    impl fidl::encoding::ResourceTypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
24072        type Borrowed<'a> = &'a mut Self;
24073        fn take_or_borrow<'a>(
24074            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24075        ) -> Self::Borrowed<'a> {
24076            value
24077        }
24078    }
24079
24080    unsafe impl fidl::encoding::TypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
24081        type Owned = Self;
24082
24083        #[inline(always)]
24084        fn inline_align(_context: fidl::encoding::Context) -> usize {
24085            4
24086        }
24087
24088        #[inline(always)]
24089        fn inline_size(_context: fidl::encoding::Context) -> usize {
24090            8
24091        }
24092    }
24093
24094    unsafe impl
24095        fidl::encoding::Encode<
24096            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
24097            fidl::encoding::DefaultFuchsiaResourceDialect,
24098        > for &mut UsageAudioConsumerFactoryCreateAudioConsumerRequest
24099    {
24100        #[inline]
24101        unsafe fn encode(
24102            self,
24103            encoder: &mut fidl::encoding::Encoder<
24104                '_,
24105                fidl::encoding::DefaultFuchsiaResourceDialect,
24106            >,
24107            offset: usize,
24108            _depth: fidl::encoding::Depth,
24109        ) -> fidl::Result<()> {
24110            encoder
24111                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
24112            // Delegate to tuple encoding.
24113            fidl::encoding::Encode::<UsageAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24114                (
24115                    <AudioRenderUsage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24116                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
24117                ),
24118                encoder, offset, _depth
24119            )
24120        }
24121    }
24122    unsafe impl<
24123            T0: fidl::encoding::Encode<AudioRenderUsage, fidl::encoding::DefaultFuchsiaResourceDialect>,
24124            T1: fidl::encoding::Encode<
24125                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24126                fidl::encoding::DefaultFuchsiaResourceDialect,
24127            >,
24128        >
24129        fidl::encoding::Encode<
24130            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
24131            fidl::encoding::DefaultFuchsiaResourceDialect,
24132        > for (T0, T1)
24133    {
24134        #[inline]
24135        unsafe fn encode(
24136            self,
24137            encoder: &mut fidl::encoding::Encoder<
24138                '_,
24139                fidl::encoding::DefaultFuchsiaResourceDialect,
24140            >,
24141            offset: usize,
24142            depth: fidl::encoding::Depth,
24143        ) -> fidl::Result<()> {
24144            encoder
24145                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
24146            // Zero out padding regions. There's no need to apply masks
24147            // because the unmasked parts will be overwritten by fields.
24148            // Write the fields.
24149            self.0.encode(encoder, offset + 0, depth)?;
24150            self.1.encode(encoder, offset + 4, depth)?;
24151            Ok(())
24152        }
24153    }
24154
24155    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24156        for UsageAudioConsumerFactoryCreateAudioConsumerRequest
24157    {
24158        #[inline(always)]
24159        fn new_empty() -> Self {
24160            Self {
24161                usage: fidl::new_empty!(
24162                    AudioRenderUsage,
24163                    fidl::encoding::DefaultFuchsiaResourceDialect
24164                ),
24165                audio_consumer_request: fidl::new_empty!(
24166                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24167                    fidl::encoding::DefaultFuchsiaResourceDialect
24168                ),
24169            }
24170        }
24171
24172        #[inline]
24173        unsafe fn decode(
24174            &mut self,
24175            decoder: &mut fidl::encoding::Decoder<
24176                '_,
24177                fidl::encoding::DefaultFuchsiaResourceDialect,
24178            >,
24179            offset: usize,
24180            _depth: fidl::encoding::Depth,
24181        ) -> fidl::Result<()> {
24182            decoder.debug_check_bounds::<Self>(offset);
24183            // Verify that padding bytes are zero.
24184            fidl::decode!(
24185                AudioRenderUsage,
24186                fidl::encoding::DefaultFuchsiaResourceDialect,
24187                &mut self.usage,
24188                decoder,
24189                offset + 0,
24190                _depth
24191            )?;
24192            fidl::decode!(
24193                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24194                fidl::encoding::DefaultFuchsiaResourceDialect,
24195                &mut self.audio_consumer_request,
24196                decoder,
24197                offset + 4,
24198                _depth
24199            )?;
24200            Ok(())
24201        }
24202    }
24203
24204    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListener2Request {
24205        type Borrowed<'a> = &'a mut Self;
24206        fn take_or_borrow<'a>(
24207            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24208        ) -> Self::Borrowed<'a> {
24209            value
24210        }
24211    }
24212
24213    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListener2Request {
24214        type Owned = Self;
24215
24216        #[inline(always)]
24217        fn inline_align(_context: fidl::encoding::Context) -> usize {
24218            8
24219        }
24220
24221        #[inline(always)]
24222        fn inline_size(_context: fidl::encoding::Context) -> usize {
24223            40
24224        }
24225    }
24226
24227    unsafe impl
24228        fidl::encoding::Encode<
24229            UsageGainReporterRegisterListener2Request,
24230            fidl::encoding::DefaultFuchsiaResourceDialect,
24231        > for &mut UsageGainReporterRegisterListener2Request
24232    {
24233        #[inline]
24234        unsafe fn encode(
24235            self,
24236            encoder: &mut fidl::encoding::Encoder<
24237                '_,
24238                fidl::encoding::DefaultFuchsiaResourceDialect,
24239            >,
24240            offset: usize,
24241            _depth: fidl::encoding::Depth,
24242        ) -> fidl::Result<()> {
24243            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
24244            // Delegate to tuple encoding.
24245            fidl::encoding::Encode::<UsageGainReporterRegisterListener2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24246                (
24247                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(&self.device_unique_id),
24248                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24249                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_gain_listener),
24250                ),
24251                encoder, offset, _depth
24252            )
24253        }
24254    }
24255    unsafe impl<
24256            T0: fidl::encoding::Encode<
24257                fidl::encoding::BoundedString<36>,
24258                fidl::encoding::DefaultFuchsiaResourceDialect,
24259            >,
24260            T1: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
24261            T2: fidl::encoding::Encode<
24262                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24263                fidl::encoding::DefaultFuchsiaResourceDialect,
24264            >,
24265        >
24266        fidl::encoding::Encode<
24267            UsageGainReporterRegisterListener2Request,
24268            fidl::encoding::DefaultFuchsiaResourceDialect,
24269        > for (T0, T1, T2)
24270    {
24271        #[inline]
24272        unsafe fn encode(
24273            self,
24274            encoder: &mut fidl::encoding::Encoder<
24275                '_,
24276                fidl::encoding::DefaultFuchsiaResourceDialect,
24277            >,
24278            offset: usize,
24279            depth: fidl::encoding::Depth,
24280        ) -> fidl::Result<()> {
24281            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
24282            // Zero out padding regions. There's no need to apply masks
24283            // because the unmasked parts will be overwritten by fields.
24284            unsafe {
24285                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
24286                (ptr as *mut u64).write_unaligned(0);
24287            }
24288            // Write the fields.
24289            self.0.encode(encoder, offset + 0, depth)?;
24290            self.1.encode(encoder, offset + 16, depth)?;
24291            self.2.encode(encoder, offset + 32, depth)?;
24292            Ok(())
24293        }
24294    }
24295
24296    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24297        for UsageGainReporterRegisterListener2Request
24298    {
24299        #[inline(always)]
24300        fn new_empty() -> Self {
24301            Self {
24302                device_unique_id: fidl::new_empty!(
24303                    fidl::encoding::BoundedString<36>,
24304                    fidl::encoding::DefaultFuchsiaResourceDialect
24305                ),
24306                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
24307                usage_gain_listener: fidl::new_empty!(
24308                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24309                    fidl::encoding::DefaultFuchsiaResourceDialect
24310                ),
24311            }
24312        }
24313
24314        #[inline]
24315        unsafe fn decode(
24316            &mut self,
24317            decoder: &mut fidl::encoding::Decoder<
24318                '_,
24319                fidl::encoding::DefaultFuchsiaResourceDialect,
24320            >,
24321            offset: usize,
24322            _depth: fidl::encoding::Depth,
24323        ) -> fidl::Result<()> {
24324            decoder.debug_check_bounds::<Self>(offset);
24325            // Verify that padding bytes are zero.
24326            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
24327            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24328            let mask = 0xffffffff00000000u64;
24329            let maskedval = padval & mask;
24330            if maskedval != 0 {
24331                return Err(fidl::Error::NonZeroPadding {
24332                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
24333                });
24334            }
24335            fidl::decode!(
24336                fidl::encoding::BoundedString<36>,
24337                fidl::encoding::DefaultFuchsiaResourceDialect,
24338                &mut self.device_unique_id,
24339                decoder,
24340                offset + 0,
24341                _depth
24342            )?;
24343            fidl::decode!(
24344                Usage2,
24345                fidl::encoding::DefaultFuchsiaResourceDialect,
24346                &mut self.usage,
24347                decoder,
24348                offset + 16,
24349                _depth
24350            )?;
24351            fidl::decode!(
24352                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24353                fidl::encoding::DefaultFuchsiaResourceDialect,
24354                &mut self.usage_gain_listener,
24355                decoder,
24356                offset + 32,
24357                _depth
24358            )?;
24359            Ok(())
24360        }
24361    }
24362
24363    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListenerRequest {
24364        type Borrowed<'a> = &'a mut Self;
24365        fn take_or_borrow<'a>(
24366            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24367        ) -> Self::Borrowed<'a> {
24368            value
24369        }
24370    }
24371
24372    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListenerRequest {
24373        type Owned = Self;
24374
24375        #[inline(always)]
24376        fn inline_align(_context: fidl::encoding::Context) -> usize {
24377            8
24378        }
24379
24380        #[inline(always)]
24381        fn inline_size(_context: fidl::encoding::Context) -> usize {
24382            40
24383        }
24384    }
24385
24386    unsafe impl
24387        fidl::encoding::Encode<
24388            UsageGainReporterRegisterListenerRequest,
24389            fidl::encoding::DefaultFuchsiaResourceDialect,
24390        > for &mut UsageGainReporterRegisterListenerRequest
24391    {
24392        #[inline]
24393        unsafe fn encode(
24394            self,
24395            encoder: &mut fidl::encoding::Encoder<
24396                '_,
24397                fidl::encoding::DefaultFuchsiaResourceDialect,
24398            >,
24399            offset: usize,
24400            _depth: fidl::encoding::Depth,
24401        ) -> fidl::Result<()> {
24402            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
24403            // Delegate to tuple encoding.
24404            fidl::encoding::Encode::<UsageGainReporterRegisterListenerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24405                (
24406                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(&self.device_unique_id),
24407                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24408                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_gain_listener),
24409                ),
24410                encoder, offset, _depth
24411            )
24412        }
24413    }
24414    unsafe impl<
24415            T0: fidl::encoding::Encode<
24416                fidl::encoding::BoundedString<36>,
24417                fidl::encoding::DefaultFuchsiaResourceDialect,
24418            >,
24419            T1: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
24420            T2: fidl::encoding::Encode<
24421                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24422                fidl::encoding::DefaultFuchsiaResourceDialect,
24423            >,
24424        >
24425        fidl::encoding::Encode<
24426            UsageGainReporterRegisterListenerRequest,
24427            fidl::encoding::DefaultFuchsiaResourceDialect,
24428        > for (T0, T1, T2)
24429    {
24430        #[inline]
24431        unsafe fn encode(
24432            self,
24433            encoder: &mut fidl::encoding::Encoder<
24434                '_,
24435                fidl::encoding::DefaultFuchsiaResourceDialect,
24436            >,
24437            offset: usize,
24438            depth: fidl::encoding::Depth,
24439        ) -> fidl::Result<()> {
24440            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
24441            // Zero out padding regions. There's no need to apply masks
24442            // because the unmasked parts will be overwritten by fields.
24443            unsafe {
24444                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
24445                (ptr as *mut u64).write_unaligned(0);
24446            }
24447            // Write the fields.
24448            self.0.encode(encoder, offset + 0, depth)?;
24449            self.1.encode(encoder, offset + 16, depth)?;
24450            self.2.encode(encoder, offset + 32, depth)?;
24451            Ok(())
24452        }
24453    }
24454
24455    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24456        for UsageGainReporterRegisterListenerRequest
24457    {
24458        #[inline(always)]
24459        fn new_empty() -> Self {
24460            Self {
24461                device_unique_id: fidl::new_empty!(
24462                    fidl::encoding::BoundedString<36>,
24463                    fidl::encoding::DefaultFuchsiaResourceDialect
24464                ),
24465                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
24466                usage_gain_listener: fidl::new_empty!(
24467                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24468                    fidl::encoding::DefaultFuchsiaResourceDialect
24469                ),
24470            }
24471        }
24472
24473        #[inline]
24474        unsafe fn decode(
24475            &mut self,
24476            decoder: &mut fidl::encoding::Decoder<
24477                '_,
24478                fidl::encoding::DefaultFuchsiaResourceDialect,
24479            >,
24480            offset: usize,
24481            _depth: fidl::encoding::Depth,
24482        ) -> fidl::Result<()> {
24483            decoder.debug_check_bounds::<Self>(offset);
24484            // Verify that padding bytes are zero.
24485            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
24486            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24487            let mask = 0xffffffff00000000u64;
24488            let maskedval = padval & mask;
24489            if maskedval != 0 {
24490                return Err(fidl::Error::NonZeroPadding {
24491                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
24492                });
24493            }
24494            fidl::decode!(
24495                fidl::encoding::BoundedString<36>,
24496                fidl::encoding::DefaultFuchsiaResourceDialect,
24497                &mut self.device_unique_id,
24498                decoder,
24499                offset + 0,
24500                _depth
24501            )?;
24502            fidl::decode!(
24503                Usage,
24504                fidl::encoding::DefaultFuchsiaResourceDialect,
24505                &mut self.usage,
24506                decoder,
24507                offset + 16,
24508                _depth
24509            )?;
24510            fidl::decode!(
24511                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24512                fidl::encoding::DefaultFuchsiaResourceDialect,
24513                &mut self.usage_gain_listener,
24514                decoder,
24515                offset + 32,
24516                _depth
24517            )?;
24518            Ok(())
24519        }
24520    }
24521
24522    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatch2Request {
24523        type Borrowed<'a> = &'a mut Self;
24524        fn take_or_borrow<'a>(
24525            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24526        ) -> Self::Borrowed<'a> {
24527            value
24528        }
24529    }
24530
24531    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatch2Request {
24532        type Owned = Self;
24533
24534        #[inline(always)]
24535        fn inline_align(_context: fidl::encoding::Context) -> usize {
24536            8
24537        }
24538
24539        #[inline(always)]
24540        fn inline_size(_context: fidl::encoding::Context) -> usize {
24541            24
24542        }
24543    }
24544
24545    unsafe impl
24546        fidl::encoding::Encode<
24547            UsageReporterWatch2Request,
24548            fidl::encoding::DefaultFuchsiaResourceDialect,
24549        > for &mut UsageReporterWatch2Request
24550    {
24551        #[inline]
24552        unsafe fn encode(
24553            self,
24554            encoder: &mut fidl::encoding::Encoder<
24555                '_,
24556                fidl::encoding::DefaultFuchsiaResourceDialect,
24557            >,
24558            offset: usize,
24559            _depth: fidl::encoding::Depth,
24560        ) -> fidl::Result<()> {
24561            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
24562            // Delegate to tuple encoding.
24563            fidl::encoding::Encode::<UsageReporterWatch2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24564                (
24565                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24566                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
24567                ),
24568                encoder, offset, _depth
24569            )
24570        }
24571    }
24572    unsafe impl<
24573            T0: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
24574            T1: fidl::encoding::Encode<
24575                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
24576                fidl::encoding::DefaultFuchsiaResourceDialect,
24577            >,
24578        >
24579        fidl::encoding::Encode<
24580            UsageReporterWatch2Request,
24581            fidl::encoding::DefaultFuchsiaResourceDialect,
24582        > for (T0, T1)
24583    {
24584        #[inline]
24585        unsafe fn encode(
24586            self,
24587            encoder: &mut fidl::encoding::Encoder<
24588                '_,
24589                fidl::encoding::DefaultFuchsiaResourceDialect,
24590            >,
24591            offset: usize,
24592            depth: fidl::encoding::Depth,
24593        ) -> fidl::Result<()> {
24594            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
24595            // Zero out padding regions. There's no need to apply masks
24596            // because the unmasked parts will be overwritten by fields.
24597            unsafe {
24598                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
24599                (ptr as *mut u64).write_unaligned(0);
24600            }
24601            // Write the fields.
24602            self.0.encode(encoder, offset + 0, depth)?;
24603            self.1.encode(encoder, offset + 16, depth)?;
24604            Ok(())
24605        }
24606    }
24607
24608    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24609        for UsageReporterWatch2Request
24610    {
24611        #[inline(always)]
24612        fn new_empty() -> Self {
24613            Self {
24614                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
24615                usage_watcher: fidl::new_empty!(
24616                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
24617                    fidl::encoding::DefaultFuchsiaResourceDialect
24618                ),
24619            }
24620        }
24621
24622        #[inline]
24623        unsafe fn decode(
24624            &mut self,
24625            decoder: &mut fidl::encoding::Decoder<
24626                '_,
24627                fidl::encoding::DefaultFuchsiaResourceDialect,
24628            >,
24629            offset: usize,
24630            _depth: fidl::encoding::Depth,
24631        ) -> fidl::Result<()> {
24632            decoder.debug_check_bounds::<Self>(offset);
24633            // Verify that padding bytes are zero.
24634            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
24635            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24636            let mask = 0xffffffff00000000u64;
24637            let maskedval = padval & mask;
24638            if maskedval != 0 {
24639                return Err(fidl::Error::NonZeroPadding {
24640                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
24641                });
24642            }
24643            fidl::decode!(
24644                Usage2,
24645                fidl::encoding::DefaultFuchsiaResourceDialect,
24646                &mut self.usage,
24647                decoder,
24648                offset + 0,
24649                _depth
24650            )?;
24651            fidl::decode!(
24652                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
24653                fidl::encoding::DefaultFuchsiaResourceDialect,
24654                &mut self.usage_watcher,
24655                decoder,
24656                offset + 16,
24657                _depth
24658            )?;
24659            Ok(())
24660        }
24661    }
24662
24663    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatchRequest {
24664        type Borrowed<'a> = &'a mut Self;
24665        fn take_or_borrow<'a>(
24666            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24667        ) -> Self::Borrowed<'a> {
24668            value
24669        }
24670    }
24671
24672    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatchRequest {
24673        type Owned = Self;
24674
24675        #[inline(always)]
24676        fn inline_align(_context: fidl::encoding::Context) -> usize {
24677            8
24678        }
24679
24680        #[inline(always)]
24681        fn inline_size(_context: fidl::encoding::Context) -> usize {
24682            24
24683        }
24684    }
24685
24686    unsafe impl
24687        fidl::encoding::Encode<
24688            UsageReporterWatchRequest,
24689            fidl::encoding::DefaultFuchsiaResourceDialect,
24690        > for &mut UsageReporterWatchRequest
24691    {
24692        #[inline]
24693        unsafe fn encode(
24694            self,
24695            encoder: &mut fidl::encoding::Encoder<
24696                '_,
24697                fidl::encoding::DefaultFuchsiaResourceDialect,
24698            >,
24699            offset: usize,
24700            _depth: fidl::encoding::Depth,
24701        ) -> fidl::Result<()> {
24702            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
24703            // Delegate to tuple encoding.
24704            fidl::encoding::Encode::<UsageReporterWatchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24705                (
24706                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24707                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
24708                ),
24709                encoder, offset, _depth
24710            )
24711        }
24712    }
24713    unsafe impl<
24714            T0: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
24715            T1: fidl::encoding::Encode<
24716                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
24717                fidl::encoding::DefaultFuchsiaResourceDialect,
24718            >,
24719        >
24720        fidl::encoding::Encode<
24721            UsageReporterWatchRequest,
24722            fidl::encoding::DefaultFuchsiaResourceDialect,
24723        > for (T0, T1)
24724    {
24725        #[inline]
24726        unsafe fn encode(
24727            self,
24728            encoder: &mut fidl::encoding::Encoder<
24729                '_,
24730                fidl::encoding::DefaultFuchsiaResourceDialect,
24731            >,
24732            offset: usize,
24733            depth: fidl::encoding::Depth,
24734        ) -> fidl::Result<()> {
24735            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
24736            // Zero out padding regions. There's no need to apply masks
24737            // because the unmasked parts will be overwritten by fields.
24738            unsafe {
24739                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
24740                (ptr as *mut u64).write_unaligned(0);
24741            }
24742            // Write the fields.
24743            self.0.encode(encoder, offset + 0, depth)?;
24744            self.1.encode(encoder, offset + 16, depth)?;
24745            Ok(())
24746        }
24747    }
24748
24749    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24750        for UsageReporterWatchRequest
24751    {
24752        #[inline(always)]
24753        fn new_empty() -> Self {
24754            Self {
24755                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
24756                usage_watcher: fidl::new_empty!(
24757                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
24758                    fidl::encoding::DefaultFuchsiaResourceDialect
24759                ),
24760            }
24761        }
24762
24763        #[inline]
24764        unsafe fn decode(
24765            &mut self,
24766            decoder: &mut fidl::encoding::Decoder<
24767                '_,
24768                fidl::encoding::DefaultFuchsiaResourceDialect,
24769            >,
24770            offset: usize,
24771            _depth: fidl::encoding::Depth,
24772        ) -> fidl::Result<()> {
24773            decoder.debug_check_bounds::<Self>(offset);
24774            // Verify that padding bytes are zero.
24775            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
24776            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24777            let mask = 0xffffffff00000000u64;
24778            let maskedval = padval & mask;
24779            if maskedval != 0 {
24780                return Err(fidl::Error::NonZeroPadding {
24781                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
24782                });
24783            }
24784            fidl::decode!(
24785                Usage,
24786                fidl::encoding::DefaultFuchsiaResourceDialect,
24787                &mut self.usage,
24788                decoder,
24789                offset + 0,
24790                _depth
24791            )?;
24792            fidl::decode!(
24793                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
24794                fidl::encoding::DefaultFuchsiaResourceDialect,
24795                &mut self.usage_watcher,
24796                decoder,
24797                offset + 16,
24798                _depth
24799            )?;
24800            Ok(())
24801        }
24802    }
24803
24804    impl StreamBufferPartialSettings {
24805        #[inline(always)]
24806        fn max_ordinal_present(&self) -> u64 {
24807            if let Some(_) = self.sysmem2_token {
24808                return 7;
24809            }
24810            if let Some(_) = self.sysmem_token {
24811                return 6;
24812            }
24813            if let Some(_) = self.packet_count_for_client {
24814                return 5;
24815            }
24816            if let Some(_) = self.packet_count_for_server {
24817                return 4;
24818            }
24819            if let Some(_) = self.single_buffer_mode {
24820                return 3;
24821            }
24822            if let Some(_) = self.buffer_constraints_version_ordinal {
24823                return 2;
24824            }
24825            if let Some(_) = self.buffer_lifetime_ordinal {
24826                return 1;
24827            }
24828            0
24829        }
24830    }
24831
24832    impl fidl::encoding::ResourceTypeMarker for StreamBufferPartialSettings {
24833        type Borrowed<'a> = &'a mut Self;
24834        fn take_or_borrow<'a>(
24835            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24836        ) -> Self::Borrowed<'a> {
24837            value
24838        }
24839    }
24840
24841    unsafe impl fidl::encoding::TypeMarker for StreamBufferPartialSettings {
24842        type Owned = Self;
24843
24844        #[inline(always)]
24845        fn inline_align(_context: fidl::encoding::Context) -> usize {
24846            8
24847        }
24848
24849        #[inline(always)]
24850        fn inline_size(_context: fidl::encoding::Context) -> usize {
24851            16
24852        }
24853    }
24854
24855    unsafe impl
24856        fidl::encoding::Encode<
24857            StreamBufferPartialSettings,
24858            fidl::encoding::DefaultFuchsiaResourceDialect,
24859        > for &mut StreamBufferPartialSettings
24860    {
24861        unsafe fn encode(
24862            self,
24863            encoder: &mut fidl::encoding::Encoder<
24864                '_,
24865                fidl::encoding::DefaultFuchsiaResourceDialect,
24866            >,
24867            offset: usize,
24868            mut depth: fidl::encoding::Depth,
24869        ) -> fidl::Result<()> {
24870            encoder.debug_check_bounds::<StreamBufferPartialSettings>(offset);
24871            // Vector header
24872            let max_ordinal: u64 = self.max_ordinal_present();
24873            encoder.write_num(max_ordinal, offset);
24874            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
24875            // Calling encoder.out_of_line_offset(0) is not allowed.
24876            if max_ordinal == 0 {
24877                return Ok(());
24878            }
24879            depth.increment()?;
24880            let envelope_size = 8;
24881            let bytes_len = max_ordinal as usize * envelope_size;
24882            #[allow(unused_variables)]
24883            let offset = encoder.out_of_line_offset(bytes_len);
24884            let mut _prev_end_offset: usize = 0;
24885            if 1 > max_ordinal {
24886                return Ok(());
24887            }
24888
24889            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24890            // are envelope_size bytes.
24891            let cur_offset: usize = (1 - 1) * envelope_size;
24892
24893            // Zero reserved fields.
24894            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24895
24896            // Safety:
24897            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24898            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24899            //   envelope_size bytes, there is always sufficient room.
24900            fidl::encoding::encode_in_envelope_optional::<
24901                u64,
24902                fidl::encoding::DefaultFuchsiaResourceDialect,
24903            >(
24904                self.buffer_lifetime_ordinal
24905                    .as_ref()
24906                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
24907                encoder,
24908                offset + cur_offset,
24909                depth,
24910            )?;
24911
24912            _prev_end_offset = cur_offset + envelope_size;
24913            if 2 > max_ordinal {
24914                return Ok(());
24915            }
24916
24917            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24918            // are envelope_size bytes.
24919            let cur_offset: usize = (2 - 1) * envelope_size;
24920
24921            // Zero reserved fields.
24922            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24923
24924            // Safety:
24925            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24926            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24927            //   envelope_size bytes, there is always sufficient room.
24928            fidl::encoding::encode_in_envelope_optional::<
24929                u64,
24930                fidl::encoding::DefaultFuchsiaResourceDialect,
24931            >(
24932                self.buffer_constraints_version_ordinal
24933                    .as_ref()
24934                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
24935                encoder,
24936                offset + cur_offset,
24937                depth,
24938            )?;
24939
24940            _prev_end_offset = cur_offset + envelope_size;
24941            if 3 > max_ordinal {
24942                return Ok(());
24943            }
24944
24945            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24946            // are envelope_size bytes.
24947            let cur_offset: usize = (3 - 1) * envelope_size;
24948
24949            // Zero reserved fields.
24950            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24951
24952            // Safety:
24953            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24954            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24955            //   envelope_size bytes, there is always sufficient room.
24956            fidl::encoding::encode_in_envelope_optional::<
24957                bool,
24958                fidl::encoding::DefaultFuchsiaResourceDialect,
24959            >(
24960                self.single_buffer_mode
24961                    .as_ref()
24962                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
24963                encoder,
24964                offset + cur_offset,
24965                depth,
24966            )?;
24967
24968            _prev_end_offset = cur_offset + envelope_size;
24969            if 4 > max_ordinal {
24970                return Ok(());
24971            }
24972
24973            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24974            // are envelope_size bytes.
24975            let cur_offset: usize = (4 - 1) * envelope_size;
24976
24977            // Zero reserved fields.
24978            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24979
24980            // Safety:
24981            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24982            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24983            //   envelope_size bytes, there is always sufficient room.
24984            fidl::encoding::encode_in_envelope_optional::<
24985                u32,
24986                fidl::encoding::DefaultFuchsiaResourceDialect,
24987            >(
24988                self.packet_count_for_server
24989                    .as_ref()
24990                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
24991                encoder,
24992                offset + cur_offset,
24993                depth,
24994            )?;
24995
24996            _prev_end_offset = cur_offset + envelope_size;
24997            if 5 > max_ordinal {
24998                return Ok(());
24999            }
25000
25001            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
25002            // are envelope_size bytes.
25003            let cur_offset: usize = (5 - 1) * envelope_size;
25004
25005            // Zero reserved fields.
25006            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
25007
25008            // Safety:
25009            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
25010            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
25011            //   envelope_size bytes, there is always sufficient room.
25012            fidl::encoding::encode_in_envelope_optional::<
25013                u32,
25014                fidl::encoding::DefaultFuchsiaResourceDialect,
25015            >(
25016                self.packet_count_for_client
25017                    .as_ref()
25018                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
25019                encoder,
25020                offset + cur_offset,
25021                depth,
25022            )?;
25023
25024            _prev_end_offset = cur_offset + envelope_size;
25025            if 6 > max_ordinal {
25026                return Ok(());
25027            }
25028
25029            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
25030            // are envelope_size bytes.
25031            let cur_offset: usize = (6 - 1) * envelope_size;
25032
25033            // Zero reserved fields.
25034            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
25035
25036            // Safety:
25037            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
25038            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
25039            //   envelope_size bytes, there is always sufficient room.
25040            fidl::encoding::encode_in_envelope_optional::<
25041                fidl::encoding::Endpoint<
25042                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
25043                >,
25044                fidl::encoding::DefaultFuchsiaResourceDialect,
25045            >(
25046                self.sysmem_token.as_mut().map(
25047                    <fidl::encoding::Endpoint<
25048                        fidl::endpoints::ClientEnd<
25049                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
25050                        >,
25051                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
25052                ),
25053                encoder,
25054                offset + cur_offset,
25055                depth,
25056            )?;
25057
25058            _prev_end_offset = cur_offset + envelope_size;
25059            if 7 > max_ordinal {
25060                return Ok(());
25061            }
25062
25063            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
25064            // are envelope_size bytes.
25065            let cur_offset: usize = (7 - 1) * envelope_size;
25066
25067            // Zero reserved fields.
25068            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
25069
25070            // Safety:
25071            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
25072            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
25073            //   envelope_size bytes, there is always sufficient room.
25074            fidl::encoding::encode_in_envelope_optional::<
25075                fidl::encoding::Endpoint<
25076                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
25077                >,
25078                fidl::encoding::DefaultFuchsiaResourceDialect,
25079            >(
25080                self.sysmem2_token.as_mut().map(
25081                    <fidl::encoding::Endpoint<
25082                        fidl::endpoints::ClientEnd<
25083                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
25084                        >,
25085                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
25086                ),
25087                encoder,
25088                offset + cur_offset,
25089                depth,
25090            )?;
25091
25092            _prev_end_offset = cur_offset + envelope_size;
25093
25094            Ok(())
25095        }
25096    }
25097
25098    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25099        for StreamBufferPartialSettings
25100    {
25101        #[inline(always)]
25102        fn new_empty() -> Self {
25103            Self::default()
25104        }
25105
25106        unsafe fn decode(
25107            &mut self,
25108            decoder: &mut fidl::encoding::Decoder<
25109                '_,
25110                fidl::encoding::DefaultFuchsiaResourceDialect,
25111            >,
25112            offset: usize,
25113            mut depth: fidl::encoding::Depth,
25114        ) -> fidl::Result<()> {
25115            decoder.debug_check_bounds::<Self>(offset);
25116            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
25117                None => return Err(fidl::Error::NotNullable),
25118                Some(len) => len,
25119            };
25120            // Calling decoder.out_of_line_offset(0) is not allowed.
25121            if len == 0 {
25122                return Ok(());
25123            };
25124            depth.increment()?;
25125            let envelope_size = 8;
25126            let bytes_len = len * envelope_size;
25127            let offset = decoder.out_of_line_offset(bytes_len)?;
25128            // Decode the envelope for each type.
25129            let mut _next_ordinal_to_read = 0;
25130            let mut next_offset = offset;
25131            let end_offset = offset + bytes_len;
25132            _next_ordinal_to_read += 1;
25133            if next_offset >= end_offset {
25134                return Ok(());
25135            }
25136
25137            // Decode unknown envelopes for gaps in ordinals.
25138            while _next_ordinal_to_read < 1 {
25139                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25140                _next_ordinal_to_read += 1;
25141                next_offset += envelope_size;
25142            }
25143
25144            let next_out_of_line = decoder.next_out_of_line();
25145            let handles_before = decoder.remaining_handles();
25146            if let Some((inlined, num_bytes, num_handles)) =
25147                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25148            {
25149                let member_inline_size =
25150                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25151                if inlined != (member_inline_size <= 4) {
25152                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25153                }
25154                let inner_offset;
25155                let mut inner_depth = depth.clone();
25156                if inlined {
25157                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25158                    inner_offset = next_offset;
25159                } else {
25160                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25161                    inner_depth.increment()?;
25162                }
25163                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
25164                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
25165                });
25166                fidl::decode!(
25167                    u64,
25168                    fidl::encoding::DefaultFuchsiaResourceDialect,
25169                    val_ref,
25170                    decoder,
25171                    inner_offset,
25172                    inner_depth
25173                )?;
25174                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25175                {
25176                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25177                }
25178                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25179                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25180                }
25181            }
25182
25183            next_offset += envelope_size;
25184            _next_ordinal_to_read += 1;
25185            if next_offset >= end_offset {
25186                return Ok(());
25187            }
25188
25189            // Decode unknown envelopes for gaps in ordinals.
25190            while _next_ordinal_to_read < 2 {
25191                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25192                _next_ordinal_to_read += 1;
25193                next_offset += envelope_size;
25194            }
25195
25196            let next_out_of_line = decoder.next_out_of_line();
25197            let handles_before = decoder.remaining_handles();
25198            if let Some((inlined, num_bytes, num_handles)) =
25199                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25200            {
25201                let member_inline_size =
25202                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25203                if inlined != (member_inline_size <= 4) {
25204                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25205                }
25206                let inner_offset;
25207                let mut inner_depth = depth.clone();
25208                if inlined {
25209                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25210                    inner_offset = next_offset;
25211                } else {
25212                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25213                    inner_depth.increment()?;
25214                }
25215                let val_ref = self.buffer_constraints_version_ordinal.get_or_insert_with(|| {
25216                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
25217                });
25218                fidl::decode!(
25219                    u64,
25220                    fidl::encoding::DefaultFuchsiaResourceDialect,
25221                    val_ref,
25222                    decoder,
25223                    inner_offset,
25224                    inner_depth
25225                )?;
25226                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25227                {
25228                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25229                }
25230                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25231                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25232                }
25233            }
25234
25235            next_offset += envelope_size;
25236            _next_ordinal_to_read += 1;
25237            if next_offset >= end_offset {
25238                return Ok(());
25239            }
25240
25241            // Decode unknown envelopes for gaps in ordinals.
25242            while _next_ordinal_to_read < 3 {
25243                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25244                _next_ordinal_to_read += 1;
25245                next_offset += envelope_size;
25246            }
25247
25248            let next_out_of_line = decoder.next_out_of_line();
25249            let handles_before = decoder.remaining_handles();
25250            if let Some((inlined, num_bytes, num_handles)) =
25251                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25252            {
25253                let member_inline_size =
25254                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25255                if inlined != (member_inline_size <= 4) {
25256                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25257                }
25258                let inner_offset;
25259                let mut inner_depth = depth.clone();
25260                if inlined {
25261                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25262                    inner_offset = next_offset;
25263                } else {
25264                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25265                    inner_depth.increment()?;
25266                }
25267                let val_ref = self.single_buffer_mode.get_or_insert_with(|| {
25268                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
25269                });
25270                fidl::decode!(
25271                    bool,
25272                    fidl::encoding::DefaultFuchsiaResourceDialect,
25273                    val_ref,
25274                    decoder,
25275                    inner_offset,
25276                    inner_depth
25277                )?;
25278                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25279                {
25280                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25281                }
25282                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25283                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25284                }
25285            }
25286
25287            next_offset += envelope_size;
25288            _next_ordinal_to_read += 1;
25289            if next_offset >= end_offset {
25290                return Ok(());
25291            }
25292
25293            // Decode unknown envelopes for gaps in ordinals.
25294            while _next_ordinal_to_read < 4 {
25295                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25296                _next_ordinal_to_read += 1;
25297                next_offset += envelope_size;
25298            }
25299
25300            let next_out_of_line = decoder.next_out_of_line();
25301            let handles_before = decoder.remaining_handles();
25302            if let Some((inlined, num_bytes, num_handles)) =
25303                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25304            {
25305                let member_inline_size =
25306                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25307                if inlined != (member_inline_size <= 4) {
25308                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25309                }
25310                let inner_offset;
25311                let mut inner_depth = depth.clone();
25312                if inlined {
25313                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25314                    inner_offset = next_offset;
25315                } else {
25316                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25317                    inner_depth.increment()?;
25318                }
25319                let val_ref = self.packet_count_for_server.get_or_insert_with(|| {
25320                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
25321                });
25322                fidl::decode!(
25323                    u32,
25324                    fidl::encoding::DefaultFuchsiaResourceDialect,
25325                    val_ref,
25326                    decoder,
25327                    inner_offset,
25328                    inner_depth
25329                )?;
25330                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25331                {
25332                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25333                }
25334                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25335                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25336                }
25337            }
25338
25339            next_offset += envelope_size;
25340            _next_ordinal_to_read += 1;
25341            if next_offset >= end_offset {
25342                return Ok(());
25343            }
25344
25345            // Decode unknown envelopes for gaps in ordinals.
25346            while _next_ordinal_to_read < 5 {
25347                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25348                _next_ordinal_to_read += 1;
25349                next_offset += envelope_size;
25350            }
25351
25352            let next_out_of_line = decoder.next_out_of_line();
25353            let handles_before = decoder.remaining_handles();
25354            if let Some((inlined, num_bytes, num_handles)) =
25355                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25356            {
25357                let member_inline_size =
25358                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25359                if inlined != (member_inline_size <= 4) {
25360                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25361                }
25362                let inner_offset;
25363                let mut inner_depth = depth.clone();
25364                if inlined {
25365                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25366                    inner_offset = next_offset;
25367                } else {
25368                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25369                    inner_depth.increment()?;
25370                }
25371                let val_ref = self.packet_count_for_client.get_or_insert_with(|| {
25372                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
25373                });
25374                fidl::decode!(
25375                    u32,
25376                    fidl::encoding::DefaultFuchsiaResourceDialect,
25377                    val_ref,
25378                    decoder,
25379                    inner_offset,
25380                    inner_depth
25381                )?;
25382                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25383                {
25384                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25385                }
25386                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25387                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25388                }
25389            }
25390
25391            next_offset += envelope_size;
25392            _next_ordinal_to_read += 1;
25393            if next_offset >= end_offset {
25394                return Ok(());
25395            }
25396
25397            // Decode unknown envelopes for gaps in ordinals.
25398            while _next_ordinal_to_read < 6 {
25399                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25400                _next_ordinal_to_read += 1;
25401                next_offset += envelope_size;
25402            }
25403
25404            let next_out_of_line = decoder.next_out_of_line();
25405            let handles_before = decoder.remaining_handles();
25406            if let Some((inlined, num_bytes, num_handles)) =
25407                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25408            {
25409                let member_inline_size = <fidl::encoding::Endpoint<
25410                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
25411                > as fidl::encoding::TypeMarker>::inline_size(
25412                    decoder.context
25413                );
25414                if inlined != (member_inline_size <= 4) {
25415                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25416                }
25417                let inner_offset;
25418                let mut inner_depth = depth.clone();
25419                if inlined {
25420                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25421                    inner_offset = next_offset;
25422                } else {
25423                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25424                    inner_depth.increment()?;
25425                }
25426                let val_ref = self.sysmem_token.get_or_insert_with(|| {
25427                    fidl::new_empty!(
25428                        fidl::encoding::Endpoint<
25429                            fidl::endpoints::ClientEnd<
25430                                fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
25431                            >,
25432                        >,
25433                        fidl::encoding::DefaultFuchsiaResourceDialect
25434                    )
25435                });
25436                fidl::decode!(
25437                    fidl::encoding::Endpoint<
25438                        fidl::endpoints::ClientEnd<
25439                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
25440                        >,
25441                    >,
25442                    fidl::encoding::DefaultFuchsiaResourceDialect,
25443                    val_ref,
25444                    decoder,
25445                    inner_offset,
25446                    inner_depth
25447                )?;
25448                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25449                {
25450                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25451                }
25452                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25453                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25454                }
25455            }
25456
25457            next_offset += envelope_size;
25458            _next_ordinal_to_read += 1;
25459            if next_offset >= end_offset {
25460                return Ok(());
25461            }
25462
25463            // Decode unknown envelopes for gaps in ordinals.
25464            while _next_ordinal_to_read < 7 {
25465                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25466                _next_ordinal_to_read += 1;
25467                next_offset += envelope_size;
25468            }
25469
25470            let next_out_of_line = decoder.next_out_of_line();
25471            let handles_before = decoder.remaining_handles();
25472            if let Some((inlined, num_bytes, num_handles)) =
25473                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25474            {
25475                let member_inline_size = <fidl::encoding::Endpoint<
25476                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
25477                > as fidl::encoding::TypeMarker>::inline_size(
25478                    decoder.context
25479                );
25480                if inlined != (member_inline_size <= 4) {
25481                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25482                }
25483                let inner_offset;
25484                let mut inner_depth = depth.clone();
25485                if inlined {
25486                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25487                    inner_offset = next_offset;
25488                } else {
25489                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25490                    inner_depth.increment()?;
25491                }
25492                let val_ref = self.sysmem2_token.get_or_insert_with(|| {
25493                    fidl::new_empty!(
25494                        fidl::encoding::Endpoint<
25495                            fidl::endpoints::ClientEnd<
25496                                fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
25497                            >,
25498                        >,
25499                        fidl::encoding::DefaultFuchsiaResourceDialect
25500                    )
25501                });
25502                fidl::decode!(
25503                    fidl::encoding::Endpoint<
25504                        fidl::endpoints::ClientEnd<
25505                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
25506                        >,
25507                    >,
25508                    fidl::encoding::DefaultFuchsiaResourceDialect,
25509                    val_ref,
25510                    decoder,
25511                    inner_offset,
25512                    inner_depth
25513                )?;
25514                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25515                {
25516                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25517                }
25518                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25519                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25520                }
25521            }
25522
25523            next_offset += envelope_size;
25524
25525            // Decode the remaining unknown envelopes.
25526            while next_offset < end_offset {
25527                _next_ordinal_to_read += 1;
25528                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25529                next_offset += envelope_size;
25530            }
25531
25532            Ok(())
25533        }
25534    }
25535}